Re: [PATCH v11 3/5] iommu/vt-d: simplify parameters of qi_submit_sync() ATS invalidation callers

From: kernel test robot
Date: Fri Jan 26 2024 - 22:55:37 EST


Hi Ethan,

kernel test robot noticed the following build warnings:

[auto build test WARNING on pci/next]
[also build test WARNING on pci/for-linus linus/master v6.8-rc1 next-20240125]
[cannot apply to joro-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#_base_tree_information]

url: https://github.com/intel-lab-lkp/linux/commits/Ethan-Zhao/PCI-make-pci_dev_is_disconnected-helper-public-for-other-drivers/20240126-094305
base: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git next
patch link: https://lore.kernel.org/r/20240126014002.481294-4-haifeng.zhao%40linux.intel.com
patch subject: [PATCH v11 3/5] iommu/vt-d: simplify parameters of qi_submit_sync() ATS invalidation callers
config: i386-buildonly-randconfig-001-20240127 (https://download.01.org/0day-ci/archive/20240127/202401271122.0kJRQe33-lkp@xxxxxxxxx/config)
compiler: gcc-7 (Ubuntu 7.5.0-6ubuntu2) 7.5.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240127/202401271122.0kJRQe33-lkp@xxxxxxxxx/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@xxxxxxxxx>
| Closes: https://lore.kernel.org/oe-kbuild-all/202401271122.0kJRQe33-lkp@xxxxxxxxx/

All warnings (new ones prefixed by >>):

drivers/iommu/intel/iommu.c: In function 'quirk_extra_dev_tlb_flush':
>> drivers/iommu/intel/iommu.c:4987:6: warning: variable 'sid' set but not used [-Wunused-but-set-variable]
u16 sid;
^~~


vim +/sid +4987 drivers/iommu/intel/iommu.c

e65a6897be5e49 Jacob Pan 2022-12-01 4957
e65a6897be5e49 Jacob Pan 2022-12-01 4958 /*
e65a6897be5e49 Jacob Pan 2022-12-01 4959 * Here we deal with a device TLB defect where device may inadvertently issue ATS
e65a6897be5e49 Jacob Pan 2022-12-01 4960 * invalidation completion before posted writes initiated with translated address
e65a6897be5e49 Jacob Pan 2022-12-01 4961 * that utilized translations matching the invalidation address range, violating
e65a6897be5e49 Jacob Pan 2022-12-01 4962 * the invalidation completion ordering.
e65a6897be5e49 Jacob Pan 2022-12-01 4963 * Therefore, any use cases that cannot guarantee DMA is stopped before unmap is
e65a6897be5e49 Jacob Pan 2022-12-01 4964 * vulnerable to this defect. In other words, any dTLB invalidation initiated not
e65a6897be5e49 Jacob Pan 2022-12-01 4965 * under the control of the trusted/privileged host device driver must use this
e65a6897be5e49 Jacob Pan 2022-12-01 4966 * quirk.
e65a6897be5e49 Jacob Pan 2022-12-01 4967 * Device TLBs are invalidated under the following six conditions:
e65a6897be5e49 Jacob Pan 2022-12-01 4968 * 1. Device driver does DMA API unmap IOVA
e65a6897be5e49 Jacob Pan 2022-12-01 4969 * 2. Device driver unbind a PASID from a process, sva_unbind_device()
e65a6897be5e49 Jacob Pan 2022-12-01 4970 * 3. PASID is torn down, after PASID cache is flushed. e.g. process
e65a6897be5e49 Jacob Pan 2022-12-01 4971 * exit_mmap() due to crash
e65a6897be5e49 Jacob Pan 2022-12-01 4972 * 4. Under SVA usage, called by mmu_notifier.invalidate_range() where
e65a6897be5e49 Jacob Pan 2022-12-01 4973 * VM has to free pages that were unmapped
e65a6897be5e49 Jacob Pan 2022-12-01 4974 * 5. Userspace driver unmaps a DMA buffer
e65a6897be5e49 Jacob Pan 2022-12-01 4975 * 6. Cache invalidation in vSVA usage (upcoming)
e65a6897be5e49 Jacob Pan 2022-12-01 4976 *
e65a6897be5e49 Jacob Pan 2022-12-01 4977 * For #1 and #2, device drivers are responsible for stopping DMA traffic
e65a6897be5e49 Jacob Pan 2022-12-01 4978 * before unmap/unbind. For #3, iommu driver gets mmu_notifier to
e65a6897be5e49 Jacob Pan 2022-12-01 4979 * invalidate TLB the same way as normal user unmap which will use this quirk.
e65a6897be5e49 Jacob Pan 2022-12-01 4980 * The dTLB invalidation after PASID cache flush does not need this quirk.
e65a6897be5e49 Jacob Pan 2022-12-01 4981 *
e65a6897be5e49 Jacob Pan 2022-12-01 4982 * As a reminder, #6 will *NEED* this quirk as we enable nested translation.
e65a6897be5e49 Jacob Pan 2022-12-01 4983 */
e2fcf16ac26679 Ethan Zhao 2024-01-25 4984 void quirk_extra_dev_tlb_flush(struct device_domain_info *info, u32 pasid,
e2fcf16ac26679 Ethan Zhao 2024-01-25 4985 unsigned long address, unsigned long mask)
e65a6897be5e49 Jacob Pan 2022-12-01 4986 {
e65a6897be5e49 Jacob Pan 2022-12-01 @4987 u16 sid;
e65a6897be5e49 Jacob Pan 2022-12-01 4988
e65a6897be5e49 Jacob Pan 2022-12-01 4989 if (likely(!info->dtlb_extra_inval))
e65a6897be5e49 Jacob Pan 2022-12-01 4990 return;
e65a6897be5e49 Jacob Pan 2022-12-01 4991
e65a6897be5e49 Jacob Pan 2022-12-01 4992 sid = PCI_DEVID(info->bus, info->devfn);
4298780126c298 Jacob Pan 2023-08-09 4993 if (pasid == IOMMU_NO_PASID) {
e2fcf16ac26679 Ethan Zhao 2024-01-25 4994 qi_flush_dev_iotlb(info->iommu, info, address, mask);
e65a6897be5e49 Jacob Pan 2022-12-01 4995 } else {
e2fcf16ac26679 Ethan Zhao 2024-01-25 4996 qi_flush_dev_iotlb_pasid(info->iommu, info, address, pasid, mask);
e65a6897be5e49 Jacob Pan 2022-12-01 4997 }
e65a6897be5e49 Jacob Pan 2022-12-01 4998 }
dc57875866ab9f Kan Liang 2023-01-31 4999

--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki