From patchwork Tue Feb 13 21:50:22 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13555707 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2053.outbound.protection.outlook.com [40.107.8.53]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 3A0F0612F9; Tue, 13 Feb 2024 21:51:17 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.53 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861079; cv=fail; b=kgKWNNKgZFvQkebME6GdyLlAN2Za8wxb7c+KUfq6lmDwUWKbQvxM46vQNTojJBrnz649mkmpeLlnFb6pn95ZCFLtilONb9ye76Cdf0TzcgVoKMrF+2dkE9LksFFtP4WH6Qvt2SDjsA7rsoFQNiz6rcTQRQjEnw/6QkZgRBwiJJY= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861079; c=relaxed/simple; bh=2ryMSn+7oWVdWbaSqBP0ADpPZJzZOgdyFOobfKXU/2Y=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=cuYtNyK9Rwm8xZm0hetK2gNzs4GCMRz6Xc/jUF+klsYfJ1mak+Kf0JfvDwbqOULjP5607jn+FiIQjUGT4ViJJZCcGFIc3P4EDt7gLV9TL+hcXcJyWfMeml/FvckUFFnQprhTg/NjSmJIjXIJAEHXEk3DEklxJgoSU9Y4OsPSDy8= 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=HL3xNrvK; arc=fail smtp.client-ip=40.107.8.53 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=nxp.com header.i=@nxp.com header.b="HL3xNrvK" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ljbWw13r8kx3qrQmLl15I95GlgZ6H0iP0CoixvIENWOOt/yzH0fGAmEEmu6DJf/uuMR8Qap2juHXcwmsA2OlTrd7CDj2Pb+7PqVm3Vtirg2Pa9LmI0QZeZF2EKW1397isuiuJosA32vUr4BXPCPvJ1gx/w++1pSlHl3Fsa9quCohMdVxt7Y7hdEP4gWuyC9caP78u7qaF09gvP7ShVZnkTHe6I+WqNciKiOGeJxGVQN+zpisYI6n2z15omU3QU32U3x+xVs9PoMYlSLdNpkQFofXcYHg4G3jr4PEHukhPZBZyuh8VXVzm5JKvq0zJUJ0PFlH80LPLlT/rsXSynwFhQ== 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=OgAIqknFZZSklfW3k7SAImxZnSCb0v6ne7wm/c2rF8SyDOujngxGZg5p/49ghQ8e+s/hujMLf/+vy1EI98rl8arWNg31Q4wdqmN7BgGvRD/QVzo8EFR3bNAeCeUbqVnNrzLUwIUZmvQ0j72H7WxMyqIcn9Z8S0FPV2EW1KZGKdZRbISOQLm8sHZG5jv7SxNpvj7Zpwoekb7BO7dEcNrV4e95sJi6kgeFWeuth6YSmzY1XT0GUD99v5qAPsnEkTnu12VOH+ILxoZK0rV6Srr0m8kWY2mjcltjRbOGxu8Q7yv8CDX/dOVBnRM8c4jj1Tz43adU78Y+Qm4eDz8tAv8h+g== 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=HL3xNrvKBjCK4uaiexAeNDpcsFC5CqgwVNSwyu76Qv5FpyZoDK3HmGTpwP3N8FC6/1SFzZ+Ws/8NIPWLzscMHxDRsmOTP5bjMBAVHVb80yxcZhP1NWxAcWsfbqsSH88cQ7122hMyPoZvxcN9rj2rdlB+OyuSi3BB1VO8phTMQMY= 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 DU2PR04MB8837.eurprd04.prod.outlook.com (2603:10a6:10:2e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.44; Tue, 13 Feb 2024 21:51:14 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7270.025; Tue, 13 Feb 2024 21:51:14 +0000 From: Frank Li Date: Tue, 13 Feb 2024 16:50:22 -0500 Subject: [PATCH v4 1/5] PCI: Add INTx Mechanism Messages macros Message-Id: <20240213-pme_msg-v4-1-e2acd4d7a292@nxp.com> References: <20240213-pme_msg-v4-0-e2acd4d7a292@nxp.com> In-Reply-To: <20240213-pme_msg-v4-0-e2acd4d7a292@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-c87ef X-Developer-Signature: v=1; a=ed25519-sha256; t=1707861066; l=1631; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=pajLHGu+pjoI9EU+H1bgcTzMS64qjiDozYPsqoeYdBU=; b=ByMTiEbf+7uN8FadYgv3U6VCoxZ95pb3iJmxGYDd1XrRbbyxugLlroEF/3JX7zeAUH1TLEDNV /v89feX3/nsDrVhAZnEumb9+wYW/bSAAkr0caDHbPgDNyhkbkIAKw/j X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0211.namprd13.prod.outlook.com (2603:10b6:a03:2c1::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU2PR04MB8837:EE_ X-MS-Office365-Filtering-Correlation-Id: dfdd61aa-c268-4c93-b3f0-08dc2cdde686 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xJSCUtmR9PmxiRhR/6d+PX4WZXqG5/JdeePYd/sDUM1fbANG7if+Tbr2btSiYAQIt/EY76SbCjFVftQle5S1JsUNyQbEviAp+1ZlsNAsmc0NeF+LqUiTRMd7XcBSWt+3R4or0XuRoC6Qb7oAlNmPnH3PV0uBa5CrKQ4Lgr3teHS4q9ceejTWWxS2hn+xET0Tkay4vx1Gfh3hg8XMmZfaVaLUfhxKGaU/qCdqgGqyZ9i7B9nLTY8MaUOa3zJ9+S2I2Ktm0qBAERQOhqAdjcvEGF7DatnVu3y+l5ggbEbAWq32sCikZ/wMwHHxLQv48ecIaXZGsgngEfiQZKy7Yr5p5kmpM3hfYjhri5n8OeEA2QbGqRvmzDDeA+qDynKgm4d/QT4PTZW/Q7+HbJp4Iww70K6rWD7542ZHNmQJEZ9N8pzyBOnOnK7TqHi52Er7z09YYpeHtcxtVdGaeBlX1NJvnR6AjXIWdveO9fMzPs83F0N5ruDNlMlrs6Dl2f4UPnCi/AqgY4stvMLi5Bpyp8z7dfxuuQ0Tu0tug2O6mQo03dqkJfKacpJJ9ud+yoCMehp/qhnpKILn6k2Z+LkkrZiXzg9fGO/s0C8epIWhqEQYUhmz1EJ9hIr6nVe0KkAn78nbkSwY+MmUSGjiddniHZBqgw== 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)(376002)(39860400002)(346002)(396003)(136003)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(83380400001)(2616005)(6486002)(478600001)(6512007)(6506007)(52116002)(7416002)(26005)(316002)(54906003)(110136005)(66946007)(6666004)(66556008)(66476007)(8676002)(4326008)(38350700005)(8936002)(5660300002)(15650500001)(2906002)(36756003)(921011)(86362001)(38100700002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?qagjoKWlBuaNI4a1nOgLjTB4NnF4?= =?utf-8?q?aYN6rXGKik5XN7dDzAgK9Xx2yGRzN3fR9f/ddz7KEl2oxQFTLX6C4b9T4UfW/u+qB?= =?utf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?utf-8?q?PTljL8psl5xjtrXGfSI8Axkodz78V09LOpU3kE+i4FcsRNU64dvtSlZVxHQC3ZiwZ?= =?utf-8?q?RmUi5PpvvYgSP9YpSPAFN6n/jRueZCcK2nWdfAU7U83SH4KmcNk78A4pL+f/qfvJA?= =?utf-8?q?rLIQOy2+5UpKw+diko7WAt+tEP/0F6hrOfLeQitti+rF8OmoN86jbFK46/j1ZFbbw?= =?utf-8?q?FOMIG9DyA2YpN1qfDJwlaWXuh1Ts9Nm+3bXqKUJd1R2yO5wv0cd9/6vhll7EHJ28J?= =?utf-8?q?l9FWQ9yjYmQ/O2QvaF5S28aZGOVAHYrFSJZwuniYEtSXvWi4tVpnLs5chqMO4Ylaf?= =?utf-8?q?K4mIy5X9VhU/KFw7eBYXqAQ+jDXxUT9CErbz3MNqE9USrVIpBswsKv3GvKL1MjQYg?= =?utf-8?q?arakvMMO07yjQdNSS+z8qFv1MxzzR2+eOfKDzGspWRxajiD8tzzC4ghtqwtMShvpN?= =?utf-8?q?K8h3v11yP5YvFd0J8jX03Ja2tRBCa2lzhFbnyIuvzyq0hb1LePv2fYaErwxl0iNCy?= =?utf-8?q?dZjikDUvlCcbXlGWe6DyLCG6W+NxdUgzi9vNeLyBWsI4p25ZzvEtiUsp5UaQcv7U3?= =?utf-8?q?bcCk2PrvRf5A?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: dfdd61aa-c268-4c93-b3f0-08dc2cdde686 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 21:51:14.7640 (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: 54PQ6fnBmSaQdWq8ijRqfscGx3EevvQiO0xhu6+EcXOaeVwMxe+OAR83OP9Ox8uTMP29KUv5fcROGYJccq2r+A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8837 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 Feb 13 21:50:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13555708 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2084.outbound.protection.outlook.com [40.107.8.84]) (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 9D5836217E; Tue, 13 Feb 2024 21:51:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861084; cv=fail; b=Nc+r/IAWykF3pBTLH2ggF8EpLwk+fPc1QJ623CHO//Ft19geMp3M1OUih0pIiQNgJW+Fq2pEBxcshxRylFBwCWglprNjQzquJJZBvKk4K6HSl/67VsWB+0JprZYblHV7dl/H33zsu1rm1JcHLI4Jba70hHMZYYA4vhv+6G/o2go= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861084; c=relaxed/simple; bh=hzGYRhAZl9U+Uvuu6aIidx5j0fhBAx2klPXN/eaV8Q8=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=KG1MtAxmz4R64j7w3lKFmBRwcUCGPOTaqg8DMSfAbplkyLqnmwbfueIW/GSjDQ5Asvw3KEj+5rGpwWHB9z2BajWTHSRgQ+4ANsd1deA+5pV3bmjYXL9w4kLYcXRBjwNsRwcPMOdOwwpPTAUYAvFPKbrblhgyOFGUUomAXEhcJj4= 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=tBO9ffhA; arc=fail smtp.client-ip=40.107.8.84 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="tBO9ffhA" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=XLFQzVqWIX7YzUAxx0QVHmldb6JtNrE08Ansb/1fZTAKjJdyDcmEvPcbPmn7mnZ+63shz2qZTzd4orMoaP5N12XkJJSdmgh8zOZRC6RktBPJIHMq0kuwA8xAKSl/05EYen1LrQwF8dhzrWLRgzCFqMvBwMRqZ+wmEko/Ju/dIkFveyk5qAe/1FVft96mZTUT9zLrFjaGEobj2XNyP+xKUZRbK7yNySY2pAm80JSZWdm4oFrJKj6wV5cQKD47mK0tGH2Pj/JhOHJmDw/IPfihzo1cKky9C2wRMYdRfHn7u7dUMAbdr+1G/ILwwERB0eN4uDi+WCL/FS7vPy973aBXYA== 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=W1RfWi/Qc1n8lp04x2c5PXqzBl6yr7BG8g2WTNwbsvEkUxNJO4QFP4iVa2LmQLQLQ43+ILp1Qbx5SOm0dlrayB3boFe+IK9GcO9LD9tSOtPTwcl0rAiNNLjWKTdRzMadiLBzeL60EW8XtJ+Cy2hrViThMBVL5feaqmslX3nkumXihy/pxtvbJFuYpjS6ZHoa18hANnTgeICwLyQWGf7D4MZ522ScyClaxKNXAq+yEq7piBNTjHsmfT1P1gjpHzQ1QHdQPiBMxzklQx2kxrefDY6/06l+FxPvPcVNvbo0Lss6/jS8vqbPFUJC6FFtcYEQYwf37nAt63IXjTd0nsAUbw== 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=tBO9ffhAYGUX8SA5b6IVt3bXBeZUt517vzuGxuRkvh4CFaBY6VG3O0H3sVKYob+9Fa4b4RNVo6krGLR+wztEdY5MXFMtxc9p9YHDqSOb96AF4+yF3bR2ROZxm8UmfePm+4dj5Vl3nFMgwHXf21PysthiKQzsaFuS3tj85qJak2k= 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 DU2PR04MB8837.eurprd04.prod.outlook.com (2603:10a6:10:2e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.44; Tue, 13 Feb 2024 21:51:18 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7270.025; Tue, 13 Feb 2024 21:51:18 +0000 From: Frank Li Date: Tue, 13 Feb 2024 16:50:23 -0500 Subject: [PATCH v4 2/5] PCI: dwc: Consolidate args of dw_pcie_prog_outbound_atu() into a structure Message-Id: <20240213-pme_msg-v4-2-e2acd4d7a292@nxp.com> References: <20240213-pme_msg-v4-0-e2acd4d7a292@nxp.com> In-Reply-To: <20240213-pme_msg-v4-0-e2acd4d7a292@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-c87ef X-Developer-Signature: v=1; a=ed25519-sha256; t=1707861067; l=12761; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=HU4ER7vz+HwzR2rHdE/BVWAKQXG5UmDhW10DZ8OHeTA=; b=oc+RI153Gd2qc4TGAFCYpI/jwXmFceGa70boCb3gGymEKW24MtGkEbsEAkDZHuQtslQ6hryTg aD05FtWAW+1BosJhmVqeRKvqKtAlMJvlpPuXEfFKLJZ0fL/WDDikR59 X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0211.namprd13.prod.outlook.com (2603:10b6:a03:2c1::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU2PR04MB8837:EE_ X-MS-Office365-Filtering-Correlation-Id: 791f9713-b07b-4ae5-eb6d-08dc2cdde8cd X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: CVBKBW2I2Fd1veSSIT5JPDzSM3utnPXZU8L/FBSuAB7ARHUgXr1C3yQx7OCc2kKRoDn+f/x4OKrhH9/TLbWnp/1aBXJez8jaPUvk7scX9j9K+7FY0bt8HlPDIuad/5bd8raMGOCHKuHsmYsWdVGC1kCBxka//j/SavmaAYnNBm1xtUtpNezjyGxOHshbn8hYOvl1/AU2MxznKZn8YPOqnrdnG3AJdnfeZkAjmtvjhWPz2kGqHWza4BL6IAuIHlXU/CK2ydK1mPvLi5DxTCoE5wZMM3ImEvEgwqM7MVy4OBMiwtGi7Vkg2eZnqtasjFPqFWXTI656TDNou/JzkQbX9OeabpaRCzG5QUukTP3A7uY0H3JoWQSDacls9Ek+LNR/RDwjCwAQjH8eUmSpmvK77vb5TB6GFcqULGnrL7vZd8TDf2dn48CyHpAVa7LA73uAleHBIzF4u+3BHfACfFWq9bnxG2URcxfrQIVSsB1DL3avzCDffb9Wm0ayFCR7c/LdKpCZkU9KlUX1UzZl82/KeUWiVE4i4+Uv3UpVx+qnpo6D69o7fZqNylJkf5Fi/OsWLwHh0BvKC8jOyjuGFJQqetJp787i8XHxNZqmYKFqU43iuq9ExcFZUtQucCANpHQ5WmaM+W+kGkBGmboqzJvHig== 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)(376002)(39860400002)(346002)(396003)(136003)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(83380400001)(2616005)(6486002)(478600001)(6512007)(6506007)(52116002)(30864003)(7416002)(26005)(316002)(54906003)(110136005)(66946007)(6666004)(66556008)(66476007)(8676002)(4326008)(38350700005)(8936002)(5660300002)(2906002)(36756003)(921011)(86362001)(38100700002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?NdTIc/skpLgVWmIcjTBx3Xk+VHFF?= =?utf-8?q?KcnFl2lh//eg62mTio8DR0pye+QrX4XYdRwtiOmNQ0VjlmYwJ/YSNziksZ+q3ehsA?= =?utf-8?q?6/d9KLbTLqL39kqjXpDR4I8eyi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1S3XIicY/mN7roPE+UwYOh1X4hQDOecTBVFjJZp?= =?utf-8?q?Gl1l6S4WpEJ/E64A2Ie+2I1Yp2JaBX5gjf5UQ762Yxile9Zn28rKnrmlJJFARQr3o?= =?utf-8?q?sBkBY6THAidf1IDkxGpv9dr9LxTRmr4wEK3wC5IGwEgV71QO+lfht0uOIK4HdFctp?= =?utf-8?q?bpB24JdcPzAKQFfQYoryvQWu8n0qNqWZ2+aVaDlsVQAtoQkrFoVfUpSCcAIVvkquW?= =?utf-8?q?hxRvLCwxhWD+GQHxcCoW9xqwbPtMbq/HwJz6vNOY2ipHoQCtOZafNFcVb6mP8md5T?= =?utf-8?q?8pCJOJhZsWWWVQXe5cw9KovNBlCy3vihE9BX9f2FfPARmUp/5+7wu6qd8wvNiNkz5?= =?utf-8?q?ciMO5RnLGt7k06tLQeQUsXs+980j9MjiH+TmCTj1VktePiXgPBz9wgaNK7MOi0jOH?= =?utf-8?q?WEoubhnD5+q+XhVwWXY7avgydIRGRatBqwqF1pDQ2mS4zo4FjgLR33jbgEshQOWp2?= =?utf-8?q?Vkg7WuOsXuZpx7YXNjCZGsR6RWjOaT84M+dslV84pMdiJPdpyFy3TJkwE5OxXHwMm?= =?utf-8?q?RCsCu5RLzsqX?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 791f9713-b07b-4ae5-eb6d-08dc2cdde8cd X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 21:51:18.5894 (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: Kwxe1jZtSFfXNHWRBwSblMnfYLyJHMW8eRtfpJyKqpnF4x4lSYewAlNtkuq4YEzZI0tyFzCusfWFIBqK/Dc1+Q== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8837 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 Feb 13 21:50:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13555709 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2084.outbound.protection.outlook.com [40.107.8.84]) (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 550DB626B4; Tue, 13 Feb 2024 21:51:24 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.84 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861086; cv=fail; b=gU2LatpU+EmftmUvbFys29i4I4nv93wJHdmDviz9mzZfKpzWF0SAw0W2Hoxa/rVJQYMRbz2iDeoXT9LErJfGQoa57aWhNLB5odiaCk75jSipAMho3xukUHupx9aKk26wvxgKdOH7Xvak91vTQHLmEoFyJ/AnDT/zfNeYe5mGoGs= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861086; c=relaxed/simple; bh=iaMVhIlaxnDKrjo/B86UwmBA4lUHgRwjSU/hHDluay0=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=crK81RnjwMgAraRRgRh5wniljvFj56lU78MFuoStdHHD6vd7Zlq2g5E8/MAYNZZcSJp6Tp5KY3K7RNu3pknhuaNnkxQJh5nHxfwAz/BUn0/ExyYbAN93G3UORff+RkE/KlSkcaZVAq9N3ujdSixjdXICaHA0M6qt1/jKc+rzYSo= 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=CawbRRHb; arc=fail smtp.client-ip=40.107.8.84 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="CawbRRHb" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ji1Hd1E7wP/jzj44BCTftqZcOsH8WP6y/N8ZZ7GnsPRCOcjcdMMrINH0bITyC2hIYLOC1+1rShqJvxjkrouM+pP2C5npwkKowy2Kq/Z/5iFXtpUVf9027/xfSSM5hZ0/T+8BPG1NcN/d7IchdW00xgCqjPToId7LMGlGfn1soDLgUacpCB0gFBIzVQeEw9Vtu63Q9S+2fWWCbM+BcZBtBnbhXFN0OL+/9H15K49nvXd8kuPbXLq2f/+FBUsyzXUOJae6DIncauXamJax3tTNE2my5mQkPGaB/GP9PzFDkLXb70eboNIhktK3uR0DzmVeaw5NWONflAh1OE8YeN8lLA== 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=hFUuDJPt+yGEEHl+PoH9Wa4756uyjw1c7OgVSCBT+zj6TOq4jVuDI8+sQyGiQVceIXnQI6VdkWgJeALiMX/0ybz1zIGSUBtliyTyXyN1nB/JY6N2dGaCwqtI7GMXgZyhlJ1r/rnk+RlpKoLjMq49LRDyp+rFbrg/4/0+PurHeVwJSuW9mQg/80AgmN7sJqZczcl4hAFYcEmTJPgpLnvFQZ75fGhrhm79Wn+7IuISJgE03XVy0Kc6Bc57fTrMzN0aM8rKkGPYh3QLl947iYCADQswOAgeIktSwm28oSdzTRKRgeDsMPu7z2So6VChCeUq0ArEvz4zjO+Yca6sBjP+1Q== 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=CawbRRHb8zRV2pqQcHrEyMSTtP9e3S019OKMnAq7HN/Yy2FC8YfksETnYx7+Ie+2rlu8Q7FvmmZFcbjri4Vvhtkx5CT0gJXT6JsA0rqKAcHRxXa1fIMnzZcT55R95/q3cuP0LLdV3s4K+Dpd9xO/4FAT4pJ6B0P9HOAe7MZhxrk= 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 DU2PR04MB8837.eurprd04.prod.outlook.com (2603:10a6:10:2e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.44; Tue, 13 Feb 2024 21:51:22 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7270.025; Tue, 13 Feb 2024 21:51:22 +0000 From: Frank Li Date: Tue, 13 Feb 2024 16:50:24 -0500 Subject: [PATCH v4 3/5] PCI: dwc: Add outbound MSG TLPs support Message-Id: <20240213-pme_msg-v4-3-e2acd4d7a292@nxp.com> References: <20240213-pme_msg-v4-0-e2acd4d7a292@nxp.com> In-Reply-To: <20240213-pme_msg-v4-0-e2acd4d7a292@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-c87ef X-Developer-Signature: v=1; a=ed25519-sha256; t=1707861067; l=2940; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=Vx141tscxeq3VO/J2v1vu73YFB2QjcNfIuChtPapKMY=; b=n4flEqJcvJfIefYWRaPHpfbduAdXCrX2UnSNlEAG8iQ+oUmcnpqZk80SlWHfu39NWRQQBmCCl YAuBpb+ymDVBGcnzL/aIKvMT3IkpdmRxukPNy6oDVOfmm/uOikKkwYc X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0211.namprd13.prod.outlook.com (2603:10b6:a03:2c1::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU2PR04MB8837:EE_ X-MS-Office365-Filtering-Correlation-Id: 11940b29-59e8-44b4-ae2a-08dc2cddeb13 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xAUCkaaSvfLWKFZkVRkRigtdwT0rvJ/9z4hjwwq0QWwmKagJc2hQw8FqnaokC21rKSJQv8pntq6z6Ek0c50E8WKsRdsO00G76KX+B48kWFrw64q5F0mz3CusfeF0LvVBzsIPT0wgMwJX+7wNyZWgy7e6TBpSktK4xlWxi3pM9XU18XqO83l8JMlvgBzhCIGRrXUSuORvx1nTx5NveqSgRH32GDiEV55c3SvIzeLbpxgf5zHcBrJ/7oRbfW6ZJpnoUilU9HGSMJSLFgtsQiXhLob9TjpWAO+i6Is3siAcZqpM6/FUiCFwGPn91lTClxBuWmLSW668BA8Q8Zu+ZQkBa2Dr+texewXqKECVK5PoEBSvM118QbB1dcqcHszXssOupOL7PGG2R2jKttapYpOGXGwE1I15X42OkirQE1a1ph0xAgMZXHILttFzHxm+xIkZh7wfpU3JAyL2Ot8VClLDqPmTs0+H+TvAF7/IVV0iH11oMbciukbPy31eIVXYZVmsf9P5AVOW54Jt3TGeyRhz+OIoTQ3PTFrEtWMy3CAxaU0FNAPnyOLVdCnclZ5hUE0c7NiqekZbHR+D8q+d4H83VJUs0J8Noo53Hl5cBpjCe+k4m79+9QDP09JrKe7Q37SGbOLxrrAgABORAYNFDHD+Tw== 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)(376002)(39860400002)(346002)(396003)(136003)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(83380400001)(2616005)(6486002)(478600001)(6512007)(6506007)(52116002)(7416002)(26005)(316002)(54906003)(110136005)(66946007)(66556008)(66476007)(8676002)(4326008)(38350700005)(8936002)(5660300002)(2906002)(36756003)(921011)(86362001)(38100700002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?UTxQ7E+E1b0XXogwmbHcIa2/Kotr?= =?utf-8?q?46jW/MR7JRj2NFiwb+NQ56NEhWbJtWAZO/HnsqYs259X6Z+u4myNAWYETpJZdykU8?= =?utf-8?q?2odkJnE3OC3B0V4hl5/sZmiNdYVyK8EIvjKkHXbLdOR/S6iZTWCAcgi/G6/u5OLxr?= =?utf-8?q?zTRB7S8OA4lw6CZ/wwBZEHbZV7/vEeTVEXGJqBu3eIZwarj3UdBzRSVUEby+xKaTS?= =?utf-8?q?aWuXTb/ysbSjRCWJR2dNpYJA1HaO+GHcccH0Br6gooPfUrMBL3RdVRpnwV0Q3R65v?= =?utf-8?q?imDtxzJE90IKSapr7YgHe9mSLlEgy+0ewvTTriJLPkpcsmAPAj3mC4ItH9/SP9ZzO?= =?utf-8?q?8PhX0kRsjh9c4rsR+CdIK2DC5TnUTaWyeQ19Bk2uFd8icgdAVJRGxp6TWUxORQ39h?= =?utf-8?q?e+0gZ0MscUDSerzMSsk1bLOrUY2gdD3nAWd3y3Mb1yJXuWS96ot5ALH/fGUgpSDdO?= =?utf-8?q?tMXqsbYRiOfyh6IrP5Elop3mHMJxl8Ta70O5dAEYpK4phiZVlvmYVXArqXCSQ37sH?= =?utf-8?q?/wrwvknS6NNTXZfEo16oFcw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OpcsfWhfMxJJZzbnfx35fgce/wLUjQ5r+pPUK?= =?utf-8?q?ZLPJnlDQ5F+bnjX/xuG4Ej2AFY7WjD9Qyz4C1PqALIH6quWfu01Hhi5tT5jZatGVo?= =?utf-8?q?lB2QYjA0S7WQ?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 11940b29-59e8-44b4-ae2a-08dc2cddeb13 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 21:51:22.3824 (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: VjzVrnooN4dygRTKG7sEad0z7jPsfLQrzmWsxNA8nwNGzB1olfFfHYlPKwHlmQ7LmSuHk10hLrDmw4XfSFGPVw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8837 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 Feb 13 21:50:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13555710 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2070.outbound.protection.outlook.com [40.107.8.70]) (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 AD7BA627F1; Tue, 13 Feb 2024 21:51:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861090; cv=fail; b=jbmy1pK4ApmLT5svEsyOyURbkBx7yvrA2evTMTI9mJQPkhZrG1YjbwUD1u/gp0poBBbnELM1IF6Zu4dkI73MRJLRssTJxLQ4eYuf8wWS3+Vbx3+GyEQyUgIhxTfNZGwo/4MyddBtjBueQt0mFxv/KJSgyHCr1Rh+BzPytotmieQ= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861090; c=relaxed/simple; bh=ze2L3Nl6ITdmvSqJ46+wd69F0Sc18FLzWocNjgTx/8s=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=RwUkKM8gBK6okMb3kV8SCDbTy+iLqHBE0Nn40Fdf0zQUNF+ne7AC+vKBOSg0hJqW2LQ7CGguIvSxf07lF8SC84CVL984DZIGfi7WMPhMoKeS89RRHqBajokkEWXHfmSmaU8rlcJ6/FBkypH+ZVl5i7fzaxim4HX9AJ8sTaJvTSw= 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=TltNZaNm; arc=fail smtp.client-ip=40.107.8.70 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="TltNZaNm" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=KCYFg0HxmyHaOLDkforCtKgxKOiFismyZvPsoOtx5Zy4qe6Kc0+2HSGNLf6DkUJ/u6Nq00u4DztW+D1JWS26yZ2hiMhBJUjghSlaQjvo8CCupse5JgqYfHQrj3xgtceH488TnYGbUrCPPtD6XrmfHJdka/MfvpVrMqdNvDe1V/quDZNDslLd/AHeguRzz0qYThptg2mhsRKcR7NpipuZ+kO5WQqW+rk6h/2k+XunT4EkYm11hcobcuEPvoJKuj6Dm65juc5VK9NwfkxJTZZD6lFfb5zX8AGJ+AF4xTo9L7R6xXJkIrOQu4LusLUCjO8eIRp2U4naVhiRjDNHVX9kYA== 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=D/CUiyIq+Y4urWCeqRMucgagTIbZrzKEs4mokzWHTDZfOn7aDlygwA13OxQVy+dy1+GXBUxAwyHIvJSZipFqO1Kkz7gqzWRvkiz6QMXvJZ9yiKOigEm9xTW1Ch4SrZOfIh9u7cO7Q3J4IzXSzneqC8LtBCymehNYfQnCQVarq8bhFDhbp4MZ8WjPQOVL96sa7DMiYZ7B4b492GOe/L5Zf6NNU+Expty8JHZP6s7aACGmkd9i+7OHUvQw8h39z+RuTzWAl0NB1lmwBp4J5vt3e2gZ7ohN5lSC2Q6N6xu7w/y92lTBVePiypILb37xtI2WO5d+3BuI67IDX7NFNu+fOw== 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=TltNZaNmqJvMwd9UDUWIpdV9JblNnviSu+C0OTunYsyzJJ9RjFZ8YtKzEOYF+/i0mDEnU7zwgOE/Pou7pl+Vm+26tvi6H6D3w6MpYtFEBV5LLUMbfpONYc7g1AYBxypYz9myJaDuC6SQbW/nJvpZr45ZJnHLfO5S4OSo6DqGJ9M= 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 DU2PR04MB8837.eurprd04.prod.outlook.com (2603:10a6:10:2e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.44; Tue, 13 Feb 2024 21:51:25 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7270.025; Tue, 13 Feb 2024 21:51:25 +0000 From: Frank Li Date: Tue, 13 Feb 2024 16:50:25 -0500 Subject: [PATCH v4 4/5] PCI: Add PCIE_MSG_CODE_PME_TURN_OFF message macro Message-Id: <20240213-pme_msg-v4-4-e2acd4d7a292@nxp.com> References: <20240213-pme_msg-v4-0-e2acd4d7a292@nxp.com> In-Reply-To: <20240213-pme_msg-v4-0-e2acd4d7a292@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-c87ef X-Developer-Signature: v=1; a=ed25519-sha256; t=1707861067; l=608; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=ze2L3Nl6ITdmvSqJ46+wd69F0Sc18FLzWocNjgTx/8s=; b=Z/RgbiQhswM47weTVGioNScneJnv0QZYjcxYdeLFqt5EruPoy63WOdJ3AWWl5bvO6QTSFDPyc jAqRE1Q9YgWDHXKkbwIUjKHb8DIaS1qF+vClK6oZJ+KHc6E+oq5s2Sf X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0211.namprd13.prod.outlook.com (2603:10b6:a03:2c1::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU2PR04MB8837:EE_ X-MS-Office365-Filtering-Correlation-Id: 112420db-3045-4861-cfd1-08dc2cdded16 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: aAnVjoyE/N3dYW3DTkNdVh66zaJ7GdDrcU2/Ek8t9h5XRWWh7fJgzSA2hQH1q3772KlxtHESNQ18mOYVAzRCFbjwQ5rLOSHeQ5ZqWykdijqlHBMEBoyQciDj0Cr8+RmPsM0WX2tAKOOq3barTg7KGE8Syxt9AGtTAf7G4FH70GZClHNGj2OHYIb/RMz3lxOC6G3BkSK2IHtl/e0z2uJRTdLQmy7Z/Sny7fSGNF4GrOamPy8OR8OCcTro85qAUlAY8vVUTXlJdQtar5ezRqZaNYKdAtzOppsECmCSLuu9V7hFJKhDZqnBAjd+4UW9sUTI0dw009agnqYhwX2sZzWFI1STeuqC3fWJHba7yThRo8sfgjORatfZGkzSCv2Kc2YOqDZQHYuAdAglSBg4OM/NkpmsWGm8ewYrZsbiGrc0FAS4mWhLcdVs2GY4LGzNlkgeryn8vqU4arKGD7hbQKk9wtdi0mEG+0iyax3TcUU6qfpdrGUpoZxYWXqoqI9TVjM+PSh2rg2nR9P/ocSwjfTybC7xD1g4Fo+wF4z26f85h9gSLVJqHPlDzFnYxvs62O5QbHuaXxOO3d+z/Uv7oFUWXOcbykktqK8vErWDED5gn8gggyMTRMMEQhsnjpZE7GI5mzQJ7bVTeB6EG2+ZY0ClCQ== 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)(376002)(39860400002)(346002)(396003)(136003)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(83380400001)(2616005)(6486002)(478600001)(6512007)(6506007)(52116002)(7416002)(4744005)(26005)(316002)(110136005)(66946007)(66556008)(66476007)(8676002)(4326008)(38350700005)(8936002)(5660300002)(15650500001)(2906002)(36756003)(921011)(86362001)(38100700002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?MO/oR/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mVUGfzFAD/RmXWNG?= =?utf-8?q?XrOC+d2mcePIRkdSbjvDYf3+h5RJEQnJ87eMH3idkuZXAZOID1dUPraKni1bD2Zam?= =?utf-8?q?WbuBOtRi63SemZ0Wb/l0zxeNN+s78owlP+9ZiRaUVeOPwlU9nlX7eIOV5ARYEOKRV?= =?utf-8?q?gXkihUdIDXpym1+0lkTnmoyd0ZhzCHm5ZWu5LlINFO/36+LhlJuX1JcADHHiPWV3C?= =?utf-8?q?ktIuSHDBIpPZwV273A55Rwa3RxZ+WctjOnk2GN0u9UDzIGCCHWv6VXgIdk+9wOprW?= =?utf-8?q?Fys22xt2agcy4ynAzzQO921ss+e9sTXK63Gz7HzZ1T70LgAe0JQ4yF9duj2S87q4O?= =?utf-8?q?oxMZ9s8wjXauqutGPe9OQq+uTC81smS/v7Bb85I1VEj14mA+1L82FXaIwfC4L7ttP?= =?utf-8?q?YQBC4uCLPXoEHcJAgMbZTDQQ3cWUz/XYYZrhiv0GChQ/i2M7Z0NQppwrEmuSCHRfB?= =?utf-8?q?HLLPv7IAg3ab3zvcWO96tZiZfGJQMEiP06tY/pMiet8P7pVBwyKpV6Jr1Lvv/B5LJ?= =?utf-8?q?js0JCFyZ0ZCMxb5HY4U19zGFVRGQGWwPyPxbHJdzZ05nBUVq+2wlQpxyeW93rLAvl?= =?utf-8?q?bDpr0SyBkYUt5a8lv2Mt/ql/cu9+yUNM8LPoWUWYGojgNSg95zuSiWMX2OH02WkuQ?= =?utf-8?q?ke7X304ySoe+?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 112420db-3045-4861-cfd1-08dc2cdded16 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 21:51:25.8060 (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: rCagIClXn7zKg86vDXP7Dfa15KJsA5xhUlbEZblJtMm+l13nlLLrUWCOuwzRsbjERNJ+iZr+13LMSTe5o97QHA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8837 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 Feb 13 21:50:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Frank Li X-Patchwork-Id: 13555711 X-Patchwork-Delegate: manivannanece23@gmail.com Received: from EUR04-VI1-obe.outbound.protection.outlook.com (mail-vi1eur04on2070.outbound.protection.outlook.com [40.107.8.70]) (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 D6FE161695; Tue, 13 Feb 2024 21:51:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.107.8.70 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861092; cv=fail; b=TIWQy1wNGEY11pEFL1oyWJSPiQKaSGO+qxVnfrrIjheFe5FSxcM1UeUdqv7O2DaLhkFVGr6J7bMMGe0bZeM8DRCe1FSWaI/a8XwGtSw1gNV+CoqbEC0wjnYOWoBFKkIWVZFTSCnof0zX8JWgSVjnVUU0vk0STF2voEKLfIu1SbM= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707861092; c=relaxed/simple; bh=0n9yn+SK8WKzfk7Sg4Bnnj9kG1xw5fJUkKrHFv0hMh4=; h=From:Date:Subject:Content-Type:Message-Id:References:In-Reply-To: To:Cc:MIME-Version; b=ggYuhgqJvzcdhIjTCFHkKUDveA74/C+Jk0u6KwG5FKowbGnvqu1XpNGwiUF8RvPrjrySw7fU3xLmntRggQroW0cfsqhkWJwbDyUtDWHpD9+26I48vpuI3vebje8rhsaz/mFeSgSeEBo/nf0eaWVYpVXSWN09foIf5F0pxjXAxDc= 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=VfFPxsBs; arc=fail smtp.client-ip=40.107.8.70 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="VfFPxsBs" ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LJuI5MnhSW/QUDlopQo5StN43Y3MWatKorb9YyIJYin4T6L+lCdSVhvu+NLURraGHWqlNj82lHMGhYjaFDmqdteaJgleY5cn6ZAPVxfVC4PjFl0xR+WElgrkSuNThL/3n6ul/ABAWlp2044hnW3fxAaEmbm+3KJvSvkfUVS9Niv09F9IJeSE6Yywp1c4iMBcy5nkdJK6l7rzDqrKp/raSLkW5vz0ovpN0XNLz90umasoq2b4vQMZm6tA+KlRoJrZopc8C3JyD8eYgM5I+Qz6EcGE9H/H04BnUMJvfSvxHpuedmun/emxIs6pyBykloq/DQVJpa99ftiJVoBmTWcu9g== 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=NSeFRmxl5iipnf4di/o6bXNzcEBqSB+o/oDR76bd9ls=; b=mFC/8AIQVfO9y+Dmk13Jkgw2Euh/aa60of4bOZh2Emr8KRAroMVBjXyhPYmagaB27xK+mTMHtju7UBaIdGaNoU0IQ7tIx+WAVeHCmr8Y0imoeGsHaGsMa8apfCQfcKdl8jkxi9UiaDQdJv2yQrm2EHx/dyXhvLo141SApynwFeeyxsbgQzQanNCsT70ZS6wbEesaljlgAbOaaW4iOepPcDHwNd+VXtRjySQCelk0DhPzQ1FV9En6oRdqwKOTBsK4pR/c6ZBu+mJnaqDjlVDZHC4YTZnVVNpgPOdQR47bDbADeCklQLovwco5mnI+WwGr6OQx739x/G85Erc0TUBnRw== 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=NSeFRmxl5iipnf4di/o6bXNzcEBqSB+o/oDR76bd9ls=; b=VfFPxsBsvYsj5QSmVghcDqKSauvMy+1ASmRgguhcW1u6tFiwLHD0d32j4Lrk2/K1eXIYyc28QMykbNael51uXB1l5SwpQnQxmEOEA7LXGTAN3xfAe73gmmOS5PPZpohViGoXwTxayGsMS3N0Ie68jiRytaJleAWyk5aH+rHQ6tQ= 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 DU2PR04MB8837.eurprd04.prod.outlook.com (2603:10a6:10:2e0::24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7249.44; Tue, 13 Feb 2024 21:51:29 +0000 Received: from PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c]) by PAXPR04MB9642.eurprd04.prod.outlook.com ([fe80::c8b4:5648:8948:e85c%3]) with mapi id 15.20.7270.025; Tue, 13 Feb 2024 21:51:29 +0000 From: Frank Li Date: Tue, 13 Feb 2024 16:50:26 -0500 Subject: [PATCH v4 5/5] PCI: dwc: Add common send PME_Turn_Off message method Message-Id: <20240213-pme_msg-v4-5-e2acd4d7a292@nxp.com> References: <20240213-pme_msg-v4-0-e2acd4d7a292@nxp.com> In-Reply-To: <20240213-pme_msg-v4-0-e2acd4d7a292@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-c87ef X-Developer-Signature: v=1; a=ed25519-sha256; t=1707861067; l=5590; i=Frank.Li@nxp.com; s=20240130; h=from:subject:message-id; bh=0n9yn+SK8WKzfk7Sg4Bnnj9kG1xw5fJUkKrHFv0hMh4=; b=jbAMBNdLFhsC4g0YQslKnAqS8HdI/vd3GKRKlFkjksfGmE02bEafj9GQFmJjNH++Rf+8Z4F3f 6p20aIdDGfCDjMhnBXgA7amLu/Hc4zYHZyfh33LM4/b4+9EBSnEP/kr X-Developer-Key: i=Frank.Li@nxp.com; a=ed25519; pk=I0L1sDUfPxpAkRvPKy7MdauTuSENRq+DnA+G4qcS94Q= X-ClientProxiedBy: SJ0PR13CA0211.namprd13.prod.outlook.com (2603:10b6:a03:2c1::6) To PAXPR04MB9642.eurprd04.prod.outlook.com (2603:10a6:102:240::14) Precedence: bulk X-Mailing-List: linux-pci@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: PAXPR04MB9642:EE_|DU2PR04MB8837:EE_ X-MS-Office365-Filtering-Correlation-Id: 0f326471-07af-498c-920d-08dc2cddef24 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: JyaSsDtp7J95LzAspbESMUULJAe+cnaaA5otkmeywD5ErJ5CGT9+RBERymZ92vJ2GNagWGIPHBXMc8sFdivFjCn2/rFuWtBo8tMNvFMm2jX5ngGZnO6mk+WNFPT/JXz8Vvl0QvoHZDUZry6SpAWwI+RURmTW0wE+FN+79bPEpRCtqvW/8TGO3l427o0EE+KxeKilT/9G9veFsLaxwQ3ZWceJQCS9vEhzVYjKPq8k63XQqfmjoX7RmCU2VUhF5zfMtuyc2m13miw8j+MLGTnf9twxBV2tH1OTWKlniu272SyrcG6vVAbGVgA0y/P/30GwPOblgD7k4bMpZ2ZpT9eFbv0O1XelcWJTfWZhFDUGzifolxbVm1fM1qSHwbEriuQrjY/DFPzLURCBrW/v9+tGmR3r/OtCAdkx6ckSWw3HOGV6dhePLiFsvQnSFDmEQbc5+8PcLgnOYaqNiIZh8xsfPsEXb3CTSBuehmIbnUTGzjVfzhnjvTEcqkFohkrc0TlnHYV9aS2zYWgItAYKarmqsJ33jpGq90XnxUxgZQQ7FcZNk9svVc528QkqljTM/jq5NErBbN+JVFdLUJH2l1zgwCm4d5BaHc4VyAAr6rBnmEenYhwRM8RRObGWzS9RxWSzYq+fm6AvLgS2re6is8v9Vw== 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)(376002)(39860400002)(346002)(396003)(136003)(366004)(230922051799003)(1800799012)(186009)(64100799003)(451199024)(83380400001)(2616005)(6486002)(478600001)(6512007)(6506007)(52116002)(7416002)(26005)(316002)(110136005)(66946007)(6666004)(66556008)(66476007)(8676002)(4326008)(38350700005)(8936002)(5660300002)(15650500001)(2906002)(36756003)(921011)(86362001)(38100700002)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: =?utf-8?q?BTgBcRPdg9g7I7Lcyi5z1cm8gpND?= =?utf-8?q?S8e+TD9PdGuaFwXktq1KZv3L1Ki2nTR/+gMtcjZtPnNopg0U4wnyEyhJwRZJFRGGM?= =?utf-8?q?+5X2uH1L3K3bO7KecrQt1mrmrJF/Wnl91Y9E3ryS8kosFIf4D9MOJudIAhgYMpzyF?= =?utf-8?q?Ri1Ro1ohwahSxbhyx3UGv61ezkRV8Muevk0djhE5maw/Gs53G7lgem/WEVfaiCKUr?= =?utf-8?q?DmWeH7Fuf5qr3MryF4zaPreJ6xWY0suuE1OzsvTjZM74e5S3sjONWi30oyzLXeM5k?= =?utf-8?q?SyvDA5i9na0sQwsmR0GPIIlNU9DFRB/26N2TEIK0DscG3gfUybDj8rCznRWfLhG6C?= =?utf-8?q?QjFMIuuEZxRsUAHuMM0EwfMiCAXMNaItTVpxNhxvIU7IytLAVHxnVYOtVyB+ZBxjz?= =?utf-8?q?Rjlb/MJeGrSaH7wr89qYhXhr6t2WzkFtOz+G/tUu/xrZoOp03n4YlGwy7WBcABF2V?= =?utf-8?q?9GzT8C8jugt1/yw+Hs82NIzu3DHh3SOJ8VO9oEfUxuLMPSbsS4hs1Hnq5awP9ri7X?= =?utf-8?q?r+gudXTv6GI3MQ7BLM0IWEeINjwZ5oudaUS2GFBtN/37bb2zowbTV2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BeL5sTBc+O+eToO?= =?utf-8?q?rFnfDMHnKtO1S8/rUsyVwh0NBLNAliu+HqOlm+1rwdfKu9P7sIvF6oZN8VPQTDAXZ?= =?utf-8?q?SWS30g/svXX1?= X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 0f326471-07af-498c-920d-08dc2cddef24 X-MS-Exchange-CrossTenant-AuthSource: PAXPR04MB9642.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Feb 2024 21:51:29.1995 (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: JE7xF6XM3252KF+jAZ6/cMGivW5g3CWheg6mrp+yWSFI3MaqiasINvtMWyPnJFTPxu9RHXHMDx18aoUd2diDlw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8837 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 | 93 ++++++++++++++++++++++- drivers/pci/controller/dwc/pcie-designware.h | 2 + 2 files changed, 91 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..5e83756492462 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,9 @@ 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() */ + dw_pcie_host_request_msg_tlp_res(pp); + ret = dw_pcie_edma_detect(pci); if (ret) goto err_free_msi; @@ -536,6 +564,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 +730,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 +765,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 +872,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 +931,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..9e6076aa4c850 100644 --- a/drivers/pci/controller/dwc/pcie-designware.h +++ b/drivers/pci/controller/dwc/pcie-designware.h @@ -341,6 +341,8 @@ struct dw_pcie_rp { struct pci_host_bridge *bridge; raw_spinlock_t lock; DECLARE_BITMAP(msi_irq_in_use, MAX_MSI_IRQS); + int msg_atu_index; + struct resource *msg_res; }; struct dw_pcie_ep_ops {