public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: zhangdongdong@eswincomputing.com
Cc: alex.williamson@redhat.com, bhelgaas@google.com,
	yishaih@nvidia.com, avihaih@nvidia.com, yi.l.liu@intel.com,
	ankita@nvidia.com, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org
Subject: Re: [PATCH] PCI: Remove redundant macro
Date: Fri, 13 Dec 2024 11:37:01 -0600	[thread overview]
Message-ID: <20241213173701.GA3419486@bhelgaas> (raw)
In-Reply-To: <20241213094617.1149-1-zhangdongdong@eswincomputing.com>

On Fri, Dec 13, 2024 at 05:46:17PM +0800, zhangdongdong@eswincomputing.com wrote:
> From: Dongdong Zhang <zhangdongdong@eswincomputing.com>
> 
> Removed the duplicate macro definition PCI_VSEC_HDR from
> pci_regs.h to avoid redundancy. Updated the VFIO PCI code
> to use the existing `PCI_VNDR_HEADER` macro for consistency,
> ensuring minimal changes to the codebase.
> 
> Signed-off-by: Dongdong Zhang <zhangdongdong@eswincomputing.com>
> ---
>  drivers/vfio/pci/vfio_pci_config.c | 3 ++-
>  include/uapi/linux/pci_regs.h      | 1 -
>  2 files changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/vfio/pci/vfio_pci_config.c b/drivers/vfio/pci/vfio_pci_config.c
> index ea2745c1ac5e..c30748912ff1 100644
> --- a/drivers/vfio/pci/vfio_pci_config.c
> +++ b/drivers/vfio/pci/vfio_pci_config.c
> @@ -1389,7 +1389,8 @@ static int vfio_ext_cap_len(struct vfio_pci_core_device *vdev, u16 ecap, u16 epo
>  
>  	switch (ecap) {
>  	case PCI_EXT_CAP_ID_VNDR:
> -		ret = pci_read_config_dword(pdev, epos + PCI_VSEC_HDR, &dword);
> +		ret = pci_read_config_dword(pdev, epos + PCI_VNDR_HEADER,
> +					    &dword);
>  		if (ret)
>  			return pcibios_err_to_errno(ret);
>  
> diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h
> index 1601c7ed5fab..7b6cad788de3 100644
> --- a/include/uapi/linux/pci_regs.h
> +++ b/include/uapi/linux/pci_regs.h
> @@ -1001,7 +1001,6 @@
>  #define PCI_ACS_CTRL		0x06	/* ACS Control Register */
>  #define PCI_ACS_EGRESS_CTL_V	0x08	/* ACS Egress Control Vector */
>  
> -#define PCI_VSEC_HDR		4	/* extended cap - vendor-specific */
>  #define  PCI_VSEC_HDR_LEN_SHIFT	20	/* shift for length field */

We should resolve the duplication of PCI_VSEC_HDR and PCI_VNDR_HEADER,
but I don't like the fact that we're left with this dangling
PCI_VSEC_HDR_LEN_SHIFT.

That leaves vfio using PCI_VNDR_HEADER and PCI_VSEC_HDR_LEN_SHIFT,
which don't match at all.

I think you should remove PCI_VSEC_HDR_LEN_SHIFT as well and change
vfio to use PCI_VNDR_HEADER_LEN() instead.

It's somewhat dicey removing things from pci_regs.h since it's in
include/uapi/, but this is such a niche thing we might be able to get
away with it.

Bjorn

  reply	other threads:[~2024-12-13 17:37 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-12-13  9:46 [PATCH] PCI: Remove redundant macro zhangdongdong
2024-12-13 17:37 ` Bjorn Helgaas [this message]
2024-12-16  1:22   ` DongdongZhang

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=20241213173701.GA3419486@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=alex.williamson@redhat.com \
    --cc=ankita@nvidia.com \
    --cc=avihaih@nvidia.com \
    --cc=bhelgaas@google.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=yi.l.liu@intel.com \
    --cc=yishaih@nvidia.com \
    --cc=zhangdongdong@eswincomputing.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