linux-renesas-soc.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 00/24] Unify PCI error response checking
@ 2021-10-15 14:35 Naveen Naidu
  2021-10-15 14:38 ` [PATCH v2 14/24] PCI: rcar: Remove redundant error fabrication when device read fails Naveen Naidu
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen Naidu @ 2021-10-15 14:35 UTC (permalink / raw)
  To: bhelgaas
  Cc: Naveen Naidu, linux-kernel-mentees, linux-pci, linux-kernel,
	linux-arm-kernel, linux-hyperv, linux-mediatek, linuxppc-dev,
	linux-renesas-soc, linux-rockchip, linux-samsung-soc,
	Rob Herring, Pali Rohár

An MMIO read from a PCI device that doesn't exist or doesn't respond
causes a PCI error.  There's no real data to return to satisfy the 
CPU read, so most hardware fabricates ~0 data.

This patch series adds PCI_ERROR_RESPONSE definition and other helper
definition SET_PCI_ERROR_RESPONSE and RESPONSE_IS_PCI_ERROR and uses it
where appropriate to make these checks consistent and easier to find.

This helps unify PCI error response checking and make error check
consistent and easier to find.

This series also ensures that the error response fabrication now happens
in the PCI_OP_READ and PCI_USER_READ_CONFIG. This removes the
responsibility from controller drivers to do the error response setting. 

Patch 1:
    - Adds the PCI_ERROR_RESPONSE and other related defintions
    - All other patches are dependent on this patch. This patch needs to
      be applied first, before the others

Patch 2:
    - Error fabrication happens in PCI_OP_READ and PCI_USER_READ_CONFIG
      whenever the data read via the controller driver fails.
    - This patch needs to be applied before, Patch 4/24 to Patch 15/24 are
      applied.

Patch 3:
    - Uses SET_PCI_ERROR_RESPONSE() when device is not found and
      RESPONSE_IS_PCI_ERROR() to check hardware read from the hardware.

Patch 4 - 15:
    - Removes redundant error fabrication that happens in controller 
      drivers when the read from a PCI device fails.
    - These patches are dependent on Patch 2/24 of the series.
    - These can be applied in any order.

Patch 16 - 22:
    - Uses RESPONSE_IS_PCI_ERROR() to check the reads from hardware
    - Patches can be applied in any order.

Patch 23 - 24:
    - Edits the comments to include PCI_ERROR_RESPONSE alsong with
      0xFFFFFFFF, so that it becomes easier to grep for faulty 
      hardware reads.

Changelog
=========

v2:
    - Instead of using SET_PCI_ERROR_RESPONSE in all controller drivers
      to fabricate error response, only use them in PCI_OP_READ and
      PCI_USER_READ_CONFIG

Naveen Naidu (24):
 [PATCH 1/24] PCI: Add PCI_ERROR_RESPONSE and it's related definitions
 [PATCH 2/24] PCI: Set error response in config access defines when ops->read() fails
 [PATCH 3/24] PCI: Unify PCI error response checking
 [PATCH 4/24] PCI: Remove redundant error fabrication when device read fails
 [PATCH 5/24] PCI: thunder: Remove redundant error fabrication when device read fails
 [PATCH 6/24] PCI: iproc: Remove redundant error fabrication when device read fails
 [PATCH 7/24] PCI: mediatek: Remove redundant error fabrication when device read fails
 [PATCH 8/24] PCI: exynos: Remove redundant error fabrication when device read fails
 [PATCH 9/24] PCI: histb: Remove redundant error fabrication when device read fails
 [PATCH 10/24] PCI: kirin: Remove redundant error fabrication when device read fails
 [PATCH 11/24] PCI: aardvark: Remove redundant error fabrication when device read fails
 [PATCH 12/24] PCI: mvebu: Remove redundant error fabrication when device read fails
 [PATCH 13/24] PCI: altera: Remove redundant error fabrication when device read fails
 [PATCH 14/24] PCI: rcar: Remove redundant error fabrication when device read fails
 [PATCH 15/24] PCI: rockchip: Remove redundant error fabrication when device read fails
 [PATCH 16/24] PCI/ERR: Use RESPONSE_IS_PCI_ERROR() to check read from hardware
 [PATCH 17/24] PCI: vmd: Use RESPONSE_IS_PCI_ERROR() to check read from hardware
 [PATCH 18/24] PCI: pciehp: Use RESPONSE_IS_PCI_ERROR() to check read from hardware
 [PATCH 19/24] PCI/DPC: Use RESPONSE_IS_PCI_ERROR() to check read from hardware
 [PATCH 20/24] PCI/PME: Use RESPONSE_IS_PCI_ERROR() to check read from hardware
 [PATCH 21/24] PCI: cpqphp: Use RESPONSE_IS_PCI_ERROR() to check read from hardware
 [PATCH 22/24] PCI: keystone: Use PCI_ERROR_RESPONSE to specify hardware error
 [PATCH 23/24] PCI: hv: Use PCI_ERROR_RESPONSE to specify hardware read error
 [PATCH 24/24] PCI: xgene: Use PCI_ERROR_RESPONSE to specify hardware error

 drivers/pci/access.c                        | 36 ++++++++--------
 drivers/pci/controller/dwc/pci-exynos.c     |  4 +-
 drivers/pci/controller/dwc/pci-keystone.c   |  4 +-
 drivers/pci/controller/dwc/pcie-histb.c     |  4 +-
 drivers/pci/controller/dwc/pcie-kirin.c     |  4 +-
 drivers/pci/controller/pci-aardvark.c       | 10 +----
 drivers/pci/controller/pci-hyperv.c         |  2 +-
 drivers/pci/controller/pci-mvebu.c          |  8 +---
 drivers/pci/controller/pci-thunder-ecam.c   | 46 +++++++--------------
 drivers/pci/controller/pci-thunder-pem.c    |  4 +-
 drivers/pci/controller/pci-xgene.c          |  8 ++--
 drivers/pci/controller/pcie-altera.c        |  4 +-
 drivers/pci/controller/pcie-iproc.c         |  4 +-
 drivers/pci/controller/pcie-mediatek.c      | 11 +----
 drivers/pci/controller/pcie-rcar-host.c     |  4 +-
 drivers/pci/controller/pcie-rockchip-host.c |  4 +-
 drivers/pci/controller/vmd.c                |  2 +-
 drivers/pci/hotplug/cpqphp_ctrl.c           |  4 +-
 drivers/pci/hotplug/pciehp_hpc.c            | 10 ++---
 drivers/pci/pci.c                           | 10 ++---
 drivers/pci/pcie/dpc.c                      |  4 +-
 drivers/pci/pcie/pme.c                      |  4 +-
 drivers/pci/probe.c                         | 10 ++---
 include/linux/pci.h                         |  9 ++++
 24 files changed, 87 insertions(+), 123 deletions(-)

-- 
2.25.1


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

* [PATCH v2 14/24] PCI: rcar: Remove redundant error fabrication when device read fails
  2021-10-15 14:35 [PATCH v2 00/24] Unify PCI error response checking Naveen Naidu
@ 2021-10-15 14:38 ` Naveen Naidu
  2021-10-18 11:32   ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen Naidu @ 2021-10-15 14:38 UTC (permalink / raw)
  To: bhelgaas
  Cc: Naveen Naidu, linux-kernel-mentees, linux-pci, linux-kernel,
	Marek Vasut, Yoshihiro Shimoda, Lorenzo Pieralisi, Rob Herring,
	Krzysztof Wilczyński,
	open list:PCI DRIVER FOR RENESAS R-CAR

