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

On 17/11, Bjorn Helgaas wrote:
> On Thu, Oct 21, 2021 at 08:37:26PM +0530, Naveen Naidu 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.
> > 
> > Add a PCI_ERROR_RESPONSE definition for that and use it where
> > appropriate to make these checks consistent and easier to find.
> > 
> > Also add helper definitions SET_PCI_ERROR_RESPONSE and
> > RESPONSE_IS_PCI_ERROR to make the code more readable.
> > 
> > Suggested-by: Bjorn Helgaas <bhelgaas@google.com>
> > Signed-off-by: Naveen Naidu <naveennaidu479@gmail.com>
> > ---
> >  include/linux/pci.h | 9 +++++++++
> >  1 file changed, 9 insertions(+)
> > 
> > diff --git a/include/linux/pci.h b/include/linux/pci.h
> > index cd8aa6fce204..689c8277c584 100644
> > --- a/include/linux/pci.h
> > +++ b/include/linux/pci.h
> > @@ -154,6 +154,15 @@ enum pci_interrupt_pin {
> >  /* The number of legacy PCI INTx interrupts */
> >  #define PCI_NUM_INTX	4
> >  
> > +/*
> > + * Reading from a device that doesn't respond typically returns ~0.  A
> > + * successful read from a device may also return ~0, so you need additional
> > + * information to reliably identify errors.
> > + */
> > +#define PCI_ERROR_RESPONSE     (~0ULL)
> > +#define SET_PCI_ERROR_RESPONSE(val)    (*(val) = ((typeof(*(val))) PCI_ERROR_RESPONSE))
> > +#define RESPONSE_IS_PCI_ERROR(val) ((val) == ((typeof(val)) PCI_ERROR_RESPONSE))
> 
> Beautiful!  I really like this.
>

Thank you very much for the review ^^

> I would prefer the macros to start with "PCI_", e.g.,
> PCI_SET_ERROR_RESPONSE().
> 

ACK

> I think "RESPONSE_IS_PCI_ERROR()" is too strong because (as the
> comment says), ~0 *may* indicate an error.  Or it may be a successful
> read of a register that happens to contain ~0.
> 
> Possibilities to convey the idea that this isn't definitive:
> 
>   PCI_POSSIBLE_ERROR_RESPONSE(val)  # a little long
>   PCI_LIKELY_ERROR(val)             # we really have no idea whether
>   PCI_PROBABLE_ERROR(val)           #   likely or probable
>   PCI_POSSIBLE_ERROR(val)           # promising?
>

ACK. Will use PCI_POSSIBLE_ERROR()

> Can you rebase to my "main" branch (v5.16-rc1), tweak the above, and
> collect up the acks/reviews?
> 

ACK

> We should also browse drivers outside drivers/pci for places we could
> use these.  Not necessarily as part of this series, although if
> authors there object, it would be good to learn that earlier than
> later.
> 
> Drivers that implement pci_error_handlers might be a fruitful place to
> start.  But you've done a great job finding users of ~0 and 0xffff...
> in drivers/pci/, too.
> 

A quick grep showed that there are around 80 drivers which have
pci_error_handlers. I was thinking that it would be better if we handle
these drivers in another patch series since the current patch series is
itself 25 patches long. And in my short tenure reading LKML, I gathered
that folks generally are not so kind to a long list of patches in a
single patch series ^^' (I might be wrong though, Apologies)

The consensus on the patch series does seem slightly positive so
ideally, I was hoping that we would not have the case where a author
does not like the way we are handling this patch. Then again, I'm
pretty sure that I might be wrong ^^'

I hope it would be okay that I send in a new patch series with the
suggested changes and handle the other changes in another patch series
^^

Thanks,
Naveen
> > +
> >  /*
> >   * pci_power_t values must match the bits in the Capabilities PME_Support
> >   * and Control/Status PowerState fields in the Power Management capability.
> > -- 
> > 2.25.1
> > 
> > _______________________________________________
> > Linux-kernel-mentees mailing list
> > Linux-kernel-mentees@lists.linuxfoundation.org
> > https://lists.linuxfoundation.org/mailman/listinfo/linux-kernel-mentees

  reply	other threads:[~2021-11-18 13:30 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 [this message]
2021-10-21 15:07 ` [PATCH v3 02/25] PCI: Set error response in config access defines when ops->read() fails Naveen Naidu
2021-10-21 15:59   ` 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=20211118133020.nkr3xzbzonxtrqbw@theprophet \
    --to=naveennaidu479@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=helgaas@kernel.org \
    --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=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).