linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Fixes for Switchtec Driver
@ 2017-05-15 16:44 Logan Gunthorpe
  2017-05-15 16:44 ` [PATCH 1/2] switchtec: utilize new device_add_cdev helper function Logan Gunthorpe
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Logan Gunthorpe @ 2017-05-15 16:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Kurt Schwemmer, Stephen Bates, linux-pci, linux-kernel, 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


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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH 1/2] switchtec: utilize new device_add_cdev helper function
  2017-05-15 16:44 [PATCH 0/2] Fixes for Switchtec Driver Logan Gunthorpe
@ 2017-05-15 16:44 ` Logan Gunthorpe
  2017-05-15 16:44 ` [PATCH 2/2] switchtec: fix minor bug with partition id register Logan Gunthorpe
  2017-05-22 21:54 ` [PATCH 0/2] Fixes for Switchtec Driver Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Logan Gunthorpe @ 2017-05-15 16:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Kurt Schwemmer, Stephen Bates, linux-pci, linux-kernel, Logan Gunthorpe

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

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
---
 drivers/pci/switch/switchtec.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index cc6e085..abaa227a 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -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");
 
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH 2/2] switchtec: fix minor bug with partition id register
  2017-05-15 16:44 [PATCH 0/2] Fixes for Switchtec Driver Logan Gunthorpe
  2017-05-15 16:44 ` [PATCH 1/2] switchtec: utilize new device_add_cdev helper function Logan Gunthorpe
@ 2017-05-15 16:44 ` Logan Gunthorpe
  2017-05-22 21:54 ` [PATCH 0/2] Fixes for Switchtec Driver Bjorn Helgaas
  2 siblings, 0 replies; 5+ messages in thread
From: Logan Gunthorpe @ 2017-05-15 16:44 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Kurt Schwemmer, Stephen Bates, linux-pci, linux-kernel, 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.

Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
Reported-by: Dingbao Chen <dingbao.chen@microsemi.com>
---
 drivers/pci/switch/switchtec.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/pci/switch/switchtec.c b/drivers/pci/switch/switchtec.c
index abaa227a..f6a6340 100644
--- a/drivers/pci/switch/switchtec.c
+++ b/drivers/pci/switch/switchtec.c
@@ -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);
-- 
2.1.4

^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Fixes for Switchtec Driver
  2017-05-15 16:44 [PATCH 0/2] Fixes for Switchtec Driver Logan Gunthorpe
  2017-05-15 16:44 ` [PATCH 1/2] switchtec: utilize new device_add_cdev helper function Logan Gunthorpe
  2017-05-15 16:44 ` [PATCH 2/2] switchtec: fix minor bug with partition id register Logan Gunthorpe
@ 2017-05-22 21:54 ` Bjorn Helgaas
  2017-05-23  3:56   ` Logan Gunthorpe
  2 siblings, 1 reply; 5+ messages in thread
From: Bjorn Helgaas @ 2017-05-22 21:54 UTC (permalink / raw)
  To: Logan Gunthorpe
  Cc: Bjorn Helgaas, Kurt Schwemmer, Stephen Bates, linux-pci, linux-kernel

On Mon, May 15, 2017 at 10:44:51AM -0600, Logan Gunthorpe wrote:
> 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(-)

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 <logang@deltatee.com>
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.
    
    Reported-by: Dingbao Chen <dingbao.chen@microsemi.com>
    Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

commit e40cf640b8f6 (refs/patches/for-linus/switchtec-use-new)
Author: Logan Gunthorpe <logang@deltatee.com>
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]
    Signed-off-by: Logan Gunthorpe <logang@deltatee.com>
    Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH 0/2] Fixes for Switchtec Driver
  2017-05-22 21:54 ` [PATCH 0/2] Fixes for Switchtec Driver Bjorn Helgaas
@ 2017-05-23  3:56   ` Logan Gunthorpe
  0 siblings, 0 replies; 5+ messages in thread
From: Logan Gunthorpe @ 2017-05-23  3:56 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Bjorn Helgaas, Kurt Schwemmer, Stephen Bates, linux-pci, linux-kernel



On 22/05/17 03:54 PM, Bjorn Helgaas wrote:
> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2017-05-23  3:56 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-05-15 16:44 [PATCH 0/2] Fixes for Switchtec Driver Logan Gunthorpe
2017-05-15 16:44 ` [PATCH 1/2] switchtec: utilize new device_add_cdev helper function Logan Gunthorpe
2017-05-15 16:44 ` [PATCH 2/2] switchtec: fix minor bug with partition id register Logan Gunthorpe
2017-05-22 21:54 ` [PATCH 0/2] Fixes for Switchtec Driver Bjorn Helgaas
2017-05-23  3:56   ` Logan Gunthorpe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).