Skip to contentSkip to conversation

Fixes for Switchtec Driver

PATCH In review Logan Gunthorpe 2 participants 5 messages May 15, 2017 – May 23, 2017

Subsystems (2)
lore
Share & tools
lore

Logan Gunthorpe

author maintainer
#0 lore raw

cover Fixes for Switchtec Driver

Hi Bjorn,

Can you please apply the following two patches? The first is a cleanup to use a new helper function I added (it had to wait until both patchsets were in). The second is a minor bug fix to the driver we found last week.

Thanks!

Logan

Logan Gunthorpe (2):
switchtec: utilize new device_add_cdev helper function
switchtec: fix minor bug with partition id register

 drivers/pci/switch/switchtec.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

--
2.1.4

author maintainer
#1 lore raw

PATCH 1/2 switchtec: utilize new device_add_cdev helper function

Very straightforward conversion to device_add_cdev. Drop cdev_add and device_add and use cdev_device_add.

---
 drivers/pci/switch/switchtec.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)
drivers/pci/switch/switchtec.c +2 -9
index cc6e085..abaa227a 100644
@@ -1291,7 +1291,6 @@ static struct switchtec_dev *stdev_create(struct pci_dev *pdev)
 	cdev = &stdev->cdev;
 	cdev_init(cdev, &switchtec_fops);
 	cdev->owner = THIS_MODULE;
-	cdev->kobj.parent = &dev->kobj;
 
 	return stdev;
 
@@ -1479,11 +1478,7 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
 		  SWITCHTEC_EVENT_EN_IRQ,
 		  &stdev->mmio_part_cfg->mrpc_comp_hdr);
 
-	rc = cdev_add(&stdev->cdev, stdev->dev.devt, 1);
-	if (rc)
-		goto err_put;
-
-	rc = device_add(&stdev->dev);
+	rc = cdev_device_add(&stdev->cdev, &stdev->dev);
 	if (rc)
 		goto err_devadd;
 
@@ -1492,7 +1487,6 @@ static int switchtec_pci_probe(struct pci_dev *pdev,
 	return 0;
 
 err_devadd:
-	cdev_del(&stdev->cdev);
 	stdev_kill(stdev);
 err_put:
 	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
@@ -1506,8 +1500,7 @@ static void switchtec_pci_remove(struct pci_dev *pdev)
 
 	pci_set_drvdata(pdev, NULL);
 
-	device_del(&stdev->dev);
-	cdev_del(&stdev->cdev);
+	cdev_device_del(&stdev->cdev, &stdev->dev);
 	ida_simple_remove(&switchtec_minor_ida, MINOR(stdev->dev.devt));
 	dev_info(&stdev->dev, "unregistered.\n");
 
Signature · 1 line
2.1.4
author maintainer
#2 lore raw

PATCH 2/2 switchtec: fix minor bug with partition id register

In reply to Logan Gunthorpe

When a switch endpoind is configured without NTB the mmio_ntb registers will read all zeros. However, in corner case configurations where the partition ID is not zero and NTB is not enabled then the code will have the wrong partition ID and this causes the driver to use the wrong set of drivers. To fix this we simply take the partition ID from the system info region.

---
 drivers/pci/switch/switchtec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/pci/switch/switchtec.c +4 -1
index abaa227a..f6a6340 100644
@@ -1441,12 +1441,15 @@ static int switchtec_init_pci(struct switchtec_dev *stdev,
 	stdev->mmio_sys_info = stdev->mmio + SWITCHTEC_GAS_SYS_INFO_OFFSET;
 	stdev->mmio_flash_info = stdev->mmio + SWITCHTEC_GAS_FLASH_INFO_OFFSET;
 	stdev->mmio_ntb = stdev->mmio + SWITCHTEC_GAS_NTB_OFFSET;
-	stdev->partition = ioread8(&stdev->mmio_ntb->partition_id);
+	stdev->partition = ioread8(&stdev->mmio_sys_info->partition_id);
 	stdev->partition_count = ioread8(&stdev->mmio_ntb->partition_count);
 	stdev->mmio_part_cfg_all = stdev->mmio + SWITCHTEC_GAS_PART_CFG_OFFSET;
 	stdev->mmio_part_cfg = &stdev->mmio_part_cfg_all[stdev->partition];
 	stdev->mmio_pff_csr = stdev->mmio + SWITCHTEC_GAS_PFF_CSR_OFFSET;
 
+	if (stdev->partition_count < 1)
+		stdev->partition_count = 1;
+
 	init_pff(stdev);
 
 	pci_set_drvdata(pdev, stdev);
Signature · 1 line
2.1.4
#3 lore raw
In reply to Logan Gunthorpe
Quoted 12 lines · Logan Gunthorpe

Hi Bjorn,

Can you please apply the following two patches? The first is a cleanup to use a new helper function I added (it had to wait until both patchsets were in). The second is a minor bug fix to the driver we found last week.

Thanks!

Logan

Quoted 6 lines

Logan Gunthorpe (2):
switchtec: utilize new device_add_cdev helper function
switchtec: fix minor bug with partition id register

 drivers/pci/switch/switchtec.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

Since we merged the Switchtec driver during the v4.12 merge window, I applied these to for-linus for v4.12, with the following changelogs to correct a few typos:

commit 9871e9bb5cf6

Author: Logan Gunthorpe <[email protected]>
Date:   Mon May 22 16:52:30 2017 -0500

switchtec: Fix minor bug with partition ID register

When a switch endpoint is configured without NTB, the mmio_ntb registers will read all zeros. However, in corner case configurations where the partition ID is not zero and NTB is not enabled, the code will have the wrong partition ID and this causes the driver to use the wrong set of drivers. To fix this we simply take the partition ID from the system info region.

commit e40cf640b8f6 (refs/patches/for-linus/switchtec-use-new)

Author: Logan Gunthorpe <[email protected]>
Date:   Mon May 22 16:52:24 2017 -0500

switchtec: Use new cdev_device_add() helper function

Convert from "cdev_add() + device_add()" to cdev_device_add(), and from "device_del() + cdev_del()" to cdev_device_del().

[bhelgaas: changelog]
author maintainer
#4 lore raw
Quoted 3 lines · Bjorn Helgaas

Since we merged the Switchtec driver during the v4.12 merge window, I applied these to for-linus for v4.12, with the following changelogs to correct a few typos:

Great! Thanks Bjorn.

Logan