An MMIO read from a PCI device that doesn't exist or doesn't respond
causes a PCI error. There's no real data to return to satisfy the
CPU read, so most hardware fabricates ~0 data.

The host controller drivers sets the error response values (~0) and
returns an error when faulty hardware read occurs. But the error
response value (~0) is already being set in PCI_OP_READ and
PCI_USER_READ_CONFIG whenever a read by host controller driver fails.

Thus, it's no longer necessary for the host controller drivers to
fabricate any error response.

This helps unify PCI error response checking and make error check
consistent and easier to find.

Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
---
 drivers/pci/controller/pcie-rcar-host.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/pci/controller/pcie-rcar-host.c b/drivers/pci/controller/pcie-rcar-host.c
index 8f3131844e77..1324cb984ed5 100644
--- a/drivers/pci/controller/pcie-rcar-host.c
+++ b/drivers/pci/controller/pcie-rcar-host.c
@@ -161,10 +161,8 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
 
 	ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_READ,
 				      bus, devfn, where, val);
-	if (ret != PCIBIOS_SUCCESSFUL) {
-		*val = 0xffffffff;
+	if (ret != PCIBIOS_SUCCESSFUL)
 		return ret;
-	}
 
 	if (size == 1)
 		*val = (*val >> (BITS_PER_BYTE * (where & 3))) & 0xff;
-- 
2.25.1


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

