From: Joerg Roedel <[email protected]>
A recent commit introduced these compile warnings:
CC drivers/iommu/amd/init.o
drivers/iommu/amd/init.c:938:12: error: ‘iommu_init_ga_log’ defined but not used [-Werror=unused-function]
938 | static int iommu_init_ga_log(struct amd_iommu *iommu)
| ^~~~~~~~~~~~~~~~~
drivers/iommu/amd/init.c:902:12: error: ‘iommu_ga_log_enable’ defined but not used [-Werror=unused-function]
902 | static int iommu_ga_log_enable(struct amd_iommu *iommu)
| ^~~~~~~~~~~~~~~~~~~
The warnings appear because both functions are defined when IRQ
remapping is not enabled, but only used when IRQ remapping is enabled.
Fix it by only defining the functions when IRQ remapping is enabled.
Fixes: c5e1a1eb9279 ("iommu/amd: Simplify and Consolidate Virtual APIC (AVIC) Enablement")
Signed-off-by: Joerg Roedel <[email protected]>
---
drivers/iommu/amd/init.c | 9 +++------
1 file changed, 3 insertions(+), 6 deletions(-)
diff --git a/drivers/iommu/amd/init.c b/drivers/iommu/amd/init.c
index 6bbaf6b971e8..fdc642362c14 100644
--- a/drivers/iommu/amd/init.c
+++ b/drivers/iommu/amd/init.c
@@ -899,9 +899,9 @@ static void free_ga_log(struct amd_iommu *iommu)
#endif
}
+#ifdef CONFIG_IRQ_REMAP
static int iommu_ga_log_enable(struct amd_iommu *iommu)
{
-#ifdef CONFIG_IRQ_REMAP
u32 status, i;
u64 entry;
@@ -931,13 +931,12 @@ static int iommu_ga_log_enable(struct amd_iommu *iommu)
if (WARN_ON(i >= LOOP_TIMEOUT))
return -EINVAL;
-#endif /* CONFIG_IRQ_REMAP */
+
return 0;
}
static int iommu_init_ga_log(struct amd_iommu *iommu)
{
-#ifdef CONFIG_IRQ_REMAP
if (!AMD_IOMMU_GUEST_IR_VAPIC(amd_iommu_guest_ir))
return 0;
@@ -955,10 +954,8 @@ static int iommu_init_ga_log(struct amd_iommu *iommu)
err_out:
free_ga_log(iommu);
return -EINVAL;
-#else
- return 0;
-#endif /* CONFIG_IRQ_REMAP */
}
+#endif /* CONFIG_IRQ_REMAP */
static int __init alloc_cwwb_sem(struct amd_iommu *iommu)
{
--
2.36.1
On Fri, Jul 29, 2022 at 12:04:32PM +0200, Joerg Roedel wrote:
> From: Joerg Roedel <[email protected]>
>
> A recent commit introduced these compile warnings:
>
> CC drivers/iommu/amd/init.o
> drivers/iommu/amd/init.c:938:12: error: ‘iommu_init_ga_log’ defined but not used [-Werror=unused-function]
> 938 | static int iommu_init_ga_log(struct amd_iommu *iommu)
> | ^~~~~~~~~~~~~~~~~
> drivers/iommu/amd/init.c:902:12: error: ‘iommu_ga_log_enable’ defined but not used [-Werror=unused-function]
> 902 | static int iommu_ga_log_enable(struct amd_iommu *iommu)
> | ^~~~~~~~~~~~~~~~~~~
>
> The warnings appear because both functions are defined when IRQ
> remapping is not enabled, but only used when IRQ remapping is enabled.
>
> Fix it by only defining the functions when IRQ remapping is enabled.
>
> Fixes: c5e1a1eb9279 ("iommu/amd: Simplify and Consolidate Virtual APIC (AVIC) Enablement")
> Signed-off-by: Joerg Roedel <[email protected]>
Reviewed-by: Jerry Snitselaar <[email protected]>
Hi Joerg,
I love your patch! Yet something to improve:
[auto build test ERROR on v5.19-rc8]
[also build test ERROR on linus/master next-20220728]
[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/Joerg-Roedel/iommu-amd-Fix-compile-warning-in-init-code/20220729-180535
base: e0dccc3b76fb35bb257b4118367a883073d7390e
config: x86_64-defconfig (https://download.01.org/0day-ci/archive/20220729/[email protected]/config)
compiler: gcc-11 (Debian 11.3.0-3) 11.3.0
reproduce (this is a W=1 build):
# https://github.com/intel-lab-lkp/linux/commit/87617e946268b6df880692ca42bae4f7fb7688de
git remote add linux-review https://github.com/intel-lab-lkp/linux
git fetch --no-tags linux-review Joerg-Roedel/iommu-amd-Fix-compile-warning-in-init-code/20220729-180535
git checkout 87617e946268b6df880692ca42bae4f7fb7688de
# save the config file
mkdir build_dir && cp config build_dir/.config
make W=1 O=build_dir ARCH=x86_64 SHELL=/bin/bash
If you fix the issue, kindly add following tag where applicable
Reported-by: kernel test robot <[email protected]>
All errors (new ones prefixed by >>):
drivers/iommu/amd/init.c: In function 'iommu_init_pci':
>> drivers/iommu/amd/init.c:1863:15: error: implicit declaration of function 'iommu_init_ga_log'; did you mean 'iommu_init_pci'? [-Werror=implicit-function-declaration]
1863 | ret = iommu_init_ga_log(iommu);
| ^~~~~~~~~~~~~~~~~
| iommu_init_pci
drivers/iommu/amd/init.c: In function 'iommu_init_irq':
>> drivers/iommu/amd/init.c:2233:9: error: implicit declaration of function 'iommu_ga_log_enable'; did you mean 'iommu_feature_enable'? [-Werror=implicit-function-declaration]
2233 | iommu_ga_log_enable(iommu);
| ^~~~~~~~~~~~~~~~~~~
| iommu_feature_enable
cc1: some warnings being treated as errors
vim +1863 drivers/iommu/amd/init.c
a44092e326d403c drivers/iommu/amd/init.c Suravee Suthikulpanit 2021-01-20 1810
24d2c521749d854 drivers/iommu/amd_iommu_init.c Joerg Roedel 2018-10-05 1811 static int __init iommu_init_pci(struct amd_iommu *iommu)
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1812 {
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1813 int cap_ptr = iommu->cap_ptr;
8bda0cfbdc1a627 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2016-08-23 1814 int ret;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1815
d5bf0f4f2bade2f drivers/iommu/amd_iommu_init.c Sinan Kaya 2017-12-19 1816 iommu->dev = pci_get_domain_bus_and_slot(0, PCI_BUS_NUM(iommu->devid),
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1817 iommu->devid & 0xff);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1818 if (!iommu->dev)
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1819 return -ENODEV;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1820
cbbc00be2ce3af5 drivers/iommu/amd_iommu_init.c Jiang Liu 2015-10-09 1821 /* Prevent binding other PCI device drivers to IOMMU devices */
cbbc00be2ce3af5 drivers/iommu/amd_iommu_init.c Jiang Liu 2015-10-09 1822 iommu->dev->match_driver = false;
cbbc00be2ce3af5 drivers/iommu/amd_iommu_init.c Jiang Liu 2015-10-09 1823
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1824 pci_read_config_dword(iommu->dev, cap_ptr + MMIO_CAP_HDR_OFFSET,
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1825 &iommu->cap);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1826
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1827 if (!(iommu->cap & (1 << IOMMU_CAP_IOTLB)))
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1828 amd_iommu_iotlb_sup = false;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1829
a44092e326d403c drivers/iommu/amd/init.c Suravee Suthikulpanit 2021-01-20 1830 late_iommu_features_init(iommu);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1831
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1832 if (iommu_feature(iommu, FEATURE_GT)) {
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1833 int glxval;
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1834 u32 max_pasid;
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1835 u64 pasmax;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1836
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1837 pasmax = iommu->features & FEATURE_PASID_MASK;
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1838 pasmax >>= FEATURE_PASID_SHIFT;
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1839 max_pasid = (1 << (pasmax + 1)) - 1;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1840
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1841 amd_iommu_max_pasid = min(amd_iommu_max_pasid, max_pasid);
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1842
a919a018cccf999 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2014-03-05 1843 BUG_ON(amd_iommu_max_pasid & ~PASID_MASK);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1844
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1845 glxval = iommu->features & FEATURE_GLXVAL_MASK;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1846 glxval >>= FEATURE_GLXVAL_SHIFT;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1847
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1848 if (amd_iommu_max_glx_val == -1)
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1849 amd_iommu_max_glx_val = glxval;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1850 else
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1851 amd_iommu_max_glx_val = min(amd_iommu_max_glx_val, glxval);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1852 }
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1853
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1854 if (iommu_feature(iommu, FEATURE_GT) &&
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1855 iommu_feature(iommu, FEATURE_PPR)) {
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1856 iommu->is_iommu_v2 = true;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1857 amd_iommu_v2_present = true;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1858 }
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1859
f2c2db53b99eb6c drivers/iommu/amd_iommu_init.c Joerg Roedel 2015-10-20 1860 if (iommu_feature(iommu, FEATURE_PPR) && alloc_ppr_log(iommu))
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1861 return -ENOMEM;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1862
eb03f2d2f6a4da2 drivers/iommu/amd/init.c Suravee Suthikulpanit 2021-08-20 @1863 ret = iommu_init_ga_log(iommu);
8bda0cfbdc1a627 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2016-08-23 1864 if (ret)
8bda0cfbdc1a627 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2016-08-23 1865 return ret;
3928aa3f5775fc4 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2016-08-23 1866
6664340cf1d541c drivers/iommu/amd/init.c Nadav Amit 2021-07-23 1867 if (iommu->cap & (1UL << IOMMU_CAP_NPCACHE)) {
47a70bea54b7afa drivers/iommu/amd/init.c Joerg Roedel 2021-08-02 1868 pr_info("Using strict mode due to virtualization\n");
47a70bea54b7afa drivers/iommu/amd/init.c Joerg Roedel 2021-08-02 1869 iommu_set_dma_strict();
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1870 amd_iommu_np_cache = true;
6664340cf1d541c drivers/iommu/amd/init.c Nadav Amit 2021-07-23 1871 }
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1872
30861ddc9cca479 drivers/iommu/amd_iommu_init.c Steven L Kinney 2013-06-05 1873 init_iommu_perf_ctr(iommu);
30861ddc9cca479 drivers/iommu/amd_iommu_init.c Steven L Kinney 2013-06-05 1874
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1875 if (is_rd890_iommu(iommu->dev)) {
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1876 int i, j;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1877
d5bf0f4f2bade2f drivers/iommu/amd_iommu_init.c Sinan Kaya 2017-12-19 1878 iommu->root_pdev =
d5bf0f4f2bade2f drivers/iommu/amd_iommu_init.c Sinan Kaya 2017-12-19 1879 pci_get_domain_bus_and_slot(0, iommu->dev->bus->number,
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1880 PCI_DEVFN(0, 0));
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1881
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1882 /*
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1883 * Some rd890 systems may not be fully reconfigured by the
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1884 * BIOS, so it's necessary for us to store this information so
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1885 * it can be reprogrammed on resume
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1886 */
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1887 pci_read_config_dword(iommu->dev, iommu->cap_ptr + 4,
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1888 &iommu->stored_addr_lo);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1889 pci_read_config_dword(iommu->dev, iommu->cap_ptr + 8,
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1890 &iommu->stored_addr_hi);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1891
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1892 /* Low bit locks writes to configuration space */
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1893 iommu->stored_addr_lo &= ~1;
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1894
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1895 for (i = 0; i < 6; i++)
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1896 for (j = 0; j < 0x12; j++)
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1897 iommu->stored_l1[i][j] = iommu_read_l1(iommu, i, j);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1898
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1899 for (i = 0; i < 0x83; i++)
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1900 iommu->stored_l2[i] = iommu_read_l2(iommu, i);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1901 }
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1902
318fe782539c415 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2013-01-24 1903 amd_iommu_erratum_746_workaround(iommu);
358875fd52ab8f0 drivers/iommu/amd_iommu_init.c Jay Cornwall 2016-02-10 1904 amd_iommu_ats_write_check_workaround(iommu);
318fe782539c415 drivers/iommu/amd_iommu_init.c Suravee Suthikulpanit 2013-01-24 1905
39ab9555c241106 drivers/iommu/amd_iommu_init.c Joerg Roedel 2017-02-01 1906 iommu_device_sysfs_add(&iommu->iommu, &iommu->dev->dev,
39ab9555c241106 drivers/iommu/amd_iommu_init.c Joerg Roedel 2017-02-01 1907 amd_iommu_groups, "ivhd%d", iommu->index);
2d471b20c55e13c drivers/iommu/amd/init.c Robin Murphy 2021-04-01 1908 iommu_device_register(&iommu->iommu, &amd_iommu_ops, NULL);
066f2e98d8c7f04 drivers/iommu/amd_iommu_init.c Alex Williamson 2014-06-12 1909
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1910 return pci_enable_device(iommu->dev);
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1911 }
23c742db2171135 drivers/iommu/amd_iommu_init.c Joerg Roedel 2012-06-12 1912
--
0-DAY CI Kernel Test Service
https://01.org/lkp
On 7/29/2022 5:04 PM, Joerg Roedel wrote:
> From: Joerg Roedel <[email protected]>
>
> A recent commit introduced these compile warnings:
>
> CC drivers/iommu/amd/init.o
> drivers/iommu/amd/init.c:938:12: error: ‘iommu_init_ga_log’ defined but not used [-Werror=unused-function]
> 938 | static int iommu_init_ga_log(struct amd_iommu *iommu)
> | ^~~~~~~~~~~~~~~~~
> drivers/iommu/amd/init.c:902:12: error: ‘iommu_ga_log_enable’ defined but not used [-Werror=unused-function]
> 902 | static int iommu_ga_log_enable(struct amd_iommu *iommu)
> | ^~~~~~~~~~~~~~~~~~~
>
> The warnings appear because both functions are defined when IRQ
> remapping is not enabled, but only used when IRQ remapping is enabled.
>
> Fix it by only defining the functions when IRQ remapping is enabled.
>
> Fixes: c5e1a1eb9279 ("iommu/amd: Simplify and Consolidate Virtual APIC (AVIC) Enablement")
> Signed-off-by: Joerg Roedel <[email protected]>
Ah... sorry. I missed this part.
Reviewed-by: Suravee Suthikulpanit <[email protected]>
Thank you,
Suravee