* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2020-12-29 8:42 kernel test robot
0 siblings, 0 replies; 14+ messages in thread
From: kernel test robot @ 2020-12-29 8:42 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 4655 bytes --]
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20201229032513.486395-4-yi.l.liu@intel.com>
References: <20201229032513.486395-4-yi.l.liu@intel.com>
TO: Liu Yi L <yi.l.liu@intel.com>
TO: baolu.lu(a)linux.intel.com
TO: joro(a)8bytes.org
TO: will(a)kernel.org
CC: kevin.tian(a)intel.com
CC: jacob.jun.pan(a)linux.intel.com
CC: ashok.raj(a)intel.com
CC: yi.l.liu(a)intel.com
CC: jun.j.tian(a)intel.com
CC: yi.y.sun(a)intel.com
CC: iommu(a)lists.linux-foundation.org
Hi Liu,
Thank you for the patch! Perhaps something to improve:
[auto build test WARNING on v5.11-rc1]
[also build test WARNING on next-20201223]
[cannot apply to iommu/next]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Liu-Yi-L/iommu-vt-d-Misc-fixes-on-scalable-mode/20201229-113203
base: 5c8fe583cce542aa0b84adc939ce85293de36e5e
:::::: branch date: 5 hours ago
:::::: commit date: 5 hours ago
config: i386-randconfig-m021-20201229 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/iommu/intel/iommu.c:1471 domain_update_iotlb() error: we previously assumed 'info' could be null (see line 1472)
Old smatch warnings:
drivers/iommu/intel/iommu.c:920 device_to_iommu() error: we previously assumed 'pdev' could be null (see line 893)
drivers/iommu/intel/iommu.c:3764 intel_iommu_add() warn: should '(1 << sp)' be a 64 bit type?
vim +/info +1471 drivers/iommu/intel/iommu.c
93a23a7271dfb81 drivers/pci/intel-iommu.c Yu Zhao 2009-05-18 1463
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1464 static void domain_update_iotlb(struct dmar_domain *domain)
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1465 {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1466 struct device_domain_info *info;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1467 bool has_iotlb_device = false;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1468
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1469 assert_spin_locked(&device_domain_lock);
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1470
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1471 list_for_each_entry(info, &domain->devices, link)
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1472 if (info && info->ats_enabled) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1473 has_iotlb_device = true;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1474 break;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1475 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1476
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1477 if (!has_iotlb_device) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1478 struct subdev_domain_info *sinfo;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1479
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1480 list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1481 info = get_domain_info(sinfo->pdev);
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1482 if (info && info->ats_enabled) {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1483 has_iotlb_device = true;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1484 break;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1485 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1486 }
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1487 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1488
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1489 domain->has_iotlb_device = has_iotlb_device;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1490 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1491
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35310 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
2021-01-05 17:23 ` Will Deacon
@ 2021-01-07 5:22 ` Liu, Yi L
-1 siblings, 0 replies; 14+ messages in thread
From: Liu, Yi L @ 2021-01-07 5:22 UTC (permalink / raw)
To: Will Deacon
Cc: Lu Baolu, joro, Tian, Kevin, jacob.jun.pan, Raj, Ashok, Tian,
Jun J, Sun, Yi Y, iommu, linux-kernel
Hi Will,
> From: Will Deacon <will@kernel.org>
> Sent: Wednesday, January 6, 2021 1:24 AM
>
> On Tue, Jan 05, 2021 at 05:50:22AM +0000, Liu, Yi L wrote:
> > > > +static void __iommu_flush_dev_iotlb(struct device_domain_info
> *info,
> > > > + u64 addr, unsigned int mask)
> > > > +{
> > > > + u16 sid, qdep;
> > > > +
> > > > + if (!info || !info->ats_enabled)
> > > > + return;
> > > > +
> > > > + sid = info->bus << 8 | info->devfn;
> > > > + qdep = info->ats_qdep;
> > > > + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > > + qdep, addr, mask);
> > > > +}
> > > > +
> > > > static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> > > > u64 addr, unsigned mask)
> > > > {
> > > > - u16 sid, qdep;
> > > > unsigned long flags;
> > > > struct device_domain_info *info;
> > > > + struct subdev_domain_info *sinfo;
> > > >
> > > > if (!domain->has_iotlb_device)
> > > > return;
> > > >
> > > > spin_lock_irqsave(&device_domain_lock, flags);
> > > > - list_for_each_entry(info, &domain->devices, link) {
> > > > - if (!info->ats_enabled)
> > > > - continue;
> > > > + list_for_each_entry(info, &domain->devices, link)
> > > > + __iommu_flush_dev_iotlb(info, addr, mask);
> > > >
> > > > - sid = info->bus << 8 | info->devfn;
> > > > - qdep = info->ats_qdep;
> > > > - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > > - qdep, addr, mask);
> > > > + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > > > + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> > > > + addr, mask);
> > > > }
> > >
> > > Nit:
> > > list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > > info = get_domain_info(sinfo->pdev);
> > > __iommu_flush_dev_iotlb(info, addr, mask);
> > > }
> >
> > you are right. this should be better.
>
> Please can you post a v4, with Lu's acks and the issue reported by Dan fixed
> too?
sure, will send out later.
Regards,
Yi Liu
> Thanks,
>
> Will
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2021-01-07 5:22 ` Liu, Yi L
0 siblings, 0 replies; 14+ messages in thread
From: Liu, Yi L @ 2021-01-07 5:22 UTC (permalink / raw)
To: Will Deacon
Cc: Tian, Kevin, Raj, Ashok, Tian, Jun J, iommu, linux-kernel, Sun, Yi Y
Hi Will,
> From: Will Deacon <will@kernel.org>
> Sent: Wednesday, January 6, 2021 1:24 AM
>
> On Tue, Jan 05, 2021 at 05:50:22AM +0000, Liu, Yi L wrote:
> > > > +static void __iommu_flush_dev_iotlb(struct device_domain_info
> *info,
> > > > + u64 addr, unsigned int mask)
> > > > +{
> > > > + u16 sid, qdep;
> > > > +
> > > > + if (!info || !info->ats_enabled)
> > > > + return;
> > > > +
> > > > + sid = info->bus << 8 | info->devfn;
> > > > + qdep = info->ats_qdep;
> > > > + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > > + qdep, addr, mask);
> > > > +}
> > > > +
> > > > static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> > > > u64 addr, unsigned mask)
> > > > {
> > > > - u16 sid, qdep;
> > > > unsigned long flags;
> > > > struct device_domain_info *info;
> > > > + struct subdev_domain_info *sinfo;
> > > >
> > > > if (!domain->has_iotlb_device)
> > > > return;
> > > >
> > > > spin_lock_irqsave(&device_domain_lock, flags);
> > > > - list_for_each_entry(info, &domain->devices, link) {
> > > > - if (!info->ats_enabled)
> > > > - continue;
> > > > + list_for_each_entry(info, &domain->devices, link)
> > > > + __iommu_flush_dev_iotlb(info, addr, mask);
> > > >
> > > > - sid = info->bus << 8 | info->devfn;
> > > > - qdep = info->ats_qdep;
> > > > - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > > - qdep, addr, mask);
> > > > + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > > > + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> > > > + addr, mask);
> > > > }
> > >
> > > Nit:
> > > list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > > info = get_domain_info(sinfo->pdev);
> > > __iommu_flush_dev_iotlb(info, addr, mask);
> > > }
> >
> > you are right. this should be better.
>
> Please can you post a v4, with Lu's acks and the issue reported by Dan fixed
> too?
sure, will send out later.
Regards,
Yi Liu
> Thanks,
>
> Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
2021-01-05 5:50 ` Liu, Yi L
@ 2021-01-05 17:23 ` Will Deacon
-1 siblings, 0 replies; 14+ messages in thread
From: Will Deacon @ 2021-01-05 17:23 UTC (permalink / raw)
To: Liu, Yi L
Cc: Lu Baolu, joro, Tian, Kevin, jacob.jun.pan, Raj, Ashok, Tian,
Jun J, Sun, Yi Y, iommu, linux-kernel
On Tue, Jan 05, 2021 at 05:50:22AM +0000, Liu, Yi L wrote:
> > > +static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
> > > + u64 addr, unsigned int mask)
> > > +{
> > > + u16 sid, qdep;
> > > +
> > > + if (!info || !info->ats_enabled)
> > > + return;
> > > +
> > > + sid = info->bus << 8 | info->devfn;
> > > + qdep = info->ats_qdep;
> > > + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > + qdep, addr, mask);
> > > +}
> > > +
> > > static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> > > u64 addr, unsigned mask)
> > > {
> > > - u16 sid, qdep;
> > > unsigned long flags;
> > > struct device_domain_info *info;
> > > + struct subdev_domain_info *sinfo;
> > >
> > > if (!domain->has_iotlb_device)
> > > return;
> > >
> > > spin_lock_irqsave(&device_domain_lock, flags);
> > > - list_for_each_entry(info, &domain->devices, link) {
> > > - if (!info->ats_enabled)
> > > - continue;
> > > + list_for_each_entry(info, &domain->devices, link)
> > > + __iommu_flush_dev_iotlb(info, addr, mask);
> > >
> > > - sid = info->bus << 8 | info->devfn;
> > > - qdep = info->ats_qdep;
> > > - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > - qdep, addr, mask);
> > > + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > > + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> > > + addr, mask);
> > > }
> >
> > Nit:
> > list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > info = get_domain_info(sinfo->pdev);
> > __iommu_flush_dev_iotlb(info, addr, mask);
> > }
>
> you are right. this should be better.
Please can you post a v4, with Lu's acks and the issue reported by Dan fixed
too?
Thanks,
Will
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2021-01-05 17:23 ` Will Deacon
0 siblings, 0 replies; 14+ messages in thread
From: Will Deacon @ 2021-01-05 17:23 UTC (permalink / raw)
To: Liu, Yi L
Cc: Tian, Kevin, Raj, Ashok, Tian, Jun J, iommu, linux-kernel, Sun, Yi Y
On Tue, Jan 05, 2021 at 05:50:22AM +0000, Liu, Yi L wrote:
> > > +static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
> > > + u64 addr, unsigned int mask)
> > > +{
> > > + u16 sid, qdep;
> > > +
> > > + if (!info || !info->ats_enabled)
> > > + return;
> > > +
> > > + sid = info->bus << 8 | info->devfn;
> > > + qdep = info->ats_qdep;
> > > + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > + qdep, addr, mask);
> > > +}
> > > +
> > > static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> > > u64 addr, unsigned mask)
> > > {
> > > - u16 sid, qdep;
> > > unsigned long flags;
> > > struct device_domain_info *info;
> > > + struct subdev_domain_info *sinfo;
> > >
> > > if (!domain->has_iotlb_device)
> > > return;
> > >
> > > spin_lock_irqsave(&device_domain_lock, flags);
> > > - list_for_each_entry(info, &domain->devices, link) {
> > > - if (!info->ats_enabled)
> > > - continue;
> > > + list_for_each_entry(info, &domain->devices, link)
> > > + __iommu_flush_dev_iotlb(info, addr, mask);
> > >
> > > - sid = info->bus << 8 | info->devfn;
> > > - qdep = info->ats_qdep;
> > > - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > > - qdep, addr, mask);
> > > + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > > + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> > > + addr, mask);
> > > }
> >
> > Nit:
> > list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > info = get_domain_info(sinfo->pdev);
> > __iommu_flush_dev_iotlb(info, addr, mask);
> > }
>
> you are right. this should be better.
Please can you post a v4, with Lu's acks and the issue reported by Dan fixed
too?
Thanks,
Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
2020-12-29 3:25 ` Liu Yi L
(?)
@ 2021-01-05 12:14 ` Dan Carpenter
-1 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2021-01-05 12:14 UTC (permalink / raw)
To: kbuild, Liu Yi L, baolu.lu, joro, will
Cc: kevin.tian, kbuild-all, lkp, jun.j.tian, iommu, yi.y.sun, ashok.raj
[-- Attachment #1: Type: text/plain, Size: 3729 bytes --]
Hi Liu,
url: https://github.com/0day-ci/linux/commits/Liu-Yi-L/iommu-vt-d-Misc-fixes-on-scalable-mode/20201229-113203
base: 5c8fe583cce542aa0b84adc939ce85293de36e5e
config: i386-randconfig-m021-20201229 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/iommu/intel/iommu.c:1471 domain_update_iotlb() error: we previously assumed 'info' could be null (see line 1472)
Old smatch warnings:
drivers/iommu/intel/iommu.c:920 device_to_iommu() error: we previously assumed 'pdev' could be null (see line 893)
drivers/iommu/intel/iommu.c:3764 intel_iommu_add() warn: should '(1 << sp)' be a 64 bit type?
vim +/info +1471 drivers/iommu/intel/iommu.c
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1464 static void domain_update_iotlb(struct dmar_domain *domain)
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1465 {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1466 struct device_domain_info *info;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1467 bool has_iotlb_device = false;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1468
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1469 assert_spin_locked(&device_domain_lock);
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1470
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1471 list_for_each_entry(info, &domain->devices, link)
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1472 if (info && info->ats_enabled) {
^^^^
"info" is the list iterator so it can't ever be NULL. Just delete the
NULL check.
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1473 has_iotlb_device = true;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1474 break;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1475 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1476
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1477 if (!has_iotlb_device) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1478 struct subdev_domain_info *sinfo;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1479
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1480 list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1481 info = get_domain_info(sinfo->pdev);
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1482 if (info && info->ats_enabled) {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1483 has_iotlb_device = true;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1484 break;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1485 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1486 }
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1487 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1488
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1489 domain->has_iotlb_device = has_iotlb_device;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1490 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 35310 bytes --]
[-- Attachment #3: Type: text/plain, Size: 156 bytes --]
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2021-01-05 12:14 ` Dan Carpenter
0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2021-01-05 12:14 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 3786 bytes --]
Hi Liu,
url: https://github.com/0day-ci/linux/commits/Liu-Yi-L/iommu-vt-d-Misc-fixes-on-scalable-mode/20201229-113203
base: 5c8fe583cce542aa0b84adc939ce85293de36e5e
config: i386-randconfig-m021-20201229 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/iommu/intel/iommu.c:1471 domain_update_iotlb() error: we previously assumed 'info' could be null (see line 1472)
Old smatch warnings:
drivers/iommu/intel/iommu.c:920 device_to_iommu() error: we previously assumed 'pdev' could be null (see line 893)
drivers/iommu/intel/iommu.c:3764 intel_iommu_add() warn: should '(1 << sp)' be a 64 bit type?
vim +/info +1471 drivers/iommu/intel/iommu.c
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1464 static void domain_update_iotlb(struct dmar_domain *domain)
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1465 {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1466 struct device_domain_info *info;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1467 bool has_iotlb_device = false;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1468
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1469 assert_spin_locked(&device_domain_lock);
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1470
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1471 list_for_each_entry(info, &domain->devices, link)
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1472 if (info && info->ats_enabled) {
^^^^
"info" is the list iterator so it can't ever be NULL. Just delete the
NULL check.
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1473 has_iotlb_device = true;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1474 break;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1475 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1476
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1477 if (!has_iotlb_device) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1478 struct subdev_domain_info *sinfo;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1479
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1480 list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1481 info = get_domain_info(sinfo->pdev);
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1482 if (info && info->ats_enabled) {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1483 has_iotlb_device = true;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1484 break;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1485 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1486 }
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1487 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1488
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1489 domain->has_iotlb_device = has_iotlb_device;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1490 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35310 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2021-01-05 12:14 ` Dan Carpenter
0 siblings, 0 replies; 14+ messages in thread
From: Dan Carpenter @ 2021-01-05 12:14 UTC (permalink / raw)
To: kbuild-all
[-- Attachment #1: Type: text/plain, Size: 3786 bytes --]
Hi Liu,
url: https://github.com/0day-ci/linux/commits/Liu-Yi-L/iommu-vt-d-Misc-fixes-on-scalable-mode/20201229-113203
base: 5c8fe583cce542aa0b84adc939ce85293de36e5e
config: i386-randconfig-m021-20201229 (attached as .config)
compiler: gcc-9 (Debian 9.3.0-15) 9.3.0
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
New smatch warnings:
drivers/iommu/intel/iommu.c:1471 domain_update_iotlb() error: we previously assumed 'info' could be null (see line 1472)
Old smatch warnings:
drivers/iommu/intel/iommu.c:920 device_to_iommu() error: we previously assumed 'pdev' could be null (see line 893)
drivers/iommu/intel/iommu.c:3764 intel_iommu_add() warn: should '(1 << sp)' be a 64 bit type?
vim +/info +1471 drivers/iommu/intel/iommu.c
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1464 static void domain_update_iotlb(struct dmar_domain *domain)
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1465 {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1466 struct device_domain_info *info;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1467 bool has_iotlb_device = false;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1468
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1469 assert_spin_locked(&device_domain_lock);
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1470
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1471 list_for_each_entry(info, &domain->devices, link)
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 @1472 if (info && info->ats_enabled) {
^^^^
"info" is the list iterator so it can't ever be NULL. Just delete the
NULL check.
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1473 has_iotlb_device = true;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1474 break;
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1475 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1476
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1477 if (!has_iotlb_device) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1478 struct subdev_domain_info *sinfo;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1479
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1480 list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1481 info = get_domain_info(sinfo->pdev);
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1482 if (info && info->ats_enabled) {
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1483 has_iotlb_device = true;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1484 break;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1485 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1486 }
1aaf68f8927fb5c drivers/iommu/intel/iommu.c Liu Yi L 2020-12-29 1487 }
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1488
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1489 domain->has_iotlb_device = has_iotlb_device;
0824c5920b16fe1 drivers/iommu/intel-iommu.c Omer Peleg 2016-04-20 1490 }
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 35310 bytes --]
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
2020-12-29 8:41 ` Lu Baolu
@ 2021-01-05 5:50 ` Liu, Yi L
-1 siblings, 0 replies; 14+ messages in thread
From: Liu, Yi L @ 2021-01-05 5:50 UTC (permalink / raw)
To: Lu Baolu, joro, will
Cc: Tian, Kevin, jacob.jun.pan, Raj, Ashok, Tian, Jun J, Sun, Yi Y,
iommu, linux-kernel
Hi Baolu,
> From: Lu Baolu <baolu.lu@linux.intel.com>
> Sent: Tuesday, December 29, 2020 4:42 PM
>
> Hi Yi,
>
> On 2020/12/29 11:25, Liu Yi L wrote:
> > iommu_flush_dev_iotlb() is called to invalidate caches on device. It only
> > loops the devices which are full-attached to the domain. For sub-devices,
> > this is ineffective. This results in invalid caching entries left on the
> > device. Fix it by adding loop for subdevices as well. Also, the domain->
> > has_iotlb_device needs to be updated when attaching to subdevices.
> >
> > Fixes: 67b8e02b5e761 ("iommu/vt-d: Aux-domain specific domain
> attach/detach")
> > Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> > ---
> > drivers/iommu/intel/iommu.c | 53 ++++++++++++++++++++++++++---------
> --
> > 1 file changed, 37 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index d7720a836268..d48a60b61ba6 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -719,6 +719,8 @@ static int domain_update_device_node(struct
> dmar_domain *domain)
> > return nid;
> > }
> >
> > +static void domain_update_iotlb(struct dmar_domain *domain);
> > +
> > /* Some capabilities may be different across iommus */
> > static void domain_update_iommu_cap(struct dmar_domain *domain)
> > {
> > @@ -744,6 +746,8 @@ static void domain_update_iommu_cap(struct
> dmar_domain *domain)
> > domain->domain.geometry.aperture_end =
> __DOMAIN_MAX_ADDR(domain->gaw - 1);
> > else
> > domain->domain.geometry.aperture_end =
> __DOMAIN_MAX_ADDR(domain->gaw);
> > +
> > + domain_update_iotlb(domain);
> > }
> >
> > struct context_entry *iommu_context_addr(struct intel_iommu *iommu,
> u8 bus,
> > @@ -1464,17 +1468,22 @@ static void domain_update_iotlb(struct
> dmar_domain *domain)
> >
> > assert_spin_locked(&device_domain_lock);
> >
> > - list_for_each_entry(info, &domain->devices, link) {
> > - struct pci_dev *pdev;
> > -
> > - if (!info->dev || !dev_is_pci(info->dev))
> > - continue;
> > -
> > - pdev = to_pci_dev(info->dev);
> > - if (pdev->ats_enabled) {
> > + list_for_each_entry(info, &domain->devices, link)
> > + if (info && info->ats_enabled) {
> > has_iotlb_device = true;
> > break;
> > }
> > +
> > + if (!has_iotlb_device) {
> > + struct subdev_domain_info *sinfo;
> > +
> > + list_for_each_entry(sinfo, &domain->subdevices,
> link_domain) {
> > + info = get_domain_info(sinfo->pdev);
> > + if (info && info->ats_enabled) {
> > + has_iotlb_device = true;
> > + break;
> > + }
> > + }
> > }
> >
> > domain->has_iotlb_device = has_iotlb_device;
> > @@ -1555,25 +1564,37 @@ static void iommu_disable_dev_iotlb(struct
> device_domain_info *info)
> > #endif
> > }
> >
> > +static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
> > + u64 addr, unsigned int mask)
> > +{
> > + u16 sid, qdep;
> > +
> > + if (!info || !info->ats_enabled)
> > + return;
> > +
> > + sid = info->bus << 8 | info->devfn;
> > + qdep = info->ats_qdep;
> > + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > + qdep, addr, mask);
> > +}
> > +
> > static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> > u64 addr, unsigned mask)
> > {
> > - u16 sid, qdep;
> > unsigned long flags;
> > struct device_domain_info *info;
> > + struct subdev_domain_info *sinfo;
> >
> > if (!domain->has_iotlb_device)
> > return;
> >
> > spin_lock_irqsave(&device_domain_lock, flags);
> > - list_for_each_entry(info, &domain->devices, link) {
> > - if (!info->ats_enabled)
> > - continue;
> > + list_for_each_entry(info, &domain->devices, link)
> > + __iommu_flush_dev_iotlb(info, addr, mask);
> >
> > - sid = info->bus << 8 | info->devfn;
> > - qdep = info->ats_qdep;
> > - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > - qdep, addr, mask);
> > + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> > + addr, mask);
> > }
>
> Nit:
> list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> info = get_domain_info(sinfo->pdev);
> __iommu_flush_dev_iotlb(info, addr, mask);
> }
you are right. this should be better.
> Others look good to me.
>
> Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
>
> Best regards,
> baolu
Regards,
Yi Liu
> > spin_unlock_irqrestore(&device_domain_lock, flags);
> > }
> >
^ permalink raw reply [flat|nested] 14+ messages in thread
* RE: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2021-01-05 5:50 ` Liu, Yi L
0 siblings, 0 replies; 14+ messages in thread
From: Liu, Yi L @ 2021-01-05 5:50 UTC (permalink / raw)
To: Lu Baolu, joro, will
Cc: Tian, Kevin, Raj, Ashok, Tian, Jun J, iommu, linux-kernel, Sun, Yi Y
Hi Baolu,
> From: Lu Baolu <baolu.lu@linux.intel.com>
> Sent: Tuesday, December 29, 2020 4:42 PM
>
> Hi Yi,
>
> On 2020/12/29 11:25, Liu Yi L wrote:
> > iommu_flush_dev_iotlb() is called to invalidate caches on device. It only
> > loops the devices which are full-attached to the domain. For sub-devices,
> > this is ineffective. This results in invalid caching entries left on the
> > device. Fix it by adding loop for subdevices as well. Also, the domain->
> > has_iotlb_device needs to be updated when attaching to subdevices.
> >
> > Fixes: 67b8e02b5e761 ("iommu/vt-d: Aux-domain specific domain
> attach/detach")
> > Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> > ---
> > drivers/iommu/intel/iommu.c | 53 ++++++++++++++++++++++++++---------
> --
> > 1 file changed, 37 insertions(+), 16 deletions(-)
> >
> > diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> > index d7720a836268..d48a60b61ba6 100644
> > --- a/drivers/iommu/intel/iommu.c
> > +++ b/drivers/iommu/intel/iommu.c
> > @@ -719,6 +719,8 @@ static int domain_update_device_node(struct
> dmar_domain *domain)
> > return nid;
> > }
> >
> > +static void domain_update_iotlb(struct dmar_domain *domain);
> > +
> > /* Some capabilities may be different across iommus */
> > static void domain_update_iommu_cap(struct dmar_domain *domain)
> > {
> > @@ -744,6 +746,8 @@ static void domain_update_iommu_cap(struct
> dmar_domain *domain)
> > domain->domain.geometry.aperture_end =
> __DOMAIN_MAX_ADDR(domain->gaw - 1);
> > else
> > domain->domain.geometry.aperture_end =
> __DOMAIN_MAX_ADDR(domain->gaw);
> > +
> > + domain_update_iotlb(domain);
> > }
> >
> > struct context_entry *iommu_context_addr(struct intel_iommu *iommu,
> u8 bus,
> > @@ -1464,17 +1468,22 @@ static void domain_update_iotlb(struct
> dmar_domain *domain)
> >
> > assert_spin_locked(&device_domain_lock);
> >
> > - list_for_each_entry(info, &domain->devices, link) {
> > - struct pci_dev *pdev;
> > -
> > - if (!info->dev || !dev_is_pci(info->dev))
> > - continue;
> > -
> > - pdev = to_pci_dev(info->dev);
> > - if (pdev->ats_enabled) {
> > + list_for_each_entry(info, &domain->devices, link)
> > + if (info && info->ats_enabled) {
> > has_iotlb_device = true;
> > break;
> > }
> > +
> > + if (!has_iotlb_device) {
> > + struct subdev_domain_info *sinfo;
> > +
> > + list_for_each_entry(sinfo, &domain->subdevices,
> link_domain) {
> > + info = get_domain_info(sinfo->pdev);
> > + if (info && info->ats_enabled) {
> > + has_iotlb_device = true;
> > + break;
> > + }
> > + }
> > }
> >
> > domain->has_iotlb_device = has_iotlb_device;
> > @@ -1555,25 +1564,37 @@ static void iommu_disable_dev_iotlb(struct
> device_domain_info *info)
> > #endif
> > }
> >
> > +static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
> > + u64 addr, unsigned int mask)
> > +{
> > + u16 sid, qdep;
> > +
> > + if (!info || !info->ats_enabled)
> > + return;
> > +
> > + sid = info->bus << 8 | info->devfn;
> > + qdep = info->ats_qdep;
> > + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > + qdep, addr, mask);
> > +}
> > +
> > static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> > u64 addr, unsigned mask)
> > {
> > - u16 sid, qdep;
> > unsigned long flags;
> > struct device_domain_info *info;
> > + struct subdev_domain_info *sinfo;
> >
> > if (!domain->has_iotlb_device)
> > return;
> >
> > spin_lock_irqsave(&device_domain_lock, flags);
> > - list_for_each_entry(info, &domain->devices, link) {
> > - if (!info->ats_enabled)
> > - continue;
> > + list_for_each_entry(info, &domain->devices, link)
> > + __iommu_flush_dev_iotlb(info, addr, mask);
> >
> > - sid = info->bus << 8 | info->devfn;
> > - qdep = info->ats_qdep;
> > - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> > - qdep, addr, mask);
> > + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> > + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> > + addr, mask);
> > }
>
> Nit:
> list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> info = get_domain_info(sinfo->pdev);
> __iommu_flush_dev_iotlb(info, addr, mask);
> }
you are right. this should be better.
> Others look good to me.
>
> Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
>
> Best regards,
> baolu
Regards,
Yi Liu
> > spin_unlock_irqrestore(&device_domain_lock, flags);
> > }
> >
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
2020-12-29 3:25 ` Liu Yi L
@ 2020-12-29 8:41 ` Lu Baolu
-1 siblings, 0 replies; 14+ messages in thread
From: Lu Baolu @ 2020-12-29 8:41 UTC (permalink / raw)
To: Liu Yi L, joro, will
Cc: baolu.lu, kevin.tian, jacob.jun.pan, ashok.raj, jun.j.tian,
yi.y.sun, iommu, linux-kernel
Hi Yi,
On 2020/12/29 11:25, Liu Yi L wrote:
> iommu_flush_dev_iotlb() is called to invalidate caches on device. It only
> loops the devices which are full-attached to the domain. For sub-devices,
> this is ineffective. This results in invalid caching entries left on the
> device. Fix it by adding loop for subdevices as well. Also, the domain->
> has_iotlb_device needs to be updated when attaching to subdevices.
>
> Fixes: 67b8e02b5e761 ("iommu/vt-d: Aux-domain specific domain attach/detach")
> Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> ---
> drivers/iommu/intel/iommu.c | 53 ++++++++++++++++++++++++++-----------
> 1 file changed, 37 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index d7720a836268..d48a60b61ba6 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -719,6 +719,8 @@ static int domain_update_device_node(struct dmar_domain *domain)
> return nid;
> }
>
> +static void domain_update_iotlb(struct dmar_domain *domain);
> +
> /* Some capabilities may be different across iommus */
> static void domain_update_iommu_cap(struct dmar_domain *domain)
> {
> @@ -744,6 +746,8 @@ static void domain_update_iommu_cap(struct dmar_domain *domain)
> domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw - 1);
> else
> domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw);
> +
> + domain_update_iotlb(domain);
> }
>
> struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
> @@ -1464,17 +1468,22 @@ static void domain_update_iotlb(struct dmar_domain *domain)
>
> assert_spin_locked(&device_domain_lock);
>
> - list_for_each_entry(info, &domain->devices, link) {
> - struct pci_dev *pdev;
> -
> - if (!info->dev || !dev_is_pci(info->dev))
> - continue;
> -
> - pdev = to_pci_dev(info->dev);
> - if (pdev->ats_enabled) {
> + list_for_each_entry(info, &domain->devices, link)
> + if (info && info->ats_enabled) {
> has_iotlb_device = true;
> break;
> }
> +
> + if (!has_iotlb_device) {
> + struct subdev_domain_info *sinfo;
> +
> + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> + info = get_domain_info(sinfo->pdev);
> + if (info && info->ats_enabled) {
> + has_iotlb_device = true;
> + break;
> + }
> + }
> }
>
> domain->has_iotlb_device = has_iotlb_device;
> @@ -1555,25 +1564,37 @@ static void iommu_disable_dev_iotlb(struct device_domain_info *info)
> #endif
> }
>
> +static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
> + u64 addr, unsigned int mask)
> +{
> + u16 sid, qdep;
> +
> + if (!info || !info->ats_enabled)
> + return;
> +
> + sid = info->bus << 8 | info->devfn;
> + qdep = info->ats_qdep;
> + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> + qdep, addr, mask);
> +}
> +
> static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> u64 addr, unsigned mask)
> {
> - u16 sid, qdep;
> unsigned long flags;
> struct device_domain_info *info;
> + struct subdev_domain_info *sinfo;
>
> if (!domain->has_iotlb_device)
> return;
>
> spin_lock_irqsave(&device_domain_lock, flags);
> - list_for_each_entry(info, &domain->devices, link) {
> - if (!info->ats_enabled)
> - continue;
> + list_for_each_entry(info, &domain->devices, link)
> + __iommu_flush_dev_iotlb(info, addr, mask);
>
> - sid = info->bus << 8 | info->devfn;
> - qdep = info->ats_qdep;
> - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> - qdep, addr, mask);
> + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> + addr, mask);
> }
Nit:
list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
info = get_domain_info(sinfo->pdev);
__iommu_flush_dev_iotlb(info, addr, mask);
}
Others look good to me.
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards,
baolu
> spin_unlock_irqrestore(&device_domain_lock, flags);
> }
>
^ permalink raw reply [flat|nested] 14+ messages in thread
* Re: [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2020-12-29 8:41 ` Lu Baolu
0 siblings, 0 replies; 14+ messages in thread
From: Lu Baolu @ 2020-12-29 8:41 UTC (permalink / raw)
To: Liu Yi L, joro, will
Cc: kevin.tian, ashok.raj, jun.j.tian, iommu, linux-kernel, yi.y.sun
Hi Yi,
On 2020/12/29 11:25, Liu Yi L wrote:
> iommu_flush_dev_iotlb() is called to invalidate caches on device. It only
> loops the devices which are full-attached to the domain. For sub-devices,
> this is ineffective. This results in invalid caching entries left on the
> device. Fix it by adding loop for subdevices as well. Also, the domain->
> has_iotlb_device needs to be updated when attaching to subdevices.
>
> Fixes: 67b8e02b5e761 ("iommu/vt-d: Aux-domain specific domain attach/detach")
> Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
> ---
> drivers/iommu/intel/iommu.c | 53 ++++++++++++++++++++++++++-----------
> 1 file changed, 37 insertions(+), 16 deletions(-)
>
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index d7720a836268..d48a60b61ba6 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -719,6 +719,8 @@ static int domain_update_device_node(struct dmar_domain *domain)
> return nid;
> }
>
> +static void domain_update_iotlb(struct dmar_domain *domain);
> +
> /* Some capabilities may be different across iommus */
> static void domain_update_iommu_cap(struct dmar_domain *domain)
> {
> @@ -744,6 +746,8 @@ static void domain_update_iommu_cap(struct dmar_domain *domain)
> domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw - 1);
> else
> domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw);
> +
> + domain_update_iotlb(domain);
> }
>
> struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
> @@ -1464,17 +1468,22 @@ static void domain_update_iotlb(struct dmar_domain *domain)
>
> assert_spin_locked(&device_domain_lock);
>
> - list_for_each_entry(info, &domain->devices, link) {
> - struct pci_dev *pdev;
> -
> - if (!info->dev || !dev_is_pci(info->dev))
> - continue;
> -
> - pdev = to_pci_dev(info->dev);
> - if (pdev->ats_enabled) {
> + list_for_each_entry(info, &domain->devices, link)
> + if (info && info->ats_enabled) {
> has_iotlb_device = true;
> break;
> }
> +
> + if (!has_iotlb_device) {
> + struct subdev_domain_info *sinfo;
> +
> + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> + info = get_domain_info(sinfo->pdev);
> + if (info && info->ats_enabled) {
> + has_iotlb_device = true;
> + break;
> + }
> + }
> }
>
> domain->has_iotlb_device = has_iotlb_device;
> @@ -1555,25 +1564,37 @@ static void iommu_disable_dev_iotlb(struct device_domain_info *info)
> #endif
> }
>
> +static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
> + u64 addr, unsigned int mask)
> +{
> + u16 sid, qdep;
> +
> + if (!info || !info->ats_enabled)
> + return;
> +
> + sid = info->bus << 8 | info->devfn;
> + qdep = info->ats_qdep;
> + qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> + qdep, addr, mask);
> +}
> +
> static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
> u64 addr, unsigned mask)
> {
> - u16 sid, qdep;
> unsigned long flags;
> struct device_domain_info *info;
> + struct subdev_domain_info *sinfo;
>
> if (!domain->has_iotlb_device)
> return;
>
> spin_lock_irqsave(&device_domain_lock, flags);
> - list_for_each_entry(info, &domain->devices, link) {
> - if (!info->ats_enabled)
> - continue;
> + list_for_each_entry(info, &domain->devices, link)
> + __iommu_flush_dev_iotlb(info, addr, mask);
>
> - sid = info->bus << 8 | info->devfn;
> - qdep = info->ats_qdep;
> - qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
> - qdep, addr, mask);
> + list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
> + __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
> + addr, mask);
> }
Nit:
list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
info = get_domain_info(sinfo->pdev);
__iommu_flush_dev_iotlb(info, addr, mask);
}
Others look good to me.
Acked-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards,
baolu
> spin_unlock_irqrestore(&device_domain_lock, flags);
> }
>
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply [flat|nested] 14+ messages in thread
* [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
2020-12-29 3:25 [PATCH v3 0/3] iommu/vt-d: Misc fixes on scalable mode Liu Yi L
@ 2020-12-29 3:25 ` Liu Yi L
0 siblings, 0 replies; 14+ messages in thread
From: Liu Yi L @ 2020-12-29 3:25 UTC (permalink / raw)
To: baolu.lu, joro, will
Cc: kevin.tian, jacob.jun.pan, ashok.raj, yi.l.liu, jun.j.tian,
yi.y.sun, iommu, linux-kernel
iommu_flush_dev_iotlb() is called to invalidate caches on device. It only
loops the devices which are full-attached to the domain. For sub-devices,
this is ineffective. This results in invalid caching entries left on the
device. Fix it by adding loop for subdevices as well. Also, the domain->
has_iotlb_device needs to be updated when attaching to subdevices.
Fixes: 67b8e02b5e761 ("iommu/vt-d: Aux-domain specific domain attach/detach")
Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
---
drivers/iommu/intel/iommu.c | 53 ++++++++++++++++++++++++++-----------
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index d7720a836268..d48a60b61ba6 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -719,6 +719,8 @@ static int domain_update_device_node(struct dmar_domain *domain)
return nid;
}
+static void domain_update_iotlb(struct dmar_domain *domain);
+
/* Some capabilities may be different across iommus */
static void domain_update_iommu_cap(struct dmar_domain *domain)
{
@@ -744,6 +746,8 @@ static void domain_update_iommu_cap(struct dmar_domain *domain)
domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw - 1);
else
domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw);
+
+ domain_update_iotlb(domain);
}
struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
@@ -1464,17 +1468,22 @@ static void domain_update_iotlb(struct dmar_domain *domain)
assert_spin_locked(&device_domain_lock);
- list_for_each_entry(info, &domain->devices, link) {
- struct pci_dev *pdev;
-
- if (!info->dev || !dev_is_pci(info->dev))
- continue;
-
- pdev = to_pci_dev(info->dev);
- if (pdev->ats_enabled) {
+ list_for_each_entry(info, &domain->devices, link)
+ if (info && info->ats_enabled) {
has_iotlb_device = true;
break;
}
+
+ if (!has_iotlb_device) {
+ struct subdev_domain_info *sinfo;
+
+ list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
+ info = get_domain_info(sinfo->pdev);
+ if (info && info->ats_enabled) {
+ has_iotlb_device = true;
+ break;
+ }
+ }
}
domain->has_iotlb_device = has_iotlb_device;
@@ -1555,25 +1564,37 @@ static void iommu_disable_dev_iotlb(struct device_domain_info *info)
#endif
}
+static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
+ u64 addr, unsigned int mask)
+{
+ u16 sid, qdep;
+
+ if (!info || !info->ats_enabled)
+ return;
+
+ sid = info->bus << 8 | info->devfn;
+ qdep = info->ats_qdep;
+ qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
+ qdep, addr, mask);
+}
+
static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
u64 addr, unsigned mask)
{
- u16 sid, qdep;
unsigned long flags;
struct device_domain_info *info;
+ struct subdev_domain_info *sinfo;
if (!domain->has_iotlb_device)
return;
spin_lock_irqsave(&device_domain_lock, flags);
- list_for_each_entry(info, &domain->devices, link) {
- if (!info->ats_enabled)
- continue;
+ list_for_each_entry(info, &domain->devices, link)
+ __iommu_flush_dev_iotlb(info, addr, mask);
- sid = info->bus << 8 | info->devfn;
- qdep = info->ats_qdep;
- qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
- qdep, addr, mask);
+ list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
+ __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
+ addr, mask);
}
spin_unlock_irqrestore(&device_domain_lock, flags);
}
--
2.25.1
^ permalink raw reply related [flat|nested] 14+ messages in thread
* [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices
@ 2020-12-29 3:25 ` Liu Yi L
0 siblings, 0 replies; 14+ messages in thread
From: Liu Yi L @ 2020-12-29 3:25 UTC (permalink / raw)
To: baolu.lu, joro, will
Cc: kevin.tian, ashok.raj, jun.j.tian, iommu, linux-kernel, yi.y.sun
iommu_flush_dev_iotlb() is called to invalidate caches on device. It only
loops the devices which are full-attached to the domain. For sub-devices,
this is ineffective. This results in invalid caching entries left on the
device. Fix it by adding loop for subdevices as well. Also, the domain->
has_iotlb_device needs to be updated when attaching to subdevices.
Fixes: 67b8e02b5e761 ("iommu/vt-d: Aux-domain specific domain attach/detach")
Signed-off-by: Liu Yi L <yi.l.liu@intel.com>
---
drivers/iommu/intel/iommu.c | 53 ++++++++++++++++++++++++++-----------
1 file changed, 37 insertions(+), 16 deletions(-)
diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
index d7720a836268..d48a60b61ba6 100644
--- a/drivers/iommu/intel/iommu.c
+++ b/drivers/iommu/intel/iommu.c
@@ -719,6 +719,8 @@ static int domain_update_device_node(struct dmar_domain *domain)
return nid;
}
+static void domain_update_iotlb(struct dmar_domain *domain);
+
/* Some capabilities may be different across iommus */
static void domain_update_iommu_cap(struct dmar_domain *domain)
{
@@ -744,6 +746,8 @@ static void domain_update_iommu_cap(struct dmar_domain *domain)
domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw - 1);
else
domain->domain.geometry.aperture_end = __DOMAIN_MAX_ADDR(domain->gaw);
+
+ domain_update_iotlb(domain);
}
struct context_entry *iommu_context_addr(struct intel_iommu *iommu, u8 bus,
@@ -1464,17 +1468,22 @@ static void domain_update_iotlb(struct dmar_domain *domain)
assert_spin_locked(&device_domain_lock);
- list_for_each_entry(info, &domain->devices, link) {
- struct pci_dev *pdev;
-
- if (!info->dev || !dev_is_pci(info->dev))
- continue;
-
- pdev = to_pci_dev(info->dev);
- if (pdev->ats_enabled) {
+ list_for_each_entry(info, &domain->devices, link)
+ if (info && info->ats_enabled) {
has_iotlb_device = true;
break;
}
+
+ if (!has_iotlb_device) {
+ struct subdev_domain_info *sinfo;
+
+ list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
+ info = get_domain_info(sinfo->pdev);
+ if (info && info->ats_enabled) {
+ has_iotlb_device = true;
+ break;
+ }
+ }
}
domain->has_iotlb_device = has_iotlb_device;
@@ -1555,25 +1564,37 @@ static void iommu_disable_dev_iotlb(struct device_domain_info *info)
#endif
}
+static void __iommu_flush_dev_iotlb(struct device_domain_info *info,
+ u64 addr, unsigned int mask)
+{
+ u16 sid, qdep;
+
+ if (!info || !info->ats_enabled)
+ return;
+
+ sid = info->bus << 8 | info->devfn;
+ qdep = info->ats_qdep;
+ qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
+ qdep, addr, mask);
+}
+
static void iommu_flush_dev_iotlb(struct dmar_domain *domain,
u64 addr, unsigned mask)
{
- u16 sid, qdep;
unsigned long flags;
struct device_domain_info *info;
+ struct subdev_domain_info *sinfo;
if (!domain->has_iotlb_device)
return;
spin_lock_irqsave(&device_domain_lock, flags);
- list_for_each_entry(info, &domain->devices, link) {
- if (!info->ats_enabled)
- continue;
+ list_for_each_entry(info, &domain->devices, link)
+ __iommu_flush_dev_iotlb(info, addr, mask);
- sid = info->bus << 8 | info->devfn;
- qdep = info->ats_qdep;
- qi_flush_dev_iotlb(info->iommu, sid, info->pfsid,
- qdep, addr, mask);
+ list_for_each_entry(sinfo, &domain->subdevices, link_domain) {
+ __iommu_flush_dev_iotlb(get_domain_info(sinfo->pdev),
+ addr, mask);
}
spin_unlock_irqrestore(&device_domain_lock, flags);
}
--
2.25.1
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu
^ permalink raw reply related [flat|nested] 14+ messages in thread
end of thread, other threads:[~2021-01-07 5:23 UTC | newest]
Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-29 8:42 [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices kernel test robot
-- strict thread matches above, loose matches on Subject: below --
2020-12-29 3:25 [PATCH v3 0/3] iommu/vt-d: Misc fixes on scalable mode Liu Yi L
2020-12-29 3:25 ` [PATCH v3 3/3] iommu/vt-d: Fix ineffective devTLB invalidation for subdevices Liu Yi L
2020-12-29 3:25 ` Liu Yi L
2020-12-29 8:41 ` Lu Baolu
2020-12-29 8:41 ` Lu Baolu
2021-01-05 5:50 ` Liu, Yi L
2021-01-05 5:50 ` Liu, Yi L
2021-01-05 17:23 ` Will Deacon
2021-01-05 17:23 ` Will Deacon
2021-01-07 5:22 ` Liu, Yi L
2021-01-07 5:22 ` Liu, Yi L
2021-01-05 12:14 ` Dan Carpenter
2021-01-05 12:14 ` Dan Carpenter
2021-01-05 12:14 ` Dan Carpenter
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.