From: Bjorn Helgaas <helgaas@kernel.org>
To: Heiner Kallweit <hkallweit1@gmail.com>
Cc: Realtek linux nic maintainers <nic_swsd@realtek.com>,
David Miller <davem@davemloft.net>,
Mirko Lindner <mlindner@marvell.com>,
Stephen Hemminger <stephen@networkplumber.org>,
Clemens Ladisch <clemens@ladisch.de>,
Jaroslav Kysela <perex@perex.cz>, Takashi Iwai <tiwai@suse.com>,
"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
alsa-devel@alsa-project.org
Subject: Re: [PATCH v4 05/10] PCI: Add pci_status_get_and_clear_errors
Date: Wed, 4 Mar 2020 07:43:18 -0600 [thread overview]
Message-ID: <20200304134318.GA193797@google.com> (raw)
In-Reply-To: <e0251b07-d08f-df4d-7e80-9eba3d3e43af@gmail.com>
On Sat, Feb 29, 2020 at 11:24:23PM +0100, Heiner Kallweit wrote:
> Several drivers use the following code sequence:
> 1. Read PCI_STATUS
> 2. Mask out non-error bits
> 3. Action based on error bits set
> 4. Write back set error bits to clear them
>
> As this is a repeated pattern, add a helper to the PCI core.
>
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
Acked-by: Bjorn Helgaas <bhelgaas@google.com>
Nit: if you have any reason to revise this, I would prefer
"pci_status_get_and_clear_errors()" (with parens) in the subject.
> ---
> v4:
> - improve commit description
> ---
> drivers/pci/pci.c | 23 +++++++++++++++++++++++
> include/linux/pci.h | 1 +
> 2 files changed, 24 insertions(+)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index d828ca835..c16b0ba2a 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -173,6 +173,29 @@ unsigned char pci_bus_max_busnr(struct pci_bus *bus)
> }
> EXPORT_SYMBOL_GPL(pci_bus_max_busnr);
>
> +/**
> + * pci_status_get_and_clear_errors - return and clear error bits in PCI_STATUS
> + * @pdev: the PCI device
> + *
> + * Returns error bits set in PCI_STATUS and clears them.
> + */
> +int pci_status_get_and_clear_errors(struct pci_dev *pdev)
> +{
> + u16 status;
> + int ret;
> +
> + ret = pci_read_config_word(pdev, PCI_STATUS, &status);
> + if (ret != PCIBIOS_SUCCESSFUL)
> + return -EIO;
> +
> + status &= PCI_STATUS_ERROR_BITS;
> + if (status)
> + pci_write_config_word(pdev, PCI_STATUS, status);
> +
> + return status;
> +}
> +EXPORT_SYMBOL_GPL(pci_status_get_and_clear_errors);
> +
> #ifdef CONFIG_HAS_IOMEM
> void __iomem *pci_ioremap_bar(struct pci_dev *pdev, int bar)
> {
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 101d71e0a..7beaf51e9 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -1210,6 +1210,7 @@ int pci_select_bars(struct pci_dev *dev, unsigned long flags);
> bool pci_device_is_present(struct pci_dev *pdev);
> void pci_ignore_hotplug(struct pci_dev *dev);
> struct pci_dev *pci_real_dma_dev(struct pci_dev *dev);
> +int pci_status_get_and_clear_errors(struct pci_dev *pdev);
>
> int __printf(6, 7) pci_request_irq(struct pci_dev *dev, unsigned int nr,
> irq_handler_t handler, irq_handler_t thread_fn, void *dev_id,
> --
> 2.25.1
>
>
next prev parent reply other threads:[~2020-03-04 13:43 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-29 22:19 [PATCH v4 00/10] PCI: Add and use constant PCI_STATUS_ERROR_BITS and helper pci_status_get_and_clear_errors Heiner Kallweit
2020-02-29 22:20 ` [PATCH v4 01/10] net: marvell: add PCI_STATUS_SIG_TARGET_ABORT to PCI status error bits Heiner Kallweit
2020-02-29 22:21 ` [PATCH v4 02/10] net: skfp: add PCI_STATUS_REC_TARGET_ABORT " Heiner Kallweit
2020-02-29 22:22 ` [PATCH v4 03/10] r8169: add PCI_STATUS_PARITY " Heiner Kallweit
2020-02-29 22:23 ` [PATCH v4 04/10] PCI: Add constant PCI_STATUS_ERROR_BITS Heiner Kallweit
2020-03-04 13:41 ` Bjorn Helgaas
2020-02-29 22:24 ` [PATCH v4 05/10] PCI: Add pci_status_get_and_clear_errors Heiner Kallweit
2020-03-04 13:43 ` Bjorn Helgaas [this message]
2020-02-29 22:25 ` [PATCH v4 06/10] r8169: use pci_status_get_and_clear_errors Heiner Kallweit
2020-02-29 22:26 ` [PATCH v4 07/10] net: sun: " Heiner Kallweit
2020-02-29 22:27 ` [PATCH v4 08/10] net: skfp: use new constant PCI_STATUS_ERROR_BITS Heiner Kallweit
2020-02-29 22:28 ` [PATCH v4 09/10] PCI: pci-bridge-emul: Use " Heiner Kallweit
2020-03-04 13:44 ` Bjorn Helgaas
2020-02-29 22:29 ` [PATCH v4 10/10] sound: bt87x: use pci_status_get_and_clear_errors Heiner Kallweit
2020-03-06 6:06 ` Takashi Iwai
2020-03-04 2:59 ` [PATCH v4 00/10] PCI: Add and use constant PCI_STATUS_ERROR_BITS and helper pci_status_get_and_clear_errors David Miller
2020-03-04 16:59 ` Bjorn Helgaas
2020-03-04 22:21 ` David Miller
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=20200304134318.GA193797@google.com \
--to=helgaas@kernel.org \
--cc=alsa-devel@alsa-project.org \
--cc=clemens@ladisch.de \
--cc=davem@davemloft.net \
--cc=hkallweit1@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mlindner@marvell.com \
--cc=netdev@vger.kernel.org \
--cc=nic_swsd@realtek.com \
--cc=perex@perex.cz \
--cc=stephen@networkplumber.org \
--cc=tiwai@suse.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).