From patchwork Wed Aug 19 21:10:02 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jay Cornwall X-Patchwork-Id: 7040611 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 3AA4D9F372 for ; Thu, 20 Aug 2015 03:42:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 33A98204B5 for ; Thu, 20 Aug 2015 03:42:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id F1CA220499 for ; Thu, 20 Aug 2015 03:42:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1750867AbbHTDm1 (ORCPT ); Wed, 19 Aug 2015 23:42:27 -0400 Received: from mail-bl2on0056.outbound.protection.outlook.com ([65.55.169.56]:46806 "EHLO na01-bl2-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750791AbbHTDm0 (ORCPT ); Wed, 19 Aug 2015 23:42:26 -0400 X-Greylist: delayed 5525 seconds by postgrey-1.27 at vger.kernel.org; Wed, 19 Aug 2015 23:42:25 EDT Received: from BLUPR02CA050.namprd02.prod.outlook.com (10.160.23.168) by BLUPR02MB1123.namprd02.prod.outlook.com (10.163.79.149) with Microsoft SMTP Server (TLS) id 15.1.243.23; Thu, 20 Aug 2015 02:10:17 +0000 Received: from BL2FFO11FD044.protection.gbl (2a01:111:f400:7c09::112) by BLUPR02CA050.outlook.office365.com (2a01:111:e400:8ad::40) with Microsoft SMTP Server (TLS) id 15.1.243.23 via Frontend Transport; Thu, 20 Aug 2015 02:10:17 +0000 Authentication-Results: spf=fail (sender IP is 165.204.84.221) smtp.mailfrom=jcornwall.me; jcornwall.me; dkim=none (message not signed) header.d=none; Received-SPF: Fail (protection.outlook.com: domain of jcornwall.me does not designate 165.204.84.221 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.221; helo=atltwp01.amd.com; Received: from atltwp01.amd.com (165.204.84.221) by BL2FFO11FD044.mail.protection.outlook.com (10.173.161.140) with Microsoft SMTP Server id 15.1.249.14 via Frontend Transport; Thu, 20 Aug 2015 02:10:16 +0000 X-WSS-ID: 0NTCZD3-07-UKW-02 X-M-MSG: Received: from satlvexedge01.amd.com (satlvexedge01.amd.com [10.177.96.28]) (using TLSv1 with cipher AES128-SHA (128/128 bits)) (No client certificate requested) by atltwp01.amd.com (Axway MailGate 5.3.1) with ESMTPS id 2339BCAE7D4; Wed, 19 Aug 2015 22:10:14 -0400 (EDT) Received: from SATLEXDAG02.amd.com (10.181.40.5) by satlvexedge01.amd.com (10.177.96.28) with Microsoft SMTP Server (TLS) id 14.3.195.1; Wed, 19 Aug 2015 21:10:17 -0500 Received: from jcornwal-tn.amd.com (10.180.168.240) by SATLEXDAG02.amd.com (10.181.40.5) with Microsoft SMTP Server id 14.3.195.1; Wed, 19 Aug 2015 22:10:14 -0400 From: Jay Cornwall To: CC: Jay Cornwall Subject: [PATCH RFC 1/1] PCI: Add pci_enable_atomic_request Date: Wed, 19 Aug 2015 16:10:02 -0500 Message-ID: <1440018602-4212-2-git-send-email-jay@jcornwall.me> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440018602-4212-1-git-send-email-jay@jcornwall.me> References: <1440018602-4212-1-git-send-email-jay@jcornwall.me> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-Matching-Connectors: 130845102170432136; (e7ef7234-5c8a-4f15-dc4e-08d10970e660); () X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11FD044; 1:SnPQB77WwnMhjNGw2i2DWkq/9iIGXEAgN9axgpICpTOmBErNnOZzdCXgEYrqRGObamj/nnh646eydUA5z+LWnxsyHTxIy7WuIPKN5ZDPIc2Co1HgbIgzERAmOWeg1ho/RY3uUQIAIDO4UWsyNsffTFqBDQS1y/4U/gOf2FAK9RXji64U1xcmOk2oK6PjVS8paYh9wTkOlxn9zIk0XpeISFXDi73nKxtCWjre+KgAwt0OG97R4LenMmX48J2aWGdihmTsyR0eEDJH0EzrDwAMXARo98EPqEd60OWbkA/MkAGO7UfuClivzgjcpqILwGi7QG0BCubCY0H5gMLOeCxGUbMmjLgaxlwClXkxMTvN+e26j8wWiqvRArf01H5iPwvPapta9xL9IbXKVHGWAQ4t6kZ038vd0+4W2GscA6943ao= X-Forefront-Antispam-Report: CIP:165.204.84.221; CTRY:US; IPV:NLI; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(2980300002)(339900001)(3050300001)(199003)(189002)(33646002)(64706001)(87936001)(86362001)(47776003)(50226001)(76176999)(85426001)(5007970100001)(50986999)(189998001)(4001540100001)(97736004)(5001830100001)(110136002)(5001860100001)(229853001)(53416004)(77096005)(19580405001)(48376002)(77156002)(5003940100001)(50466002)(5001920100001)(19580395003)(62966003)(2950100001)(36756003)(105606002)(106466001)(92566002)(46102003)(74482002)(68736005)(2351001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:BLUPR02MB1123; H:atltwp01.amd.com; FPR:; SPF:Fail; PTR:InfoDomainNonexistent; A:1; MX:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB1123; 2:obOjgzFp5W+yIJRjqfUNzu857RfkIH/D+sQt4/Br2uboD7k9bIr0er5T6f/9DS9TkguBQO12xnEgI75mUuNtixIoWRbiHZA5ZcGUFQi6b0PR3sWDGANd/O5fKSCKaTNciD4ZuUjdfqjf8JRnuME0mIrEYbPu2Dxut4MLmHLobyI=; 3:W2/WXqgfXFhP4O7mh3VBXd8T/Qf84R9OOd7xM/fDpN9dJ9nhNs/ybvZ2+y4FVZ+buMExFvfIXCI3etpR+RlKc/OVnTxap0MqtUXCcArT4ramUtUR4pXeYAlN6yY6wp/xHtBbXn8eAgG6ssZcffmyyfi9uxFsP2GU8ysDfmK3/Kcl2BQCUt7WQWAHdLFh3h9uo5IpS0RCF14ttBy2XxlUZN/eIVbVOucoFnluFxOr9csSCAZbxVQ4idRMJrC9iX/4; 25:OkTzhzuTjF+H6kEFvjGXYlzYB9jd1UoxpsRk/8vLSOJCxoHUDCB6aSRiPoQbLFTNzXitaKi6hwz/whUSNTXiepHAmbfIoYi6QqvMi8OwW65YBBOyw4cConBHMdv/aet3fAx7q7zeTyLA7j1DknyJH/ByVZQ1TcHDbYwkjdxDaTeQea2NN6UycV+92EAckujvNGYl1Rx1K18EhHUdYtRLtd3QPneieYhsYBV0WQQGLSoxa6WcOSxfcP7XNr+hNpei X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:BLUPR02MB1123; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(601004)(8121501046)(5005006)(3002001); SRVR:BLUPR02MB1123; BCL:0; PCL:0; RULEID:(400006); SRVR:BLUPR02MB1123; X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB1123; 4:lGuJN+GUhVsWRlXKenEVqr+lQmZucsquwJ4kssQkTIpDSt96k2MoHUjJEM3bbbW2smcq+kAtTrDpjNEXFRegx7Q2soT+1FpExk+S16gx7KVNKQo2cpWNtVzaDT9ZsUS/lap0GmV4LEiiJvZZBiXLYe75BcozyRZ33cjZXKuo/60VLICCkZEBq0Zk1KEExWafz1F1NTM4MCUjWVqCqB4zhHY85lQE1JNEJuNIwK8GT1e8NsxfpPWl1AkTnfLPR3wntUSMyJtq0zTW0t81dEVl52WFJYUJnnq8ciLV48KE6H9Q61S74q3iWeGgbqDDP3dW X-Forefront-PRVS: 0674DC6DD3 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR02MB1123; 23:COhcEqPOL+/TbF0PJ+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5S951ra8eLOTP7LNXQVBhPH7X+DWZ8Vrbn42H5ERmXMeYLHCKNuC6JQZe5?= =?us-ascii?Q?H71ZBQB8oUp4WnyavR4pHnCc+grinwyBHwWg3OoPT1xm8Zihklo1a/XEOJx+?= =?us-ascii?Q?uLOME+MwgQXIjf/dGp+kZhtp9MqIp03SQZkFg8JNmz/RuwymfrUYL9VC7SDW?= =?us-ascii?Q?nzBLQmqQfHfEyZ1MrJXsZ46cD3G9H2kEB8FwsrhpsUmewSZlsHBRXBXQa6NU?= =?us-ascii?Q?rmFPr8yLmDrab3ZirNQs3AZSuEN7WgSo6zQL1PQ6tYqCgCR5URCHw=3D=3D?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR02MB1123; 5:v5hBJG+SeU0BUSAKJYqw3zGwLB4xQKHjtdC7ln5yTH3ae/9vg5E1+V2wSKZj76MY68iRfpOkHCmt2cdngaxX4+lFi+zO95Uvn7GIjCG1FwWgwXJ0rL+XJq5z9nTI7EhRgVI/hSmU65XpqhIJouCiILRFJ5S+Y3JmdJ/Q/g1nEvo=; 24:T4jGu0QNOw8842fuG8yjP0SUruWU2irCcOfVeVRYc4mnc4FpiPdWM6TzXIgVahlJZJVw0LjRUdN558bOvEe7G24bgwWMk8lKcd/jw610P7g= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-MS-Exchange-CrossTenant-OriginalArrivalTime: 20 Aug 2015 02:10:16.9652 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[165.204.84.221]; Helo=[atltwp01.amd.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR02MB1123 Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-5.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_03_06, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Allow individual drivers to control AtomicOp Requester PCIe 3.0 capability. This is a no-op on devices which do not support AtomicOp requests. Signed-off-by: Jay Cornwall --- drivers/pci/pci.c | 23 +++++++++++++++++++++++ include/linux/pci.h | 1 + include/uapi/linux/pci_regs.h | 1 + 3 files changed, 25 insertions(+) diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 0008c95..1b9d1a9 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -2410,6 +2410,29 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) } /** + * pci_enable_atomic_request - enable or disable AtomicOp requester + * @dev: the PCI device + */ +void pci_enable_atomic_request(struct pci_dev *dev) +{ + if (!pci_is_pcie(dev)) + return; + + switch (pci_pcie_type(dev)) { + /* PCIe 3.0, 6.15 specifies that endpoints and root ports are permitted + * to implement AtomicOp requester capabilities. */ + case PCI_EXP_TYPE_ENDPOINT: + case PCI_EXP_TYPE_LEG_END: + case PCI_EXP_TYPE_RC_END: + case PCI_EXP_TYPE_ROOT_PORT: + pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, + PCI_EXP_DEVCTL2_ATOMICOP_REQ); + break; + } +} +EXPORT_SYMBOL(pci_enable_atomic_request); + +/** * pci_acs_path_enable - test ACS flags from start to end in a hierarchy * @start: starting downstream device * @end: ending upstream device or NULL to search to the root bus diff --git a/include/linux/pci.h b/include/linux/pci.h index 8a0321a..946c3ce 100644 --- a/include/linux/pci.h +++ b/include/linux/pci.h @@ -1750,6 +1750,7 @@ void pci_request_acs(void); bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags); bool pci_acs_path_enabled(struct pci_dev *start, struct pci_dev *end, u16 acs_flags); +void pci_enable_atomic_request(struct pci_dev *dev); #define PCI_VPD_LRDT 0x80 /* Large Resource Data Type */ #define PCI_VPD_LRDT_ID(x) ((x) | PCI_VPD_LRDT) diff --git a/include/uapi/linux/pci_regs.h b/include/uapi/linux/pci_regs.h index 413417f..d2d2e8d 100644 --- a/include/uapi/linux/pci_regs.h +++ b/include/uapi/linux/pci_regs.h @@ -578,6 +578,7 @@ #define PCI_EXP_DEVCTL2 40 /* Device Control 2 */ #define PCI_EXP_DEVCTL2_COMP_TIMEOUT 0x000f /* Completion Timeout Value */ #define PCI_EXP_DEVCTL2_ARI 0x0020 /* Alternative Routing-ID */ +#define PCI_EXP_DEVCTL2_ATOMICOP_REQ 0x0040 /* Allow AtomicOp Requests */ #define PCI_EXP_DEVCTL2_IDO_REQ_EN 0x0100 /* Allow IDO for requests */ #define PCI_EXP_DEVCTL2_IDO_CMP_EN 0x0200 /* Allow IDO for completions */ #define PCI_EXP_DEVCTL2_LTR_EN 0x0400 /* Enable LTR mechanism */