All of lore.kernel.org
 help / color / mirror / Atom feed
From: Marc Zyngier <maz@kernel.org>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH v3 2/3] PCI/sysfs: Don't depend on pci_dev.irq for IRQ entry
Date: Wed, 25 Aug 2021 14:30:04 +0100	[thread overview]
Message-ID: <87czq1ps83.wl-maz@kernel.org> (raw)
In-Reply-To: <20210825102636.52757-3-21cnbao@gmail.com>

On Wed, 25 Aug 2021 11:26:35 +0100,
Barry Song <21cnbao@gmail.com> wrote:
> 
> From: Barry Song <song.bao.hua@hisilicon.com>
> 
> Explicitly use IRQ number from MSI list for IRQ sysfs entry. Then sysfs
> will decouple with the odd implementation depending on pci_dev.irq.
> 
> Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
> ---
>  drivers/pci/pci-sysfs.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 7bbf2673..f5a06b9 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -26,6 +26,7 @@
>  #include <linux/slab.h>
>  #include <linux/vgaarb.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/msi.h>
>  #include <linux/of.h>
>  #include "pci.h"
>  
> @@ -49,7 +50,27 @@ static DEVICE_ATTR_RO(field)
>  pci_config_attr(subsystem_device, "0x%04x\n");
>  pci_config_attr(revision, "0x%02x\n");
>  pci_config_attr(class, "0x%06x\n");
> -pci_config_attr(irq, "%u\n");
> +
> +static ssize_t irq_show(struct device *dev,
> +			struct device_attribute *attr,
> +			char *buf)
> +{
> +	struct pci_dev *pdev = to_pci_dev(dev);
> +#ifdef CONFIG_PCI_MSI
> +	/*
> +	 * For MSI, return the 1st IRQ in IRQ vector; for all other cases
> +	 * including MSI-X, return legacy INTx
> +	 */
> +	if (pdev->msi_enabled) {
> +		struct msi_desc *desc = first_pci_msi_entry(pdev);
> +
> +		return sysfs_emit(buf, "%u\n", desc->irq);
> +	}
> +#endif

nit: It would be worth adding a comment indicating that we only do
this to preserve an existing userspace ABI. Just in case someone
thinks it is pointless and remove it... ;-)

	M.

-- 
Without deviation from the norm, progress is not possible.

WARNING: multiple messages have this Message-ID (diff)
From: Marc Zyngier <maz@kernel.org>
To: Barry Song <21cnbao@gmail.com>
Cc: bhelgaas@google.com, tglx@linutronix.de,
	Jonathan.Cameron@huawei.com, bilbao@vt.edu, corbet@lwn.net,
	gregkh@linuxfoundation.org, leon@kernel.org,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org,
	linuxarm@huawei.com, luzmaximilian@gmail.com,
	mchehab+huawei@kernel.org, schnelle@linux.ibm.com,
	jesse.brandeburg@intel.com, anthony.l.nguyen@intel.com,
	intel-wired-lan@lists.osuosl.org,
	Barry Song <song.bao.hua@hisilicon.com>
Subject: Re: [PATCH v3 2/3] PCI/sysfs: Don't depend on pci_dev.irq for IRQ entry
Date: Wed, 25 Aug 2021 14:30:04 +0100	[thread overview]
Message-ID: <87czq1ps83.wl-maz@kernel.org> (raw)
In-Reply-To: <20210825102636.52757-3-21cnbao@gmail.com>

On Wed, 25 Aug 2021 11:26:35 +0100,
Barry Song <21cnbao@gmail.com> wrote:
> 
> From: Barry Song <song.bao.hua@hisilicon.com>
> 
> Explicitly use IRQ number from MSI list for IRQ sysfs entry. Then sysfs
> will decouple with the odd implementation depending on pci_dev.irq.
> 
> Signed-off-by: Barry Song <song.bao.hua@hisilicon.com>
> ---
>  drivers/pci/pci-sysfs.c | 23 ++++++++++++++++++++++-
>  1 file changed, 22 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
> index 7bbf2673..f5a06b9 100644
> --- a/drivers/pci/pci-sysfs.c
> +++ b/drivers/pci/pci-sysfs.c
> @@ -26,6 +26,7 @@
>  #include <linux/slab.h>
>  #include <linux/vgaarb.h>
>  #include <linux/pm_runtime.h>
> +#include <linux/msi.h>
>  #include <linux/of.h>
>  #include "pci.h"
>  
> @@ -49,7 +50,27 @@ static DEVICE_ATTR_RO(field)
>  pci_config_attr(subsystem_device, "0x%04x\n");
>  pci_config_attr(revision, "0x%02x\n");
>  pci_config_attr(class, "0x%06x\n");
> -pci_config_attr(irq, "%u\n");
> +
> +static ssize_t irq_show(struct device *dev,
> +			struct device_attribute *attr,
> +			char *buf)
> +{
> +	struct pci_dev *pdev = to_pci_dev(dev);
> +#ifdef CONFIG_PCI_MSI
> +	/*
> +	 * For MSI, return the 1st IRQ in IRQ vector; for all other cases
> +	 * including MSI-X, return legacy INTx
> +	 */
> +	if (pdev->msi_enabled) {
> +		struct msi_desc *desc = first_pci_msi_entry(pdev);
> +
> +		return sysfs_emit(buf, "%u\n", desc->irq);
> +	}
> +#endif

nit: It would be worth adding a comment indicating that we only do
this to preserve an existing userspace ABI. Just in case someone
thinks it is pointless and remove it... ;-)

	M.