* Re: [PATCH v2 14/24] PCI: rcar: Remove redundant error fabrication when device read fails
  2021-10-15 14:38 ` [PATCH v2 14/24] PCI: rcar: Remove redundant error fabrication when device read fails Naveen Naidu
@ 2021-10-18 11:32   ` Geert Uytterhoeven
  2021-10-18 11:51     ` Naveen Naidu
  0 siblings, 1 reply; 5+ messages in thread
From: Geert Uytterhoeven @ 2021-10-18 11:32 UTC (permalink / raw)
  To: Naveen Naidu
  Cc: Bjorn Helgaas, linux-kernel-mentees, linux-pci,
	Linux Kernel Mailing List, Marek Vasut, Yoshihiro Shimoda,
	Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński,
	open list:PCI DRIVER FOR RENESAS R-CAR

Hi Naveen,

On Sat, Oct 16, 2021 at 5:33 PM Naveen Naidu <naveennaidu479@gmail.com> wrote:
> An MMIO read from a PCI device that doesn't exist or doesn't respond
> causes a PCI error. There's no real data to return to satisfy the
> CPU read, so most hardware fabricates ~0 data.
>
> The host controller drivers sets the error response values (~0) and
> returns an error when faulty hardware read occurs. But the error
> response value (~0) is already being set in PCI_OP_READ and
> PCI_USER_READ_CONFIG whenever a read by host controller driver fails.
>
> Thus, it's no longer necessary for the host controller drivers to
> fabricate any error response.
>
> This helps unify PCI error response checking and make error check
> consistent and easier to find.
>
> Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>

Thanks for your patch!

> --- a/drivers/pci/controller/pcie-rcar-host.c
> +++ b/drivers/pci/controller/pcie-rcar-host.c
> @@ -161,10 +161,8 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
>
>         ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_READ,
>                                       bus, devfn, where, val);
> -       if (ret != PCIBIOS_SUCCESSFUL) {
> -               *val = 0xffffffff;

I don't see the behavior you describe in PCI_OP_READ(), so dropping
this will lead to returning an uninitialized value?

> +       if (ret != PCIBIOS_SUCCESSFUL)
>                 return ret;
> -       }
>
>         if (size == 1)
>                 *val = (*val >> (BITS_PER_BYTE * (where & 3))) & 0xff;

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

* Re: [PATCH v2 14/24] PCI: rcar: Remove redundant error fabrication when device read fails
  2021-10-18 11:32   ` Geert Uytterhoeven
@ 2021-10-18 11:51     ` Naveen Naidu
  2021-10-18 12:00       ` Geert Uytterhoeven
  0 siblings, 1 reply; 5+ messages in thread
From: Naveen Naidu @ 2021-10-18 11:51 UTC (permalink / raw)
  To: Geert Uytterhoeven
  Cc: Bjorn Helgaas, linux-kernel-mentees, linux-pci,
	Linux Kernel Mailing List, Marek Vasut, Yoshihiro Shimoda,
	Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński,
	open list:PCI DRIVER FOR RENESAS R-CAR

On 18/10, Geert Uytterhoeven wrote:
> Hi Naveen,
> 
> On Sat, Oct 16, 2021 at 5:33 PM Naveen Naidu <naveennaidu479@gmail.com> wrote:
> > An MMIO read from a PCI device that doesn't exist or doesn't respond
> > causes a PCI error. There's no real data to return to satisfy the
> > CPU read, so most hardware fabricates ~0 data.
> >
> > The host controller drivers sets the error response values (~0) and
> > returns an error when faulty hardware read occurs. But the error
> > response value (~0) is already being set in PCI_OP_READ and
> > PCI_USER_READ_CONFIG whenever a read by host controller driver fails.
> >
> > Thus, it's no longer necessary for the host controller drivers to
> > fabricate any error response.
> >
> > This helps unify PCI error response checking and make error check
> > consistent and easier to find.
> >
> > Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
> 
> Thanks for your patch!
> 
> > --- a/drivers/pci/controller/pcie-rcar-host.c
> > +++ b/drivers/pci/controller/pcie-rcar-host.c
> > @@ -161,10 +161,8 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
> >
> >         ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_READ,
> >                                       bus, devfn, where, val);
> > -       if (ret != PCIBIOS_SUCCESSFUL) {
> > -               *val = 0xffffffff;
> 
> I don't see the behavior you describe in PCI_OP_READ(), so dropping
> this will lead to returning an uninitialized value?
>

Hello Geert,

Thank you for looking into the patch.

The described behaviour for PCI_OP_READ is part of the 01/24 [1] patch of
the series. 

[1]:
https://lore.kernel.org/linux-pci/b913b4966938b7cad8c049dc34093e6c4b2fae68.1634306198.git.naveennaidu479@gmail.com/T/#u

It looks like, I did not add proper receipients for that patch and hence
is leading to confusion. I really apologize for that.

I do not know what the right approach here should be, should I resend
the entire patch series, adding proper receipients OR should I reply to
each of the patches for the drivers and add the link to the patch. I did
not want to spam people with a lot of mails so I was confused as to what
the right option is.

Thanks,
Naveen

> > +       if (ret != PCIBIOS_SUCCESSFUL)
> >                 return ret;
> > -       }
> >
> >         if (size == 1)
> >                 *val = (*val >> (BITS_PER_BYTE * (where & 3))) & 0xff;
> 
> Gr{oetje,eeting}s,
> 
>                         Geert
> 
> --
> Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org
> 
> In personal conversations with technical people, I call myself a hacker. But
> when I'm talking to journalists I just say "programmer" or something like that.
>                                 -- Linus Torvalds

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

