From patchwork Wed Dec 11 20:57:33 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13904143 Received: from EUR03-DBA-obe.outbound.protection.outlook.com (mail-dbaeur03on2053.outbound.protection.outlook.com [40.107.104.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA628239BB2; Wed, 11 Dec 2024 20:58:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.104.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950693; cv=fail; b=O3cs5gawom8wkWFdUSJ8zGD8/qtd7Z+lYRwwAa91Z0waP3LaDvQwyUVB3xyIna50cmFkuAy5ZSyQh78fU00iuE6PNRDB4czQW6wjU5Vw1r5f3lsgFKfoQAYBmHdXrs8SyerzAybSz9EHLKpzt9POQg3Caon6YZqSWalbaZKt/dE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733950693; c=relaxed/simple; bh=D50BZ5miN8e3VcmEA4cRlQ94cGINq2BVNdkDZoLWxHU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=s1tefaIA/yirGJGqnmUVHqMzWUywBnhHymVJ9A64R1ObUh7WhoD9U3dHnWyEXQC/g3ruS4GLuFK5Ntu25Qkj8TiZV/vF/oQyhi9+Sji3/jKL9/E4arnfUa1ShZLcv6jtXjauBonqiZq1/fhFD+c9akQv9g9c5CuXD+ZUuo/LeYo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=Vv0YXuVq; arc=fail smtp.client-ip=40.107.104.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="Vv0YXuVq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=o3sVGIpZ29YiCGDxXBjg4Rkj8OAC0PgBfgezjnIX+z0YLV04fBV/JNZa2QJoGgwQKonUNuq+MVvv6Nw/2T4khvnQ9GaywtRtMw43ZFDC0OVapCsodeevA/N+Z49oTeZJZHkpTRxvBWSpdXjF3gkcUM0QBix/DyZl2ABQhi6txEF+BXoVvLD2K09pyDT5VP8JthDDlkMZP+dqOBIUrxxBw5LE8EyS8V4emxicj0Dxu3mIIUjtMTYW73ZNb6K4ETF3rxdwEbk/iuPO9Om0BK5xqgaO823mi2InF9MI5eYpt1kKwkuXLmqhJMICrrt382RPFBNYzIgVDvrMMgfTDAnAkQ== 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=36Izu18hCRGkuhjDFOd9R0YMGeiuE6syosxzvqdXwDI=; b=YU5zBA8jk4eEEA/05AB+sOclZwZEiIvsFai8AMVRMeJjdNIBu4XiPDOzx56bBQQyP3pazjNzOTLEMdHP4kot/102o++8c4C0hvhhaVrVOvNeztTgbGIMUohksFUdoR4vtgv74hgnZ4VE8LxTU3iWYLBBLU7QplMurVSEYpfZVJfoq4Z1P0fP/j/vFP7OCJM8fwvdg6BcNDid53MTxFqugeAtrGPq2ocIovfIBPGb+QWy0SkcP+fQyrHwiHQiuP4wv6Fu07V0DdrO5NbIcoIv41yeyfeF9pAVB17cyYUc9UbO5TdXV4k7L7CwFWc2SdFa0uLzVxayv+Em6XAPERApFg== 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=36Izu18hCRGkuhjDFOd9R0YMGeiuE6syosxzvqdXwDI=; b=Vv0YXuVqpYUA8F9pWeHCl3lZPc7dqRDO6l+r+hpnQLax6joQeDQelvu4O9cyW5D3FDHgVTGb8LFE3FpYNpWlmehLeA0nVqmtF1hXUpP7fOaOl3UDhOQsTcSUEfOTf+fqtyW6ygcuudsyiU9BqeAN7+yloVwr85MVkBxfo0+Y4OaM9Kb3PewZkd/lnpTVPvXTm2oL8GCexTuVJn2qMH5uBLWy8ycqtpvWIHRPflP/nYFds0uj9N9MQv/1jmYUqZuQtePzCymwd7O7gOr+HaQ1+ycJ5hCZeEd0kqEeiDpfGD0+8fjXZTa8gexhwcPJ3a5dsP1bTsCrDKHuJbQ6LEjjwQ== 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 AM0PR04MB7139.eurprd04.prod.outlook.com (2603:10a6:208:19d::9) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8251.16; Wed, 11 Dec 2024 20:58:09 +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.8230.010; Wed, 11 Dec 2024 20:58:09 +0000 From: Frank Li Date: Wed, 11 Dec 2024 15:57:33 -0500 Subject: [PATCH v12 5/9] PCI: endpoint: pci-ep-msi: Add check for MSI address/data pair immutability Message-Id: <20241211-ep-msi-v12-5-33d4532fa520@nxp.com> References: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> In-Reply-To: <20241211-ep-msi-v12-0-33d4532fa520@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzy?= =?utf-8?q?sztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman , "Rafael J. Wysocki" , Thomas Gleixner , Anup Patel , Marc Zyngier Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, jdmason@kudzu.us, linux-arm-kernel@lists.infradead.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1733950663; l=1254; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=D50BZ5miN8e3VcmEA4cRlQ94cGINq2BVNdkDZoLWxHU=; b=1sb9dAGttqH8P7CjUNrMxsMzRP0NEC+vA4sl2/yVV3DBxkKNXbba9W9FhU+m4Am6vJ+q6eUZ8 PIoONzggDPMBcArX/Sl7byxm2BuatYebiIdx1mUpu5DS4UDtwqAmPan X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR01CA0037.prod.exchangelabs.com (2603:10b6:a03:94::14) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|AM0PR04MB7139:EE_ X-MS-Office365-Filtering-Correlation-Id: d157aaf6-9c68-4bdf-8e98-08dd1a26849e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|1800799024|7416014|366016|921020|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?q?RbQnUWX/faU5bRo8J8SEov9e9r0SzZu?= =?utf-8?q?wr8kdKdQm+kSrAawJNINaSBeKPO+cHOz6tlFin/4ikqB6+18WGWQ864AH2ahS9+Vp?= =?utf-8?q?mo8+yBeTR8C/EGaYo326Fyd+1I8MfTVZwvfUvxP2igG+5pqYtvCLescy/Vlol+lBJ?= =?utf-8?q?uys1uv3w4bvNPNc88myXV/9DPAT8mo9rCpYNtxyjxYSPd2wZ6w6GziPQ/h72b/XHz?= =?utf-8?q?xtBlBXSxJxRJOuZ+3wiHOKwh+bnBs28ph0nwggd/Kxay7rjhPoz/IR1b6qFzYr0TS?= =?utf-8?q?hRWYnxy03SchrnyNOoKn/ne3REEl3PtrdpTtz/BsFsBgzvD+S6kwexFhmeWudqdgF?= =?utf-8?q?cOC00MCdL+8r9ORGukh6f9y2sbjfyMjqKzM74pQP1Ih3EsFqIg3cwIl9+xYXmwsrQ?= =?utf-8?q?pPUhE57r7TcD4jTZ9sJkskEg1RCNYw/8reM1MJTiv6hBK+NlvGJV+dfabIZM/8b32?= =?utf-8?q?/VQsDITsbtZTv37d+UVtrw1DgZ5WcBFPBG+WClfwFAXSz+SwDvpZZfB/99Jr/I7rJ?= =?utf-8?q?uXDlMBHG1ylK8fnGn9WxvrCdvx90letstbE6HLrf1TrED/zZCgUQcRmpyp7Mm4lZr?= =?utf-8?q?9mJbBZLGGX9f8+TksF+oLNqt7n55+HNA8+uhMcPLPOosDUWv6Y7nsIE+pgraRlS43?= =?utf-8?q?SjasA3eT3E5ncwqLGmhK64L6KHDyk/qu7kIKCm8eiUO3m+xdg1aJo5QD0ACZgsKeE?= =?utf-8?q?AH1zhPkmorBfokh7avW3lFvmo78NVufWurMA7kx5ClR3Q6n5jA6tvgFjYq1pvasnj?= =?utf-8?q?4D6XpGkzskHEzlTcNvhvTxmVnXN/+uNXExlTqEN99RJZ8JtnsouJw7NEHld2NSkGe?= =?utf-8?q?GvDsgNi8CHCDvkeV8d4xgcB5SsWRWeHK50wsW9kpEP3AMUBIwc3ZI9knCfTtf9SsR?= =?utf-8?q?ZX9wEg0g5cC2TTXCsHfP+IviF18T2WF+O/nM2a7koi88/SapDuFdcUbgU3HAIbbIy?= =?utf-8?q?YIEtP4jmfn/JOr/x3KLXvx876cZmTi2Ya0uqK1hAWpQLqpyS0S7xJF42xgqo5/pjY?= =?utf-8?q?cUztj/td9ioozy5qqma4QTbnEfDV+JvjA0OTwgNPSN46gic2EertWebV0r7Q8IgYU?= =?utf-8?q?PEoyDAsZKcuC4EHZrfyOTF7W7g2hwmbuY5FYT7hjU7tNwtwxBg0559AcLA8ZUaZUR?= =?utf-8?q?dJe75tgFKCTVz/0ghjqeQo930OsrrbVFYLOsK5OzeZ2UvJ3q2syASIyq0eFuPIq2I?= =?utf-8?q?Cs9Z/DwiRoRIN6KsP8DAk2h6fAjF0umalQ/I+fJcWEYJAdlpmneU2KAhZAyZVJRAH?= =?utf-8?q?paoQV1srrXF+xYdRc1BRe4mlqCZOICNBOE/CDmOA0RfNGM4PRxX4Gpq5Dy7+VNHzz?= =?utf-8?q?p60lSjTx4rjbBm5RB0E4T/0XF5qbRzRs/oz4xRhWR1Aj5vdxOJWmVhw=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)(52116014)(376014)(1800799024)(7416014)(366016)(921020)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?LX9k7XPUwN2V97vBzkqYCF6R8ZR8?= =?utf-8?q?1ZF05FcrHAxNyoYSGgVL/TqvmjBNtPgZN6p1I0ugGCWfUEuiktrKRceRhF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utf-8?q?+5wFd6SD+0E1EXjvXqkoynDjHto+171mfKXiaYgbZP8s6BlYz4pSdOmgh0EUcJd9P?= =?utf-8?q?4I4f5bmRF/yZWTBexLYvGONckFtVS97tmQL0oZIeOowXDvfHwaIqL5z0erW7DNu1t?= =?utf-8?q?6TKhB1jLbKOb9Nw2mDkxRMlkmDJ7NfH840EJcuVVwE200k6W0wxg6TfmPPDak82vx?= =?utf-8?q?hurUUQ4DAW/tECp9FvxzVdCBEo4/jT8M4/0qnxYTEO341+mT1vWvG8AmNTBoPBXfP?= =?utf-8?q?s33t+OMZgzqPZ2NG5CuqQAYLylhNHa6kAaTPzNFsgD+YFBVB9DzbrmRQ5fZsn/X26?= =?utf-8?q?nub+wsF9Ut4hUpekYcq2Eih1kCDwkv05alGzvKZTupVLd8u82cmyK1DYAxfuMiTmR?= =?utf-8?q?kHuh6clUoMP8bTpF5K3K8aIk1Y6OC7PrpfwqVZfK05Na3GUF+sak9p4ddzzTqSt0t?= =?utf-8?q?CunldrtsKCk8ZqUnGIBhn+6yBr+Uy2U02D7Y/17pn4CrE1FnzyjN4+Gem8H3FVYsK?= =?utf-8?q?tWDKid0pLqjsM4iH0XFuj5WCd8OaspwAbV3M1d0ol4PnntE1NzEBWZj1BBUZ10ZvD?= =?utf-8?q?ZCG4wSvO97dY?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d157aaf6-9c68-4bdf-8e98-08dd1a26849e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 11 Dec 2024 20:58:09.4363 (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: Vjhu8a1hR7Svg1/4FA5bk4oqG/BH0RLafNwgODUG3KTn1F+gMG+htGawKRALGEhPfLZu8vzeHNDZ0JacJmsCgw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM0PR04MB7139 Check the immutability of the MSI address/data pair by calling irq_domain_is_msi_immutable() when allocating a doorbell. Prevent the use of MSI controllers that change the address/data pair during irq_set_affinity(), as the current PCI endpoint implementation does not support such behavior. Signed-off-by: Frank Li --- Change from v11 to v12 - use helper function irq_domain_is_msi_immutable(). - remove msi parent check. - split msi header, its and endpoint to 3 patches. - rework commit message. Change from v9 to v11 - new patch --- drivers/pci/endpoint/pci-ep-msi.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c index b0a91fde202f3..eda027b734b73 100644 --- a/drivers/pci/endpoint/pci-ep-msi.c +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -107,6 +107,11 @@ int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) return -EINVAL; } + if (!irq_domain_is_msi_immutable(dom)) { + dev_err(dev, "Can't support mutable address/data pair MSI controller\n"); + return -EINVAL; + } + dev_set_msi_domain(dev, dom); msg = kcalloc(num_db, sizeof(struct pci_epf_doorbell_msg), GFP_KERNEL);