From patchwork Tue Mar 19 16:07:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13596843 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2050.outbound.protection.outlook.com [40.107.15.50]) (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 B82E65915E for ; Tue, 19 Mar 2024 16:07:25 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864447; cv=fail; b=ax2iGZakHv4xxZlXSfMMQgKD+0aMjPB5nqDkLGeBq1OMs0FVUkQ+Qp2Jg6bnbKR0ucpxkYZS+2nKlystBnBWkTcpRmuHc7LQefU34dDrgw3tuQ23DfeNCicfVvOstbcLvyah2fPjh2sWwLG2sYius/JG/02LkmZauxUmRb/m7OU= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864447; c=relaxed/simple; bh=2ryMSn+7oWVdWbaSqBP0ADpPZJzZOgdyFOobfKXU/2Y=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=mA5isdu4y64tOmM3PDmmT+RDZ5011wMWoxWnTYQXCmN28lrGma3reR4WnG280JT1MRsZ3ZruwOx0q2Wtl0760hbhilNR+qdMo3O5yl81Z0PNyiYr3IIz8FvL8NZ2ztQBJG6LyvEONV7jI48E3CgP4v5NSrol5PNsTGIh9q94EX0= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=cD3e55Uz; arc=fail smtp.client-ip=40.107.15.50 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="cD3e55Uz" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YCxFHexyDyJDYIJDnETaZ+7cSUGs3XbMbzWDARZx7lNbZpRuOzx1bva3ljditqWTrkpp9phE+54qoM6Zrq1POQz8t/xU2tDFQVvdi1QxrF1gEEgCIGKMTgYFIQDlGzfB8+TE1UWWtnNeRBb1yf1cAAIeVhBIUA6jDhVQcM4we/JifQ/hDtS7GBL7ef3nrlyN3ZOZKldJXW0J7vm1JztAZ1WGfx0XkW+WC7dHBJeZvoM5mSMDyVDjmf0ImWrc2yyZIJkYpS/SoYDoOZ6s6wgzWDQdyaPlr7G0Mv9yrDighD0w+A1oZt0zgqpxK3S3Z/tQNn1QG/vaa4xsK7myXIkGCA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=V/j9LMNuY8Cie7KYHeJpRADBHByenFKKikBZEbSU5P4=; b=l3yzsEFUfhORrfikGR1uVh45bAhKWjKyfz0dWKLveYon23TToDkfzvjs0FDsolvqC98zuwQIT/ejXTRrM0FxUpquSCOJ6HSMIS0ndKWWgnf5aLXyqMWC93DXjxFGrB2yu7xD917CPvo34zXeEEX0FDLL44x/tAXhI/qnNX5hsMVknbq8JJw7QTr/wluUVDVudZ7bl14j/QG+ZpUh4uloUD0AL5ZC319+0lTVscgPo7t6dfVI+z/VEJWuWNsdAaR4TCebfWtHRkvxz/j4gKyS8QrpK7AJ7nolsjwsEOZIasE6zAjzOCDxHFFmi5v64ehLpcT8D764ReZwcjq4qbh0ZA== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=V/j9LMNuY8Cie7KYHeJpRADBHByenFKKikBZEbSU5P4=; b=cD3e55UzlSGFdEexALe2tOZ837V66101ErCiL86WhUbIvOai40xqT3svAWpfQVuveB95btIVvsCDLivr+6Rvetr0gMnPn5ZrWg/oNLsntppnshvSSIQlNzEJaQfylIKkZJEM1ABhZwI+UHp5dRLqjNG1BmtLxbVZAFMoCn2tYIQ= 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 DBBPR04MB7772.eurprd04.prod.outlook.com (2603:10a6:10:1e3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 16:07:23 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6%3]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 16:07:23 +0000 From: Frank Li Date: Tue, 19 Mar 2024 12:07:11 -0400 Subject: [PATCH v5 1/5] PCI: Add INTx Mechanism Messages macros Message-Id: <20240319-pme_msg-v5-1-af9ffe57f432@nxp.com> References: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> In-Reply-To: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Yoshihiro Shimoda , Serge Semin X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1710864436; l=1631; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pajLHGu+pjoI9EU+H1bgcTzMS64qjiDozYPsqoeYdBU=; b=SE6AW7dYycxh9+7spGycHPI+NjYDtO3Sn/mBgKiZU2EXshOBv2pKH+djRyDQ8ce176dZzPdC4 NGdRbvrQ1D7BmU0TrugA+Trp6hX0DmRba4zpOea9b0ka5X3jLaHP1VU X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR07CA0104.namprd07.prod.outlook.com (2603:10b6:a03:12b::45) 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_|DBBPR04MB7772:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f5025d7-e973-4c97-af08-08dc482ea9d6 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 48J4fC1DiCZwn2FtI2yl4Y6VmWNYuQqB3OmSGJFskOQHQ6MoDmB47o4DKaVi9mRGfRPClt2SN65YYVZPZ3eTqemfUOO9KaZHjc98n9Qoo65ahNcrR18S15p6dPOutHDV/KHEZyCEl5T+nnF8K06i8EbdWjhQ4YSU4hs8csbplhHDVXqeP0QeBK5QyyqeErg1zMvyClGnGBMea3VwiflzPREkDupA7kflx5wjGivT6K324iHkI16d6LBNqPqmU9bX0rKH/D1fy4AW/WvvQXvNHfJc81NmMUfyOYVH44fX9/fqpiXBOHR9K8UOR7dMsBGCvwUIPOeYrFY1qWaQpWgMpSy+nCS+K/3MiW3d9oyCW3IAlsiP1hD9uzlTmB1ED+ThtQNgVfuIN3tTwQFplm0LuaghOWbRprWWJ1l3jAKUAMW/wzGB5C+Mj1/3nxlTOC6fr4sBYlXPQqG5BGhVl3ZmkekHFg+SLOnmDIAkNcq8CiNHnHCroeU1zXHLyrAaH4wH4u99Pzo7DUotVoTaDfrU3BffVmf8fsDVj2coyjaU+1g/5DsPzO0sCJkO1qqdBnRVkCpP+uLs0zOQpsxpsY72yqxLC3Ajyy4Hg8/816Fw8UQZDM/0oZz1zTdONe7OXPj4e9SpRg68CucQHBAk0/thGfwHTMgtEKL/wQcswcLV42ePaTA/ZvMo1SfOLd85n8JhwhH/DRCqVi6U6AMNXRk6JTKKGmGeCrR+dNmp5akds5s= 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:(13230031)(52116005)(366007)(1800799015)(7416005)(376005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?GLd4+5CWmW0vP7cgPJjvsp1xfxvl?= =?utf-8?q?ue0FHBSSM1Pcih8jo/hvRlQmzy1hHurGPc4QAM7QO/r0yRTTGynDKzY2KwBXqifuG?= =?utf-8?q?pIHdc1x2hW2d6F7+LKb25DoLxIuDgt7xf+9NlYBAI5+f722oDnkYYMja4w9XXAGNM?= =?utf-8?q?P1ad0BrJyrf3t56qm1MmddQnBPzo1342hP+4l0doSxgkbFAk9lA5+14R6fjAVYDRY?= =?utf-8?q?J4rya2A8LX6q2v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WPsDNF+u7ksqJlAFmyCfk8xhFMqcFjT2nlzWIkoY?= =?utf-8?q?33/ZdirWOcXWM8323JKCu1jUAA6AqdDaTR1Loj9aN8xSVNMcL9Ro/m0RwyzyhU8tF?= =?utf-8?q?Ybjt1XJt0Fwvv0j2Ksg78zwZLSi4yz1/1Z+jT4LL1y857bA1B4Lp0/82xCPhCmZHA?= =?utf-8?q?f939UsNnV20Gph98Tsxo68AbBuJbeZyZ7g4DxsnM2A7JLOHuCdK8B9FLWTpyH8qMD?= =?utf-8?q?tLgZV9NGvWSZEynmdnit7UOafwivaVp+dZEhikrjA5xkQNMzHOkRIIKyRetUtkJ12?= =?utf-8?q?jZ39HXwmRq+5tgZNBCaq/s/Tqvv9ZFGa+DvAuGI/ZW3JVFc3lwdsEO3geKfxu5tXe?= =?utf-8?q?kRuUXMIOM8A0nIoQ0zrccZk3biN84VSH9Xqvd1wPRGKA6aVe/RyYHnurx28WNewwu?= =?utf-8?q?fjUCaPxuOZxi?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f5025d7-e973-4c97-af08-08dc482ea9d6 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 16:07:23.5828 (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: VMKFD4SYzFF5fgSDtHyLDHyWFw0y+dE91w9Erxt4jDal7F3e1KjehY3Of1cJSyKzLRVo3QqY8ypFrr7rpDIksQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7772 From: Yoshihiro Shimoda Add "Message Routing" and "INTx Mechanism Messages" macros to enable a PCIe driver to send messages for INTx Interrupt Signaling. The "Message Routing" is in the section 2.2.8, and the "INTx Mechanism Messages" is in the section 2.2.8.1 on the PCI Express Base Specification, Rev 6.1. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Acked-by: Bjorn Helgaas Signed-off-by: Frank Li --- drivers/pci/pci.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index 2336a8d1edab2..ffd066c15f3bb 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -22,6 +22,24 @@ */ #define PCIE_PME_TO_L2_TIMEOUT_US 10000 +/* Message Routing (r[2:0]) See: PCIe r6.0, sec 2.2.8 */ +#define PCIE_MSG_TYPE_R_RC 0 +#define PCIE_MSG_TYPE_R_ADDR 1 +#define PCIE_MSG_TYPE_R_ID 2 +#define PCIE_MSG_TYPE_R_BC 3 +#define PCIE_MSG_TYPE_R_LOCAL 4 +#define PCIE_MSG_TYPE_R_GATHER 5 + +/* INTx Mechanism Messages See: PCIe r6.0, sec 2.2.8.1 */ +#define PCIE_MSG_CODE_ASSERT_INTA 0x20 +#define PCIE_MSG_CODE_ASSERT_INTB 0x21 +#define PCIE_MSG_CODE_ASSERT_INTC 0x22 +#define PCIE_MSG_CODE_ASSERT_INTD 0x23 +#define PCIE_MSG_CODE_DEASSERT_INTA 0x24 +#define PCIE_MSG_CODE_DEASSERT_INTB 0x25 +#define PCIE_MSG_CODE_DEASSERT_INTC 0x26 +#define PCIE_MSG_CODE_DEASSERT_INTD 0x27 + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; From patchwork Tue Mar 19 16:07:12 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13596844 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2050.outbound.protection.outlook.com [40.107.15.50]) (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 19EEC823A3 for ; Tue, 19 Mar 2024 16:07:29 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864452; cv=fail; b=RbrptHK37Z6cVwmf4DFsJSGOXCBaisJYUhQzBM3OHb6ZwY2LqNmRMm34HoJAS5vTTYXyAXq2GN+1h+4Fd/7WgojgaiyK0NFfQ9DlTlM5ppVvyv6lwpbcmlBBItHSQwGr7DuGUiV5qAFy8q4z8pfFhl+La9H17HcjQucj8EIDIzM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864452; c=relaxed/simple; bh=hzGYRhAZl9U+Uvuu6aIidx5j0fhBAx2klPXN/eaV8Q8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=mA2cIZEczgM6e23V2ovl67MYarNWW35GxuYiZo5mGQ/BayZgS8LmUpzmk5MBwA+tYTTvfXDlKF5TPizzI8YfhDg+Q2RG8GtOTt5zAD5lXVf1y2HuyFB79u+pBH86ss+1P+OgkajY8MtqDy2mJG3vB2pccvRDTkxsNbWXgc3Fy14= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=VoUymeaQ; arc=fail smtp.client-ip=40.107.15.50 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="VoUymeaQ" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mMzXAptE6/7MhPC8Tk5B+C0sCKGufXiZabSQp9FGr7HbJnoEIZ5vLT2IeHJwK/rUAHiLlxXsI13xdMPMEeBr6q1oU0abLDJ7QBbiq/vk63kzKui4wEQvBeVUtNmRkH7AIKZ9X1vH9tPqeEGkbHF8V6gP79qiOP0Fg4XW7Z5lKaoIgpOA0DXXa/hCihHVfXys+X5tDd/aTGAGfQs4zMX52XL3/CrCFeEjpXqCyNVCMkrLy7thMKRIFRDukShrjuHIiNB+VOMEysRB2ddZUZrt8Ngw+TFgs9o9JCLvS8OOgRLMU/05ydAiFVrHeLXo+mQl1USpkBo095pv+VftuyBYHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=0z4U3sEC3khiRNkm46MPnkPrIySIybGo6ofqvEZ86Bc=; b=iYbW7ydT9J3WSGEQMr4/5eSc7DUdV0ZUTewQblylbyxgBvpDONY47RfI8j/u/tQ6r+7kwGxiblrPjmCO7/4vLhQLHO2QiXy+qGkYUQSYqR4gNMxosAAo6UOh95g0B1a2wtAdo5X6GgicAMrwlOXL8Qk3NSGSfu8cutAX5rFLFf4vTgDrgNKd2VkVBv8A5/nKdpVlh3PdwALUx5Zz+X3RbTtXeN4fNl1da9wO8mZHKkXz/ronhT++b8FuNo3HzndRyLScqv5H5Cg9dMwaYPQfvTMtrIwmhTX0McZ5AOSz6CCfe8wqq+0i0IewUfYSKuskX2flRr60EQrH0h7IpmCUew== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=0z4U3sEC3khiRNkm46MPnkPrIySIybGo6ofqvEZ86Bc=; b=VoUymeaQT3zDPoiEplNBomuntoRlyaXoY9lQU05So8hOMZkNvEO61C/HNd3uEkN1U09yz+GW31Dhyy72jgRcB3wTtL+fRm5nVEMaPrsHcWHHUyEzvZPJlQI2+3iAKJxkfQg5h8zHGom9ZCOwck2KxlDhV6srjpMxdECQzeTJCkg= 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 DBBPR04MB7772.eurprd04.prod.outlook.com (2603:10a6:10:1e3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 16:07:27 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6%3]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 16:07:27 +0000 From: Frank Li Date: Tue, 19 Mar 2024 12:07:12 -0400 Subject: [PATCH v5 2/5] PCI: dwc: Consolidate args of dw_pcie_prog_outbound_atu() into a structure Message-Id: <20240319-pme_msg-v5-2-af9ffe57f432@nxp.com> References: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> In-Reply-To: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Yoshihiro Shimoda , Serge Semin X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1710864436; l=12761; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HU4ER7vz+HwzR2rHdE/BVWAKQXG5UmDhW10DZ8OHeTA=; b=EDn4raAqkbBLG5kX0Lfze5u5jRZioRdAWPq+OiTbLIrEIppBWG0AQTSqvcYGldRUGutP32YA0 5SZzauTLPhOBr6u1foDXJT1VXLVX++KgXHmGJJ+/u+hgF0ajNCvFc9Q X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR07CA0104.namprd07.prod.outlook.com (2603:10b6:a03:12b::45) 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_|DBBPR04MB7772:EE_ X-MS-Office365-Filtering-Correlation-Id: 8f489feb-20c3-479d-d96d-08dc482eac0a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ttfvV+rDnZkQXRX7LSMk7FJF3aJEhNB6aEGO755FFSV6WkfDujd+6/56lMidtzjLzMgdzPiMuWE5lG24Jq3CCnVNTnF+Q0sZ7u8M53FLA682zzyGAl/f1mOt0CWDgmD1MBpRoSfMHSYecBMdhAGlpvrPV0RfpRnA+hMNH31abe7pvwz9jQf6UMye78t0Jp6pxQiT7e4q4RbiqEwTU5+r8w2WyEWX+HsJT2WAPG1VDc8olLZgJuKXurimK/ZCXxf8CkIgJM3XJ2uRpbXiaI059DeIQfqYtNB0ToJCcC8yffRc8BCEK3c1fS2ZKKN3yQBnfOPw8HNizOihzsGujZyXin/4fAgDw/OKuhehBTgNPgvjYg15gwW+FhfkmRNng+w+7+FHEzjTJ/vDYAiG/33gz/o29DStUChjNd9NuJ2WlXxlSJZQ5eBi9auA9igHmAKFnShi5Jmdz7hSXhEz0e3vONUi0Tz2JahDdztqOBm8qNZiCQ3vxuKHifagxqmedgf5kqrsGdHnYnJjPxMXq6NO81wL2fFZxJk71uDPodOKGS3DK+nQc62GGnDVU6ROvHy2WuVzLzZcCUDSB8gbdNaiCV60DWmR0O2OHZb8ldYdq4xShQVatXokNEV4RIPb6nf56LOEm5gUiYmJ/KI4vDAgcXZckJbqo2N9xOMXAK//K2CSp/F7mJPTc2dE8NcN2EBcgsnxXUUApF7xxLiu1GQBQl+zdOh2eu16Xm+41Wp57Ck= 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:(13230031)(52116005)(366007)(1800799015)(7416005)(376005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?3oC8blcnIj1s52/+bWO+aY49muh7?= =?utf-8?q?9v7zO8U6CGu/q1rv7KuoedGd+uQnvjcN62Vnob4xFxBQTPsL7VZoHafC0+wovX6ce?= =?utf-8?q?8U/IiW93w3aTqSBPqhSPtzyUG9xilcnDTV5mvtP7L+ZpuU4WTDYtV88lwbiIVSd5U?= =?utf-8?q?F+8UZ6ysKxF0uYtawzJyxWDiIc9eSz6u/qiigQ7QvhVV/5hGDXaeW+tj/TqXOI/Eu?= =?utf-8?q?W5kpGTVeKNkIuVgN2f6gWVXlE9lsuo8rvwwdxo+3GGTg4Qb5KYAAh4rVBw3AiCpbZ?= =?utf-8?q?9ZDldeVb35k+4WfyzEy6oyEAgRXcI+893efuWsF1KP5zUlxNmO+zjCKtKei+ih9Ae?= =?utf-8?q?Ia1C4rNCfSf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?= =?utf-8?q?uH0+v5DOeu43SY+DSb7JQWOmOpN5uK6v3aQxJPCSmsSRUBCyU9edH6oxzuvFttdoe?= =?utf-8?q?Z0PWKfJbveaFGbifHmcceA9PNdptc37mzFxYEkjwUJ9BhlumJfivVU+yvElpDQIAA?= =?utf-8?q?zthc60v9Mq2J/tGV0au5RaSpoS4q0mVgXpU8tgiKDrKozYve4Lna95w6pAxSHCDo8?= =?utf-8?q?UVMF4+7EZ9ay5Q9xCFqgTelrm4aJiAYAJuKnXgqGk6PvQ5lNqbe5Uoc3hiwSvSqlb?= =?utf-8?q?r5tnNy24zgZRw6eYA9gjo9SuOB9PABnJAtM6KJX45Jzajnf3pNhXy+2I6hUQpg86h?= =?utf-8?q?fSqjuxKU91hk?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8f489feb-20c3-479d-d96d-08dc482eac0a X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 16:07:27.2607 (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: LVByM+84sK7SaSApct6Veh4f5zN1FTCBLQp+Y8jiU3Jj7d7O60aUdF6fuOuwAiFs+3QoT2YL5itXkEl6VFaDWA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7772 From: Yoshihiro Shimoda This is a preparation before adding the Msg-type outbound iATU mapping. The respective update will require two more arguments added to __dw_pcie_prog_outbound_atu(). That will make the already complicated function prototype even more hard to comprehend accepting _eight_ arguments. In order to prevent that and keep the code more-or-less readable all the outbound iATU-related arguments are moved to the new config-structure: struct dw_pcie_ob_atu_cfg pointer to which shall be passed to dw_pcie_prog_outbound_atu(). The structure is supposed to be locally defined and populated with the outbound iATU settings implied by the caller context. As a result of the denoted change there is no longer need in having the two distinctive methods for the Host and End-point outbound iATU setups since the corresponding code can directly call the dw_pcie_prog_outbound_atu() method with the config-structure populated. Thus dw_pcie_prog_ep_outbound_atu() is dropped. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pcie-designware-ep.c | 21 +++++---- drivers/pci/controller/dwc/pcie-designware-host.c | 52 ++++++++++++++++------- drivers/pci/controller/dwc/pcie-designware.c | 49 ++++++++------------- drivers/pci/controller/dwc/pcie-designware.h | 15 +++++-- 4 files changed, 77 insertions(+), 60 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 5befed2dc02b7..27956b2a73be7 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c @@ -159,9 +159,8 @@ static int dw_pcie_ep_inbound_atu(struct dw_pcie_ep *ep, u8 func_no, int type, return 0; } -static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, u8 func_no, - phys_addr_t phys_addr, - u64 pci_addr, size_t size) +static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, + struct dw_pcie_ob_atu_cfg *atu) { struct dw_pcie *pci = to_dw_pcie_from_ep(ep); u32 free_win; @@ -173,13 +172,13 @@ static int dw_pcie_ep_outbound_atu(struct dw_pcie_ep *ep, u8 func_no, return -EINVAL; } - ret = dw_pcie_prog_ep_outbound_atu(pci, func_no, free_win, PCIE_ATU_TYPE_MEM, - phys_addr, pci_addr, size); + atu->index = free_win; + ret = dw_pcie_prog_outbound_atu(pci, atu); if (ret) return ret; set_bit(free_win, ep->ob_window_map); - ep->outbound_addr[free_win] = phys_addr; + ep->outbound_addr[free_win] = atu->cpu_addr; return 0; } @@ -279,8 +278,14 @@ static int dw_pcie_ep_map_addr(struct pci_epc *epc, u8 func_no, u8 vfunc_no, int ret; struct dw_pcie_ep *ep = epc_get_drvdata(epc); struct dw_pcie *pci = to_dw_pcie_from_ep(ep); - - ret = dw_pcie_ep_outbound_atu(ep, func_no, addr, pci_addr, size); + struct dw_pcie_ob_atu_cfg atu = { 0 }; + + atu.func_no = func_no; + atu.type = PCIE_ATU_TYPE_MEM; + atu.cpu_addr = addr; + atu.pci_addr = pci_addr; + atu.size = size; + ret = dw_pcie_ep_outbound_atu(ep, &atu); if (ret) { dev_err(pci->dev, "Failed to enable address\n"); return ret; diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index d5fc31f8345f7..267687ab33cbc 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -549,6 +549,7 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus, { struct dw_pcie_rp *pp = bus->sysdata; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; int type, ret; u32 busdev; @@ -571,8 +572,12 @@ static void __iomem *dw_pcie_other_conf_map_bus(struct pci_bus *bus, else type = PCIE_ATU_TYPE_CFG1; - ret = dw_pcie_prog_outbound_atu(pci, 0, type, pp->cfg0_base, busdev, - pp->cfg0_size); + atu.type = type; + atu.cpu_addr = pp->cfg0_base; + atu.pci_addr = busdev; + atu.size = pp->cfg0_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) return NULL; @@ -584,6 +589,7 @@ static int dw_pcie_rd_other_conf(struct pci_bus *bus, unsigned int devfn, { struct dw_pcie_rp *pp = bus->sysdata; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; int ret; ret = pci_generic_config_read(bus, devfn, where, size, val); @@ -591,9 +597,12 @@ static int dw_pcie_rd_other_conf(struct pci_bus *bus, unsigned int devfn, return ret; if (pp->cfg0_io_shared) { - ret = dw_pcie_prog_outbound_atu(pci, 0, PCIE_ATU_TYPE_IO, - pp->io_base, pp->io_bus_addr, - pp->io_size); + atu.type = PCIE_ATU_TYPE_IO; + atu.cpu_addr = pp->io_base; + atu.pci_addr = pp->io_bus_addr; + atu.size = pp->io_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) return PCIBIOS_SET_FAILED; } @@ -606,6 +615,7 @@ static int dw_pcie_wr_other_conf(struct pci_bus *bus, unsigned int devfn, { struct dw_pcie_rp *pp = bus->sysdata; struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; int ret; ret = pci_generic_config_write(bus, devfn, where, size, val); @@ -613,9 +623,12 @@ static int dw_pcie_wr_other_conf(struct pci_bus *bus, unsigned int devfn, return ret; if (pp->cfg0_io_shared) { - ret = dw_pcie_prog_outbound_atu(pci, 0, PCIE_ATU_TYPE_IO, - pp->io_base, pp->io_bus_addr, - pp->io_size); + atu.type = PCIE_ATU_TYPE_IO; + atu.cpu_addr = pp->io_base; + atu.pci_addr = pp->io_bus_addr; + atu.size = pp->io_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) return PCIBIOS_SET_FAILED; } @@ -650,6 +663,7 @@ static struct pci_ops dw_pcie_ops = { static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct dw_pcie_ob_atu_cfg atu = { 0 }; struct resource_entry *entry; int i, ret; @@ -677,10 +691,13 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) if (pci->num_ob_windows <= ++i) break; - ret = dw_pcie_prog_outbound_atu(pci, i, PCIE_ATU_TYPE_MEM, - entry->res->start, - entry->res->start - entry->offset, - resource_size(entry->res)); + atu.index = i; + atu.type = PCIE_ATU_TYPE_MEM; + atu.cpu_addr = entry->res->start; + atu.pci_addr = entry->res->start - entry->offset; + atu.size = resource_size(entry->res); + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) { dev_err(pci->dev, "Failed to set MEM range %pr\n", entry->res); @@ -690,10 +707,13 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) if (pp->io_size) { if (pci->num_ob_windows > ++i) { - ret = dw_pcie_prog_outbound_atu(pci, i, PCIE_ATU_TYPE_IO, - pp->io_base, - pp->io_bus_addr, - pp->io_size); + atu.index = i; + atu.type = PCIE_ATU_TYPE_IO; + atu.cpu_addr = pp->io_base; + atu.pci_addr = pp->io_bus_addr; + atu.size = pp->io_size; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) { dev_err(pci->dev, "Failed to set IO range %pr\n", entry->res); diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index 250cf7f40b858..df2575ec5f44c 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -465,56 +465,56 @@ static inline u32 dw_pcie_enable_ecrc(u32 val) return val | PCIE_ATU_TD; } -static int __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, - int index, int type, u64 cpu_addr, - u64 pci_addr, u64 size) +int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, + const struct dw_pcie_ob_atu_cfg *atu) { + u64 cpu_addr = atu->cpu_addr; u32 retries, val; u64 limit_addr; if (pci->ops && pci->ops->cpu_addr_fixup) cpu_addr = pci->ops->cpu_addr_fixup(pci, cpu_addr); - limit_addr = cpu_addr + size - 1; + limit_addr = cpu_addr + atu->size - 1; if ((limit_addr & ~pci->region_limit) != (cpu_addr & ~pci->region_limit) || !IS_ALIGNED(cpu_addr, pci->region_align) || - !IS_ALIGNED(pci_addr, pci->region_align) || !size) { + !IS_ALIGNED(atu->pci_addr, pci->region_align) || !atu->size) { return -EINVAL; } - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_LOWER_BASE, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_LOWER_BASE, lower_32_bits(cpu_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_UPPER_BASE, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_BASE, upper_32_bits(cpu_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_LIMIT, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_LIMIT, lower_32_bits(limit_addr)); if (dw_pcie_ver_is_ge(pci, 460A)) - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_UPPER_LIMIT, + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_LIMIT, upper_32_bits(limit_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_LOWER_TARGET, - lower_32_bits(pci_addr)); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_UPPER_TARGET, - upper_32_bits(pci_addr)); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_LOWER_TARGET, + lower_32_bits(atu->pci_addr)); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_TARGET, + upper_32_bits(atu->pci_addr)); - val = type | PCIE_ATU_FUNC_NUM(func_no); + val = atu->type | PCIE_ATU_FUNC_NUM(atu->func_no); if (upper_32_bits(limit_addr) > upper_32_bits(cpu_addr) && dw_pcie_ver_is_ge(pci, 460A)) val |= PCIE_ATU_INCREASE_REGION_SIZE; if (dw_pcie_ver_is(pci, 490A)) val = dw_pcie_enable_ecrc(val); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_REGION_CTRL1, val); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL1, val); - dw_pcie_writel_atu_ob(pci, index, PCIE_ATU_REGION_CTRL2, PCIE_ATU_ENABLE); + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2, PCIE_ATU_ENABLE); /* * Make sure ATU enable takes effect before any subsequent config * and I/O accesses. */ for (retries = 0; retries < LINK_WAIT_MAX_IATU_RETRIES; retries++) { - val = dw_pcie_readl_atu_ob(pci, index, PCIE_ATU_REGION_CTRL2); + val = dw_pcie_readl_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2); if (val & PCIE_ATU_ENABLE) return 0; @@ -526,21 +526,6 @@ static int __dw_pcie_prog_outbound_atu(struct dw_pcie *pci, u8 func_no, return -ETIMEDOUT; } -int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, - u64 cpu_addr, u64 pci_addr, u64 size) -{ - return __dw_pcie_prog_outbound_atu(pci, 0, index, type, - cpu_addr, pci_addr, size); -} - -int dw_pcie_prog_ep_outbound_atu(struct dw_pcie *pci, u8 func_no, int index, - int type, u64 cpu_addr, u64 pci_addr, - u64 size) -{ - return __dw_pcie_prog_outbound_atu(pci, func_no, index, type, - cpu_addr, pci_addr, size); -} - static inline u32 dw_pcie_readl_atu_ib(struct dw_pcie *pci, u32 index, u32 reg) { return dw_pcie_readl_atu(pci, PCIE_ATU_REGION_DIR_IB, index, reg); diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 26dae48374627..d21db82e586d5 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -299,6 +299,15 @@ enum dw_pcie_ltssm { DW_PCIE_LTSSM_UNKNOWN = 0xFFFFFFFF, }; +struct dw_pcie_ob_atu_cfg { + int index; + int type; + u8 func_no; + u64 cpu_addr; + u64 pci_addr; + u64 size; +}; + struct dw_pcie_host_ops { int (*init)(struct dw_pcie_rp *pp); void (*deinit)(struct dw_pcie_rp *pp); @@ -434,10 +443,8 @@ void dw_pcie_write_dbi2(struct dw_pcie *pci, u32 reg, size_t size, u32 val); int dw_pcie_link_up(struct dw_pcie *pci); void dw_pcie_upconfig_setup(struct dw_pcie *pci); int dw_pcie_wait_for_link(struct dw_pcie *pci); -int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, int index, int type, - u64 cpu_addr, u64 pci_addr, u64 size); -int dw_pcie_prog_ep_outbound_atu(struct dw_pcie *pci, u8 func_no, int index, - int type, u64 cpu_addr, u64 pci_addr, u64 size); +int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, + const struct dw_pcie_ob_atu_cfg *atu); int dw_pcie_prog_inbound_atu(struct dw_pcie *pci, int index, int type, u64 cpu_addr, u64 pci_addr, u64 size); int dw_pcie_prog_ep_inbound_atu(struct dw_pcie *pci, u8 func_no, int index, From patchwork Tue Mar 19 16:07:13 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13596845 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2050.outbound.protection.outlook.com [40.107.15.50]) (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 898CD823A3 for ; Tue, 19 Mar 2024 16:07:32 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.50 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864454; cv=fail; b=nMIeBSfXntVO27qJMxLkjB+OarJgRvw6P9nOKiaXE06MP24uuAyA2xxOaS3z27nIEaxw6UUEQ12MFtiaQ8gkQTJerYqTWlQemk00kGzKK+fE/0LeA69R9/b+w9Pst2ODCuNFNDfrkjV45o3rxgyt1sZb5mlmcz+3Mxzxq0h4J5Y= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864454; c=relaxed/simple; bh=iaMVhIlaxnDKrjo/B86UwmBA4lUHgRwjSU/hHDluay0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=rKUg0G9d3QAWXJLU4iyZTFr4iq51eXXIy2RrHNfuXLB9H/jW3Zd0bN/sxzg2qBuRAdwPHOvLunnjNDB12xJIh48y07Blh7giMNXog7rduFNpkpVPlmyH+QkXefxRTqZPVjVLoyTMwPCa6+NmcQKy6z/b11kyC1XluJVUTq5R9Hc= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=DDMHYYRW; arc=fail smtp.client-ip=40.107.15.50 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="DDMHYYRW" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=j3bTlkRXHTcbxVHiLdBbUQFiMlWQfVcTUBbAdh0l6IUdhQU+AY3HDaH9+mRDlcYKQKelubkSnkRFGlwH30ZYEEiq/IX+SwzWK4tbYXuznj4cl0jCPV1Fwxm0kVpZuXVYTOV24UPB3/n9FYPlumkeE9FA4WHO4VBEouFVpTi9hP9Q3LegjHfsuwG7x0eY+/Fcl/3kZ0cFkRRx+2tcLmqpf3G6+aus6NEv1xR67E/mO1Y+hxKvgko0TFC0w2BXuFpqAMg39wRz35QEcTeVpiXm9ZYcjjCAI+yglfA3AOsmzhNmAXD6QxiXlOR0t4Kjw2aAxRr5UstQ6ZiMACXWVNMfrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=wqraZNkbMXJ8bdVBUWBtPeGCWP+ilAu0pVj9SSD+e7E=; b=iaetgCAYyxwcO3suo/+fKR4KCiAWKxPqkFUKsBbOc0GAwSGqP9uyg6ysQ6+yaVVfL90i7Ci1PQ0062B2acF4bwQ4D3qh9eSaknAO/3bS1koF8RQAsotU8di9ziNeq1+SmZAKRa59xOdO5PRI2oGIHl7IwWShKnlfGWBNX4Uxec4Y3mXg3RnQhxLwIMgZlEZglkGJHf4L1wrIXa16mbr2PfzuapnLjTooGDBp3nNqW6d62K9nG7d8KYdJuIrcYh0RiXlUEEuUBm/KrEoJIMeG+wX8FlhE3Gl7A/f9o7ShuMeTsu8BHgx+saOJx3BL5TZnzHiWah2ZUZWCGYQguVrYPg== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=wqraZNkbMXJ8bdVBUWBtPeGCWP+ilAu0pVj9SSD+e7E=; b=DDMHYYRWzSsF5x/lG8ZPj5ZgZx3E4m0rF8vikVXVUQWZy0mzewfHE8/DCGOqi1AENhM5+3eCuEcc1DqiTTmNpi2e6DHBJTzb8PwWwsK0Ra+ZUNiriNx4Hw0k7DbfnyCrfIp4jko86EwBMN+uuCqmXR9IlgoxyzkpwP+cfYSWXBg= 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 DBBPR04MB7772.eurprd04.prod.outlook.com (2603:10a6:10:1e3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 16:07:31 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6%3]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 16:07:30 +0000 From: Frank Li Date: Tue, 19 Mar 2024 12:07:13 -0400 Subject: [PATCH v5 3/5] PCI: dwc: Add outbound MSG TLPs support Message-Id: <20240319-pme_msg-v5-3-af9ffe57f432@nxp.com> References: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> In-Reply-To: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li , Yoshihiro Shimoda , Serge Semin X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1710864436; l=2940; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Vx141tscxeq3VO/J2v1vu73YFB2QjcNfIuChtPapKMY=; b=j2SQMTUWx8vap6et+1knqpQcLJ8Y0lAC0MCg7FCGJEcmjp5roEi6wyicb6+2Hi5OT3LMqG6MS AtuMrkSgWP1BDCeOzsTXMBvt3Nf98Jzrlk83IMxF18QNDTNVGAmdgMS X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR07CA0104.namprd07.prod.outlook.com (2603:10b6:a03:12b::45) 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_|DBBPR04MB7772:EE_ X-MS-Office365-Filtering-Correlation-Id: 8465c673-5a75-43ce-9f7b-08dc482eae38 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3+ddwlEpbUaQ3T3+gpjlikVyrjA8MdXwYBPXwqWxXY4Bsw0VQWPs6CryBNkLVaz/a95iuNquCZvZsQXgny4sAli/Fj4ex+my7+SrmQ+EHl5cQF6kiSBCr0RdNON2P2eVtwwPjrCfGgXVGtHI5IcjxWrJ/zmXhTLsTEUIJDv33TBpRNOvfIpvsluZ/99DEeL/xgveOLMScwsjlL4h+Swn8QxSCuIwH7muhsA3G34U8Ol4gWAGF31WM68sKAvNVXp/yYuHYp4FOPI2Ug0DyVJKv0nnrPIfVgGD5in8KOzPYfLlTLxE0FLxCVMX98944Mu5STojBoAUEOqY6RvX4VtkVUnKV2KApTgux00XjTZiPSCFb9Y/VruhAa40X4HSgs2lQbiDKjrS2BuB2lohCAniZoRhNWUyOPGW02ZSdpWZtKNQYozvLhmkvnFUBdsfgShf3kbqwvJZfZ3oqDTOMbc+kez3smg+eVK0IEuJKYS33CZO1mlmGe8sMrf7Su4HEtd8wUWDogtaguoOY/pOzRiEtIpPC3SZD6EJ9t82M8s7iVolWSqilDZnGtJWjDh8WV1JdB0raUFPQHm1vGAq6gzpG2fapSyYBiU3W2ZTAcXY0ozAdtNwT+T8yX94hHqdxL0DOUCyUeVOSRsObzIlKsGu0n4DS1lmgQWMCa3j6SU64PAR4+uLJYR+nf+AovzNb6fnLl6AsXpxjJqDVF+k9TC9YBqoogL9WJl1VKtDVQpE95I= 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:(13230031)(52116005)(366007)(1800799015)(7416005)(376005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-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WiHEA54mUo9NOBfdCuhD5pUlhGwP6j6Hju6acF3tuqmHxl3/5ysfs9Tv4P7hi5Xe?= =?utf-8?q?QytYOezwcxaLDYnlbIKUBxJTSVX61v8n3qvrTyVNftAzvc77HP4JeAe8zPjhVaEo3?= =?utf-8?q?3RoCIR+1+bhpSKz6F6sJ1rXKoaLx2JKt2arCFvdiR7zbKrWa7ORNcCJBWd+y887Z3?= =?utf-8?q?/Vn/bVCGx+tyMX0NaW4imEwFNuQtvOvBIjDDmXxLnufuJR7hqjo/ReqQDYlciXOWE?= =?utf-8?q?NrrMk6f7MKcGOVexcepJubMvOmk2NU5Xx8V6xqzM1EcalObCGR53Pa4oTKjIAU/Fo?= =?utf-8?q?grrgpF8vpYlSysm7W3f6IB902cXm/5vdYJuPU2u801grFkl9b8djDUuFCsdCQWHus?= =?utf-8?q?yxsmuCa+QweSWLApWeWx7jugiH5tupBXTEmrEXG6zkaA4AGH87waAEKFK72WXnG7a?= =?utf-8?q?DW5nmAlVU+BQkRE7gecuOFk8in/eLNkw1nIqQZqwouzOYLg9vMOnE1dyQAig6xE6n?= =?utf-8?q?nnd+ciPnLzzx3ZiqU7STknyxZpf0V0my/9L6xudId+yjWkgPsQ21UbcqdhXC/7Ukr?= =?utf-8?q?S7yH2PdiHUqUq8lsc0ikHmaLDfdcRKJoqc+wMLc4gO3ZT9BtdhP8qFMYnP5xygMsl?= =?utf-8?q?ZnDLThsBumCTQ3ou/r4q9e+xzNlIQqrh9Xjc9+4yAwbDXXhcLDYPYZYiuj0sMa6yl?= =?utf-8?q?ACr2iXDjoZxK?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8465c673-5a75-43ce-9f7b-08dc482eae38 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 16:07:30.9328 (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: QfiJWMtI13vPRDWkicPnaX7X0/Ezge53fKv9ncmr/05+9ADw3TsHe6Y4oSzbcb4njjcCofYEaPUNkcE7nUOMLQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7772 From: Yoshihiro Shimoda Add "code" and "routing" into struct dw_pcie_ob_atu_cfg for triggering INTx IRQs by iATU in the PCIe endpoint mode in near the future. PCIE_ATU_INHIBIT_PAYLOAD is set to issue TLP type of Msg instead of MsgD. So, this implementation supports the data-less messages only for now. Signed-off-by: Yoshihiro Shimoda Reviewed-by: Serge Semin Reviewed-by: Manivannan Sadhasivam Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pcie-designware.c | 9 +++++++-- drivers/pci/controller/dwc/pcie-designware.h | 4 ++++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware.c b/drivers/pci/controller/dwc/pcie-designware.c index df2575ec5f44c..ba909fade9db1 100644 --- a/drivers/pci/controller/dwc/pcie-designware.c +++ b/drivers/pci/controller/dwc/pcie-designware.c @@ -499,7 +499,7 @@ int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_UPPER_TARGET, upper_32_bits(atu->pci_addr)); - val = atu->type | PCIE_ATU_FUNC_NUM(atu->func_no); + val = atu->type | atu->routing | PCIE_ATU_FUNC_NUM(atu->func_no); if (upper_32_bits(limit_addr) > upper_32_bits(cpu_addr) && dw_pcie_ver_is_ge(pci, 460A)) val |= PCIE_ATU_INCREASE_REGION_SIZE; @@ -507,7 +507,12 @@ int dw_pcie_prog_outbound_atu(struct dw_pcie *pci, val = dw_pcie_enable_ecrc(val); dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL1, val); - dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2, PCIE_ATU_ENABLE); + val = PCIE_ATU_ENABLE; + if (atu->type == PCIE_ATU_TYPE_MSG) { + /* The data-less messages only for now */ + val |= PCIE_ATU_INHIBIT_PAYLOAD | atu->code; + } + dw_pcie_writel_atu_ob(pci, atu->index, PCIE_ATU_REGION_CTRL2, val); /* * Make sure ATU enable takes effect before any subsequent config diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index d21db82e586d5..703b50bc5e0f1 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -148,11 +148,13 @@ #define PCIE_ATU_TYPE_IO 0x2 #define PCIE_ATU_TYPE_CFG0 0x4 #define PCIE_ATU_TYPE_CFG1 0x5 +#define PCIE_ATU_TYPE_MSG 0x10 #define PCIE_ATU_TD BIT(8) #define PCIE_ATU_FUNC_NUM(pf) ((pf) << 20) #define PCIE_ATU_REGION_CTRL2 0x004 #define PCIE_ATU_ENABLE BIT(31) #define PCIE_ATU_BAR_MODE_ENABLE BIT(30) +#define PCIE_ATU_INHIBIT_PAYLOAD BIT(22) #define PCIE_ATU_FUNC_NUM_MATCH_EN BIT(19) #define PCIE_ATU_LOWER_BASE 0x008 #define PCIE_ATU_UPPER_BASE 0x00C @@ -303,6 +305,8 @@ struct dw_pcie_ob_atu_cfg { int index; int type; u8 func_no; + u8 code; + u8 routing; u64 cpu_addr; u64 pci_addr; u64 size; From patchwork Tue Mar 19 16:07:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13596846 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2073.outbound.protection.outlook.com [40.107.15.73]) (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 E48828287C for ; Tue, 19 Mar 2024 16:07:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864458; cv=fail; b=UxAYro85OAEOPBhpQp9hBc4/IYtfsGj/cwJO3tH7HSuX1MpWC+DFK+aMoDLhrQBBiK6bcYmCujSpbzAAshlolFxhx4hkHb7BMbINRiZeO/CRJfQQmwn7PEpf8RAKT4Euq5XXWg5K7rjFi6y+BNBDDyILodLv0vGEqN27Bw8XkSA= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864458; c=relaxed/simple; bh=ze2L3Nl6ITdmvSqJ46+wd69F0Sc18FLzWocNjgTx/8s=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=PNRH+lzAxWkSieamFsQxs2WpQcbPfRuqMy1fg10ApVKC12WFKIpa7Vp9kMcRd0/6XqdZtyABRu5w5Fr5ahbo5rZdNhKTkM5M0mQEZt9DYDR+ddQBGY1j684KBR2NSVSWh2u3Z5dfhVqPVc88RfsTwtIVRconJHcteKEJ8qxxrOw= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=Gl9qZfE5; arc=fail smtp.client-ip=40.107.15.73 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="Gl9qZfE5" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hm5rFdsfH9kY9QH3zcq4c4FqE8GCAUDhX3S4mKjQdgDe3YDBVsWWx9hzTgizKW6bqCpUuySPHGIZNddk2D2J0A4hAfbEz3X+MpsjSSL/8/6fSui+IfDrH/WAsh/qtB0LEKbjR/fj7oUqTbi7ZysoRMd45c/NtSAbEy/YPEIdtNWSZwoaCBBz0m2YZA6H8He8zIja0LYv1+xOHF+5TbNfVgKBQERYh1Si7Jzz+mNZEt+sZI8h08pOur79yIxYVOMseYDKx5HPUoVFircrWhzXsbqB8crPd4SWsWeYIg4ZKL3wvKrqfMDwAAkQmpa8I+u2RlHIVkbwKGjtcSWkePXHxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=lCa+JiPEcnah1R3m5WeFYRmyUijTCb6SN5/1c3JFNUU=; b=hGG/LCqOa2F1rSiAevC0l0BOLGJ83SIIMoWiKedpioZSYFmvLPzsR9DlEgSXy6XTH9TPCY3Lh6lAy8EP0OlPXT09d11D0S+hwDN9+HrJ8u47CCOmvBgvjNcfHW1PXKaBKQUw/ZIU8RZ0wVDTLqhWOLJESLAuHBL2Q6RwmzJ1LGxg+xlQkR+/3dkx5OY1MYMfB7Eu/J2ibsvMivhntFCK/2XbS+qjbnfR8hLCdB/bwOJXDDclSyuP3QmQHbr0nciGIaEmLv4Hi7AJzpbA0BHT6JHlRSUUnOHEALKh7QKW4pD/2mz2L5gKh2E8GxWYlh6v/QDLyxdlnaQp3BBJp7ELdw== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=lCa+JiPEcnah1R3m5WeFYRmyUijTCb6SN5/1c3JFNUU=; b=Gl9qZfE5Nxt1jX0tdS4OQcNS97quz5sYL9OBU7I/3N1W3vqVDJx6W3N4gwM4SI2KudXxVUY4S05e4R20GZd1gcnTRElmxGmi1SYY3PHehHLmUXrenRwP5GWSkspQ+BEkPXQ8gyFhhhOELVjF284rStPFlOKpgXc4LSiAkX4o4Is= 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 DBBPR04MB7772.eurprd04.prod.outlook.com (2603:10a6:10:1e3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 16:07:34 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6%3]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 16:07:34 +0000 From: Frank Li Date: Tue, 19 Mar 2024 12:07:14 -0400 Subject: [PATCH v5 4/5] PCI: Add PCIE_MSG_CODE_PME_TURN_OFF message macro Message-Id: <20240319-pme_msg-v5-4-af9ffe57f432@nxp.com> References: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> In-Reply-To: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1710864436; l=608; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ze2L3Nl6ITdmvSqJ46+wd69F0Sc18FLzWocNjgTx/8s=; b=v0Oe1wNs9IYAxjmNZF7xccBvtMkRKbU5zDnc/GJcW6Fq9xxLR8OeRUZgi7GQzhtjCAp7KgTop uHFmZ2AKGvvCz0bZVb/06FuEq7fHbTCiK8bPpZkcAR/bYg37eyr3vU5 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR07CA0104.namprd07.prod.outlook.com (2603:10b6:a03:12b::45) 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_|DBBPR04MB7772:EE_ X-MS-Office365-Filtering-Correlation-Id: 22c077e8-39ba-4f2b-cf01-08dc482eb035 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: gv1LK2SdC5m2EITTpg573sN86WlQaLsoFxJCbRw6BIVWr7a3oVcY3ivlbF0+C17Z1gFnawZ2ZvWE6w9Tc3pTlpuQILeYnOiy27IVR4wDyxIiX1ONE273OxDb99OQOJhYTOHRPIXkRecb2N2dUcHYMRu6G95IKwRmQKop6jXbYhaXzmhxFKiNYvo9HITDthm7B9QFGg0Clh1UMr+jddJmiEMooF0bElqiZ8lfR8sPqp8fG8J25ww1N6RbI9D4VlSyDx8yH/scZfB5rhiSwbbq5aiA8Ay2MhuTH7vJAyg95YdjLaqeVUcb/r1DYKLcUZygO5TmKRUKhMWF124PTwhbbKuWRhFahdii5ryNUsrXe0/UyGfPcYty2wIAZLCyNjOmkiea2OXiFxgIqYj8MLOwMI4P99Nihed7g6aulnqSZ9ZucbDsIbABnLL1ermJF8BvVry/EHBKMuTWj9G+dEXVMsusPTWKIfWhjn1y5S0lqzUzMTWiyJ/45ZCeGbEUkbe8/JmP+CAKAvn1stYwQ5+pku6ET+jlFM+eVlF4y4rtRl/ueQ9VSnwVPk7d7vQp+8x3o1b+FsixdE34L6kKaBaXoMv+ooEDLVy0RptlG1RvHanJvv58BNEpxVi0zQIE8+MDfi3hbovYyVzWySggV+hREg0Hm5n68r21HirHTxRzicwQPgP9UzXk6aGJNrXxJIu9W7e+F7FfoODoGSK/kyVbA/N9YS7T7YZMk/EXAWJJTrE= 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:(13230031)(52116005)(366007)(1800799015)(7416005)(376005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?PvUMdEzkE3sNv96tdgsN2Quc8+Iq?= =?utf-8?q?TMswgawPQLTA/EaHUYJuoMn/5Est3aoDrLHEnBiRZjXXX8t4Seq/pNVPV9Lurr8Tf?= =?utf-8?q?k7nfSifiX54f1xuaB06rn/tpQfO642nAFkOYmg8yEv0BlvGgOHVQ+e/WTUUpZHAEz?= =?utf-8?q?S0yTUew1djg4gPzP7y2HHGFgsJqNbnHSbK0T71HVG7YXNFU/YsX/lyzqsaSSWOX19?= =?utf-8?q?rMKIRjcDOlX0AIcqaIYfAwV0Xkdu9UpWRDjx20B7PV3kTodRkbp0nK8Y6wOZF+OSj?= =?utf-8?q?GMKt+/eUjDvCZctRld+9HNkf9dSWktdSx76xaxmlNURfHKYl+taWvDhwKJlhAX8sr?= =?utf-8?q?iSZjIflDO1NMK5F66ScfOyHodIvMPfyq4CE7kEPb7tnczc6ZSIi2DgufhHYiVnmKP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/M?= =?utf-8?q?CpRIpYzPTbkcEeZNU3vKGpNO4ame2AyxKX7tonQ+YUEdn2SQUm+q6Jg0PlyKslNST?= =?utf-8?q?Se1MHHIZo/Z5+dbeKV1fQzvWmFXr6unxMoGLaoT1EUQcN4Q+8QNiLr0FnzxVk5mR/?= =?utf-8?q?HjuutB5wP904XjH0cLcPIRZFWiMJwjk00TxEVF41NhCxEfWLcerYSTDsWoROK3QzB?= =?utf-8?q?qdVlGu2+fzO+V6HbTrLfUXbLnb0y1wADA4l2MYRVy5W9Y9RMP+9820OoAw9+MvnW8?= =?utf-8?q?C0HAiZnocsIP?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 22c077e8-39ba-4f2b-cf01-08dc482eb035 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 16:07:34.2598 (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: ricgGTH3YVYezQJP8ah2pob4J3SmbsmHUa2r453yebqPOzDnnLQVxzZpTb7nv5vLV2kZqxwXD0AOklX5JZ8KuA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7772 Add PCIE_MSG_CODE_PME_TURN_OFF macros to enable a PCIe host driver to send PME_Turn_Off messages. Signed-off-by: Frank Li --- drivers/pci/pci.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/pci/pci.h b/drivers/pci/pci.h index ffd066c15f3bb..989681a0d6057 100644 --- a/drivers/pci/pci.h +++ b/drivers/pci/pci.h @@ -40,6 +40,8 @@ #define PCIE_MSG_CODE_DEASSERT_INTC 0x26 #define PCIE_MSG_CODE_DEASSERT_INTD 0x27 +#define PCIE_MSG_CODE_PME_TURN_OFF 0x19 + extern const unsigned char pcie_link_speed[]; extern bool pci_early_dump; From patchwork Tue Mar 19 16:07:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13596847 Received: from EUR01-DB5-obe.outbound.protection.outlook.com (mail-db5eur01on2073.outbound.protection.outlook.com [40.107.15.73]) (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 DEA168287C for ; Tue, 19 Mar 2024 16:07:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.15.73 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864460; cv=fail; b=SdHfbSt0HrVn0JvEtBG8D60ifJL9VyrOSACiH48hCqQMz8GL8rC/DSjknbX0BU7zT+oWO91AbCenn3kt2gWpUy9ZAfGXE6S9yERYDg8sXa4dvS9yk+Kwbjw+fjZgdsfim1BvLb4+RxaaSaJWyanp/qPxY4ZbLU6WR40r/iJR2Vo= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710864460; c=relaxed/simple; bh=ubK5KYt7VQOKIPtdMUTb6BLNf6RphFRaoUgDr6itmew=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=o+czGibTaWNXeCcCV4WHMKHXmnJ7J7iAtNeiIU+1Jw/FUfuDKEZSE8mvcMXnqiWQ2NWrEsCLGAwH0g4If+iUbXj3LrISaYl2I1q8QxdDwgn5+hq0F2BflwT0R4+TsRbfPd2L95CLbTFo0Bjx7XTSMUF8IHvq13hY0ODLquUJHWs= 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b=SGEW6zyE; arc=fail smtp.client-ip=40.107.15.73 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 (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="SGEW6zyE" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LVClrZGvgGHlPex2ao5BI/4Lbvrhe0Aj/nmOMiShL7FQ0xl9nP0IRUs+H1i0tyOleW8hlMKkvP1I+3jH+rdimGDWl1Rk1Uk262BpSDYYCCr/ih2ipk5W58Z7kyk9+Mw5BFvE4sORDQ++GuPmcundMrphW2rYxk2+/p/S9zSs151Wx971K9Y6R37fM0W9Ew2sIKm+caWeX7gOBsd1K48Lryn7FTODjbAw+/mLaHGuxGYii2o2sygtGyEQ7gkEwd0zjtKm+CzpeWLbusJUJdkLD5+TydT+r1FKbG6m3JrHiWxINl5B4RpoBG3cOVi89ZPjfedDMpFbqKBPBCpwU4Zxkw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; 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=qIrCamd/WiRIq3iCLG5qfP2Vfg5QxB36ARsrGQKXIu0=; b=M7OKPZMKrDLxUwZZV7M3rlazmL8WP6JlLAge/wobo0+7pWdjkEoyB10A92KasPUe48oN5UKUMo12jVTKyuLh6oOc+/Q3xRhtpFJ/er2/CJrdwquFgfWMLzuT+GVBpZvvrx4RtgCW4SFj5QYnO+Eq18+v7NfIUWvnFcJ0gYsYtJkzzeINAzdv/gbY5qFbX9cSazF3fqgZx679nKGJYsQ4LqEAZCNPJDDejvoZhpV0g5t+jDG5xDopEKrlAVsnL1Jo8MIAqMGGf7Lr/8ZWb8K4x1UT8tVtCiKej7WS/x3u0hSL/OudgtwYAf2jJvIRILcZO1SGpy85RU6BBlQG/oasBQ== 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=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=qIrCamd/WiRIq3iCLG5qfP2Vfg5QxB36ARsrGQKXIu0=; b=SGEW6zyEoi68V2gS9b47b2U/71euYvQOLxk+7yK2tHowWhsp/dxQ5jeXevsOVCkTPMo3SxkBltCu9nULJL786H/FbBkGUYvYNlHKkmNx5BveumwsTwApV24PCSRAiX4KlALNdmHFuErng/556Z8vfdP+F9s6TNyOyM78s/12M1M= 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 DBBPR04MB7772.eurprd04.prod.outlook.com (2603:10a6:10:1e3::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7386.27; Tue, 19 Mar 2024 16:07:37 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::3168:91:27c6:edf6%3]) with mapi id 15.20.7386.025; Tue, 19 Mar 2024 16:07:37 +0000 From: Frank Li Date: Tue, 19 Mar 2024 12:07:15 -0400 Subject: [PATCH v5 5/5] PCI: dwc: Add common send PME_Turn_Off message method Message-Id: <20240319-pme_msg-v5-5-af9ffe57f432@nxp.com> References: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> In-Reply-To: <20240319-pme_msg-v5-0-af9ffe57f432@nxp.com> To: Bjorn Helgaas , Jingoo Han , Gustavo Pimentel , Manivannan Sadhasivam , Lorenzo Pieralisi , =?utf-8?q?Krzysztof_Wilczy?= =?utf-8?q?=C5=84ski?= , Rob Herring , Krzysztof Kozlowski , Conor Dooley , imx@lists.linux.dev Cc: linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Frank Li X-Mailer: b4 0.13-dev-e586c X-Developer-Signature: v=1; a=ed25519-sha256; t=1710864436; l=5639; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ubK5KYt7VQOKIPtdMUTb6BLNf6RphFRaoUgDr6itmew=; b=F0PLKbXsKLB4yZreCfTuhgLPr2jTxhiFQiNoH2xAS09OnMjAcxVQX4/Mct2VhCPQj9I/n66LS lomVUYRad/rCJ/eOTy9b/v2CJAdDxFWGoZyadLpEoWTKlBV4AgCdwtp X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: BYAPR07CA0104.namprd07.prod.outlook.com (2603:10b6:a03:12b::45) 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_|DBBPR04MB7772:EE_ X-MS-Office365-Filtering-Correlation-Id: 5a22b166-c021-440c-0476-08dc482eb230 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: ZaFmkPXgiCnD7vfJNj4wcgQK3+hXdsu85G127l6xIE2cRYhLSfCRyb+t+dIg1UNRb4iTA7Qzkm84p4ZRI23b3kWv5z3Z04NTcYSqiwnqzvDtqO/n7gs8brHar9NABQo3p7tGZukxyV9mp6EoVeRsFJHE/myk7jnhxRp5UCNOLICC8F8I5w52uLGWkovDGp+99iueXGPcjtZZbVkd9qhDRD3FK77kNDXIldHWaYwa6iXhjKkYIui8oX/v0+fsEnHryMoXCD8Xu+oc7a7Yd2tcXjMoHjmdy6AytgajtjHWfnvpyfb7eSQo1xDRw8QcVg/eDA4KJNou4XVbnWGcA38U3VKqly6Ts8Jg4eeuB2xdBFdmMbXYkrlI6T4EEErZJD7Td9Q89aFgWfz2PjGEvamBSbHGmgz5js5LH7dKumo3omuiLH3DITtalxlR5rwiMk+2D4oaPZNm0a5BEZ0gaCpepRZrpyE4Qg2mNZlamu0zdTlu8sck0H8W78evqBlzXIfh2dhnllyEOSH1UUA322IL7fWDPLAC4JAstRx6WaFMLgpcjuNYfhYR4pW0RPVizxu0XI5xoG9rWGvPJyyNIEf1kTfzo0L+OVPzKMjvsCdFlJ+3Iv0yazZ64iwi6SMpHj3vTBfXM+Tcn1O6kIlpLP2wANg5/dYAbxvQKZkICjIk4ZcIpLux2hXp3HPA1WwSZGLX8TYSEW9uATdcFJGNl3pj7LnlQ0T4zjE0JVbjZzvHOWg= 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:(13230031)(52116005)(366007)(1800799015)(7416005)(376005)(38350700005)(921011);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?ysqQi/KLWnsNz/Z1K+HYmMLPq/hd?= =?utf-8?q?GC6VS6MzRWz+3+vQK0PeyV8QK72dta36vPXmS5G38N5x/rKgttF7fCtFtj//jtBdU?= =?utf-8?q?hyObhXbzAHLN6uSQJTZEs2XR/HsDtbImBMu50DKbiqTDsbXpdIfKKBNG+t3LVWUd8?= =?utf-8?q?FzbU6ib1OBuR30cK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ATNXDJOj+GuoUC5tURypIwHJYfvaXYa+pEKAcqAt1UnmRFx+pajK?= =?utf-8?q?WU/k4ZE1LYqFirYcZGURnD2OiWCWWBsQ5X5VyVmiD5ome7HffLz2EoqauG9OBgfao?= =?utf-8?q?fSLncOoIM+ratRh80VEf21sDXvHi88imnrVpiz5/Ryou5PFIvCT1qa5vtpIJ+HIxs?= =?utf-8?q?M7O7CPyOqescORWican/o2CN+Kd2noLgfk5y7s8rQukZv/cwMHCKW3yvE7s0OQ77/?= =?utf-8?q?vXwQHmCoJ4jd4YaAliKclISwwfCcb2eM0Z87sQJU4ABaqZQNWrwowWN6y7qvvSkhg?= =?utf-8?q?Yh8bXdmgyz+SSj04ywiBrlX5cg307BrSbyCuIxdVhxOQXIWkYfSPkz2W+zmO1Y52A?= =?utf-8?q?uW/jS/RmaVb2oLLNAhgt7hHuJ9ug/wtBMpw+A4MpPoxUtcOtLV9Yss3QJmA9Q1phz?= =?utf-8?q?zV4VKoH9Nx+ZhsruzHee3gSfMJ/9LYSxLi2vknvUpBPJHuKGngXvDyNx4fUwHexBK?= =?utf-8?q?hqDjSxbwzfqO?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5a22b166-c021-440c-0476-08dc482eb230 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 19 Mar 2024 16:07:37.5746 (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: R46hvF2TaVw+0IEzDGXeKahGUFt5AdE9nNbpC4sL4mUNGc8dhhJ7aDX+iqKmCQfvhaA8YUteO6HxGioOux9nww== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DBBPR04MB7772 Reserve space at end of first IORESOURCE_MEM window as message TLP MMIO window. This space's size is 'region_align'. Set outbound ATU map memory write to send PCI message. So one MMIO write can trigger a PCI message, such as PME_Turn_Off. Add common dwc_pme_turn_off() function. Call dwc_pme_turn_off() to send out PME_Turn_Off message in general dw_pcie_suspend_noirq() if there are not platform callback pme_turn_off() exist. Signed-off-by: Frank Li --- drivers/pci/controller/dwc/pcie-designware-host.c | 94 ++++++++++++++++++++++- drivers/pci/controller/dwc/pcie-designware.h | 3 + 2 files changed, 93 insertions(+), 4 deletions(-) diff --git a/drivers/pci/controller/dwc/pcie-designware-host.c b/drivers/pci/controller/dwc/pcie-designware-host.c index 267687ab33cbc..d5723fce7a894 100644 --- a/drivers/pci/controller/dwc/pcie-designware-host.c +++ b/drivers/pci/controller/dwc/pcie-designware-host.c @@ -393,6 +393,31 @@ static int dw_pcie_msi_host_init(struct dw_pcie_rp *pp) return 0; } +static void dw_pcie_host_request_msg_tlp_res(struct dw_pcie_rp *pp) +{ + struct dw_pcie *pci = to_dw_pcie_from_pp(pp); + struct resource_entry *win; + struct resource *res; + + win = resource_list_first_type(&pp->bridge->windows, IORESOURCE_MEM); + if (win) { + res = devm_kzalloc(pci->dev, sizeof(*res), GFP_KERNEL); + if (!res) + return; + + /* Reserve last region_align block as message TLP space */ + res->start = win->res->end - pci->region_align + 1; + res->end = win->res->end; + res->name = "msg"; + res->flags = win->res->flags | IORESOURCE_BUSY; + + if (!request_resource(win->res, res)) + pp->msg_res = res; + else + devm_kfree(pci->dev, res); + } +} + int dw_pcie_host_init(struct dw_pcie_rp *pp) { struct dw_pcie *pci = to_dw_pcie_from_pp(pp); @@ -479,6 +504,10 @@ int dw_pcie_host_init(struct dw_pcie_rp *pp) dw_pcie_iatu_detect(pci); + /* Need call after dw_pcie_iatu_detect() before dw_pcie_setup_rc() */ + if (pp->use_atu_msg) + dw_pcie_host_request_msg_tlp_res(pp); + ret = dw_pcie_edma_detect(pci); if (ret) goto err_free_msi; @@ -536,6 +565,11 @@ void dw_pcie_host_deinit(struct dw_pcie_rp *pp) dw_pcie_edma_remove(pci); + if (pp->msg_res) { + release_resource(pp->msg_res); + devm_kfree(pci->dev, pp->msg_res); + } + if (pp->has_msi_ctrl) dw_pcie_free_msi(pp); @@ -697,6 +731,10 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) atu.pci_addr = entry->res->start - entry->offset; atu.size = resource_size(entry->res); + /* MSG TLB window resource reserve at one of end of IORESOURCE_MEM resource */ + if (pp->msg_res && pp->msg_res->parent == entry->res) + atu.size -= resource_size(pp->msg_res); + ret = dw_pcie_prog_outbound_atu(pci, &atu); if (ret) { dev_err(pci->dev, "Failed to set MEM range %pr\n", @@ -728,6 +766,8 @@ static int dw_pcie_iatu_setup(struct dw_pcie_rp *pp) dev_warn(pci->dev, "Ranges exceed outbound iATU size (%d)\n", pci->num_ob_windows); + pp->msg_atu_index = i; + i = 0; resource_list_for_each_entry(entry, &pp->bridge->dma_ranges) { if (resource_type(entry->res) != IORESOURCE_MEM) @@ -833,11 +873,54 @@ int dw_pcie_setup_rc(struct dw_pcie_rp *pp) } EXPORT_SYMBOL_GPL(dw_pcie_setup_rc); +/* Using message outbound ATU to send out PME_Turn_Off message for dwc PCIe controller */ +static int dw_pcie_pme_turn_off(struct dw_pcie *pci) +{ + struct dw_pcie_ob_atu_cfg atu = { 0 }; + void __iomem *m; + int ret; + + if (pci->num_ob_windows <= pci->pp.msg_atu_index) + return -EINVAL; + + if (!pci->pp.msg_res) + return -EINVAL; + + atu.code = PCIE_MSG_CODE_PME_TURN_OFF; + atu.routing = PCIE_MSG_TYPE_R_BC; + atu.type = PCIE_ATU_TYPE_MSG; + atu.size = resource_size(pci->pp.msg_res); + atu.index = pci->pp.msg_atu_index; + + if (!atu.size) { + dev_dbg(pci->dev, + "atu memory map windows is zero, please check 'msg' reg in dts\n"); + return -ENOMEM; + } + + atu.cpu_addr = pci->pp.msg_res->start; + + ret = dw_pcie_prog_outbound_atu(pci, &atu); + if (ret) + return ret; + + m = ioremap(atu.cpu_addr, pci->region_align); + if (!m) + return -ENOMEM; + + /* A dummy write is converted to a Msg TLP */ + writel(0, m); + + iounmap(m); + + return 0; +} + int dw_pcie_suspend_noirq(struct dw_pcie *pci) { u8 offset = dw_pcie_find_capability(pci, PCI_CAP_ID_EXP); u32 val; - int ret; + int ret = 0; /* * If L1SS is supported, then do not put the link into L2 as some @@ -849,10 +932,13 @@ int dw_pcie_suspend_noirq(struct dw_pcie *pci) if (dw_pcie_get_ltssm(pci) <= DW_PCIE_LTSSM_DETECT_ACT) return 0; - if (!pci->pp.ops->pme_turn_off) - return 0; + if (pci->pp.ops->pme_turn_off) + pci->pp.ops->pme_turn_off(&pci->pp); + else + ret = dw_pcie_pme_turn_off(pci); - pci->pp.ops->pme_turn_off(&pci->pp); + if (ret) + return ret; ret = read_poll_timeout(dw_pcie_get_ltssm, val, val == DW_PCIE_LTSSM_L2_IDLE, PCIE_PME_TO_L2_TIMEOUT_US/10, diff --git a/drivers/pci/controller/dwc/pcie-designware.h b/drivers/pci/controller/dwc/pcie-designware.h index 703b50bc5e0f1..dca5de4c6e877 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -341,6 +341,9 @@ struct dw_pcie_rp { struct pci_host_bridge *bridge; raw_spinlock_t lock; DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); + bool use_atu_msg; + int msg_atu_index; + struct resource *msg_res; }; struct dw_pcie_ep_ops {