* Re: [PATCH v2 14/24] PCI: rcar: Remove redundant error fabrication when device read fails
  2021-10-18 11:51     ` Naveen Naidu
@ 2021-10-18 12:00       ` Geert Uytterhoeven
  0 siblings, 0 replies; 5+ messages in thread
From: Geert Uytterhoeven @ 2021-10-18 12:00 UTC (permalink / raw)
  To: Naveen Naidu
  Cc: Bjorn Helgaas, linux-kernel-mentees, linux-pci,
	Linux Kernel Mailing List, Marek Vasut, Yoshihiro Shimoda,
	Lorenzo Pieralisi, Rob Herring, Krzysztof Wilczyński,
	open list:PCI DRIVER FOR RENESAS R-CAR

Hi Naveen,

On Mon, Oct 18, 2021 at 1:52 PM Naveen Naidu <naveennaidu479@gmail.com> wrote:
> On 18/10, Geert Uytterhoeven wrote:
> > On Sat, Oct 16, 2021 at 5:33 PM Naveen Naidu <naveennaidu479@gmail.com> wrote:
> > > An MMIO read from a PCI device that doesn't exist or doesn't respond
> > > causes a PCI error. There's no real data to return to satisfy the
> > > CPU read, so most hardware fabricates ~0 data.
> > >
> > > The host controller drivers sets the error response values (~0) and
> > > returns an error when faulty hardware read occurs. But the error
> > > response value (~0) is already being set in PCI_OP_READ and
> > > PCI_USER_READ_CONFIG whenever a read by host controller driver fails.
> > >
> > > Thus, it's no longer necessary for the host controller drivers to
> > > fabricate any error response.
> > >
> > > This helps unify PCI error response checking and make error check
> > > consistent and easier to find.
> > >
> > > Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
> >
> > Thanks for your patch!
> >
> > > --- a/drivers/pci/controller/pcie-rcar-host.c
> > > +++ b/drivers/pci/controller/pcie-rcar-host.c
> > > @@ -161,10 +161,8 @@ static int rcar_pcie_read_conf(struct pci_bus *bus, unsigned int devfn,
> > >
> > >         ret = rcar_pcie_config_access(host, RCAR_PCI_ACCESS_READ,
> > >                                       bus, devfn, where, val);
> > > -       if (ret != PCIBIOS_SUCCESSFUL) {
> > > -               *val = 0xffffffff;
> >
> > I don't see the behavior you describe in PCI_OP_READ(), so dropping
> > this will lead to returning an uninitialized value?
> >
>
> Hello Geert,
>
> Thank you for looking into the patch.
>
> The described behaviour for PCI_OP_READ is part of the 01/24 [1] patch of
> the series.
>
> [1]:
> https://lore.kernel.org/linux-pci/b913b4966938b7cad8c049dc34093e6c4b2fae68.1634306198.git.naveennaidu479@gmail.com/T/#u

OK, in that case:
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>

> It looks like, I did not add proper receipients for that patch and hence
> is leading to confusion. I really apologize for that.

Indeed. If there are dependencies, all recipients should receive all
dependencies.

> I do not know what the right approach here should be, should I resend
> the entire patch series, adding proper receipients OR should I reply to
> each of the patches for the drivers and add the link to the patch. I did
> not want to spam people with a lot of mails so I was confused as to what
> the right option is.

Probably a resend would be best.
Thanks!

Gr{oetje,eeting}s,

                        Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds

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

end of thread, other threads:[~2021-10-18 12:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-15 14:35 [PATCH v2 00/24] Unify PCI error response checking Naveen Naidu
2021-10-15 14:38 ` [PATCH v2 14/24] PCI: rcar: Remove redundant error fabrication when device read fails Naveen Naidu
2021-10-18 11:32   ` Geert Uytterhoeven
2021-10-18 11:51     ` Naveen Naidu
2021-10-18 12:00       ` Geert Uytterhoeven

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