linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Naveen Naidu <naveennaidu479@gmail.com>
To: bhelgaas@google.com
Cc: "Naveen Naidu" <naveennaidu479@gmail.com>,
	linux-kernel-mentees@lists.linuxfoundation.org,
	linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-hyperv@vger.kernel.org, linux-mediatek@lists.infradead.org,
	linuxppc-dev@lists.ozlabs.org, linux-renesas-soc@vger.kernel.org,
	linux-rockchip@lists.infradead.org,
	linux-samsung-soc@vger.kernel.org,
	"Rob Herring" <robh@kernel.org>, "Pali Rohár" <pali@kernel.org>,
	skhan@linuxfoundation.org, "Robert Richter" <rric@kernel.org>,
	"Lorenzo Pieralisi" <lorenzo.pieralisi@arm.com>,
	"Krzysztof Wilczyński" <kw@linux.com>,
	"Ray Jui" <rjui@broadcom.com>,
	"Scott Branden" <sbranden@broadcom.com>,
	bcm-kernel-feedback-list@broadcom.com (maintainer:BROADCOM IPROC
	ARM ARCHITECTURE), "Ryder Lee" <ryder.lee@mediatek.com>,
	"Jianjun Wang" <jianjun.wang@mediatek.com>,
	"Matthias Brugger" <matthias.bgg@gmail.com>,
	"Jingoo Han" <jingoohan1@gmail.com>,
	"Krzysztof Kozlowski" <krzysztof.kozlowski@canonical.com>,
	"Shawn Guo" <shawn.guo@linaro.org>,
	"Xiaowei Song" <songxiaowei@hisilicon.com>,
	"Binghui Wang" <wangbinghui@hisilicon.com>,
	"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
	"Joyce Ooi" <joyce.ooi@intel.com>,
	"Marek Vasut" <marek.vasut+renesas@gmail.com>,
	"Yoshihiro Shimoda" <yoshihiro.shimoda.uh@renesas.com>,
	"Shawn Lin" <shawn.lin@rock-chips.com>,
	"Heiko Stuebner" <heiko@sntech.de>,
	"Nirmal Patel" <nirmal.patel@linux.intel.com>,
	"Jonathan Derrick" <jonathan.derrick@linux.dev>,
	"Kuppuswamy Sathyanarayanan"
	<sathyanarayanan.kuppuswamy@linux.intel.com>,
	"Lukas Wunner" <lukas@wunner.de>,
	"Amey Narkhede" <ameynarkhede03@gmail.com>,
	"Russell Currey" <ruscur@russell.cc>,
	"Oliver O'Halloran" <oohall@gmail.com>,
	"Sean V Kelley" <sean.v.kelley@intel.com>,
	"Qiuxu Zhuo" <qiuxu.zhuo@intel.com>,
	"Marc Zyngier" <maz@kernel.org>,
	"K. Y. Srinivasan" <kys@microsoft.com>,
	"Haiyang Zhang" <haiyangz@microsoft.com>,
	"Stephen Hemminger" <sthemmin@microsoft.com>,
	"Wei Liu" <wei.liu@kernel.org>,
	"Dexuan Cui" <decui@microsoft.com>,
	"Toan Le" <toan@os.amperecomputing.com>
Subject: [PATCH v3 02/25] PCI: Set error response in config access defines when ops->read() fails
Date: Thu, 21 Oct 2021 20:37:27 +0530	[thread overview]
Message-ID: <56642edd0d6bf8a8e3d20b5fcc088fd6389b827f.1634825082.git.naveennaidu479@gmail.com> (raw)
In-Reply-To: <cover.1634825082.git.naveennaidu479@gmail.com>

Make PCI_OP_READ and PCI_USER_READ_CONFIG set the data value with error
response (~0), when the PCI device read by a host controller fails.

This ensures that the controller drivers no longer need to fabricate
(~0) value when they detect error. It also  gurantees that the error
response (~0) is always set when the controller drivers fails to read a
config register from a device.

This makes error response fabrication consistent and helps in removal of
a lot of repeated code.

Suggested-by: Rob Herring <robh@kernel.org>
Reviewed-by: Rob Herring <robh@kernel.org>
Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
---
 drivers/pci/access.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/access.c b/drivers/pci/access.c
index 46935695cfb9..0f732ba2f71a 100644
--- a/drivers/pci/access.c
+++ b/drivers/pci/access.c
@@ -42,7 +42,10 @@ int noinline pci_bus_read_config_##size \
 	if (PCI_##size##_BAD) return PCIBIOS_BAD_REGISTER_NUMBER;	\
 	pci_lock_config(flags);						\
 	res = bus->ops->read(bus, devfn, pos, len, &data);		\
-	*value = (type)data;						\
+	if (res)							\
+		SET_PCI_ERROR_RESPONSE(value);				\
+	else								\
+		*value = (type)data;					\
 	pci_unlock_config(flags);					\
 	return res;							\
 }
