From patchwork Tue Jan 28 22:07:39 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13953246 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id C47B5C0218A for ; Tue, 28 Jan 2025 22:19:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:MIME-Version:Cc:To: In-Reply-To:References:Message-Id:Content-Transfer-Encoding:Content-Type: Subject:Date:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=ek6Zk7JGxc1j9p1VFdmOCv0GNNKfJXOaWInK2IQR9mk=; b=JjclgYyMDSbhH1Aq+Y+wmDfh7z 5QVnd0qtouoxCxCJ8ZT1FJ97soq0m+Ogf+L1pykuy0iCZUQWfi5XuVIv8XhpkdaST9Dr4znG7a8o0 m2l7+wI996ZsuXQHhnO98dKwcTlM1vxFyg1a4DG0+mpfoMlz5OeNTiHNRYEe8TsQsh9IFhp5qWCSv 3LjA24RTIFnG58Y2xYeCf2c4Fx+NFTQZXFCJlTnN5TwEJRrx/uUqJKH3ZT8jB6D2kO0kNwo58EjUm pp7Jg8UVy+m2XXzxerkHikaj4sPqg4bquklfTl3WPoSR8BPwW2TgzN49L4wI4mGdrDDMMEPkS0dXh sXvNPbfQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tctvW-00000005uqi-03Bk; Tue, 28 Jan 2025 22:19:22 +0000 Received: from mail-norwayeastazlp170130007.outbound.protection.outlook.com ([2a01:111:f403:c20f::7] helo=OSPPR02CU001.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tctlQ-00000005tfw-3zRW for linux-arm-kernel@lists.infradead.org; Tue, 28 Jan 2025 22:08:58 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jk4wcmcOF24mbHrxyVVZvtWMXJywxSQ5vOAbr1QVdiM1MGZd6RvM7DQnBBOmVHopReJ9CDDBdDWmL5IJmNoci9s9XqVMqjG5yG2V+/g72rybUk+mzMi+XYV3Epe/OKwfA8PvOn6zzv9KQ/g9UATwP+UH4he9BMVj/CMAuQEr1B7OSWPW5VNr+2GFJtzYjaUMGz1D3WZ85DykGzXcxmTzyDwE/xRBgqPxIIPKHqp8eL0WTvVT/oAGFxv0ImK8pbAoiFxilKeUU71/bYCqQ+9ipNpgxwJ9BbQoWXq1AbUYojiVEmVushEymkKY0Am/i+oWAlWjvCMn3+uxq7mt7iGnWA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=ek6Zk7JGxc1j9p1VFdmOCv0GNNKfJXOaWInK2IQR9mk=; b=Bnyk+O42fTJNrXUKBkwOWXo2B7aln2pqo67E+LtXvsPL5totD7cV7kb0YIEcL5vv8RcH58sfS3Z6ZmtdTGIsg+6f/KVjFmSD7ziJDP1IuIH6rHpILf3QosgG99JQxvz8aNY+QcpRmnsxZUZ2OgSuNbaxsEwO2WPNF7rVNZRhM6IdfcEV0nApOj94DlNFzIWB/ZHLPZvuyaNOp28L8p6roY/viEea63/r/43hgx1hHkn8dLTDiM9olDaRDLG8h1xwgYDvIrvfvRNbLcyipyeUeAUWuApr0f3HuCR2IFEQ1m/j9bW7SwncDyBLGvuO35vMiSkTcyK7mtV9dgjacgC9Ow== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=ek6Zk7JGxc1j9p1VFdmOCv0GNNKfJXOaWInK2IQR9mk=; b=gzBJfiNb6AjdFo3Fky/3iLPmhyG66Gy3KBtoSt0veva78GnmSEvp5SOA0uC5Upwl4L95PeK1NY+WjUCqByvHgOYh6ErRNqKE+vW2qksw/9WkBe6/4jfWBLEqVTSyVOVJXKzXq8hkG79zMIXMNNvPoqVUyOf8rSjJgYNg2pNwlLRcJUuMlxshrnsOsWmDpIez91E3eIaX203aZm1MOjn1iROKLhdXAmmoSggxxwESqbo9l8AANh9k54FOCz4VyspKXAs/Pwyr8bjEq94W9shsdl+DvD6vVYH3keQD+5rs6X7hulOBWnggSgABSIZeE1xb3wJOwentl08e/RNjVmuSRw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) by AM9PR04MB8555.eurprd04.prod.outlook.com (2603:10a6:20b:436::16) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8398.18; Tue, 28 Jan 2025 22:08:53 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%5]) with mapi id 15.20.8377.021; Tue, 28 Jan 2025 22:08:53 +0000 From: Frank Li Date: Tue, 28 Jan 2025 17:07:39 -0500 Subject: [PATCH v9 6/7] PCI: dwc: ep: Ensure proper iteration over outbound map windows Message-Id: <20250128-pci_fixup_addr-v9-6-3c4bb506f665@nxp.com> References: <20250128-pci_fixup_addr-v9-0-3c4bb506f665@nxp.com> In-Reply-To: <20250128-pci_fixup_addr-v9-0-3c4bb506f665@nxp.com> To: Rob Herring , Saravana Kannan , Jingoo Han , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Bjorn Helgaas , Richard Zhu , Lucas Stach , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Fabio Estevam Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, linux-arm-kernel@lists.infradead.org, imx@lists.linux.dev, Niklas Cassel , Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1738102099; l=1409; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Qtxc1V3k3e4Ca0xXnwE31Cml7yIQ9kLsWImFVASGIz8=; b=+mo5CH4A9gHYSrjIhSwt736ICapBVWSaLCW2H79VxFDRUagnRrLXvlZSZz6/eEB4Ts01iGG9s U7b11XwKC80By5EkByk7JMrO7si2GhOcWPbnG2kesE5Ktd5xAoa3zbf X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR03CA0130.namprd03.prod.outlook.com (2603:10b6:a03:33c::15) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM9PR04MB8555:EE_ X-MS-Office365-Filtering-Correlation-Id: e8a294f6-7ee1-4bda-9168-08dd3fe859fd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|366016|7416014|376014|52116014|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?4SajXoNcg8TOv+4rIS5c9eq5sfyHix6?= =?utf-8?q?eR+Rqol8bQ3UnQNrV2UzJOOv1mvZMvgH2d6ApmJ9ecwec5cxdNFHYugecL9fMzyHH?= =?utf-8?q?tesi3GUu/S5gaO+25x9x0eUy7XYerG2MOERu+Qc55/5THUVpg3I4A9J3B5qsjPvbL?= =?utf-8?q?tdlP7hmrLNqPJJGtnKM9Eh13/m1pE5Azz5XI6NVj8Kmy4L8Kd0JNyLqlsCsJPWq1e?= =?utf-8?q?r4Aci7zldgohsIYUJN1LpyVkS8T5yU6aaN7ilqfueD/wT4bxhNPP5PXtnKxClwOdn?= =?utf-8?q?c4RqbBsxbNYT7XoipjcnQ14XANYB64FA2AZPeXjSSpp8ZwmtA6AYsW8EUSieXcVoi?= =?utf-8?q?+SzmMpauw3NXjr3dc1OGdIf3R+k1PX/UwwncFDDjujEyEb7ckZrh4TLs8vjkZvD6s?= =?utf-8?q?F7wx8MY1nCDRYp2BKz14+ChdHqfvupHl7/C34eC4jm7vMM5+Z0QHoCrIm3LopVz9w?= =?utf-8?q?G0SuRFe80ey/Fnz1AVLUPNQoceWNcCVMvPviz+Rtd7jqUYOoDX3Y1wsCzJHb9cxX+?= =?utf-8?q?/LJUXlFB2csvf5bHWhCs7kXSISZLpHmabkWS8c2xSvfGIfmmr2EScgrtkwkStujfK?= =?utf-8?q?EuXFLu/++39eGGlpUfBm8Wd+5OACcdy4GHQqjspLFchkiViFqIKrFHMGsJi8GLuBk?= =?utf-8?q?Z74VE7XWBqo4Ddp5baM3T4K/XxJFSPYuGyJsVsEiO7ufFeu3vqeQWG51es1aZVoWn?= =?utf-8?q?c5+ANi+OhSFIZm5TBKOczeaVwCN2aijKzXEi20aJza4FMwKgULNu2rI4QiSfJBPI3?= =?utf-8?q?Ndg7qOBH9SA706E2hjpbhTegIIhxXNAbY2ztDaGpYiAW8aUeGzYTTPH4AapvG5+vA?= =?utf-8?q?Oi0mUeS3nFqn8osgrn8eebQdGySDq/NtRLT8l4XDwdZySD77aCskRWlkTBmqTB7j+?= =?utf-8?q?PVlkEMyhq3tZtBzH7OwT+kXnlfnphBhdH/SVSdL/7WIW42cQu/J2gOOrNd6lyLWWo?= =?utf-8?q?iu6uxFtl2sQyRMqEBzawBc0YIEqQNzwYsJGGz9m8hTecpsEiljP/yiw76mcHSN49w?= =?utf-8?q?cLEv6px0jwPVLLea1YlUXURDSaHqV1H5gnoVHlttT2XLxu3IAukslh59WPcUZAdDn?= =?utf-8?q?qT/bLsvZPOozftOEjEvqWn8e4FsAH9kCOJd2Ynb4FuFNsUaidlwUtWWGc4H/H3bpx?= =?utf-8?q?e4qWhnjS31Y5KerCAv/LZNssloLE3wEPUu4tGO8bzfCClu+Ho06KKDUGmPt/kBGap?= =?utf-8?q?w3l2J8kZn//Q3XYckTfBFpgN7ceqoLikxm9D7ImrEOJ431HUz7q5iqEBP+u0foEqE?= =?utf-8?q?FqMwWkEUDcflnPewAUTKsIyh9UL+fwc0WdV+NsTGy+s4OwyU9U9ByLZvEY+EhKdi/?= =?utf-8?q?KuiPAfIiQQA4FFQyahwZQNnhnxXQGAa3WyXnk5o4iThK+k9BqjVDHNYwEAF6jhJnh?= =?utf-8?q?bGNrSd4MAw4idJkPjS1BLhU6pe9THUfHQ=3D=3D?= X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:PAXPR04MB9642.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230040)(1800799024)(366016)(7416014)(376014)(52116014)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?mzRocLNE2NK8dH5Wy+GJqyqSL7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5?= =?utf-8?q?3st9b+dHDRrk3Zu1uFgFotPOLZ7OujKgMIKX7IshGwVXBB17NgA1vXjEAYB18cx+Z?= =?utf-8?q?eEPZjAUTU2yckOY+qWYW5y0ygE47MZn0bDHsAgrC3f+zVtRpeLnw/R42+AZ7JocpE?= =?utf-8?q?WjSSi//ENmr23+rqG0YFcP+jieL69kaxP9RyAr8E6zTUyLvWIexegTUrfvjKsYAW2?= =?utf-8?q?tmqHi3ANnTiyxIbDLNKotzXcza99bVWrUdqhTscHSJH7o8K/Qq0JJ/xJaQBpg+KkB?= =?utf-8?q?D/tJrwpFyutOohoy473ONMGS5ZUti2LtWzsjmr8t1v1ZXudCp36Dhc/iAFtAIGl+X?= =?utf-8?q?GPjhd7RrB0i0c8Z5XoE5MRzhwy4++nW0LnUTU4pmZiW2OpX3KwukRhdhcU0l7lCcc?= =?utf-8?q?ityq0eeEqEBWl+SDOW3SC/mUuAS+lMTrc+s7FCin6v1q7M3IsaiRbNX4NPBY3ROml?= =?utf-8?q?Zs6YaxdUKodDPZ4V1452UpR8tr68EARN4olRV2LOmidGNEle9q5iL5LBA+yUDYdab?= =?utf-8?q?M4Ex8khBAFJ9tTC580xzXbwfWlMd47zfXpAokyu9mXDnsYASgTQp0fyuD3TMvKrfg?= =?utf-8?q?VXL9J/lI3MMCzxGqe9L5iB/Rb0EZ1l5oS3ngSalpYaaziC/A655DHCBO0hjnictxP?= =?utf-8?q?Oz68R/sc6+8N?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: e8a294f6-7ee1-4bda-9168-08dd3fe859fd X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Jan 2025 22:08:53.2414 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: XsjqgVKJv0GyZ0LvLHVLez+rK2RoAaoddkPPLem/F5evG5VMU1P4DEF3xkLJ/U/wiJDcbiIyBmRnSFzkIlOJ3A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM9PR04MB8555 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20250128_140856_995353_F4BE84C7 X-CRM114-Status: GOOD ( 13.53 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org Most systems' PCIe outbound map windows have non-zero physical addresses, but the possibility of encountering zero increased with commit 700cafbb642b ("PCI: dwc: ep: Add bus_addr_base for outbound window"). 'ep->outbound_addr[n]', representing 'parent_bus_address', might be 0 on some hardware, which trims high address bits through bus fabric before sending to the PCIe controller. Replace the iteration logic with 'for_each_set_bit()' to ensure only allocated map windows are iterated when determining the ATU index from a given address. Signed-off-by: Frank Li --- change from v8 to v9 - new patch --- drivers/pci/controller/dwc/pcie-designware-ep.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index d0d6c4e8df80c..c1767450541a4 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -284,7 +284,7 @@ static int dw_pcie_find_index(struct dw_pcie_ep *ep, phys_addr_t addr, u32 index; struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - for (index = 0; index < pci->num_ob_windows; index++) { + for_each_set_bit(index, ep->ob_window_map, pci->num_ob_windows) { if (ep->outbound_addr[index] != parent_bus_addr) continue; *atu_index = index;