linux-block.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] mtip32xx: Prefer pcie_capability_read_word()
       [not found] <20190718020745.8867-1-fred@fredlawl.com>
@ 2019-07-18  2:07 ` Frederick Lawler
  2019-07-18 12:48   ` Bjorn Helgaas
  2019-07-18  2:07 ` [PATCH] skd: " Frederick Lawler
  1 sibling, 1 reply; 4+ messages in thread
From: Frederick Lawler @ 2019-07-18  2:07 UTC (permalink / raw)
  To: axboe; +Cc: Frederick Lawler, linux-block, linux-kernel, bhelgaas

Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
added accessors for the PCI Express Capability so that drivers didn't
need to be aware of differences between v1 and v2 of the PCI
Express Capability.

Replace pci_read_config_word() and pci_write_config_word() calls with
pcie_capability_read_word() and pcie_capability_write_word().

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
---
 drivers/block/mtip32xx/mtip32xx.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
index f0105d118056..b7b26e33248b 100644
--- a/drivers/block/mtip32xx/mtip32xx.c
+++ b/drivers/block/mtip32xx/mtip32xx.c
@@ -3952,22 +3952,18 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
 	int pos;
 	unsigned short pcie_dev_ctrl;
 
-	pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
-	if (pos) {
-		pci_read_config_word(pdev,
-			pos + PCI_EXP_DEVCTL,
-			&pcie_dev_ctrl);
-		if (pcie_dev_ctrl & (1 << 11) ||
-		    pcie_dev_ctrl & (1 << 4)) {
-			dev_info(&dd->pdev->dev,
-				"Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
-					pdev->vendor, pdev->device);
-			pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
-						PCI_EXP_DEVCTL_RELAX_EN);
-			pci_write_config_word(pdev,
-				pos + PCI_EXP_DEVCTL,
-				pcie_dev_ctrl);
-		}
+	if (!pci_is_pcie(pdev))
+		return;
+
+	pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &pcie_dev_ctrl);
+	if (pcie_dev_ctrl & (1 << 11) ||
+	    pcie_dev_ctrl & (1 << 4)) {
+		dev_info(&dd->pdev->dev,
+			 "Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
+			 pdev->vendor, pdev->device);
+		pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
+					PCI_EXP_DEVCTL_RELAX_EN);
+		pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, pcie_dev_ctrl);
 	}
 }
 
-- 
2.17.1


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

* [PATCH] skd: Prefer pcie_capability_read_word()
       [not found] <20190718020745.8867-1-fred@fredlawl.com>
  2019-07-18  2:07 ` [PATCH] mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
@ 2019-07-18  2:07 ` Frederick Lawler
  2019-07-18 12:43   ` Bjorn Helgaas
  1 sibling, 1 reply; 4+ messages in thread
From: Frederick Lawler @ 2019-07-18  2:07 UTC (permalink / raw)
  To: axboe; +Cc: Frederick Lawler, bvanassche, linux-block, linux-kernel, bhelgaas

Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
added accessors for the PCI Express Capability so that drivers didn't
need to be aware of differences between v1 and v2 of the PCI
Express Capability.

Replace pci_read_config_word() and pci_write_config_word() calls with
pcie_capability_read_word() and pcie_capability_write_word().

Signed-off-by: Frederick Lawler <fred@fredlawl.com>
---
 drivers/block/skd_main.c | 8 ++------
 1 file changed, 2 insertions(+), 6 deletions(-)

diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
index 7d3ad6c22ee5..996c38d03fc4 100644
--- a/drivers/block/skd_main.c
+++ b/drivers/block/skd_main.c
@@ -3137,18 +3137,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
 
 static char *skd_pci_info(struct skd_device *skdev, char *str)
 {
-	int pcie_reg;
-
 	strcpy(str, "PCIe (");
-	pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
 
-	if (pcie_reg) {
+	if (pci_is_pcie(skdev->pdev)) {
 
 		char lwstr[6];
 		uint16_t pcie_lstat, lspeed, lwidth;
 
-		pcie_reg += 0x12;
-		pci_read_config_word(skdev->pdev, pcie_reg, &pcie_lstat);
+		pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
 		lspeed = pcie_lstat & (0xF);
 		lwidth = (pcie_lstat & 0x3F0) >> 4;
 
-- 
2.17.1


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

* Re: [PATCH] skd: Prefer pcie_capability_read_word()
  2019-07-18  2:07 ` [PATCH] skd: " Frederick Lawler
@ 2019-07-18 12:43   ` Bjorn Helgaas
  0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2019-07-18 12:43 UTC (permalink / raw)
  To: Frederick Lawler
  Cc: Jens Axboe, bvanassche, linux-block, Linux Kernel Mailing List

On Wed, Jul 17, 2019 at 9:09 PM Frederick Lawler <fred@fredlawl.com> wrote:
>
> Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
> added accessors for the PCI Express Capability so that drivers didn't
> need to be aware of differences between v1 and v2 of the PCI
> Express Capability.
>
> Replace pci_read_config_word() and pci_write_config_word() calls with
> pcie_capability_read_word() and pcie_capability_write_word().
>
> Signed-off-by: Frederick Lawler <fred@fredlawl.com>
> ---
>  drivers/block/skd_main.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/block/skd_main.c b/drivers/block/skd_main.c
> index 7d3ad6c22ee5..996c38d03fc4 100644
> --- a/drivers/block/skd_main.c
> +++ b/drivers/block/skd_main.c
> @@ -3137,18 +3137,14 @@ MODULE_DEVICE_TABLE(pci, skd_pci_tbl);
>
>  static char *skd_pci_info(struct skd_device *skdev, char *str)
>  {
> -       int pcie_reg;
> -
>         strcpy(str, "PCIe (");
> -       pcie_reg = pci_find_capability(skdev->pdev, PCI_CAP_ID_EXP);
>
> -       if (pcie_reg) {
> +       if (pci_is_pcie(skdev->pdev)) {
>
>                 char lwstr[6];
>                 uint16_t pcie_lstat, lspeed, lwidth;
>
> -               pcie_reg += 0x12;
> -               pci_read_config_word(skdev->pdev, pcie_reg, &pcie_lstat);
> +               pcie_capability_read_word(skdev->pdev, 0x12, &pcie_lstat);
>                 lspeed = pcie_lstat & (0xF);
>                 lwidth = (pcie_lstat & 0x3F0) >> 4;

This should use PCI_EXP_LNKSTA, PCI_EXP_LNKSTA_CLS, PCI_EXP_LNKSTA_NLW, etc.

Would probably make sense to do that in a separate patch so this patch
matches the other conversions to pcie_capability_read_word().

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

* Re: [PATCH] mtip32xx: Prefer pcie_capability_read_word()
  2019-07-18  2:07 ` [PATCH] mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
@ 2019-07-18 12:48   ` Bjorn Helgaas
  0 siblings, 0 replies; 4+ messages in thread
From: Bjorn Helgaas @ 2019-07-18 12:48 UTC (permalink / raw)
  To: Frederick Lawler; +Cc: Jens Axboe, linux-block, Linux Kernel Mailing List

On Wed, Jul 17, 2019 at 9:09 PM Frederick Lawler <fred@fredlawl.com> wrote:
>
> Commit 8c0d3a02c130 ("PCI: Add accessors for PCI Express Capability")
> added accessors for the PCI Express Capability so that drivers didn't
> need to be aware of differences between v1 and v2 of the PCI
> Express Capability.
>
> Replace pci_read_config_word() and pci_write_config_word() calls with
> pcie_capability_read_word() and pcie_capability_write_word().
>
> Signed-off-by: Frederick Lawler <fred@fredlawl.com>
> ---
>  drivers/block/mtip32xx/mtip32xx.c | 28 ++++++++++++----------------
>  1 file changed, 12 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/block/mtip32xx/mtip32xx.c b/drivers/block/mtip32xx/mtip32xx.c
> index f0105d118056..b7b26e33248b 100644
> --- a/drivers/block/mtip32xx/mtip32xx.c
> +++ b/drivers/block/mtip32xx/mtip32xx.c
> @@ -3952,22 +3952,18 @@ static void mtip_disable_link_opts(struct driver_data *dd, struct pci_dev *pdev)
>         int pos;
>         unsigned short pcie_dev_ctrl;
>
> -       pos = pci_find_capability(pdev, PCI_CAP_ID_EXP);
> -       if (pos) {
> -               pci_read_config_word(pdev,
> -                       pos + PCI_EXP_DEVCTL,
> -                       &pcie_dev_ctrl);
> -               if (pcie_dev_ctrl & (1 << 11) ||
> -                   pcie_dev_ctrl & (1 << 4)) {
> -                       dev_info(&dd->pdev->dev,
> -                               "Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
> -                                       pdev->vendor, pdev->device);
> -                       pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
> -                                               PCI_EXP_DEVCTL_RELAX_EN);
> -                       pci_write_config_word(pdev,
> -                               pos + PCI_EXP_DEVCTL,
> -                               pcie_dev_ctrl);
> -               }
> +       if (!pci_is_pcie(pdev))
> +               return;
> +
> +       pcie_capability_read_word(pdev, PCI_EXP_DEVCTL, &pcie_dev_ctrl);
> +       if (pcie_dev_ctrl & (1 << 11) ||
> +           pcie_dev_ctrl & (1 << 4)) {

Hmm, sort of sloppy that  d1e714db8129 ("mtip32xx: Fix ERO and NoSnoop
values in PCIe upstream on AMD systems") used
PCI_EXP_DEVCTL_NOSNOOP_EN and PCI_EXP_DEVCTL_RELAX_EN below, but not
here.  Could be fixed with a separate follow-on patch.

> +               dev_info(&dd->pdev->dev,
> +                        "Disabling ERO/No-Snoop on bridge device %04x:%04x\n",
> +                        pdev->vendor, pdev->device);
> +               pcie_dev_ctrl &= ~(PCI_EXP_DEVCTL_NOSNOOP_EN |
> +                                       PCI_EXP_DEVCTL_RELAX_EN);
> +               pcie_capability_write_word(pdev, PCI_EXP_DEVCTL, pcie_dev_ctrl);
>         }
>  }
>
> --
> 2.17.1
>

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

end of thread, other threads:[~2019-07-18 12:49 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20190718020745.8867-1-fred@fredlawl.com>
2019-07-18  2:07 ` [PATCH] mtip32xx: Prefer pcie_capability_read_word() Frederick Lawler
2019-07-18 12:48   ` Bjorn Helgaas
2019-07-18  2:07 ` [PATCH] skd: " Frederick Lawler
2019-07-18 12:43   ` Bjorn Helgaas

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).