@@ -228,7 +231,10 @@ int pci_user_read_config_##size						\
 	ret = dev->bus->ops->read(dev->bus, dev->devfn,			\
 					pos, sizeof(type), &data);	\
 	raw_spin_unlock_irq(&pci_lock);				\
-	*val = (type)data;						\
+	if (ret)							\
+		SET_PCI_ERROR_RESPONSE(val);				\
+	else								\
+		*val = (type)data;					\
 	return pcibios_err_to_errno(ret);				\
 }									\
 EXPORT_SYMBOL_GPL(pci_user_read_config_##size);
-- 
2.25.1


  parent reply	other threads:[~2021-10-21 15:09 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-10-21 15:07 [PATCH v3 00/25] Unify PCI error response checking Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 01/25] PCI: Add PCI_ERROR_RESPONSE and it's related definitions Naveen Naidu
2021-10-21 16:08   ` Pali Rohár
2021-11-17 23:58   ` Bjorn Helgaas
2021-11-18 13:30     ` Naveen Naidu
2021-10-21 15:07 ` Naveen Naidu [this message]
2021-10-21 15:59   ` [PATCH v3 02/25] PCI: Set error response in config access defines when ops->read() fails Pali Rohár
2021-10-21 15:07 ` [PATCH v3 03/25] PCI: Use SET_PCI_ERROR_RESPONSE() when device not found Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 04/25] PCI: Remove redundant error fabrication when device read fails Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 05/25] PCI: thunder: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 06/25] PCI: iproc: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 07/25] PCI: mediatek: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 08/25] PCI: exynos: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 09/25] PCI: histb: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 10/25] PCI: kirin: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 11/25] PCI: aardvark: " Naveen Naidu
2021-10-21 15:58   ` Pali Rohár
2021-10-21 15:07 ` [PATCH v3 12/25] PCI: mvebu: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 13/25] PCI: altera: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 14/25] PCI: rcar: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 15/25] PCI: rockchip: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 16/25] PCI/ERR: Use RESPONSE_IS_PCI_ERROR() to check read from hardware Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 17/25] PCI: vmd: " Naveen Naidu
2021-10-21 15:19   ` Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 18/25] PCI: pciehp: " Naveen Naidu
2021-10-21 15:22   ` Naveen Naidu
2021-10-22  7:01     ` Lukas Wunner
2021-10-21 15:07 ` [PATCH v3 19/25] PCI/DPC: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 20/25] PCI/PME: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 21/25] PCI: cpqphp: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 22/25] PCI: Use PCI_ERROR_RESPONSE to specify hardware error Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 23/25] PCI: keystone: " Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 24/25] PCI: hv: Use PCI_ERROR_RESPONSE to specify hardware read error Naveen Naidu
2021-10-21 15:07 ` [PATCH v3 25/25] PCI: xgene: Use PCI_ERROR_RESPONSE to specify hardware error Naveen Naidu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=56642edd0d6bf8a8e3d20b5fcc088fd6389b827f.1634825082.git.naveennaidu479@gmail.com \
    --to=naveennaidu479@gmail.com \
    --cc=ameynarkhede03@gmail.com \
    --cc=bcm-kernel-feedback-list@broadcom.com \
    --cc=bhelgaas@google.com \
    --cc=decui@microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=heiko@sntech.de \
    --cc=jianjun.wang@mediatek.com \
    --cc=jingoohan1@gmail.com \
    --cc=jonathan.derrick@linux.dev \
    --cc=joyce.ooi@intel.com \
    --cc=krzysztof.kozlowski@canonical.com \
    --cc=kw@linux.com \
    --cc=kys@microsoft.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel-mentees@lists.linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-renesas-soc@vger.kernel.org \
    --cc=linux-rockchip@lists.infradead.org \
    --cc=linux-samsung-soc@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lorenzo.pieralisi@arm.com \
    --cc=lukas@wunner.de \
    --cc=marek.vasut+renesas@gmail.com \
    --cc=matthias.bgg@gmail.com \
    --cc=maz@kernel.org \
    --cc=nirmal.patel@linux.intel.com \
    --cc=oohall@gmail.com \
    --cc=pali@kernel.org \
    --cc=qiuxu.zhuo@intel.com \
    --cc=rjui@broadcom.com \
    --cc=robh@kernel.org \
    --cc=rric@kernel.org \
    --cc=ruscur@russell.cc \
    --cc=ryder.lee@mediatek.com \
    --cc=sathyanarayanan.kuppuswamy@linux.intel.com \
    --cc=sbranden@broadcom.com \
    --cc=sean.v.kelley@intel.com \
    --cc=shawn.guo@linaro.org \
    --cc=shawn.lin@rock-chips.com \
    --cc=skhan@linuxfoundation.org \
    --cc=songxiaowei@hisilicon.com \
    --cc=sthemmin@microsoft.com \
    --cc=thomas.petazzoni@bootlin.com \
    --cc=toan@os.amperecomputing.com \
    --cc=wangbinghui@hisilicon.com \
    --cc=wei.liu@kernel.org \
    --cc=yoshihiro.shimoda.uh@renesas.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).