From patchwork Mon Dec 9 17:48:16 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13900171 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 C0CF8E7717D for ; Mon, 9 Dec 2024 17:57:18 +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=mx8CH+EoHbmFyezPK355CdtDc8U5uUJoKs7Xm1ppR/E=; b=UKGAk3W4x7oaayLxdKhCC4yWe/ pI3aFxKpYzdqzqcLHxhjP4dYTfNnqy5Va9nXIqkNu8E/zzGu1Bz9KFskqB5X+8DJpSXlwFAjz+SH/ kRZ69j3nQyzSkps2mb4n+VgtTPqbPyCsWTvINpJX/Leh/JzwHQwF8EAoU//OrI8N3pNAZHrjgKpkv EFoBjVpdDyJW6+Ps5S8aSfGxptE2HhndCyaTcYTetqvGtlWHwOb4ynNwAR0EOh674fetvz7K271fR pG0EA/bNwK4eTMr9jS7YxIP2Au6JT8it4wQbEKB3t4fTE26QGj+rT03c0IKjmVvtTwL64tJwZ0ezL B5Grwd7A==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKi0G-00000008ojS-2OKw; Mon, 09 Dec 2024 17:57:04 +0000 Received: from mail-vi1eur02on2062c.outbound.protection.outlook.com ([2a01:111:f403:2607::62c] helo=EUR02-VI1-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKhsK-00000008mx4-0Sqf for linux-arm-kernel@lists.infradead.org; Mon, 09 Dec 2024 17:48:54 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=JUE0ywnMedM9XhwZANz6RIp554NCm09v2feUmLrdsTvz/ISHXCXZJO3qaXqdUdCpyzQaeC5qMBVnBuFtPezG3CiPnuDL8UnozfTSbFmKi85b3NknUI5K3/Tt3wiuqTgWFy20rxCMGFW2ngGXiRe5fXG/kcMyknLB/vou3vvu2eHGss479z4F5fHp3tk/ZP667otdUCySAfSPnPPMOmXTmijHqetO8UWmGDVNavnns3s/bUhPbhnp5Lm0jfHfeF0efmVSIQWU+h3Axzif1BaZXETSs8UuPf5UtO8A6XMNWnnnl/SOQLOzB2j3po/kTaD5dq4fYyWbgrO5mKQeMZvayA== 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=mx8CH+EoHbmFyezPK355CdtDc8U5uUJoKs7Xm1ppR/E=; b=nlIbmBw4QIDr/NZaXxws3nSPvzZBJmjtGIhQObflUMlalPVjKUQ5ieMDa2mp0ckwmkOExODVGevkloJqpJipM33LMRASGsJERg8qvVeodw2wtIJZrKC9dzfUeDtirjvjK7RaZ5rytFT+NbUdTxXkaSgXGoXhon42GfvCswRatQ6OMH0IpNmJsXRjzF5PU9OXzzhPq+X/A5ys2F/kiPmltydQrLwaY3rzwuYc0hFv0P6E6LqfimcL0a+vBVNXMJMUZRHoutMHaeRYtAmprnPYQT4teNHxWaUUJ0KpN/pG13dtClxshl0WjaIJ3NLVkkvjNzFUN7ku5TXnLZOHRBQm4g== 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=mx8CH+EoHbmFyezPK355CdtDc8U5uUJoKs7Xm1ppR/E=; b=HsiGkUGoM+BegwZi5C2yUvUtnMKPzL2L+FJhZ1YMnWmJOSvczM++SiX7ATeN+CXtqef7zsgaw+NXX74oxeSEAd2RbpyAEUE5CBZjFGozyeTlKA2v6SWYZNx4bDwbyblrdCp5tHkvgcNFfcMSC/l7hqxbhcyVyxUeeGsuDUURYgO6HfRh3OMq8v1dK3iiG2wm7tzuxibrBNjhmjZI6p+fVucVpcMmbUVpzbNm9ybVcVmgDU5xMHhi8NIb7OaD6r3RHJjNkInH6toFplm5UFiw17bORN7zvrfLcnHVH79rv7D0WSDzfiIreOsWzXiPScD7tdOO1QEWCL2jvGGLpDNM2g== 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 GVXPR04MB11017.eurprd04.prod.outlook.com (2603:10a6:150:21c::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.18; Mon, 9 Dec 2024 17:48:48 +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; Mon, 9 Dec 2024 17:48:48 +0000 From: Frank Li Date: Mon, 09 Dec 2024 12:48:16 -0500 Subject: [PATCH v11 3/7] PCI: endpoint: pci-ep-msi: Add MSI address/data pair mutable check Message-Id: <20241209-ep-msi-v11-3-7434fa8397bd@nxp.com> References: <20241209-ep-msi-v11-0-7434fa8397bd@nxp.com> In-Reply-To: <20241209-ep-msi-v11-0-7434fa8397bd@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=1733766511; l=2150; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=PgF8iXUfL14mEGYw4rl2HUwUv7bZbYuVrZCh/TdXXi0=; b=qGaobY/De0ThtjW3FuLJDy16y88UAzIa6rABWSn8fvT+DldmtXWM8xEM8g43FYYmWlrRS0HKp fETRrwaJJUkCUBsB06yHVNCYZoYbO8iSTsQhEJw6WJQxkHMImpOhDDK X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BY5PR17CA0070.namprd17.prod.outlook.com (2603:10b6:a03:167::47) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|GVXPR04MB11017:EE_ X-MS-Office365-Filtering-Correlation-Id: 7e4d280e-3d1f-45fd-42da-08dd1879bbdf X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|52116014|376014|366016|1800799024|7416014|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?pmj+yNlFCPztNLP5rl4syRsM8Y+iUpU?= =?utf-8?q?2lX+Cu2Z330Sh3XzZVTjvA5G4wVAXUgmB7Il+TKlMJY46kKGCxtyWn/HE1CcXwuiF?= =?utf-8?q?w4Hqre9y1yMHXY23JG7lf/VcPBkHyo6uJAv2Zwzx4pgCoQ5iAT15UBmwea9P5QbRM?= =?utf-8?q?cWWwaD1j+KmSQqcapnzSnFTwy/WJUI/oFi9NZJy9uwkcT6xM8H5bhuQXoOUnvn2K9?= =?utf-8?q?mgpu4CME7A94DufABHHctTDnGEi09V2rGjts6quA9bS5bSAo/fNax02+CDMb1Br9e?= =?utf-8?q?+teflWDzjwwO4H2o/zQbQHKtOBfDjnesTANPX/ylzam7AX7gej0bg02mDsTk4KV51?= =?utf-8?q?PeyWRt1OD54xFL8dHD8YzDtKlsn1TNFbhFsyZ7syHlHEg2r8zTWfP2CUZgxI1spFR?= =?utf-8?q?JAse5gacmsLw/NpB+HdPDderNv2cofEXJuMeV1UeD8QTBNvRRYkhfg3As4BVYC3qP?= =?utf-8?q?OhsSY07Ke91EoxpTcD7ogq9bmcJTRt1Tvu6YtUWrWb2csEm7R0QsPIh2UKuMfwe4r?= =?utf-8?q?kIGKFQfFBHWN4C97X6aoRpxd6lWVsq5vx6NbSuXZwGTEUDXU2D76X9Kh8JKJ4Wk6z?= =?utf-8?q?fRKEv5YKwRxUdh9IoC9DWf84rWXExCIGQ9BG8l8b4eq2pzrD6oMF3j3L+ebflXY1i?= =?utf-8?q?ZYwhlKCKYrCmA/9WaIf0cYXxMty0xcH8ZEI6R8P/x6+eiJOYW9abOvFYNsFPDIdFA?= =?utf-8?q?KI9BhuexBGeUC62jRZtghH0AXD/D3S9rq5FnpNs6TOOHBNHLa6kMNyko5IPUcPsHb?= =?utf-8?q?jybjFE4K0VMGdzFrfYDFGBv0zRYN1UNdCh6ajC6ZFOVLjVDdFxraPIh9BkzyD5Fez?= =?utf-8?q?hZG3zVzJlP8xNfYLAEmqllqOZ6PS8SW553YOIJ7UvwizzwvqdukNymjIrHh7zeZXd?= =?utf-8?q?qvGSnqAZkASyXx0qnpKM4OhA26PfygFCeBfBpC8SFcepe4JPS2Rv+ydS64Ui5yZIi?= =?utf-8?q?fowKRdnjINoYQUvkF9701TFl9GcTbHfe2eF5PTSiMqrVTEQpqOm7zdA8OSuhKD5kU?= =?utf-8?q?kMCIfuTGbJJO9uT846CSwvxmBBxXv/7jFrNyHFvnR1s1Vada+xDUJeIT+FiA0V4AU?= =?utf-8?q?JL4jZle0NLczsAGsOHbUQnZXUggxOOj3Q8EnLgNE66NF7NoSWSxQkfUAFhtvWV+Uu?= =?utf-8?q?WFi3Psr9/GTVfvVuvGKvblNHTytG6B2R8CRgDnxRirq38ITHnSL5+XNIC2eh4lHFk?= =?utf-8?q?dc/D/r8C8D8zxrIFiwUn2WlrrXuU1a58A3OraqCjfClTDyYmdrncPefVizZn8vm/1?= =?utf-8?q?jryvdeLWSDRdAdSQLoCoOQa4fOrGcbS3DMkNbBR80vNbF5g69jqVMXS85sqtl5QeT?= =?utf-8?q?a6iaHkPlUIjAYD+1S8VciNeBSH36U49JrwpydQbeJaEXFDqR9C5CET4=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)(366016)(1800799024)(7416014)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?w5inkS0r9/H0bf/ppmMuRCZg1lj9?= =?utf-8?q?cZS4hck2vOHSyw5eUN/wffJIR+0N1WNKG6Q8iEiFrO2jYBuEhcmL0xlwm7eE88V0M?= =?utf-8?q?Av8qxL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78WlYZatpElnDgFEarcdgZGnd6+tDZp2Nv7oiXciBnPH1uKCy3P?= =?utf-8?q?6NOHLlKKYlekQvo873wI7XWDgACz7zKbt7gZqwB7oaD4wYjqVgTGfikIT+4jRuOLu?= =?utf-8?q?sPEwXfzncSWVw5cHbQ/IJ3H6j7k1SP19LWML/huVOLM4hWWsuO4/HwwHMu9TQl0PV?= =?utf-8?q?mcZwJRGpwBNZmcPwLs+RBRqRuRb87j2i/U0vuCLi04jvooXVEn/K98jp44bktSne1?= =?utf-8?q?d8pGQSSHjkE9sCQzLbpp869oCP10RicPvxI1S+wd6bmUavXXxPuhAUTwymqHbJKIg?= =?utf-8?q?yB6Drg1KygPuGQ5TRpjCpMo0U0Mbqygt/gDX6fk6HeAuLZw26JjQ8x3ao4Dpf7NK3?= =?utf-8?q?sVsbpwzbbuxqTkAaoO8R+1kTFen3K5c4a9gGMnFJd6UJ+8sYyUu8BZ2ccB1eMQcNW?= =?utf-8?q?Jnjm4QKq8rzc0NhQ8WFC109PgFL8FhFfL5RVmD8GeEZESw/qr8LuSe4ghJNFC4VXm?= =?utf-8?q?AANjsyId5EsWsNEPsVdQBu7M0LIOpSEDB5lJC3xG7LeL7UXTwo7XtvVs=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e4d280e-3d1f-45fd-42da-08dd1879bbdf X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Dec 2024 17:48:47.9766 (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: dpVDYNBgyfJbm7mBVvJcf1YDxhd9ptxFS5ditAwlEuWnC/ZCNXsTdNkILVeGK2v7hcaNs1DyHpM6/sOvp4RypA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: GVXPR04MB11017 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241209_094852_166390_051E4927 X-CRM114-Status: GOOD ( 12.95 ) 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 Some MSI controller change address/data pair when irq_set_affinity(). Current PCI endpoint can't support this type MSI controller. So add flag MSI_FLAG_MSG_IMMUTABLE in include/linux/msi.h, set this flags in ARM GIC ITS MSI controller and check it when allocate doorbell. Signed-off-by: Frank Li --- Change from v9 to v11 - new patch --- drivers/irqchip/irq-gic-v3-its-msi-parent.c | 1 + drivers/pci/endpoint/pci-ep-msi.c | 8 ++++++++ include/linux/msi.h | 2 ++ 3 files changed, 11 insertions(+) diff --git a/drivers/irqchip/irq-gic-v3-its-msi-parent.c b/drivers/irqchip/irq-gic-v3-its-msi-parent.c index 33e94cfc4d506..a34e9bf93f991 100644 --- a/drivers/irqchip/irq-gic-v3-its-msi-parent.c +++ b/drivers/irqchip/irq-gic-v3-its-msi-parent.c @@ -16,6 +16,7 @@ #define ITS_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \ MSI_FLAG_PCI_MSIX | \ + MSI_FLAG_MSG_IMMUTABLE | \ MSI_FLAG_MULTI_PCI_MSI) #ifdef CONFIG_PCI_MSI diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c index b0a91fde202f3..1c157e0a81456 100644 --- a/drivers/pci/endpoint/pci-ep-msi.c +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -107,6 +107,14 @@ int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) return -EINVAL; } + if (!dom->msi_parent_ops) + return -EINVAL; + + if (!(dom->msi_parent_ops->supported_flags & MSI_FLAG_MSG_IMMUTABLE)) { + 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); diff --git a/include/linux/msi.h b/include/linux/msi.h index b10093c4d00ea..d95d979e4747a 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -556,6 +556,8 @@ enum { MSI_FLAG_PCI_MSIX_ALLOC_DYN = (1 << 20), /* PCI MSIs cannot be steered separately to CPU cores */ MSI_FLAG_NO_AFFINITY = (1 << 21), + /* Address and data pair is mutable when irq_set_affinity() */ + MSI_FLAG_MSG_IMMUTABLE = (1 << 22), }; /**