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@intel.com>
---
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);
rcu_read_lock();
list_for_each_entry_rcu(satcu, &dmar_satc_units, list) {
--
2.43.0
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@intel.com>
> ---
> 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);
> rcu_read_lock();
>
> list_for_each_entry_rcu(satcu, &dmar_satc_units, list) {
--
Regards,
Yi Liu
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@intel.com> > > --- > > 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)
© 2016 - 2025 Red Hat, Inc.