From nobody Tue Nov 26 20:03:56 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013029.outbound.protection.outlook.com [52.101.67.29]) (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 B44361B0F2D; Tue, 15 Oct 2024 22:08:04 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.29 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030086; cv=fail; b=ntZzAr/mPHOJfjlg1kkG5AUGNWAc1SRD4Pb3MY3YuuvYMzJlQdU3XhODJk1zopucwPZxPLhR/NinY8y2Gl+jQsXz+AMzWRTcowOhDthzMKeZ32aDbK6oQAJuRM5BEGODT+RhzS5LVlT06SglyqLgyje14+RSywy/YWO3cccxsJA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030086; c=relaxed/simple; bh=dpRuTumZhFUVbKPOdmtAMQ5zSKVcrdkbzwxxi6fJUz8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=cmwufRgKtCezf12njk6VPKZs+UFu57O/wBo+HxCf/nLblHnWDkM2sQL7NVO5n3xUivZdtQ6/M5gmusUFNVNY2a8Gjf+QUYZWfnG229wBICZagGNCEseOzJ4vqDo7xNjwichxVTa0V856tXyEHNqsL/0TUAZOkLe6Er8/syEUaCk= 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=XM2y38Qp; arc=fail smtp.client-ip=52.101.67.29 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="XM2y38Qp" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ohBqd6KkVhftuO4VqhKCJENTeM4OPsaX/TSbDOIq4NHj5ufQV7ls84wbuDhB4jCbLjMNTuveU5lRJcR9MBYSpSqQj2q9xrNZzJkIbhclxph8gl6x41//Qx1DB73nAndplYNQR9OSE+jF644oftwDdx2DiEB8vwndBpN/GxSXQyG8wiiChN1NhlmFH21/5A92yhRhO7/mnzqmRq28K48gThjMd6bx7AYhleGNaHFC2xVwg8MHY+SwtenTSF8J0A0s+kO4xKBPNnMKzkiIt5vA2hEYlmmuYCSSxZ2eedxzp/Acytkt972YlKceeiWbhhnuFXtnJLMbS7LP1wVUiJn3Vg== 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=swW1eyLF2wHdo0B2Hb3YfQpGGihq8nZ9DTnuN6C2Omg=; b=o/AlepONR9l6KxO8iKKKCVDpC3+HMcZSFw/eRxOFiaJIV+Fr7hosyzH9FTGDHW/AWeT22bsL44Sm8Eq04unSTJhFsPmlFrkAMTvEfq+Wdgzb2/31hL06NvinTgJuPs4h2Pjbpd3Wii1RpDtDzeIdC8Se60Gs0jtjmcJYlYJzoOpp4KW9/xGgIYQoos4WECXaXxGhJ/JM7+JugDo69NUle98L7KzzDfGQD0AN0Wz8xJShgnoN2qOycFW3xOxQFBrUv5LzL/B6q1zhWSeK4o4vVKfjB+Qk9PIBOaghTC1Qt3goDiAN9ehn5WZHIViYScaJ7Su+HGYkspey+WcUWM4vEQ== 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=swW1eyLF2wHdo0B2Hb3YfQpGGihq8nZ9DTnuN6C2Omg=; b=XM2y38Qp8zevU7ORrcX11DucfhVs5Yp3PaFwyEV7Gh6RAJHmp7mw3umEAPiU4ltBJ7+ppoO47fi4O27IssCKYQudc8HOZKZmk9/JBqgVhvjTsKWZy2ON8uhkalGLuhk/8/ZFyxx9ejOmRv6JT0IezktEDN9tt9vFP6gl31HxgdqmbZnoUbRgjxeFeUxIMPSxQ5CIRqomVSzySDsZMN9iLzX0kmtRcnseS8AKwagMB6BPVIaP60AJvlBc9o/BvlkjzXxshV+VyKRoLguf/AkbCwZ0nQNzJOyZ+wEzZbIIOPh0hCOohtUxNf/BGJl0VDIiER3zwRO5X15nFB50gRTfrw== 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 DBBPR04MB7788.eurprd04.prod.outlook.com (2603:10a6:10:1e4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 22:08:01 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 22:08:01 +0000 From: Frank Li Date: Tue, 15 Oct 2024 18:07:14 -0400 Subject: [PATCH v3 1/6] genirq/msi: Add cleanup guard define for msi_lock_descs()/msi_unlock_descs() Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-ep-msi-v3-1-cedc89a16c1a@nxp.com> References: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> In-Reply-To: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729030073; l=791; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=dpRuTumZhFUVbKPOdmtAMQ5zSKVcrdkbzwxxi6fJUz8=; b=5WhOgWPZ4IGIHmznpYsjRFzEk+lVGdt0p3vms3BedG0LqO+CX5RpnQWxJ6ypDWH8zAPX4BuyQ ZOwIThBonCUATNAwpQ8x8Lse5nQaq11Z7nx6ERwk3vmVGnYDa2vZ8e8 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0059.namprd13.prod.outlook.com (2603:10b6:a03:2c2::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7788:EE_ X-MS-Office365-Filtering-Correlation-Id: aa8c6dab-3e34-412b-bd6c-08dced65d5c9 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?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rVVdRcnBudDhCZWppaCtobWFQ?= =?utf-8?B?Nk5IMXhyVmlQS0dTUE8xdz09?= 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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eXFWMG5XbG9LRTZaSUl0UDVNNHRSb29XUVNEdHhtbE9oSU5FWko2ZUp5OG84?= =?utf-8?B?S25YTVFRMVJ3Q0VYZXNzRHB2S2JnM2RCNHFGTTYyNGlTRWdWVU81ZFZzTjhD?= =?utf-8?B?SVk5b0NIWHpqYzZtdm5hOTVCTmplZG01aXY3Qm9OaEl2bHZvT1VKRjRTa1VM?= =?utf-8?B?TTZhSUZFTkEwcElUUERqSldZdmhXQWZuaGlHUDhIV2k4bUpsaFR5TE1BWXZG?= =?utf-8?B?NE96eFdDYnIvakpKdnJ3cXBuMTYzTngzTGZYU090dk9FTklwazcxUFJOZHQ0?= =?utf-8?B?OXo0cE05VE43QlBIbitqeGFFOURxSTV6bkZzVi9hdmRETTMrVFpYeWs4ZFYw?= =?utf-8?B?MXlpZEVIdzBrNWU2Y3hTc0FuR1JBQjI4Z3haNlpmbEtGUUdhNERJWVVnbVg3?= =?utf-8?B?aTMyYzBWd3M2VUdKMkJDSitXcHNHY3dDc1NnMVBqdmUrSGVpWk4vTDlVSDVD?= =?utf-8?B?UW10MzdidktJc24xNTJtQm4rb2JFeXU5ck5ocXorcFY0NHlJb2JRaXVXaXRh?= =?utf-8?B?SFlRUHJxVmVhKzJaRU1hRDhmaWVqWU52ZVdiTlpoMDk1czArcWtDa1ljaGhB?= =?utf-8?B?a29BV0VSQkhjb1lIUFVCeGJvaDFzWnlHRDM2OEZ5N0IxRVdjY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hVlJ3WC9FRUZ1blV5SDJHaFhZ?= =?utf-8?B?eXF5ZUVNR3hWdExVMHg3ckMxSGV2Wnd2VnYvVlAzSTVjazJUcFFtL2l5SDQ1?= =?utf-8?B?SnJIL0FRWE5YZHV3YW5VK3Zwa1JYbXo1cmRVUlluQ2JWcmJZWE1GVkZxRzVP?= =?utf-8?B?VGpFcnZkWnhNNURidkpmYjlEeEo2SWhnejhCbnZ0bFJobWFPTWdxQzdwdTZQ?= =?utf-8?B?Wjh0ZTc3WXR1bGtYWWZPSmxoQkFtd01sT0lLNm1WMkhCMmpjREYrczlDQ0Y3?= =?utf-8?B?MXI4RithVXlsOFNPQVBTYTlRZDhTbXBKK1VMMnQ0TG9OMjJWaVVmdlRxZUsr?= =?utf-8?B?KzlkV0tLMHREWnJ0T3pCWFFZMzZxdEg1M2JiOENjbWN4VlVDT05YeXFBd0xX?= =?utf-8?B?bUdzUkdLL2FYOXNWeFBrN28yV2NyQ3F5TlpDUkgyWDJHWHk3SHpwVUFqMGhG?= =?utf-8?B?MkRMMnlTRGV0VGdJR1JSN0lLVnFsMkRwSWI1U2ZLTk9FYWtuNG0rQUpwTkU3?= =?utf-8?B?aU9wSnlqMkxxSy9OZTRTK1ZKcEk1enM0VFd5VGpHMFdIay9ZYkNubks4RkNk?= =?utf-8?Q?jOP4=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: aa8c6dab-3e34-412b-bd6c-08dced65d5c9 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 22:08:01.4871 (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: q/42s0zFaX077BEkWmrLTbTPnk1OTKQ5RgpI7lcd+j1yblzq8jCCRrJvt/XBA0IxHOgEUQ2SGDurKjuo0bVijA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7788 Add a cleanup DEFINE_GUARD macro for msi_lock_descs() and msi_unlock_descs() to simplify lock and unlock operations in error path. Signed-off-by: Frank Li --- include/linux/msi.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/include/linux/msi.h b/include/linux/msi.h index b10093c4d00ea..0b6cb7f303887 100644 --- a/include/linux/msi.h +++ b/include/linux/msi.h @@ -228,6 +228,8 @@ int msi_setup_device_data(struct device *dev); void msi_lock_descs(struct device *dev); void msi_unlock_descs(struct device *dev); =20 +DEFINE_GUARD(msi_descs, struct device *, msi_lock_descs(_T), msi_unlock_de= scs(_T)) + struct msi_desc *msi_domain_first_desc(struct device *dev, unsigned int do= mid, enum msi_desc_filter filter); =20 --=20 2.34.1 From nobody Tue Nov 26 20:03:56 2024 Received: from DUZPR83CU001.outbound.protection.outlook.com (mail-northeuropeazon11013029.outbound.protection.outlook.com [52.101.67.29]) (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 CC14A1B6D08; Tue, 15 Oct 2024 22:08:06 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.67.29 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030088; cv=fail; b=C4w+av2ZTlSK6LnQKdozrqLwSFtlCDcqef0IvULb2cc7wg0d/M5g1fdgXZ5IFnOCLG62a4gOGMCbnDTaKjfm7tSZerN1BI0rsPsNON7R9OK/vyKxrK1TO+kTbF7MKufR3+dG05gkdHzbcT5Xf7myOMexiQP2r/FvIR/Ry5LBDyE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030088; c=relaxed/simple; bh=UAeOGcPYB4r9eUK8PFb6MZTw8YYA0IZ33NSNOk8EfxU=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=hYAOkenwoa7MC9vww+8eqk47nkAud8jQG84xyjsTIoblIy90vbQTjtVZZLFPktTCIL29ScN7ipxy8c3VHcNuVSm8KzLqP99SDeRrHHBJmzAPSBK2EnUBbMUvYilcNWCdpp7NoJ0G61p5tzK2VrM1mZ4b6VMEPJUilqxDWxtKfYA= 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=nxN7KuKY; arc=fail smtp.client-ip=52.101.67.29 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="nxN7KuKY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=mM9s9bJMAz1R3sMLJGDRUSFZXyrydEj8M4ztuy3RlNDabdc90u2zhxKJxbh8ZO/zVgeV7QLanRWGM+LG+ltFoDtCACbjxvPCbI1h+8bHUntMXSvR1tbE3Wvkxpdoccpgy5eNTs2vbtD08j+/vjc9fqb4EfHD9xgD8yCVNjPp8eaeVl2TkeCsLUAERuL69dlLTaUXx9Dh7C1TvVWULX0rB6SbjC6nSB6KqWgcUbXnKtQDNTQTh8Y7EU1DMLXlBNkJ0vOKw5ZJaj2tQvp+MxNNJwHZLfCGVM1MooYDS9QvbhbZPZR4zQ3GfkuSdaRuwmzBIQth2/cz2ze6t+D9CwQO5Q== 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=Zr2KqpZqpb5XrDUTkmOe8bdajmgYdiot4oZ3RjQBM0w=; b=gh6SMFVlFy4yMma36jmQ+0XwDqMaKTQa824Nrn0sl5ZOjqEA9Q3h+YuguK0Ai9rZ5PW0SCy7SNn90ApmcI4QmWA4YiWJtXbWNizuzHeHS7WNuf/CTlH7uCbSh3d0IgORkKuM5Rss5lvtg3ourOhA83kqdPgndqkqWkjvttCkT0yba2hAcMSgShrocA2DiaUuOvZ7ptZosdvPWyfd/2ZMd+Gchg2BpIpYgCd4Py+vC3vjjhEKJT2vsDkAxMlG1J+6jbE8/ow7+QvzfLzyZRAbCcfuM1fPOxBn8Jl8vrcdMTWiMPCJRZV+pBBolCkOP+/Eo/leEvVxnc2QfNtHsa+llg== 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=Zr2KqpZqpb5XrDUTkmOe8bdajmgYdiot4oZ3RjQBM0w=; b=nxN7KuKYSnChn2PTYvJR+zduQlNR9YZyZNobm8Vu0f+bJ3jU72mzJPKYZocs65Lrlvdby2UtgqIbw/V6XTil5+1X6J/rTESvOpMJ/Jc/5SfW+O4WAJtrcfBucl+MCEAQ4/605JhNxLFEe2MDe2phhT9QJ0b3eQCjG5h8E/38PcCAB5OWyGLBxjCW2HyuYyI2ccsEgiqiW9kXQ6n6tCtVNUsQK2+P7rNOF9dy+MUygAsKmi7HF6NtY7kaWnHRrAJLarlQPCn8ky2kmqg8dF+pvGJjO3mo/43L8IJDDGHScBsdlff9eWQupxMcHiYHTaDRLPval1ya62kkALtaUdjoNA== 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 DBBPR04MB7788.eurprd04.prod.outlook.com (2603:10a6:10:1e4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 22:08:05 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 22:08:05 +0000 From: Frank Li Date: Tue, 15 Oct 2024 18:07:15 -0400 Subject: [PATCH v3 2/6] PCI: endpoint: Add pci_epc_get_fn() API for customizable filtering Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-ep-msi-v3-2-cedc89a16c1a@nxp.com> References: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> In-Reply-To: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729030073; l=3066; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=UAeOGcPYB4r9eUK8PFb6MZTw8YYA0IZ33NSNOk8EfxU=; b=3F6duJQ0TcqVVtPOFL5oV8U1QskUO8PM3H1Gy7/b/4jHvG4fr5KMxRuWupP9aMcxm4cPVOV/F Mfwf/Nv//SkAkZtpcfn/hGK1qMFhqUXDzBzPdGCQDHE6V9TbZY1t5Di X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0059.namprd13.prod.outlook.com (2603:10b6:a03:2c2::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7788:EE_ X-MS-Office365-Filtering-Correlation-Id: f5434e67-3416-4b9c-d4ec-08dced65d811 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?WnRwMFhjY2pydTdMWnAzQW1mOVVzcmNHbmswanV2bWN0bDhaWVNGUnYrYXZO?= =?utf-8?B?eUVUdnF0MG5TWk9Jd1Brb0lkWUlLbzVhLzlrUHo2U1BBbXJPajNMTUFnVHVy?= =?utf-8?B?RU5uNkNMeG9CeHhoMFl0N2J4NE0wTW5yQ0dZa3VQeXlHTXBxdXZ1MmF6aDgw?= =?utf-8?B?aFc1TUkvdEZEMjJtTUg1K1Rzd3BYR1hZaTgyN1EzSHFEa1ZWVW1TRkRKV1F1?= =?utf-8?B?cEQ1WEd4ZU5rV1BuNTlKREllNldPbmU0UHdBek5kbDJzQW5wWW1PaWlhT2RU?= =?utf-8?B?eUVpQjJSUnhwczRxRFJJNWpwTEc5cjFVZ0xqNW53V3kvaEI3TktVWUs1bnR2?= =?utf-8?B?Z3dHTFlYWkptc1pvdnVHdklmQUdrQk1mT2lzb3BPb01lS2xQTk51cFRlZVpU?= =?utf-8?B?d25HMWRTNWJPUW9pYVNkWEM4NGowR1JBK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1pKMURqc25TT1JOd0E5MHhOWmE4QnVPTFU1Vmw4?= =?utf-8?B?VkVHNTBtQWZ5UVA3ZUhHWG56Unc4MHcxNmY4VHlpbXJudnc4V1NnRkd1UEpv?= =?utf-8?B?ZVRGM1kwdnloTmtpQlg0a1BYZWV1a0luUFRLWktFdEpjUFF3WDh1RzY1L25q?= =?utf-8?B?WTFHSlRnSGRaNVBuSXhGekl3K0NQejM4bWR6MHh3M1B4dGNZU3ZHZ1hwbHVD?= =?utf-8?B?b3UvbFB1eFJqeTdVdVVuTllySXRTaThSNVVjelUrYTlvS3ZVZFMzNmU5eTg4?= =?utf-8?B?cmpScVBNZDEyVVcxZllob0I1Q2tHaXlOTUx2bDZoR2h2SzU4dmZYTjhCZ1Rx?= =?utf-8?B?SjNPYmxoUnhjNTJLeFY5ZiswUkNwTFhsWnArb1N6RVFpKzJkTzNrMlVQWU5P?= =?utf-8?B?Z0szMkJ5WEZtUldkcll2NW5rd0hLN0ZuMFpxcWxJb0c2T3pvbjFSV0RSRDY3?= =?utf-8?B?T3hiZXFFbGU0a2pXYkZDQT09?= 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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?TUkzMVpmSFI1MXJJRDhsZ1RKQ2NkMFM2RnhpUzRveVJFS2dRZFRzNWRSanFM?= =?utf-8?B?VitneHg4aFJOSDVzRW9QTEdvMFAvaU9GSGdBZk9JVEphQXovOGQxWHZOOGNn?= =?utf-8?B?dnVRaW1qMjlFVmVXbnJKZ1JwQTJReHp0Y3R2OGtxd2JINGVQRWdtYVZ3Tkwr?= =?utf-8?B?RmJxM0lKZGh6bHFsNnpIaE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DbFhycVl1V0dYdVZ4?= =?utf-8?B?YVhRV2RpSjJ1VDIyN3dwbGd5OEE1Y0pWdGFHTCs3NlJ2dDJPaEI2RmZtRkJq?= =?utf-8?B?bERHUWRpUmRnQ0NNa0hmODhsWEl5UDFyOE1rTk5mZlAreVFCQW9BWlY5SGdI?= =?utf-8?Q?YgPQ=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: f5434e67-3416-4b9c-d4ec-08dced65d811 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 22:08:05.3419 (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: 1zUJIOBKA94J9XelJrZMX5hCCdpoQXAJjgBxZ/mfBvkeehhEc8mqkJPbj4EHxQxeVHC9EgqoKOkPm94SiBZgYw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7788 Introduce the pci_epc_get_fn() API, allowing a custom filter callback function to be passed. Reimplement pci_epc_get() using pci_epc_get_fn() with a match name callback. Prepare the codebase for adding RC-to-EP doorbell support. Add DEFINE_FREE(pci_epc_put) to implement scope based auto cleanup. Signed-off-by: Frank Li --- drivers/pci/endpoint/pci-epc-core.c | 23 +++++++++++++++++++++-- include/linux/pci-epc.h | 2 ++ 2 files changed, 23 insertions(+), 2 deletions(-) diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci= -epc-core.c index 17f0071092550..14e6011df4b2c 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -48,6 +48,11 @@ void pci_epc_put(struct pci_epc *epc) } EXPORT_SYMBOL_GPL(pci_epc_put); =20 +static bool pci_epc_match_name(struct device *dev, void *name) +{ + return strcmp(dev_name(dev), name) =3D=3D 0; +} + /** * pci_epc_get() - get the PCI endpoint controller * @epc_name: device name of the endpoint controller @@ -56,6 +61,20 @@ EXPORT_SYMBOL_GPL(pci_epc_put); * endpoint controller */ struct pci_epc *pci_epc_get(const char *epc_name) +{ + return pci_epc_get_fn(pci_epc_match_name, (void *)epc_name); +} +EXPORT_SYMBOL_GPL(pci_epc_get); + +/** + * pci_epc_get_fn() - get the PCI endpoint controller + * @fn: callback match filter function, return true when matched + * @param: parameter for callback function fn + * + * Invoke to get struct pci_epc * corresponding to the device name of the + * endpoint controller + */ +struct pci_epc *pci_epc_get_fn(bool (*fn)(struct device *dev, void *param)= , void *param) { int ret =3D -EINVAL; struct pci_epc *epc; @@ -64,7 +83,7 @@ struct pci_epc *pci_epc_get(const char *epc_name) =20 class_dev_iter_init(&iter, &pci_epc_class, NULL, NULL); while ((dev =3D class_dev_iter_next(&iter))) { - if (strcmp(epc_name, dev_name(dev))) + if (!fn(dev, param)) continue; =20 epc =3D to_pci_epc(dev); @@ -82,7 +101,7 @@ struct pci_epc *pci_epc_get(const char *epc_name) class_dev_iter_exit(&iter); return ERR_PTR(ret); } -EXPORT_SYMBOL_GPL(pci_epc_get); +EXPORT_SYMBOL_GPL(pci_epc_get_fn); =20 /** * pci_epc_get_first_free_bar() - helper to get first unreserved BAR diff --git a/include/linux/pci-epc.h b/include/linux/pci-epc.h index 42ef06136bd1a..682808f4510be 100644 --- a/include/linux/pci-epc.h +++ b/include/linux/pci-epc.h @@ -266,7 +266,9 @@ pci_epc_get_first_free_bar(const struct pci_epc_feature= s *epc_features); enum pci_barno pci_epc_get_next_free_bar(const struct pci_epc_features *epc_features, enum pci_barno bar); struct pci_epc *pci_epc_get(const char *epc_name); +struct pci_epc *pci_epc_get_fn(bool (*fn)(struct device *dev, void *param)= , void *param); void pci_epc_put(struct pci_epc *epc); +DEFINE_FREE(pci_epc_put, void *, if (!(_T)) pci_epc_put(_T)) =20 int pci_epc_mem_init(struct pci_epc *epc, phys_addr_t base, size_t size, size_t page_size); --=20 2.34.1 From nobody Tue Nov 26 20:03:56 2024 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012042.outbound.protection.outlook.com [52.101.66.42]) (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 3B3D41B0F39; Tue, 15 Oct 2024 22:08:11 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030094; cv=fail; b=PUIZBdGzDm594/mq9PotPFNjxCQdhhFkyD4wiDBJgPzpw52rifU62gNZZL4D/FlaGN5WfyqhP9xN0Y6urNGRNHrT1MiiVWqJskPC0LblapwWeOI4FYL+bUR2tlK70SJO2IcbEsOJqa/2DslY8VknYtzx1fIqkY5vivHJFLKvGbo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030094; c=relaxed/simple; bh=pJGXreHYbzV6pOZjMjyos+FLFaeZcfFY9O59zMqECaM=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=kYf64tjHUKZIU3nDGBnahWUKXcRgJZM/ywcWbwdf1mR7+s33yoAgqzal5Kc6+1UQyg4mK8Y1VY4BeuFc5lKlHC+3H7IBRDLwJCAhAOzQnbRYN4D10QhrZ5sZ+N1Ty159273OU+GxBnQK9EM2S41VOdhxTLUmignBvZlmTUDHaLw= 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=EQv1ylZq; arc=fail smtp.client-ip=52.101.66.42 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="EQv1ylZq" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=qAiFxKdSqpCN8CKwUV/K0lx+Qq7LMXpW1mEtgx5lZKinQqlH5jx48RsE3NJr3iGhDoM4w3WuTtFbU58njp/QY1+txU16nx/rLKYWs0GCH9iaajotZiR119YF/37SNv+M/ddsjDFKikdUK4XWqu6xHH5E0qtZpkSZdLQwcf5cj8EpUJqjyKn4xA/BVcCLLrmSICc7Uu+lXwGPu/3x7q97QMR+u+QQrfew2G276CZUgUkMx6Bo2+sSRnHXtkrv3lDcc91olHoyxsKS2ZEY8mPZC9OGJdu7CFMF/8uyL5rZYpkxXX14l8Pj01r7pZxFq3dWEg9FF5xKHXIQ3jqsJim/eg== 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=F/9JpupgQ96f5TjTCekrzDyc6NamB8T99UcVfyvl6zs=; b=yc5QM+Uc2UDJ3zef1PrFbV9rzdPkfHMh5uwLP/5sesPL//Slp06OGrPYZJCVIZNSwrym5s5YVd394sDoIsQGA3GV9LhBGcXz2qsLH+nRtbX2T7ioJgnXkRHxnLM1rZ6+ALdYkFFXNA6FKoLOxwSEIKro2rKKC2qsO514QWRhB8eUt2le28rCNjbDxvhZLMIGE8gZv7vMEhPoWjZ3W8vMab6LLLVzcz2GnmNKxAL6HZ2+61Cv/J3siKF24zK7S7C4Beh4yUyQClSEc2k1H+pxDcyw7sjPI8x/HW1uKNihgndJjjh48vED0SA2IhKMLM1xwJN639d9TyqvYgZEqktOBg== 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=F/9JpupgQ96f5TjTCekrzDyc6NamB8T99UcVfyvl6zs=; b=EQv1ylZqRJcBPQUkLhWitkuXX7l7WXXWjUBE8UhikB4AB/17q45CNcikZsSLePKrKqOiI12ErRvcEEGzpih1x75FYBwQD2DLRl0qIl1RLGFqyl9A1p1zIm/kvk4bp4J2L0eaVMtCXl5FC4F4FVZjIxlbxXizh1LRb9u+qykR+ov8SrpVaSUbGQubBSG56fotnEMlKsod+AAi7CXhd0IKXGNY5d2rE29GpZD5fwBIMqJBurlZrqxolUvahrh2sNbiLoVu4QjMiuz3Xecf8PfLRbI2lm2qjV5qe8nZs8zm/KbxfzPEVezHah+X58PIUdlHBVnJGick3zAsyiW5b+eSYA== 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 DBBPR04MB7788.eurprd04.prod.outlook.com (2603:10a6:10:1e4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 22:08: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%4]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 22:08:09 +0000 From: Frank Li Date: Tue, 15 Oct 2024 18:07:16 -0400 Subject: [PATCH v3 3/6] PCI: endpoint: Add RC-to-EP doorbell support using platform MSI controller Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-ep-msi-v3-3-cedc89a16c1a@nxp.com> References: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> In-Reply-To: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729030073; l=7041; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pJGXreHYbzV6pOZjMjyos+FLFaeZcfFY9O59zMqECaM=; b=9dOrBghNwgYKOSVoqa8ePrZBzQDXnWv6v/HGCIqT7GzqcBEt9LHUWSxbT6pfSib+3KLFYAbBB vPLB7hWFMFzDDskU5XhC97dPP22qC6YYuQUQtXRRIThRJ94AXPCYBGf X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0059.namprd13.prod.outlook.com (2603:10b6:a03:2c2::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7788:EE_ X-MS-Office365-Filtering-Correlation-Id: d8a96be5-ef53-46dd-4b1f-08dced65da8a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?dlV2aHZ4bk1ONjZ3ODlFVW1FN080TElIelNuc0VxZTB3SmNyaVBZTHZwNFdG?= =?utf-8?B?bDFWMXd0cGdIRlNESzVmNis2Z0hwZzlxV3JyRld4bkRPSUJDQWpCdDFkdmdK?= =?utf-8?B?a25NWHdtc1ArV0V0YVQ5RWE0ODNDUzE2aHl2Wm5qM1ZyMStpUWN5VmtTeUha?= =?utf-8?B?L0ZKeXpIbmNsYUh4b2NpNUdFVk9nbXNDSUZLbTVScEpHendnQ1l0ZGQ2Wllh?= =?utf-8?B?bDVtZE9GV3pZY01XbHRuM204VW5QZGJsZXRrdDlRTTRaM3BjcWM0V3FCSmxN?= =?utf-8?B?WHBYQ1p2ZVFSNHZ2Yk05bndXVkJQY0Y4OXVUQVMwWGpKdGx2dlYrWFFjWDdI?= =?utf-8?B?aysrM2lrdW9LVjBHRWRVMUZzMmpicnpYOFNoUVczRHBkbWFkVXFaQnljejkz?= =?utf-8?B?ZzRvMlg3dXBRMTJIRHJ5bWw5Rm8wUlJlNlI5NW9MbURZbHFjN21sTWNoUEto?= =?utf-8?B?dUF5VHJtWGh2M3p4K3YwcGJRNStFRHpMRjlkdThDc2NiMzlyS0hENzMzWUVD?= =?utf-8?B?Z0VpZFowOEZYejJlUmQvQWtjUGFaMy8wM3V2OGlMUzRyaXQwUWVSVzM0a01n?= =?utf-8?B?TEJUOGxORVRKeDRxVlJqc3VsdHRkUGRwcE9LbjhNSTh2MFhURDhySWIvU1Ra?= =?utf-8?B?YVFCVGx4UGlydzdHeUZYaUZUSmZLMjhPczcrNTJPejNYamQxanozL0hheDNB?= =?utf-8?B?SENzRU9zMWwwY0hIN3FQNGhGdGdES2RrRnZ2SWZraUtkeE0xQ1lCMlBldC9P?= =?utf-8?B?NzQrVUVhdUVFN3ZXYzRUT3BOWXBVTldQU0JRUml0ck9uSnhmVXlZRC9MdXFZ?= =?utf-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eEtsVTJoZnJ5RnJN?= =?utf-8?B?Wnd1SnJTaDJDSTQ5Yk5jQnk4Yk83R1pIRHlwTkNkbFpDZXZFWHdBVDRQVkFU?= =?utf-8?B?Y2sxSVp1RzVBL1VTdGVtUT09?= 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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?eU04R2ZLWGVzZExWMTZxTE9ncStHNUp0WGdVN294V1o4QkNWTjB6NFMyeXk2?= =?utf-8?B?QlM0R3poVTBzRlFDVzgzeWZFTUNXTzFLWjlCL1g2TWxwdmlRcDh2MkY4UlVI?= =?utf-8?B?ODUxUUY1NzZ0R0tMSVV6NytjWkIyQWtESnFicEV6N0x3anRxYktrVDZTL3lL?= =?utf-8?B?N2FhbE41MG5NaTJPTFFOOFlPM3JkUjFwczhpNmNNZ01YR2RycG1oT2N6emcr?= =?utf-8?B?dnJ6UWdnZEVIcmR2WHVyUStrb21OVXg1cW91K1JXbFdkb0U0djZLWWt6U3l3?= =?utf-8?B?bksxZlVGS2wxTk5xamZWMklzWEF0K0ZsTER2WnZHOEVxTkRueUQzU2p0VUVr?= =?utf-8?B?cUkxdUEwakFwYUg5RkdiZXZtbVZORTlpalJlSkd3Vm1NOVQ5S2ZzZnVUelFF?= =?utf-8?B?Zzc4TFhWc3B4UzdzRWV4ak1EeHhPMlNxRkYxUVQ0bXk4dk13TkhkY2lBdHpl?= =?utf-8?B?M0xBM05TMVVsSVhZdUhiNmRUNlRKTkV0UHZvNWhlTS9zYnM0NnVKMVlFck9R?= =?utf-8?B?UEZNLzd0T3J2bWxrZWtpMnRGNit4c1dZTERrN2kyYUx2eGc1TUdFZS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MyRWRrc0V4RFI1cGZ5U1BHazhpVTFNK0Zk?= =?utf-8?B?VFlSeGtTOW5MaVcrMTJiTmJSM3gyUmM4bEIxeStycTBkRzhscmRmcGFxU2hS?= =?utf-8?B?WTBBc29oVlU3d3lobDFuVSs1Q1ozb1o3UXFoSmpuZ0dYV29iZlN1T0EwMWhU?= =?utf-8?B?MXE3bHNBSC90dEZkd3MraHIwSU1QTmxvT3I3aDJaRnNDN2paTzkra0hFQkIy?= =?utf-8?B?SVAyZE00eWpTNnk3UElUVEdkMXAxUmxIZzNtODdUTno5b2hrdHVIS1hJdWZu?= =?utf-8?B?MnpRdm9rRXdLeENBeFFCWjgvbTdTZWdTZ1BpbXczZGVtUHVIZEdPeGsyZHlk?= =?utf-8?B?Q1BRaFJLd0xIcXNBOGM1MEw5L1FUN3dXTUU4Mzk4LzY3ZHVMU29UWlR2VGJ5?= =?utf-8?B?U0NIcmNMZlRFK2ZQelZSTmN3amk2bE5FU2tVRVhUNU9xeloyczhtRm1VSG5s?= =?utf-8?B?V0dNSFNBOG9ZNlA1ekhsbHU2c3VrOXVjeHpPR3BBM0F1S3JyMzJQNmliLzRz?= =?utf-8?B?R3Y4Um50TTA1eGlQSHRPcGw3bUdhM2JMaDRaZW5TQkJuSVBJVEJGWUV3ZWhu?= =?utf-8?B?djVTSEFXUS91dGJWY3B5WHdEOWlrSGRjaEFndVRMUGlBenFtSXF5NldzWGN1?= =?utf-8?Q?8kPE=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: d8a96be5-ef53-46dd-4b1f-08dced65da8a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 22:08:09.5112 (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: anXZuXv0Mk3VoQ/cpQ170Bm3Y+J8DB9mSvv/Rk8XtTiRnomNnrB0uIqPhRSjGLUJSCX5ggjcl1XQgRS5Z0ivQQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7788 Doorbell feature is implemented by mapping the EP's MSI interrupt controller message address to a dedicated BAR in the EPC core. It is the responsibility of the EPF driver to pass the actual message data to be written by the host to the doorbell BAR region through its own logic. Signed-off-by: Frank Li --- drivers/pci/endpoint/Makefile | 2 +- drivers/pci/endpoint/pci-ep-msi.c | 162 ++++++++++++++++++++++++++++++++++= ++++ include/linux/pci-ep-msi.h | 15 ++++ include/linux/pci-epf.h | 6 ++ 4 files changed, 184 insertions(+), 1 deletion(-) diff --git a/drivers/pci/endpoint/Makefile b/drivers/pci/endpoint/Makefile index 95b2fe47e3b06..a1ccce440c2c5 100644 --- a/drivers/pci/endpoint/Makefile +++ b/drivers/pci/endpoint/Makefile @@ -5,4 +5,4 @@ =20 obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS) +=3D pci-ep-cfs.o obj-$(CONFIG_PCI_ENDPOINT) +=3D pci-epc-core.o pci-epf-core.o\ - pci-epc-mem.o functions/ + pci-epc-mem.o pci-ep-msi.o functions/ diff --git a/drivers/pci/endpoint/pci-ep-msi.c b/drivers/pci/endpoint/pci-e= p-msi.c new file mode 100644 index 0000000000000..534dcd05c435c --- /dev/null +++ b/drivers/pci/endpoint/pci-ep-msi.c @@ -0,0 +1,162 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PCI Endpoint *Controller* (EPC) MSI library + * + * Copyright (C) 2024 NXP + * Author: Frank Li + */ + +#include +#include +#include +#include + +#include +#include +#include +#include +#include + +static irqreturn_t pci_epf_doorbell_handler(int irq, void *data) +{ + struct pci_epf *epf =3D data; + struct msi_desc *desc =3D irq_get_msi_desc(irq); + + if (desc && epf->event_ops && epf->event_ops->doorbell) + epf->event_ops->doorbell(epf, desc->msi_index); + + return IRQ_HANDLED; +} + +static bool pci_epc_match_parent(struct device *dev, void *param) +{ + return dev->parent =3D=3D param; +} + +static void pci_epc_write_msi_msg(struct msi_desc *desc, struct msi_msg *m= sg) +{ + struct pci_epc *epc __free(pci_epc_put) =3D NULL; + struct pci_epf *epf; + + epc =3D pci_epc_get_fn(pci_epc_match_parent, desc->dev); + + if (!epc) + return; + + /* Only support one EPF for doorbell */ + epf =3D list_first_entry_or_null(&epc->pci_epf, struct pci_epf, list); + if (!epf) + return; + + if (epf->msg && desc->msi_index < epf->num_db) + memcpy(epf->msg, msg, sizeof(*msg)); +} + +static int pci_epc_alloc_doorbell(struct pci_epc *epc, u8 func_no, u8 vfun= c_no, int num_db) +{ + struct msi_desc *desc, *failed_desc; + struct pci_epf *epf; + struct device *dev; + int i =3D 0; + int ret; + + if (IS_ERR_OR_NULL(epc)) + return -EINVAL; + + /* Currently only support one func and one vfunc for doorbell */ + if (func_no || vfunc_no) + return -EINVAL; + + epf =3D list_first_entry_or_null(&epc->pci_epf, struct pci_epf, list); + if (!epf) + return -EINVAL; + + dev =3D epc->dev.parent; + ret =3D platform_device_msi_init_and_alloc_irqs(dev, num_db, pci_epc_writ= e_msi_msg); + if (ret) { + dev_err(dev, "Failed to allocate MSI\n"); + return -ENOMEM; + } + + scoped_guard(msi_descs, dev) + msi_for_each_desc(desc, dev, MSI_DESC_ALL) { + ret =3D request_irq(desc->irq, pci_epf_doorbell_handler, 0, + kasprintf(GFP_KERNEL, "pci-epc-doorbell%d", i++), epf); + if (ret) { + dev_err(dev, "Failed to request doorbell\n"); + failed_desc =3D desc; + goto err_request_irq; + } + } + + return 0; + +err_request_irq: + scoped_guard(msi_descs, dev) + msi_for_each_desc(desc, dev, MSI_DESC_ALL) { + if (desc =3D=3D failed_desc) + break; + kfree(free_irq(desc->irq, epf)); + } + + platform_device_msi_free_irqs_all(epc->dev.parent); + + return ret; +} + +static void pci_epc_free_doorbell(struct pci_epc *epc, u8 func_no, u8 vfun= c_no) +{ + struct msi_desc *desc; + struct pci_epf *epf; + struct device *dev; + + dev =3D epc->dev.parent; + + scoped_guard(msi_descs, dev) + msi_for_each_desc(desc, dev, MSI_DESC_ALL) + kfree(free_irq(desc->irq, epf)); + + platform_device_msi_free_irqs_all(epc->dev.parent); +} + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 num_db) +{ + struct pci_epc *epc; + struct device *dev; + void *msg; + int ret; + + epc =3D epf->epc; + dev =3D &epc->dev; + + guard(mutex)(&epc->lock); + + msg =3D kcalloc(num_db, sizeof(struct msi_msg), GFP_KERNEL); + if (!msg) + return -ENOMEM; + + epf->num_db =3D num_db; + epf->msg =3D msg; + + ret =3D pci_epc_alloc_doorbell(epc, epf->func_no, epf->vfunc_no, num_db); + if (ret) + kfree(msg); + + return ret; +} +EXPORT_SYMBOL_GPL(pci_epf_alloc_doorbell); + +void pci_epf_free_doorbell(struct pci_epf *epf) +{ + struct pci_epc *epc =3D epf->epc; + + guard(mutex)(&epc->lock); + + epc =3D epf->epc; + pci_epc_free_doorbell(epc, epf->func_no, epf->vfunc_no); + + kfree(epf->msg); + epf->msg =3D NULL; + epf->num_db =3D 0; +} +EXPORT_SYMBOL_GPL(pci_epf_free_doorbell); diff --git a/include/linux/pci-ep-msi.h b/include/linux/pci-ep-msi.h new file mode 100644 index 0000000000000..f0cfecf491199 --- /dev/null +++ b/include/linux/pci-ep-msi.h @@ -0,0 +1,15 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* + * PCI Endpoint *Function* side MSI header file + * + * Copyright (C) 2024 NXP + * Author: Frank Li + */ + +#ifndef __PCI_EP_MSI__ +#define __PCI_EP_MSI__ + +int pci_epf_alloc_doorbell(struct pci_epf *epf, u16 nums); +void pci_epf_free_doorbell(struct pci_epf *epf); + +#endif /* __PCI_EP_MSI__ */ diff --git a/include/linux/pci-epf.h b/include/linux/pci-epf.h index 18a3aeb62ae4e..1e7e5eb4067d7 100644 --- a/include/linux/pci-epf.h +++ b/include/linux/pci-epf.h @@ -75,6 +75,7 @@ struct pci_epf_ops { * @link_up: Callback for the EPC link up event * @link_down: Callback for the EPC link down event * @bus_master_enable: Callback for the EPC Bus Master Enable event + * @doorbell: Callback for EPC receive MSI from RC side */ struct pci_epc_event_ops { int (*epc_init)(struct pci_epf *epf); @@ -82,6 +83,7 @@ struct pci_epc_event_ops { int (*link_up)(struct pci_epf *epf); int (*link_down)(struct pci_epf *epf); int (*bus_master_enable)(struct pci_epf *epf); + int (*doorbell)(struct pci_epf *epf, int index); }; =20 /** @@ -152,6 +154,8 @@ struct pci_epf_bar { * @vfunction_num_map: bitmap to manage virtual function number * @pci_vepf: list of virtual endpoint functions associated with this func= tion * @event_ops: Callbacks for capturing the EPC events + * @msg: data for MSI from RC side + * @num_db: number of doorbells */ struct pci_epf { struct device dev; @@ -182,6 +186,8 @@ struct pci_epf { unsigned long vfunction_num_map; struct list_head pci_vepf; const struct pci_epc_event_ops *event_ops; + struct msi_msg *msg; + u16 num_db; }; =20 /** --=20 2.34.1 From nobody Tue Nov 26 20:03:56 2024 Received: from DU2PR03CU002.outbound.protection.outlook.com (mail-northeuropeazon11012042.outbound.protection.outlook.com [52.101.66.42]) (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 A3C2E1D6DB1; Tue, 15 Oct 2024 22:08:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.66.42 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030096; cv=fail; b=ZeEhZrrw6zjFSTFhbkYP9Lb4BnQuI/yDj0mqMzggidBCYMqEXNjTDZNRX53TvKiTM/rovv30bxJr9kEFMbJ+jroTPOZJ8efeHNBWGMhf4MLMjQHESq7VwZzED8B10G0Q5HKQxXYDx5I6ocY+iVE0z5jhAJD4+s9kTHAC3hEeDCk= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030096; c=relaxed/simple; bh=vg1b8fZ0ikOaTJqSjYHEd0OEjyDNFXGxJ24NF7GoDWk=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=HXqUXEL7nSYVe86D5R4Nlb9026Jo9avxurky2bwdb54stTqyl+5SawbPVSILJBZY9xUQGpQaYAGnKO132rrWegh4n27GH9xJpnJ597OcEWKVkdG8gx6iTPt+XXrKnPZJzS3p85OawYGK9jNXM2nc6ZyRJsPaPNEYnsIkppXE+l0= 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=U5b+XHpY; arc=fail smtp.client-ip=52.101.66.42 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="U5b+XHpY" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=aXpFabaRDe3aAvALoj85336gmfzK3IS+cSAJyWvAKiJRVwXyVdXi0fZIFEgWJObduNVy+27GWjugt0HBFejnyhAXDsI070heIEdhydH+XPeGM+EwfDHpLYwAIwy3m4GrlXqB7btBadpbJOYtQsgLZWNcf5Ctv+fNTuGrcXLfU1T/S8DgaLIpvyb29O2frzn/kd5uSTt2FlLJdjIevN7lJCXFfmC6LostboKFRLsQ0paAgX1PAEcQYTjIkdtFSzRuud3WbA5aM9W2Rtv8QClK5wOioitjjp9T0jNNPXnygTmo5D4A1551mPnIbP8qE+cwIcexMPbhAaqFiFnP8Zl0fg== 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=e233vooloI8RoJJfdyVli25FRPVZrIal9Vo3c9mUtok=; b=MrvqnqlPNufN9bsl3jMkYBfXIH6E7mXiT7D7mFDjZJPqVEJaoYajjcEr6XDsbcVrEjmKUWgGdZhkwsX+VUuCy0bKXvM/6HETMk+TpJsSUuyH35WB32cosoY3tzFAEUr2OecWgKNzRSH5C8UayZJGEDsCNqKW9L7mBQwjbTz6AwPFjVPvZWtogusAV6MzhArS0FyPXY3jkahbibPqPaFU4bpfoZf1FY6jKioxc3J/MTv1Tdgy34ZTKmCT8bPSl2VGR2Ujcxh4C19d/g2LG1dkwAZQsiRWKqnhs+PvXSGoi1x2TulxiRLS8FrxCTfGk/79AUiOTs5ZWAN8C1w7AxB6qA== 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=e233vooloI8RoJJfdyVli25FRPVZrIal9Vo3c9mUtok=; b=U5b+XHpYvkhPIG95cHwg8OqhAjkc2xIkHxbhmwqJiu55VUoBW95qFt1W0o8YHYYdH12Zv97VHzey8Snkn0hFxpuq9bqyF6hTBNJqlEgEK+HsEB09pIpLA8KgrBQdMOJwWWl1/9dLeCd82rgXmijPnTzRLWeUNwWlCh8NCApfYEau/4Hp9hiPIZ6UmbfcKecAY4huKXScdghe8Xi/QL6Ui+cJNiWCEFHOptuzd0pzSlRLt53bSH9rTrZhkChv927hL3q9f9c4QCliQLlczKJqmGOKD6mwM6xbZc9f3N357QM7XO2TkF9cJyFmvn61nydNDE4arlBuCXrkYBUtn6pVkA== 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 DBBPR04MB7788.eurprd04.prod.outlook.com (2603:10a6:10:1e4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 22:08:13 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 22:08:13 +0000 From: Frank Li Date: Tue, 15 Oct 2024 18:07:17 -0400 Subject: [PATCH v3 4/6] PCI: endpoint: pci-epf-test: Add doorbell test support Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-ep-msi-v3-4-cedc89a16c1a@nxp.com> References: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> In-Reply-To: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729030073; l=5157; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=vg1b8fZ0ikOaTJqSjYHEd0OEjyDNFXGxJ24NF7GoDWk=; b=tm3dItJmYQGV/xS43LPWjmHikztC3AnbZl7D7Z+wQ3GrxC1/3sRNYLjPHJlmaGUdvqnaCXsGB tfP5d/mPvPAB011H898pLmyGcExmW6jX9AtvG4AGGYhgiwoL8shSIpx X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0059.namprd13.prod.outlook.com (2603:10b6:a03:2c2::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7788:EE_ X-MS-Office365-Filtering-Correlation-Id: 1288cba9-37db-4f32-6560-08dced65dcdb X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?bzc5bjlBTkhuVlJBZnNMVm03NWtzeldjdkNCZVRoUUNTbmFnd1VGQ0VhTXg5?= =?utf-8?B?VlVweEZ6OTlvNXcvaWh2eW9nTEdiRStza2FaR2tlVkQ2c1UzSFhQc3k1NVdt?= =?utf-8?B?dFArNnlZYk5PS1htck9yNWMvV0JlS3JBWHV3bU13UkNtb0wzakE3di9VaXV2?= =?utf-8?B?eEVzOFUyeEpFaDBTRkpDa0Jiay9pTTk0YWRGdzhjWFVSZUtySHB4MHBVdmRM?= =?utf-8?B?WnJpNUdmMTlGbTFXUWxsQ0lNaFErWnovUXRzVENSdUN3V0xaK0I3TnVFdGJ3?= =?utf-8?B?aEVUWkZCaWV4eGQ4ZzBLV2xaODNvOVJmeGt2cm1xdVI4NTNWR3BoeVpGd2V1?= =?utf-8?B?NGtLaCtBMXo1WWhIdFNaZUtFaWRDUGFlMjRXOTliWkQvMnZBajV0RHNibm5D?= =?utf-8?B?cEltTmZBRzZ5MGIzSGorMzFwNG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?B?dDNpRFgvRTNQR3kzaDJTanNEZTVIakhKTjFaOWRSaW9sd1F3UElxUjVYRkUr?= =?utf-8?B?WEhTbURaQm81b0paL1ZRdkdiU0RlNEhBNWNFaVJydmV1b1ZUcEp3MFZFblZZ?= =?utf-8?B?TzJhR3oxenNVOWQ3cy9rdm1LUlc5QW5DZVQzN1dCVW5YYWZ0VFpqa2xnbXZr?= =?utf-8?B?OGlVblpsbHdmVDlBeEhzYTRSRDBjaWJkN0JkbVNycWtNSHNiWHdhYXRnRG9k?= =?utf-8?B?elJncC9MT3F5WW91cnZkN0Q0cFJWNzlNbVlhQ216bjNhYXhEQ0Y2eGxrUUJ1?= =?utf-8?B?WjF2NlczRmJwUUtmM0g1eTRRRG01VHBPQUZuZXZhZTdCR2ozUWZmQ29TQitw?= =?utf-8?B?V3dTMjR2RDJtcE1VMW43NzhNY08xRFJQSW5TR0YrQUNtclgwNGQ0NndFcFZD?= =?utf-8?B?SWJtdUlZdm83RmtrRDNoMi9XaHdpYU40dFhXc3YwQjlvTGRmdERXQmpkU1JC?= =?utf-8?B?c1RTZ1dqTFZSNXhOQ3p5UT09?= 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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?ckxrR3dtdVErbVA0cDVKT3REQnBXMEtPaXlaRVlvMkhOR2wwSUdpZkcyOHVE?= =?utf-8?B?b3VkZ3VjdWhidFc3elVaR0xVQ0R2ZndaWTZZenZWSlNHcGxFMFhBSWRmdmtr?= =?utf-8?B?YVNQb2toQm92MHBSU1dIUFNpUlFIRWRESFRxZFltekF3SGd5UXpuNUtpejdN?= =?utf-8?B?NnRtWXdZWD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XppUUY1RzBudDRZOE16c0xKQUNUdFVJS3E5TitkRmR5UE8rTWIz?= =?utf-8?B?MmU3eGJIbldieWo2eG9OYWJIaDVqVDJNZXl0RGRDeVZIL0d3K0VMRFFhL2Zo?= =?utf-8?Q?sItE=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 1288cba9-37db-4f32-6560-08dced65dcdb X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 22:08:13.3583 (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: YbGAvhfc3XY3p3nmM4S4nagpL7gAQW+47MTtUJmvTofozIv7+cxFRfDbbM/0oLHwWygRe73zhbca7YzxIoohEQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7788 Add three registers: doorbell_bar, doorbell_addr, and doorbell_data, along with doorbell_done. Use pci_epf_alloc_doorbell() to allocate a doorbell address space. Enable the Root Complex (RC) side driver to trigger pci-epc-test's doorbell callback handler by writing doorbell_data to the mapped doorbell_bar's address space. Set doorbell_done in the doorbell callback to indicate completion. To avoid broken compatibility, use new PID/VID and set RevID bigger than 0. So only new pcitest program can distinguish with/without doorbell support and avoid wrongly write test data to doorbell bar. Signed-off-by: Frank Li --- drivers/pci/endpoint/functions/pci-epf-test.c | 58 +++++++++++++++++++++++= +++- 1 file changed, 56 insertions(+), 2 deletions(-) diff --git a/drivers/pci/endpoint/functions/pci-epf-test.c b/drivers/pci/en= dpoint/functions/pci-epf-test.c index 7c2ed6eae53ad..c054d621353a6 100644 --- a/drivers/pci/endpoint/functions/pci-epf-test.c +++ b/drivers/pci/endpoint/functions/pci-epf-test.c @@ -11,12 +11,14 @@ #include #include #include +#include #include #include #include =20 #include #include +#include #include =20 #define IRQ_TYPE_INTX 0 @@ -39,6 +41,7 @@ #define STATUS_IRQ_RAISED BIT(6) #define STATUS_SRC_ADDR_INVALID BIT(7) #define STATUS_DST_ADDR_INVALID BIT(8) +#define STATUS_DOORBELL_SUCCESS BIT(9) =20 #define FLAG_USE_DMA BIT(0) =20 @@ -50,6 +53,7 @@ struct pci_epf_test { void *reg[PCI_STD_NUM_BARS]; struct pci_epf *epf; enum pci_barno test_reg_bar; + enum pci_barno doorbell_bar; size_t msix_table_offset; struct delayed_work cmd_handler; struct dma_chan *dma_chan_tx; @@ -74,6 +78,9 @@ struct pci_epf_test_reg { u32 irq_type; u32 irq_number; u32 flags; + u32 doorbell_bar; + u32 doorbell_addr; + u32 doorbell_data; } __packed; =20 static struct pci_epf_header test_header =3D { @@ -695,7 +702,7 @@ static int pci_epf_test_set_bar(struct pci_epf *epf) enum pci_barno test_reg_bar =3D epf_test->test_reg_bar; =20 for (bar =3D 0; bar < PCI_STD_NUM_BARS; bar++) { - if (!epf_test->reg[bar]) + if (!epf_test->reg[bar] && bar !=3D epf_test->doorbell_bar) continue; =20 ret =3D pci_epc_set_bar(epc, epf->func_no, epf->vfunc_no, @@ -810,11 +817,24 @@ static int pci_epf_test_link_down(struct pci_epf *epf) return 0; } =20 +static int pci_epf_test_doorbell(struct pci_epf *epf, int index) +{ + struct pci_epf_test *epf_test =3D epf_get_drvdata(epf); + enum pci_barno test_reg_bar =3D epf_test->test_reg_bar; + struct pci_epf_test_reg *reg =3D epf_test->reg[test_reg_bar]; + + reg->status |=3D STATUS_DOORBELL_SUCCESS; + pci_epf_test_raise_irq(epf_test, reg); + + return 0; +} + static const struct pci_epc_event_ops pci_epf_test_event_ops =3D { .epc_init =3D pci_epf_test_epc_init, .epc_deinit =3D pci_epf_test_epc_deinit, .link_up =3D pci_epf_test_link_up, .link_down =3D pci_epf_test_link_down, + .doorbell =3D pci_epf_test_doorbell, }; =20 static int pci_epf_test_alloc_space(struct pci_epf *epf) @@ -853,7 +873,7 @@ static int pci_epf_test_alloc_space(struct pci_epf *epf) if (bar =3D=3D NO_BAR) break; =20 - if (bar =3D=3D test_reg_bar) + if (bar =3D=3D test_reg_bar || bar =3D=3D epf_test->doorbell_bar) continue; =20 base =3D pci_epf_alloc_space(epf, bar_size[bar], bar, @@ -887,7 +907,11 @@ static int pci_epf_test_bind(struct pci_epf *epf) struct pci_epf_test *epf_test =3D epf_get_drvdata(epf); const struct pci_epc_features *epc_features; enum pci_barno test_reg_bar =3D BAR_0; + enum pci_barno doorbell_bar =3D NO_BAR; struct pci_epc *epc =3D epf->epc; + struct msi_msg *msg; + u64 doorbell_addr; + u32 align; =20 if (WARN_ON_ONCE(!epc)) return -EINVAL; @@ -905,10 +929,40 @@ static int pci_epf_test_bind(struct pci_epf *epf) epf_test->test_reg_bar =3D test_reg_bar; epf_test->epc_features =3D epc_features; =20 + align =3D epc_features->align; + align =3D align ? align : 128; + + /* Only revid >=3D1 support RC-to-EP Door bell */ + ret =3D epf->header->revid > 0 ? pci_epf_alloc_doorbell(epf, 1) : -EINVA= L; + if (!ret) { + msg =3D epf->msg; + doorbell_bar =3D pci_epc_get_next_free_bar(epc_features, test_reg_bar + = 1); + + if (doorbell_bar > 0) { + epf_test->doorbell_bar =3D doorbell_bar; + doorbell_addr =3D msg->address_hi; + doorbell_addr <<=3D 32; + doorbell_addr |=3D msg->address_lo; + epf->bar[doorbell_bar].phys_addr =3D round_down(doorbell_addr, align); + epf->bar[doorbell_bar].barno =3D doorbell_bar; + epf->bar[doorbell_bar].size =3D align; + } else { + pci_epf_free_doorbell(epf); + } + } + ret =3D pci_epf_test_alloc_space(epf); if (ret) return ret; =20 + if (doorbell_bar > 0) { + struct pci_epf_test_reg *reg =3D epf_test->reg[test_reg_bar]; + + reg->doorbell_addr =3D doorbell_addr & (align - 1); + reg->doorbell_data =3D msg->data; + reg->doorbell_bar =3D doorbell_bar; + } + return 0; } =20 --=20 2.34.1 From nobody Tue Nov 26 20:03:56 2024 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010038.outbound.protection.outlook.com [52.101.69.38]) (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 2DD8D1C9EDB; Tue, 15 Oct 2024 22:08:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030102; cv=fail; b=lO5a1zql6FEa1+hHorOusLfvq6m5N9zsUZ05FwYht0sc0eKWQvh7rz7bzxJ43yzaOZTw9s8UKvWLYK9TIxK/dhTfvamnWCYytdwXYAW2W694md0CxyNYse86wnYrWjfn2P87LFxFX7oibtnZBiCxlFc1CmdSv+2KMR+foRrOpOA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030102; c=relaxed/simple; bh=OuA7849U5QN+fJd6KNFSJXtAX3g+s+58VR7NcMSn4OE=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=t+4PlHTvp4DORXS7K52s9PzU6afdF9mDlvcDpIaCixDZG7LLs18YivT9hRSVjYy4cz164uiXX12GXQ4N+I7mlGeVyJht9wPew5CYWrFeUz+o5a7of1TZ8hV6psfjz3Rl9YtOib7QV0RqFiX/5MNYHMZpeTPm/jRInUNGfe9RCkE= 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=Q5V1lNrS; arc=fail smtp.client-ip=52.101.69.38 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="Q5V1lNrS" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=x+agtq6LJB2DLR2oa9SdP6zwIGr7ms7jhKfLlEF6xv/sdS97jYtYyOWTAxVMV+1zymPfsPE/klzzAO6ysIp8xoxWzZrUFvGfVx6nL85j6Odu+cHEs5W7qfqH1MCO/iaoefpYmvZ6UDugQHrpufKIW5GJ3+Sh7uY/dXhfhNPbDthy+qt3lKoGCytLf8K+Tqy9EetWNP4N+Q/8+pBlXoFdqIjmVSSFhjoA//+YXIAAVwNzB6GOQXRGNLT+IODqH13AzLCT/GUbXEPYO3jpwTSA7ZE/StBkfZef750JyiuEH7vxvzM5Jv/9Q6382MJDtCq9BoqR1R1i5ssf/MFWhSOluQ== 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=ixq2N5yHgGG9SsucChG7MqayQqlFRic7PqHLPs/ALyU=; b=HM3w8Hq/n9aX4+WKJfAS9ua7y2qucXbhthlCLWPtcj0RDfBj9dcyRaxQ36zNDcW0/KH6N4gswmOl1eL3R1TcCflCl412GuewjELAWrjopK2ivDTDs9giicmQEzgmcN1d+IUK0qm4YcAPqz0xJ8pc8dKS90SWVu3BOOd/W104nKjvinnvkDlz3F5w+sO/eyKnKMS1QywgbC1qx7pXyDo9j6dtb3PBXiZ75Av7TGnIbsc2v1LhAA5IFL40T+04sEBPdpY36eP1Vt+XkRjdbdgvGcVsHpsK8GDRP7DEIDR8+NIUYhZotoazksCIfdHKiR3pKAV1EQzvxKRjohma/q+6gg== 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=ixq2N5yHgGG9SsucChG7MqayQqlFRic7PqHLPs/ALyU=; b=Q5V1lNrSX4oNbEuHHoSU04km2Hl4uMGmlnc8c7gkKrVv9IpNRBXmoy6Iu3Vk5Y+5FixBu7qFdS/gKVkpMWicmuXgH21JjkglUTgBzvaYb44qwhAknEq7R+aop5+tX5KfUtMAAv4mmeh5o+VcNXjABp6XhlXbJTRWK3c9K8U4j1hX+rkx9fjdX+3iuPuf176MRkLPx4JwJuia2J9hgENfUbDURUKOOi/zyljmH1fv0ZPp4IK9+xclr77U/3eF5/OQ15sROiGxg0ENhE6Jn2sQcHzU0QkUgVG5JnocBkjz5bCAXambwGl6p5yVzIMLfch5KOLrosiM6VXNGJk/52BQkw== 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 DBBPR04MB7788.eurprd04.prod.outlook.com (2603:10a6:10:1e4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 22:08:17 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 22:08:17 +0000 From: Frank Li Date: Tue, 15 Oct 2024 18:07:18 -0400 Subject: [PATCH v3 5/6] misc: pci_endpoint_test: Add doorbell test case Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-ep-msi-v3-5-cedc89a16c1a@nxp.com> References: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> In-Reply-To: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729030073; l=5945; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=OuA7849U5QN+fJd6KNFSJXtAX3g+s+58VR7NcMSn4OE=; b=JbkbUIvfNJmmZ7raOw1+A1Z4SuUrr/aGfwbaAuZ/xPbrKJdgX6iMQpL/iBlWXizVtcUl0k9OI 0fQd4gtDHJdBBBbYWkyyODK2hc16aW8plmTNr8OFbzr2IslxI7WdapG X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0059.namprd13.prod.outlook.com (2603:10b6:a03:2c2::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7788:EE_ X-MS-Office365-Filtering-Correlation-Id: 5f5d52a3-6ec6-48de-3ec8-08dced65df28 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?SmZ2Y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ncXNzYkZMc3V2SURCdXcz?= =?utf-8?B?bEpTRytFcHFiVVpIVGUxZz09?= 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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?YmtsZ2dHamxWRUNNY1RWSDl4NExqZHVnTjJENzN1WmdWQm9EYTRTVUhleWRj?= =?utf-8?B?R0xKMzNOeC9HZG4wNzQxVXphQi9rS2NyMXdrbkJ6c1FBTUVsVEtGWVNFNjVx?= =?utf-8?B?dGJYZll3VE9wdG04WjZPaEZ0K3pkUkJzclBocVlGWGFNbTVMWWl2amtRbWpy?= =?utf-8?B?ejZKK1VCT2t1aFcreFpOVDhYVkNFUDdrRk9xUjduOXIyOFVGMy9BcWl4Ym1x?= =?utf-8?B?R29YT3hTQS9ZaU5hM3NwRTV4UDZQRDdlTitOVFVSTGdZa3FYcnllcTdtL0JH?= =?utf-8?B?N2lXaUZqYTVCeFNJU0U3THpsbC9BWjVuZUdYb3R2KzZ4cW9XS0FIMloxeHh3?= =?utf-8?B?dnBlMzZuUWdsaThGUStPcUQxUEdBTzY2dUl3YWNCMjRuQnJaRllkZFoySkJo?= =?utf-8?B?UDVpOTZhK1U0SXJFdFhPNElnT1RDVTZoTDhBNjg2YjBOdWhiSm4wYzNjNGJK?= =?utf-8?B?Zk52RHlDSFd6ZHN4NVlRVk00TFNxbERxUzV5UVEzS0NUUXY0S2dPNzNUM1Yr?= =?utf-8?B?NzNFZkFPZGJ5S296UDJsNWtSMEp3VmVSSTZlcmZ0Q054ZlVScFdHbjhIdnNt?= =?utf-8?B?OHp0dW1uTWtveEpzL0JzeFkyVnR5YjFHNWNhZ2FUZTB0N2pTTl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prY0kyQ0ZjWUhUTE1rbUd1OEFNcnU3QUE1UzVaYUZS?= =?utf-8?B?QTd0OGt6TFl2a2pzb2Irdk9HdFI5d1NiUWx0QUJETTJNM0FUaDhJd0pmNFBK?= =?utf-8?B?YlI3aVkrTVBVZXBkaTRHWFFUck8rTVZ4ZWtqVW9KdmIwMnl2SExBSDZpVk81?= =?utf-8?B?MzFjZnc4QnBYVDJGMTM1cEZ4dWIzM09qbkpDMkFERGIrWThLeWdyQTRRNWtt?= =?utf-8?B?Y0kvelZhM3cxSTlkTDhwTS9wRCtBYytoSzZZcEc2ek9FRE5KQVJaSFVzM2Qx?= =?utf-8?B?NjlJUDZYeTN6RjBCRG5GTDR0bnhNN2hhdXFncTVnZS8zKyt4RGtjV01hNGNh?= =?utf-8?B?RmtLc2xiUzU4alNBSG5abG5wUEI4TWlFSWxjSzZRbEI2U05yeldaMExicldm?= =?utf-8?B?TnhHcnpaeHlMemUyVDhtQWRUVXRNTno2TGZreERoVjE3b1NpV3dFdnZkNGlN?= =?utf-8?B?T1JqcUppVWVkQUxuOEZETkVId09YbVFkcmpnOEwyS3ozY1oyTEtYaDY5SU5y?= =?utf-8?B?Mnd5MUdIRm5oN2R4VXdLL0FVN044V0hVSTdiNzg3ZDY4Z01yL1Q1UTFOYUZr?= =?utf-8?Q?49xw=3D?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5f5d52a3-6ec6-48de-3ec8-08dced65df28 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 22:08:17.2277 (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: msbM90+ebZPYKQpHhFvXvvFiHlDHm6HDjPCZA9PSUeKkGxGbp58DvKoBto9eF7Fz2BWUmCWPUAqHYpw+JDWavQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7788 Add three registers: PCIE_ENDPOINT_TEST_DB_BAR, PCIE_ENDPOINT_TEST_DB_ADDR, and PCIE_ENDPOINT_TEST_DB_DATA. Trigger the doorbell by writing data from PCI_ENDPOINT_TEST_DB_DATA to the address provided by PCI_ENDPOINT_TEST_DB_ADDR and wait for endpoint feedback. Enable doorbell support only for PCI_DEVICE_ID_IMX8_DB, while other devices keep the same behavior as before. EP side RC with old driver RC with new driver PCI_DEVICE_ID_IMX8_DB no probe doorbell enabled Other device ID doorbell disabled* doorbell disabled* * Behavior remains unchanged. Return failure if pcitest try to test doorbell bar. Signed-off-by: Frank Li --- drivers/misc/pci_endpoint_test.c | 60 ++++++++++++++++++++++++++++++++++++= ++++ include/uapi/linux/pcitest.h | 1 + 2 files changed, 61 insertions(+) diff --git a/drivers/misc/pci_endpoint_test.c b/drivers/misc/pci_endpoint_t= est.c index 3aaaf47fa4ee2..a2b68c613c782 100644 --- a/drivers/misc/pci_endpoint_test.c +++ b/drivers/misc/pci_endpoint_test.c @@ -53,6 +53,7 @@ #define STATUS_IRQ_RAISED BIT(6) #define STATUS_SRC_ADDR_INVALID BIT(7) #define STATUS_DST_ADDR_INVALID BIT(8) +#define STATUS_DOORBELL_SUCCESS BIT(9) =20 #define PCI_ENDPOINT_TEST_LOWER_SRC_ADDR 0x0c #define PCI_ENDPOINT_TEST_UPPER_SRC_ADDR 0x10 @@ -67,7 +68,12 @@ #define PCI_ENDPOINT_TEST_IRQ_NUMBER 0x28 =20 #define PCI_ENDPOINT_TEST_FLAGS 0x2c +#define PCI_ENDPOINT_TEST_DB_BAR 0x30 +#define PCI_ENDPOINT_TEST_DB_ADDR 0x34 +#define PCI_ENDPOINT_TEST_DB_DATA 0x38 + #define FLAG_USE_DMA BIT(0) +#define FLAG_SUPPORT_DOORBELL BIT(1) =20 #define PCI_DEVICE_ID_TI_AM654 0xb00c #define PCI_DEVICE_ID_TI_J7200 0xb00f @@ -75,6 +81,7 @@ #define PCI_DEVICE_ID_TI_J721S2 0xb013 #define PCI_DEVICE_ID_LS1088A 0x80c0 #define PCI_DEVICE_ID_IMX8 0x0808 +#define PCI_DEVICE_ID_IMX8_DB 0x080c =20 #define is_am654_pci_dev(pdev) \ ((pdev)->device =3D=3D PCI_DEVICE_ID_TI_AM654) @@ -108,6 +115,7 @@ enum pci_barno { BAR_3, BAR_4, BAR_5, + NO_BAR =3D -1, }; =20 struct pci_endpoint_test { @@ -124,12 +132,14 @@ struct pci_endpoint_test { enum pci_barno test_reg_bar; size_t alignment; const char *name; + bool support_db; }; =20 struct pci_endpoint_test_data { enum pci_barno test_reg_bar; size_t alignment; int irq_type; + bool support_db; }; =20 static inline u32 pci_endpoint_test_readl(struct pci_endpoint_test *test, @@ -746,6 +756,39 @@ static bool pci_endpoint_test_set_irq(struct pci_endpo= int_test *test, return false; } =20 +static bool pci_endpoint_test_doorbell(struct pci_endpoint_test *test) +{ + enum pci_barno bar; + u32 data, status; + u32 addr; + + if (!test->support_db) + return false; + + bar =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); + if (bar =3D=3D NO_BAR) + return false; + + data =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_DATA); + addr =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_ADDR); + bar =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_TYPE, irq_type); + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_IRQ_NUMBER, 1); + + pci_endpoint_test_writel(test, PCI_ENDPOINT_TEST_STATUS, 0); + + writel(data, test->bar[bar] + addr); + + wait_for_completion_timeout(&test->irq_raised, msecs_to_jiffies(1000)); + + status =3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_STATUS); + if (status & STATUS_DOORBELL_SUCCESS) + return true; + + return false; +} + static long pci_endpoint_test_ioctl(struct file *file, unsigned int cmd, unsigned long arg) { @@ -762,6 +805,9 @@ static long pci_endpoint_test_ioctl(struct file *file, = unsigned int cmd, switch (cmd) { case PCITEST_BAR: bar =3D arg; + if (test->support_db && + bar =3D=3D pci_endpoint_test_readl(test, PCI_ENDPOINT_TEST_DB_BAR)) + goto ret; if (bar > BAR_5) goto ret; if (is_am654_pci_dev(pdev) && bar =3D=3D BAR_0) @@ -793,6 +839,9 @@ static long pci_endpoint_test_ioctl(struct file *file, = unsigned int cmd, case PCITEST_CLEAR_IRQ: ret =3D pci_endpoint_test_clear_irq(test); break; + case PCITEST_DOORBELL: + ret =3D pci_endpoint_test_doorbell(test); + break; } =20 ret: @@ -839,6 +888,7 @@ static int pci_endpoint_test_probe(struct pci_dev *pdev, test_reg_bar =3D data->test_reg_bar; test->test_reg_bar =3D test_reg_bar; test->alignment =3D data->alignment; + test->support_db =3D data->support_db; irq_type =3D data->irq_type; } =20 @@ -986,6 +1036,13 @@ static const struct pci_endpoint_test_data default_da= ta =3D { .irq_type =3D IRQ_TYPE_MSI, }; =20 +static const struct pci_endpoint_test_data default_data_db =3D { + .test_reg_bar =3D BAR_0, + .alignment =3D SZ_4K, + .irq_type =3D IRQ_TYPE_MSI, + .support_db =3D true, +}; + static const struct pci_endpoint_test_data am654_data =3D { .test_reg_bar =3D BAR_2, .alignment =3D SZ_64K, @@ -1017,6 +1074,9 @@ static const struct pci_device_id pci_endpoint_test_t= bl[] =3D { .driver_data =3D (kernel_ulong_t)&default_data, }, { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_IMX8),}, + { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_IMX8_DB), + .driver_data =3D (kernel_ulong_t)&default_data_db, + }, { PCI_DEVICE(PCI_VENDOR_ID_FREESCALE, PCI_DEVICE_ID_LS1088A), .driver_data =3D (kernel_ulong_t)&default_data, }, diff --git a/include/uapi/linux/pcitest.h b/include/uapi/linux/pcitest.h index 94b46b043b536..06d9f548b510e 100644 --- a/include/uapi/linux/pcitest.h +++ b/include/uapi/linux/pcitest.h @@ -21,6 +21,7 @@ #define PCITEST_SET_IRQTYPE _IOW('P', 0x8, int) #define PCITEST_GET_IRQTYPE _IO('P', 0x9) #define PCITEST_CLEAR_IRQ _IO('P', 0x10) +#define PCITEST_DOORBELL _IO('P', 0x11) =20 #define PCITEST_FLAGS_USE_DMA 0x00000001 =20 --=20 2.34.1 From nobody Tue Nov 26 20:03:56 2024 Received: from AM0PR83CU005.outbound.protection.outlook.com (mail-westeuropeazon11010038.outbound.protection.outlook.com [52.101.69.38]) (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 81F181F80C9; Tue, 15 Oct 2024 22:08:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.69.38 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030104; cv=fail; b=uxI/J0Z4r5HfjavCa+HVxqe574YnX1qsrq1/PipLWQ3AdOlArrZQ877KA/nRANODPdyeS1nwC3EZIERf+gWHKYuZjQiKQeocoXFeOsSOaybe+xK831WWybcHzdUmxRcYTzWL1MZk/wSf1f3iHgEZH/KohA8RWHE3PMLAa2Xptz0= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729030104; c=relaxed/simple; bh=oLfeRG2JJa/EVak0ZqRbgfNgEQ6xhDK04ybgk4QBnh0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=cLrrJ36LvMGMaaNTZZXXaFAV/pOHD/bXkEgTGscFeju7fbIoRnJr4eJYEaGQEuQkzWyUvrJp146eQIjh88N/xlEQVPqiaMqdP7PRwee/95C0AAs7S0EORWyMWtolZYJoAw6srkqe5TH+zClUJkWPvIHOOTfLagCvQhm27cXezoc= 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=KYtdnDXi; arc=fail smtp.client-ip=52.101.69.38 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="KYtdnDXi" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=s8WBViq283QXcCinzg3aplHWoRzFUnl8i3FDBhYiPtKAA9xSSxhDdmjI6DIyF7iXNpjo5MRPjpzMp8fqHSyxYspk0LnzTRM4fYBTr4IEQObc5Zo3Z5dVH4X87XtnaaVCA1mkbmcRdQCl+Z/WjnSeMuHZVI97dd68hTDUNAz8Xy39jCGt5noXY4tcAitreTSlHQw5VKqS+WXZ611lQuks8BkhppqLFg+rhCptvZ1b5sgDHOi0J5HxHoHYaQETpCiKzcbPZqbmFYuwp9g2MCdmrGsXweXdje6P8PU+aM2XBQ/jFHTeLx+Fz7qG4wXV/Yq71ubF4KtGtsN4I1or74GRqw== 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=HRw0nM+ngMAE6u8ALv623oDL1F1mp7li7piBbTWnJ98=; b=w4A3a/zZKuEeGeqz8d/W1Qx4TIbXkAtMNpBOtpd6BPzNhWiN+NEDxoT2vmZui3/cYGqify9UMilIvC3NZLV7//+vCAsvKVhS8q3KRVjcTIPKookdoDE1Ag8EggZ/Zj9YUuFdSsBftCL+ftni5kXZtg4C9Bfv78TV8kVLwyrKAIUoTk0aIJCGxMz3IbpUg0FpHjRLpgfwUCSuYKEGN4RjncaV3ayRL98bPPRElWBwi7t/n3KTn8q04mmwnJOKMJoH4lOUuPPA1sp2ad4mozlkbKHC1IUs0XDaqnYpxaEQcYtMg9RfP+gQeXoPxcZEo4DUP3xU4EtvpqdpaVe8UUEdJw== 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=HRw0nM+ngMAE6u8ALv623oDL1F1mp7li7piBbTWnJ98=; b=KYtdnDXiQaRnKJ9eb98BnsnQx/tg7iTwqStAs+4LOCVuFjsog2VSuR+2P2AwUSWtjdAqmECPATtx8I/NWWbbFU1tmGavZQKfKjaLhhKeggCQSRqJ4BARj0LGAFJICqBpYku6nKGl0976/AI/k3aYBGVhT1LXyXYV5vL68LVkQ6nfQuZPhOVnNEpo+Bv79rbX4EZ03kqpLIpTaqvJwFrB9KZmrk9uZ7+e9Duo/ypvKqFApgqG7DHsFET221fTOfPng0LyNSsdIoyC1KtJVTPMo819spBEd5Cmv69tDvuLPGyzORKxbVmRpQrEIwZyzPZYh0DnG0LTq3fe23zryhGNAQ== 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 DBBPR04MB7788.eurprd04.prod.outlook.com (2603:10a6:10:1e4::15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.8048.27; Tue, 15 Oct 2024 22:08:21 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::9126:a61e:341d:4b06%4]) with mapi id 15.20.8069.016; Tue, 15 Oct 2024 22:08:21 +0000 From: Frank Li Date: Tue, 15 Oct 2024 18:07:19 -0400 Subject: [PATCH v3 6/6] tools: PCI: Add 'B' option for test doorbell Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20241015-ep-msi-v3-6-cedc89a16c1a@nxp.com> References: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> In-Reply-To: <20241015-ep-msi-v3-0-cedc89a16c1a@nxp.com> To: Manivannan Sadhasivam , =?utf-8?q?Krzysztof_Wilczy=C5=84ski?= , Kishon Vijay Abraham I , Bjorn Helgaas , Arnd Bergmann , Greg Kroah-Hartman Cc: linux-kernel@vger.kernel.org, linux-pci@vger.kernel.org, imx@lists.linux.dev, Niklas Cassel , dlemoal@kernel.org, maz@kernel.org, tglx@linutronix.de, jdmason@kudzu.us, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1729030073; l=1769; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=oLfeRG2JJa/EVak0ZqRbgfNgEQ6xhDK04ybgk4QBnh0=; b=ggtUqSjG0x79ltLdbRziV+1fQMtLGonP7mytNXC8zbANXa9FirOFw5AzTBQStHed8I7eXFU4x 3OLE48THL6dDKyaXkJxOOuEoKxuWLFFdAQrxKVHBU+4XNxPUlWck2K4 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0059.namprd13.prod.outlook.com (2603:10b6:a03:2c2::34) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DBBPR04MB7788:EE_ X-MS-Office365-Filtering-Correlation-Id: c910bd8f-30d0-47f0-522d-08dced65e172 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|7416014|376014|52116014|366016|1800799024|38350700014; X-Microsoft-Antispam-Message-Info: =?utf-8?B?TjR4RlFvWUxBSkx0bEZRSGhPU21JY01FamxJSXNuek9iRXpmSG5xOFdLRTY5?= =?utf-8?B?QldTdml6N2RiZVhwd21yWkt5RU9JM2V6TURjWHQrdWlUcFFwZmtoeEV4SllR?= =?utf-8?B?aWZnMXpqTVZGZjMxL25xTnVOZGVPMTlUVitNdEpacnNsQzg5cEVqOWpXNDVl?= =?utf-8?B?c3l2U3d6OWcvZVJhWUVMSEJoNVgvS3A2Qjc2NHB4dXlDRHFSRlo2am1iTGo0?= =?utf-8?B?MUVuYlF1UEZxN1FFV0tkL3dmZXl1WEJYUnhMQmtKM3UxZUZtMkc3VnU1NUxB?= =?utf-8?B?c0dqenFmbkg1aFBBcXlXTVFqdXpZbnFHOHJ3S21iUTdreEhrODRpUzczSDhs?= =?utf-8?B?cTI4czJ2anlEcEpSUU55YWtuSHBlTUhvWis2a2s0TSt0Y0tXa3pySHF1TS95?= =?utf-8?B?QTZFa0VOZ1JHV3oybHFvbmo1QzczMzVRM1VXRHJwOXFRbXJQQm1BbGpMamNl?= =?utf-8?B?M3VxdXNJWG5QRUwrMjc0VU1Oa1I4QWRtZG11bUhDT3hvcTF5bUUybVlOVGNN?= =?utf-8?B?WVMzRmYzWUhUMzJWdzFtZFMvb2xhSXNTd1pMSVhuUERQaXF3R3d5dWdtYUs2?= =?utf-8?B?WTdCcTB5N2loQnBMT3Vjc1AyQW5pOG9KdEpQR1M5czJPU0xCWkpEbXRNYXEy?= =?utf-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1Qlg5Uzd5NXhS?= =?utf-8?B?eTVqay9QOWJCNDRUNWVZOXNPbFBaVTdtYngrUjJPanIyUnZGVEcwbC9nc2xN?= =?utf-8?B?RU9iZkpKTnhWS3BTRTVZOW5rbXJtMGJKaGlFZWRVODR1dVl3Z2NQOHhNQ3M1?= =?utf-8?B?TkJoUk5DbjVVNlJWVzVpVU8ydmVjWGs2QUVIN3dFVWkvTHFGemF3S05qKzhp?= =?utf-8?B?SXlZaEJjYnJWSDJCdXQ5WCtqSXozVGFRc3RLa0ROZGNySmVkZWludXpZRStE?= =?utf-8?B?UzN1WGJwaU80elVUMUh1dz09?= 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)(7416014)(376014)(52116014)(366016)(1800799024)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?B?Z3B3bUwvcWxtQ0tYdFZLMHpvVGJ4b2JUV1lzT0o4U2UrVXIxVU5PYUR5SXds?= =?utf-8?B?bWZhaVpJTmpzOVFrYzdMT2J3WXVrekJ2cllJbUJuaVJxRmJ6U2N3SENMb1B3?= =?utf-8?B?NE4xNWxrTjEycG5MK2ZsQ3JqOU5IR29uTVY3bWw5N3dFL1MyU1V6Z3N6cmJo?= =?utf-8?B?anJscGVTT1cxNjFMWUl4R1dpOUdjVXNNemt6SUc1ekUxRFlTc01BZ29YNzln?= =?utf-8?B?U0ZhbTVkeTloUkZGZDlnYnJhOVlQYVJ5Q0pYVkw0bXpQL1JZV1pZOHc1NGt4?= =?utf-8?B?Vk4vbThZWlJSakhzM3FxcHNqVXhwQjBJcm80NVBZNC9DMXVDWDdjNk1Kb1FZ?= =?utf-8?B?MDVaYTJsNEIrN21DcjJLa0tlaHh4OURzOUJEb3ZrcW1zaTRY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 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 15 Oct 2024 22:08:21.0568 (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: AQhKV8F1fCrWYN3UEyX2/sm+pn1RkrqftuCWNcMDAkQqoIhbYRrQlocwHyFweNArQobKSIJNG/XEeAWtxYYAwA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7788 Add doorbell test support. Signed-off-by: Frank Li --- tools/pci/pcitest.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/tools/pci/pcitest.c b/tools/pci/pcitest.c index 470258009ddc2..bbe26ebbfd945 100644 --- a/tools/pci/pcitest.c +++ b/tools/pci/pcitest.c @@ -34,6 +34,7 @@ struct pci_test { bool copy; unsigned long size; bool use_dma; + bool doorbell; }; =20 static int run_test(struct pci_test *test) @@ -147,6 +148,15 @@ static int run_test(struct pci_test *test) fprintf(stdout, "%s\n", result[ret]); } =20 + if (test->doorbell) { + ret =3D ioctl(fd, PCITEST_DOORBELL, 0); + fprintf(stdout, "Ringing doorbell on the EP\t\t"); + if (ret < 0) + fprintf(stdout, "TEST FAILED\n"); + else + fprintf(stdout, "%s\n", result[ret]); + } + fflush(stdout); close(fd); return (ret < 0) ? ret : 1 - ret; /* return 0 if test succeeded */ @@ -172,7 +182,7 @@ int main(int argc, char **argv) /* set default endpoint device */ test->device =3D "/dev/pci-endpoint-test.0"; =20 - while ((c =3D getopt(argc, argv, "D:b:m:x:i:deIlhrwcs:")) !=3D EOF) + while ((c =3D getopt(argc, argv, "D:b:m:x:i:BdeIlhrwcs:")) !=3D EOF) switch (c) { case 'D': test->device =3D optarg; @@ -222,6 +232,9 @@ int main(int argc, char **argv) case 'd': test->use_dma =3D true; continue; + case 'B': + test->doorbell =3D true; + continue; case 'h': default: usage: @@ -241,6 +254,7 @@ int main(int argc, char **argv) "\t-w Write buffer test\n" "\t-c Copy buffer test\n" "\t-s Size of buffer {default: 100KB}\n" + "\t-B Doorbell test\n" "\t-h Print this help message\n", argv[0]); return -EINVAL; --=20 2.34.1