* [pci:controller/imx6 2/2] drivers/pci/controller/dwc/pci-imx6.c:1116:11: warning: variable 'sid' is used uninitialized whenever 'if' condition is false
@ 2025-01-15 7:19 kernel test robot
2025-01-15 21:03 ` Bjorn Helgaas
0 siblings, 1 reply; 2+ messages in thread
From: kernel test robot @ 2025-01-15 7:19 UTC (permalink / raw)
To: Frank Li
Cc: llvm, oe-kbuild-all, linux-pci, Krzysztof Wilczyński,
Bjorn Helgaas
tree: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git controller/imx6
head: bc92494deb1c40f7336ca645c3815f19a5d0e2af
commit: d02f7572cb39c962d0e432f57a267a844d164b4f [2/2] PCI: imx6: Add IOMMU and ITS MSI support for i.MX95
config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250115/202501151501.d4MgHDRq-lkp@intel.com/config)
compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250115/202501151501.d4MgHDRq-lkp@intel.com/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@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202501151501.d4MgHDRq-lkp@intel.com/
All warnings (new ones prefixed by >>):
In file included from drivers/pci/controller/dwc/pci-imx6.c:19:
In file included from include/linux/module.h:19:
In file included from include/linux/elf.h:6:
In file included from arch/s390/include/asm/elf.h:181:
In file included from arch/s390/include/asm/mmu_context.h:11:
In file included from arch/s390/include/asm/pgalloc.h:18:
In file included from include/linux/mm.h:2223:
include/linux/vmstat.h:504:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
504 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
505 | item];
| ~~~~
include/linux/vmstat.h:511:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
511 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
512 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
include/linux/vmstat.h:518:36: warning: arithmetic between different enumeration types ('enum node_stat_item' and 'enum lru_list') [-Wenum-enum-conversion]
518 | return node_stat_name(NR_LRU_BASE + lru) + 3; // skip "nr_"
| ~~~~~~~~~~~ ^ ~~~
include/linux/vmstat.h:524:43: warning: arithmetic between different enumeration types ('enum zone_stat_item' and 'enum numa_stat_item') [-Wenum-enum-conversion]
524 | return vmstat_text[NR_VM_ZONE_STAT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~ ^
525 | NR_VM_NUMA_EVENT_ITEMS +
| ~~~~~~~~~~~~~~~~~~~~~~
>> drivers/pci/controller/dwc/pci-imx6.c:1116:11: warning: variable 'sid' is used uninitialized whenever 'if' condition is false [-Wsometimes-uninitialized]
1116 | else if (!err_m)
| ^~~~~~
drivers/pci/controller/dwc/pci-imx6.c:1119:41: note: uninitialized use occurs here
1119 | return imx_pcie_add_lut(imx_pcie, rid, sid);
| ^~~
drivers/pci/controller/dwc/pci-imx6.c:1116:7: note: remove the 'if' if its condition is always true
1116 | else if (!err_m)
| ^~~~~~~~~~~
1117 | sid = sid_m & IMX95_SID_MASK;
drivers/pci/controller/dwc/pci-imx6.c:1044:9: note: initialize the variable 'sid' to silence this warning
1044 | u32 sid;
| ^
| = 0
5 warnings generated.
vim +1116 drivers/pci/controller/dwc/pci-imx6.c
1035
1036 static int imx_pcie_enable_device(struct pci_host_bridge *bridge,
1037 struct pci_dev *pdev)
1038 {
1039 struct imx_pcie *imx_pcie = to_imx_pcie(to_dw_pcie_from_pp(bridge->sysdata));
1040 u32 sid_i, sid_m, rid = pci_dev_id(pdev);
1041 struct device_node *target;
1042 struct device *dev;
1043 int err_i, err_m;
1044 u32 sid;
1045
1046 dev = imx_pcie->pci->dev;
1047
1048 target = NULL;
1049 err_i = of_map_id(dev->of_node, rid, "iommu-map", "iommu-map-mask",
1050 &target, &sid_i);
1051 if (target) {
1052 of_node_put(target);
1053 } else {
1054 /*
1055 * "target == NULL && err_i == 0" means RID out of map range.
1056 * Use 1:1 map RID to streamID. Hardware can't support this
1057 * because the streamID is only 6 bits
1058 */
1059 err_i = -EINVAL;
1060 }
1061
1062 target = NULL;
1063 err_m = of_map_id(dev->of_node, rid, "msi-map", "msi-map-mask",
1064 &target, &sid_m);
1065
1066 /*
1067 * err_m target
1068 * 0 NULL RID out of range. Use 1:1 map RID to
1069 * streamID, Current hardware can't
1070 * support it, so return -EINVAL.
1071 * != 0 NULL msi-map does not exist, use built-in MSI
1072 * 0 != NULL Get correct streamID from RID
1073 * != 0 != NULL Invalid combination
1074 */
1075 if (!err_m && !target)
1076 return -EINVAL;
1077 else if (target)
1078 of_node_put(target); /* Find streamID map entry for RID in msi-map */
1079
1080 /*
1081 * msi-map iommu-map
1082 * N N DWC MSI Ctrl
1083 * Y Y ITS + SMMU, require the same SID
1084 * Y N ITS
1085 * N Y DWC MSI Ctrl + SMMU
1086 */
1087 if (err_i && err_m)
1088 return 0;
1089
1090 if (!err_i && !err_m) {
1091 /*
1092 * Glue Layer
1093 * <==========>
1094 * ┌─────┐ ┌──────────┐
1095 * │ LUT │ 6-bit streamID │ │
1096 * │ │─────────────────►│ MSI │
1097 * └─────┘ 2-bit ctrl ID │ │
1098 * ┌───────────►│ │
1099 * (i.MX95) │ │ │
1100 * 00 PCIe0 │ │ │
1101 * 01 ENETC │ │ │
1102 * 10 PCIe1 │ │ │
1103 * │ └──────────┘
1104 * The MSI glue layer auto adds 2 bits controller ID ahead of
1105 * streamID, so mask these 2 bits to get streamID. The
1106 * IOMMU glue layer doesn't do that.
1107 */
1108 if (sid_i != (sid_m & IMX95_SID_MASK)) {
1109 dev_err(dev, "iommu-map and msi-map entries mismatch!\n");
1110 return -EINVAL;
1111 }
1112 }
1113
1114 if (!err_i)
1115 sid = sid_i;
> 1116 else if (!err_m)
1117 sid = sid_m & IMX95_SID_MASK;
1118
1119 return imx_pcie_add_lut(imx_pcie, rid, sid);
1120 }
1121
--
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread* Re: [pci:controller/imx6 2/2] drivers/pci/controller/dwc/pci-imx6.c:1116:11: warning: variable 'sid' is used uninitialized whenever 'if' condition is false
2025-01-15 7:19 [pci:controller/imx6 2/2] drivers/pci/controller/dwc/pci-imx6.c:1116:11: warning: variable 'sid' is used uninitialized whenever 'if' condition is false kernel test robot
@ 2025-01-15 21:03 ` Bjorn Helgaas
0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2025-01-15 21:03 UTC (permalink / raw)
To: kernel test robot
Cc: Frank Li, llvm, oe-kbuild-all, linux-pci,
Krzysztof Wilczyński
On Wed, Jan 15, 2025 at 03:19:09PM +0800, kernel test robot wrote:
> tree: https://git.kernel.org/pub/scm/linux/kernel/git/pci/pci.git controller/imx6
> head: bc92494deb1c40f7336ca645c3815f19a5d0e2af
> commit: d02f7572cb39c962d0e432f57a267a844d164b4f [2/2] PCI: imx6: Add IOMMU and ITS MSI support for i.MX95
> config: s390-allmodconfig (https://download.01.org/0day-ci/archive/20250115/202501151501.d4MgHDRq-lkp@intel.com/config)
> compiler: clang version 19.1.3 (https://github.com/llvm/llvm-project ab51eccf88f5321e7c60591c5546b254b6afab99)
> reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250115/202501151501.d4MgHDRq-lkp@intel.com/reproduce)
Resolved as below (I also renamed this branch from pci/controller/imx6
to pci/controller/iommu-map because I added Marc's pcie-apple patches
on top):
> vim +1116 drivers/pci/controller/dwc/pci-imx6.c
>
> 1035
> 1036 static int imx_pcie_enable_device(struct pci_host_bridge *bridge,
> 1037 struct pci_dev *pdev)
> 1038 {
> 1039 struct imx_pcie *imx_pcie = to_imx_pcie(to_dw_pcie_from_pp(bridge->sysdata));
> 1040 u32 sid_i, sid_m, rid = pci_dev_id(pdev);
> 1041 struct device_node *target;
> 1042 struct device *dev;
> 1043 int err_i, err_m;
> 1044 u32 sid;
I made this "u32 sid = 0;" to resolve this warning.
> 1046 dev = imx_pcie->pci->dev;
> 1047
> 1048 target = NULL;
> 1049 err_i = of_map_id(dev->of_node, rid, "iommu-map", "iommu-map-mask",
> 1050 &target, &sid_i);
> 1051 if (target) {
> 1052 of_node_put(target);
> 1053 } else {
> 1054 /*
> 1055 * "target == NULL && err_i == 0" means RID out of map range.
> 1056 * Use 1:1 map RID to streamID. Hardware can't support this
> 1057 * because the streamID is only 6 bits
> 1058 */
> 1059 err_i = -EINVAL;
> 1060 }
> 1061
> 1062 target = NULL;
> 1063 err_m = of_map_id(dev->of_node, rid, "msi-map", "msi-map-mask",
> 1064 &target, &sid_m);
> 1065
> 1066 /*
> 1067 * err_m target
> 1068 * 0 NULL RID out of range. Use 1:1 map RID to
> 1069 * streamID, Current hardware can't
> 1070 * support it, so return -EINVAL.
> 1071 * != 0 NULL msi-map does not exist, use built-in MSI
> 1072 * 0 != NULL Get correct streamID from RID
> 1073 * != 0 != NULL Invalid combination
> 1074 */
> 1075 if (!err_m && !target)
> 1076 return -EINVAL;
> 1077 else if (target)
> 1078 of_node_put(target); /* Find streamID map entry for RID in msi-map */
> 1079
> 1080 /*
> 1081 * msi-map iommu-map
> 1082 * N N DWC MSI Ctrl
> 1083 * Y Y ITS + SMMU, require the same SID
> 1084 * Y N ITS
> 1085 * N Y DWC MSI Ctrl + SMMU
> 1086 */
> 1087 if (err_i && err_m)
> 1088 return 0;
> 1089
> 1090 if (!err_i && !err_m) {
> 1091 /*
> 1092 * Glue Layer
> 1093 * <==========>
> 1094 * ┌─────┐ ┌──────────┐
> 1095 * │ LUT │ 6-bit streamID │ │
> 1096 * │ │─────────────────►│ MSI │
> 1097 * └─────┘ 2-bit ctrl ID │ │
> 1098 * ┌───────────►│ │
> 1099 * (i.MX95) │ │ │
> 1100 * 00 PCIe0 │ │ │
> 1101 * 01 ENETC │ │ │
> 1102 * 10 PCIe1 │ │ │
> 1103 * │ └──────────┘
> 1104 * The MSI glue layer auto adds 2 bits controller ID ahead of
> 1105 * streamID, so mask these 2 bits to get streamID. The
> 1106 * IOMMU glue layer doesn't do that.
> 1107 */
> 1108 if (sid_i != (sid_m & IMX95_SID_MASK)) {
> 1109 dev_err(dev, "iommu-map and msi-map entries mismatch!\n");
> 1110 return -EINVAL;
> 1111 }
> 1112 }
> 1113
> 1114 if (!err_i)
> 1115 sid = sid_i;
> > 1116 else if (!err_m)
> 1117 sid = sid_m & IMX95_SID_MASK;
> 1118
> 1119 return imx_pcie_add_lut(imx_pcie, rid, sid);
> 1120 }
> 1121
>
> --
> 0-DAY CI Kernel Test Service
> https://github.com/intel/lkp-tests/wiki
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2025-01-15 21:03 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-15 7:19 [pci:controller/imx6 2/2] drivers/pci/controller/dwc/pci-imx6.c:1116:11: warning: variable 'sid' is used uninitialized whenever 'if' condition is false kernel test robot
2025-01-15 21:03 ` Bjorn Helgaas
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox