RE: [PATCH v1 1/3] iommu/vt-d: Eliminate pci_physfn() in dmar_find_matched_satc_unit()
From: Wang, Wei W
Date: Fri May 09 2025 - 07:39:59 EST
On Friday, May 9, 2025 5:16 PM, Liu, Yi L wrote:
> On 2025/5/9 22:00, Wei Wang wrote:
> > The function dmar_find_matched_satc_unit() contains a duplicate call
> > to pci_physfn(). This call is unnecessary as pci_physfn() has already
> > been invoked by the caller. Removing the redundant call simplifies the
> > code and improves efficiency a bit.
> >
> > Signed-off-by: Wei Wang <wei.w.wang@xxxxxxxxx>
> > ---
> > drivers/iommu/intel/iommu.c | 1 -
> > 1 file changed, 1 deletion(-)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index cb0b993bebb4..d8aa71305509 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -2744,7 +2744,6 @@ static struct dmar_satc_unit
> *dmar_find_matched_satc_unit(struct pci_dev *dev)
> > struct device *tmp;
> > int i;
> >
> > - dev = pci_physfn(dev);
>
> better have a comment to highlight the input dev should be PF. also, can add a
> WARN_ON(dev->is_virtfn);
How about changing the input to "struct pci_dev *pf_pdev " (like the one used
in device_lookup_iommu())?
This way, we probably don't need extra comments, and WARN_ON() might not be
necessary IMHO, as this is a static function with only one caller currently (already
clear that the input is a pf_dev)