-- 
Without deviation from the norm, progress is not possible.

  reply	other threads:[~2021-08-25 13:30 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-25 10:26 [Intel-wired-lan] [PATCH v3 0/3] PCI/MSI: Clarify the IRQ sysfs ABI for PCI devices Barry Song
2021-08-25 10:26 ` Barry Song
2021-08-25 10:26 ` [Intel-wired-lan] [PATCH v3 1/3] Documentation: ABI: sysfs-bus-pci: Add description for IRQ entry Barry Song
2021-08-25 10:26   ` Barry Song
2021-08-25 10:26 ` [Intel-wired-lan] [PATCH v3 2/3] PCI/sysfs: Don't depend on pci_dev.irq " Barry Song
2021-08-25 10:26   ` Barry Song
2021-08-25 13:30   ` Marc Zyngier [this message]
2021-08-25 13:30     ` Marc Zyngier
2021-08-25 10:26 ` [Intel-wired-lan] [PATCH v3 3/3] PCI/MSI: remove msi_attrib.default_irq in msi_desc Barry Song
2021-08-25 10:26   ` Barry Song
2021-08-25 13:38   ` [Intel-wired-lan] " Marc Zyngier
2021-08-25 13:38     ` Marc Zyngier
2021-08-29 14:55   ` [Intel-wired-lan] [PCI/MSI] a4fc4cf388: dmesg.genirq:Flags_mismatch_irq##(mei_me)vs.#(xhci_hcd) kernel test robot
2021-08-29 14:55     ` kernel test robot
2021-08-29 14:55     ` kernel test robot
2021-08-31  1:21     ` [Intel-wired-lan] " Barry Song
2021-08-31  1:21       ` Barry Song
2021-08-31  1:21       ` Barry Song
2021-08-31  1:36       ` [Intel-wired-lan] " Barry Song
2021-08-31  1:36         ` Barry Song
2021-08-31  1:36         ` Barry Song
2021-09-02 19:34         ` [Intel-wired-lan] " Winkler, Tomas
2021-09-02 19:34           ` Winkler, Tomas
2021-09-02 19:34           ` Winkler, Tomas
2021-10-03  8:32           ` [Intel-wired-lan] " Barry Song
2021-10-03  8:32             ` Barry Song
2021-10-03  8:32             ` Barry Song
2021-10-15 14:45             ` [Intel-wired-lan] [LKP] " Carel Si
2021-10-15 14:45               ` Carel Si
2021-10-15 14:45               ` Carel Si
2021-10-16  0:08               ` [Intel-wired-lan] [LKP] " Barry Song
2021-10-16  0:08                 ` Barry Song
2021-10-16  0:08                 ` [LKP] " Barry Song
2021-10-19  6:52                 ` [Intel-wired-lan] " Carel Si
2021-10-19  6:52                   ` Carel Si
2021-10-19  6:52                   ` Carel Si
2021-08-31  8:08       ` [Intel-wired-lan] " Marc Zyngier
2021-08-31  8:08         ` Marc Zyngier
2021-08-31  8:08         ` Marc Zyngier
2021-08-31 21:36         ` [Intel-wired-lan] " Barry Song
2021-08-31 21:36           ` Barry Song
2021-08-31 21:36           ` Barry Song
2021-09-01 13:09           ` [Intel-wired-lan] " Marc Zyngier
2021-09-01 13:09             ` Marc Zyngier
2021-09-01 13:09             ` Marc Zyngier
2021-10-16 10:11 ` [Intel-wired-lan] [PATCH v3 0/3] PCI/MSI: Clarify the IRQ sysfs ABI for PCI devices Barry Song
2021-10-16 10:11   ` Barry Song
2021-10-18 21:50 ` [Intel-wired-lan] " Bjorn Helgaas
2021-10-18 21:50   ` Bjorn Helgaas
2021-10-19  7:39   ` [Intel-wired-lan] " Marc Zyngier
2021-10-19  7:39     ` Marc Zyngier

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=87czq1ps83.wl-maz@kernel.org \
    --to=maz@kernel.org \
    --cc=intel-wired-lan@osuosl.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.