From patchwork Wed Dec 4 23:25:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13894448 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2041.outbound.protection.outlook.com [40.107.241.41]) (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 77EA020C483 for ; Wed, 4 Dec 2024 23:26:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.241.41 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733354792; cv=fail; b=L81Zw0dR6TQOya7T3dRy9ubQ+jDi7nO6OLfBaE79nI3W6ZtiiqbFPpXIzMWPqL+tK9bpsOPwQIfdyfmC6YWbVLwkvrMDeiBO0uzosEiv7g1w2InWDX6vXpk2/KdLJ7HhUf8HKNiRbW+UwnMYxVmR9NKRnIUuKqh+bXw/HeBqeME= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1733354792; c=relaxed/simple; bh=KBig+EizkbOsM7GH8GEr11XjaV4NgLu98GEXwecGT00=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=FfmWIgf8H0BTjQD87k5Qa2+MtIZXjtxZDxPlYPE6f6CVUOZb0OeLYuC5EbPNtxLcSM2Trx86KlBN1LUHgCZjiR7B3VnIjjSGIcP4sTYJUoE1euceID/7/jlqEov8yOFoouI6rWVddTRQAlM/MQVwPOsYvvYSLSEyuKionM/3YMU= 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=c1OrDomK; arc=fail smtp.client-ip=40.107.241.41 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="c1OrDomK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=K/mfMuOFCrDYsxNE9W1yqAjR/Zb2wqkl73891KJMjG11j/5GsFag/yZyl/BkVrp/91JanNcaR+SxA6s+YSE820LTAsyJdCA4583QmUF0wB0KZBykPWfTcPuFY6xQzlfQUn26Pyur8iEEONvrOjhOQGSebjQpvh3wOHn0sqcHS0hWb4DMDZgxBWJJ/19UZggttij3pJL8J78i+r/2oNqufMryg65MRj+7YEq6Yy+rfKQbSTjl9fJX/rxKUhp5t7+/fWkir54bO/LmnOt7w8Hd62Zk5YfVxE6x2FfucQH7y93fs0Ywid1jbx2wzt8f4MN9828CPAi2dsdL6eNqBTzm1Q== 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=aj9graMXGsBoC4IL7er4ah2Xyl37vVo+7FWav4/gUuk=; b=l1SkPi/E1H15EY+hBgezoxwLobonEnzsC18CXKpDKBZ7XC3wsYpj9te5zfbFN5gG+shQC3cAWQfUghvuh9vlHHeE+gENxaZ36sgALJIOX3TH8L9nMxoZoJNCgSwSlAiGIajsnx6nV7ahhMgJqn4ujuzPVh9V0cpROZ59JNxLv3i1tBQJwYftRT1dH0+oKGGSMkI09gSdBeeARnL47X3Mja1DuN6RN+hRpENOCuy+JXfwJoWKnOShmo0KTZQ8KjooplAyPN7tfwJcNU9qQZGbXp1EgwTeYiru74k467+JcMepGIs/p0Mp3cIqbfoBGQkmzpHIN3iaW/9BbU64pkOnIg== 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=aj9graMXGsBoC4IL7er4ah2Xyl37vVo+7FWav4/gUuk=; b=c1OrDomK8m3iv7ncZvZyD9oEmb7H5Ohjf0k0fBDzq1gABAKFU13wstHBbcYW6fHrNRbVY8Cns2GxpCFAWUihi7emdaLkwRWebQONu0GYZ/I/+1jfIg4MR2vIVmfDgvPZplCoRAtexsg5pkDudqn0oLFkEaMavkn17QtwMSbkvYWyYhOO67WWWWkTiLQ9HdzN2pnM+PEitqrg41lX8l7TuKvWGLvPoMtsA5KsAQ8DpenVyLJKuOXtfcdQLWwYdSkyNRlwsu66ZX67LRqaSyt5KeX1SVISW2j3gUFp5O02MgWg5TV9jngmsswfgzrsQVs8WZj/HZr1WGnOVlyp8FeSxQ== 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 DU4PR04MB11006.eurprd04.prod.outlook.com (2603:10a6:10:58a::7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8230.11; Wed, 4 Dec 2024 23:26:27 +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, 4 Dec 2024 23:26:27 +0000 From: Frank Li Date: Wed, 04 Dec 2024 18:25:53 -0500 Subject: [PATCH v10 3/7] PCI: endpoint: pci-ep-msi: Add MSI address/data pair mutable check Message-Id: <20241204-ep-msi-v10-3-87c378dbcd6d@nxp.com> References: <20241204-ep-msi-v10-0-87c378dbcd6d@nxp.com> In-Reply-To: <20241204-ep-msi-v10-0-87c378dbcd6d@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=1733354769; l=1552; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=KBig+EizkbOsM7GH8GEr11XjaV4NgLu98GEXwecGT00=; b=sn9M8HcPxQyXDjCF2IOqes4/02ZuyOuaN7xETANuysykGF1rcnHJq5o8KTX3piZjOrIPcEctF vetFMAuPtHDBNKbJKLyVV5QoVCPQt23OMp+vQXUbtCWX0NaNRkPXHNk X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR05CA0031.namprd05.prod.outlook.com (2603:10b6:a03:33f::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU4PR04MB11006:EE_ X-MS-Office365-Filtering-Correlation-Id: 3a48ec29-f3d7-4ee2-9c01-08dd14bb134e X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|366016|52116014|376014|7416014|1800799024|38350700014|921020; X-Microsoft-Antispam-Message-Info: =?utf-8?q?MYd6CYLr49sLLmlAwfZeI4l+evhrMDM?= =?utf-8?q?lmkbZYpqccFqElftqtZAsiee93/wsVqMNxtH7CvayeqNlLvDA76t9OAd46WcBRCcI?= =?utf-8?q?+pDnJJzV7JXWFGRYC2QQuHhuujvkWY+O7IdtzzgmtOV5DsvY5o1asrnHRSGClF7Eu?= =?utf-8?q?+Dv9yLqMSb76LKiKZhaIXCYUpwUiN65pzIhKvutxWhEYMvAKlxczRbx3YhWemAS6M?= =?utf-8?q?NpWSmjoghx5+UfwlkKa0ZijFpKrGRs70jvB2zetRm5UXB/mte5uq1RhUrVG4lpk+b?= =?utf-8?q?AqKIKeheN26eo9DW1AaDo2NtGu1KkPNztwZK3fiZT+bUTlB9p0xXqn5mkTD2G7z1v?= =?utf-8?q?i5ypvs71AknMiMz9k8lE/8g0Xkrqch3WyYDaQiM7ryCjY5nnOOpzKOmpHKCiYyPlY?= =?utf-8?q?VpNS9CkTpM/LLesi24SPP1naF7UUzm44qN89mRqC8tUhJvAOrC4rX6fugTchpCKuY?= =?utf-8?q?uXdUsI1/pcNUHR0hctPOslotMqJuoW6r0ecGFq+OELweOqYoq2i1i3sUVpts0KfVe?= =?utf-8?q?QeokAyYBHtk5oViViPqT6aZCL2A0WbC31AqiHfwbj8SScmPaeUUiqlG3eOl77ECtB?= =?utf-8?q?KwFp5V9wYvetQRUXC2i+39NO37TlqmhWdZ1glVzazBor94W+nE+XG08kOpMuZx4Bs?= =?utf-8?q?UidEeyqbrvaCiuKlVYixNHtAZxF+oqLCxFg8rPS/3XPh+dtu2XnnZmnlqBNqwLk+n?= =?utf-8?q?s2SXS1MLbyY9vCH2js5TpAuV74JNe/GgEwC6+gMlvK2Fb0f6uGjKkkqZv80XhBfFp?= =?utf-8?q?m1fn6lCsWy7TfuPu9Iq3p+0OIdD15IsvDCdagjGl2x/yjh48nUobchDVFKkMClD7p?= =?utf-8?q?BJiFc3JbdnshxElQMXScAX72ZfsJOkPppHIk8TZHpDhk4ShBKQvfgLhsf/ge/jWpd?= =?utf-8?q?PmusiMX4IGQLfXCX5sZwaFqSYmjUwgz/BIaNQjMa62EdY40Sxe7QGCsKuUQp1aR7P?= =?utf-8?q?G4UETOTkR6qbR4I4FOtR/88shfqI917tvJntrEJ9dqq59iThr+Y/fotvQNvo7+hJO?= =?utf-8?q?YRE2zxkTo7kOCIIN3b+M47Mhfo9lMXzxOV1gpa5xwTE+obk8y05p9Ql27HnTGFsE9?= =?utf-8?q?CBWZDTqAV3FJ2Ihk2tpPRO2qmGxxz1zn1OJSb4maEyHoJsufCkKgRe6ONnv9TR1in?= =?utf-8?q?TN5eN4+xCVNreFUPLAuMVCwwO9+agdWtuTY1lz4M27A7tCy70XJuI2yICHrbC5y0p?= =?utf-8?q?pnAfB2DEYkr77NzvibSu8anbXm/Lo3SjFmf0xdQ6N1Ghfrx8PtVM4YYub6qjiPyzx?= =?utf-8?q?CJmi98GGDLY9T/YULWLsUe2BsvKiQk9ub47aEuq2VchrwrV7cTW/zKTZAMR+umEXq?= =?utf-8?q?aFJ/rQCNh0rch8l4VJbgGMp4KIKhLP3Nr6kdeBo2hgDOeWpslXuGryE=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)(366016)(52116014)(376014)(7416014)(1800799024)(38350700014)(921020);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?RTwjuzK4yRdYK9vvoF70Gj35i4Pt?= =?utf-8?q?mU4d9LTYrhW3S6tsMlN3poyDHAyq0xRvIZ0ruBhPH+g0wmlW2Exs7PrYbdIhPy51F?= =?utf-8?q?wNNsTXzt8w9iXbvAfBCWY+hkkI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woEXIhviQsxtNNKkQLyNfs4zuSc2U5O?= =?utf-8?q?N8zFrOdddzWmpqrXq5KXfeGOdZDHJ+p9y+iT+7xuFkNKyCVpLMDpkeA79QSwXz8zz?= =?utf-8?q?a5WJSnzLjwRoPfL7xWN8LNxD6Xu6dUcSw+FASVskOmw8/713T/nF4qA4SLLsVvEOM?= =?utf-8?q?YOdG+HuFv5SsR6wR7KGlKo6MoJni+W7G1DK48PKMjqYpPlnx7vy7wfCUYe5gcnav8?= =?utf-8?q?GaSvBGUIfZrIF3Zc+OT8041grxo5prNmyA2F1BufG7si1g/H5+oSqY2C5yTfPaB61?= =?utf-8?q?RvWyZ8k4AfezbeD6ZRX4T8CORrdudWbsfmCF9G/g3m/dXGY9EenQgiNjvZ63UsmVc?= =?utf-8?q?9ccaqY9u0AMW4SE6VK9DyoattNV0qMqYwAAhI0o1zr6DMav3aFCxMaryjpYihJN7m?= =?utf-8?q?E8im4KUh7L7lta89uQLDZxfyXGcnowno5YJLVMn8kyOhEfj9oeIKA0V2x9qBIfKhM?= =?utf-8?q?tLKf18nqAiQv3VOjNP4+hujL6wgQpmiZUViqmz2hS9noAEAT5tSZDw/cpu0qh3QzP?= =?utf-8?q?dPYny7t6pGl1?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3a48ec29-f3d7-4ee2-9c01-08dd14bb134e X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 04 Dec 2024 23:26:27.2807 (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: EjTwG4lY5Xa2uJvcGeNwXJ5VeDsSQ+6I2kF3ECuTG8kq8YgaE7/NeJKznhktkPuOYlfnTMW9y+VEcueEgh5jDw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU4PR04MB11006 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_MUTABLE in include/linux/msi.h and check it when allocate doorbell. Signed-off-by: Frank Li --- Change from v9 to v10 - new patch --- drivers/pci/endpoint/pci-ep-msi.c | 8 ++++++++ include/linux/msi.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-ep-msi.c index b0a91fde202f3..c4a4f211cb27d 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_MUTABLE) { + 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..e404e0a01692a 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_MUTABLE = (1 << 22), }; /**