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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx/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@xxxxxxxxx/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




[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux