Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933023AbbLGXWv (ORCPT ); Mon, 7 Dec 2015 18:22:51 -0500 Received: from mail-bn1on0071.outbound.protection.outlook.com ([157.56.110.71]:6399 "EHLO na01-bn1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932589AbbLGXWt (ORCPT ); Mon, 7 Dec 2015 18:22:49 -0500 Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=David.Daney@caviumnetworks.com; Message-ID: <566614C2.1030705@caviumnetworks.com> Date: Mon, 7 Dec 2015 15:22:42 -0800 From: David Daney User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 MIME-Version: 1.0 To: Bjorn Helgaas CC: David Daney , , Bjorn Helgaas , , Will Deacon , Rob Herring , Pawel Moll , Mark Rutland , Ian Campbell , Kumar Gala , , , Marc Zyngier , David Daney Subject: Re: [PATCH v2] PCI: generic: Add support for Cavium ThunderX PCIe root complexes. References: <1442967415-13595-1-git-send-email-ddaney.cavm@gmail.com> <20151207224314.GE14429@localhost> In-Reply-To: <20151207224314.GE14429@localhost> Content-Type: text/plain; charset="ISO-8859-1"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [64.2.3.194] X-ClientProxiedBy: SN1PR0701CA0042.namprd07.prod.outlook.com (25.162.96.52) To SN1PR07MB2144.namprd07.prod.outlook.com (25.164.47.14) X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2144;2:JjIF3TBVdtZNAcgk1O1/MUEOn7K1VQwjtJSCVKzn0jDRxoFE7ydJAdGqogQ3zU9KCtEL5kSVyKWKIfqWV0MuXO4KlFXnzbtLdSBibmibS1qwtJuot6e2gEDRfruR7vskeq0gctV2+zoAfsV3YbyySA==;3:kCFhnVoNzgrWWauKGW5yf0vxHywTXAHv/VHwpAdtGEIfgY+ZRTC6vU29zMrv/47DNn3AWAHytZ+/q1fI2LrYgI091hhelXZsspmGelkC2Ggp6H154mbR2+pk3g5TX6Q4SKcYD2wjMVadLTlYQ7SC5hloQhKlipyL9+qj+cEckgmho1UsRYvesl5uOOGYcKpA;25:1LyKzyF+l26Pq2unBa1tK5N039v3VAj1SvUf6YZzhlWwmB/dJhhEOsej9PMT1o0PcC6KD22l1qBtYwCsShRCRzNWLMtp0NNDRqJbkR/Ye9Fz5ZtaUPA/LoOHU99V5Hlm8t8r/Vxak3L6ogUuTWLYFYCY7wtzgL4yk/jJ7sxooIGoozliCzY9TsYAGUNxyku3+nhtdhULhE7cUc9/p99rGhHjbCy24UPomfofGdvDvqnuwEE1Ygvvzb7lRwaxR/DjDI8zPeZjCYXuYwTlMP4viA== X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(42134001)(42139001);SRVR:SN1PR07MB2144; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2144;20:ICpOZTfhtKDSQO111F6qpuyMWbVB8hakfw21y111NahooH8snJtNuxHPpsyawK15uMJZK1RGIvx2DdQNVhN8XVD6QlPFuGJlPOQ25gVo4eXrphGpWoq+j+ZRPyjj9GJS+BB9JFU803lCcBnpWBAHimB80MKi7pr8M5hrn065I5Ldbb6J9Nda7QAAB+eekWyvoDSIszCZAyOqJZbxiRhZtmkfHuGC4oD4nseKizPZEH8ulGLj5sUGPgH0jcDVTpz+rzGlsaGyGd9NpEDf5tIMw4rdMndo5StVwV8h58n/Z0E2+iuS9DOGXk4z9yf/o0h02j1BWkSQ0EpoP4ba7Lz7tCw73WVLcSn2s3lkOaFO3aatsanAquHHMtNc0MIZLA3+0cQInNCW/bGRCiGgaykRD5Z+WxmtISjcYO5EtTK81850CU4euRY6rPg8kY4w9qcPyAnR7l88TTKUrTyd7X4qzZTrkK/22mrMZJ421+zcP/If9gue0Wip3J2xugXL/cWsZhE2Y/oaVRJY+voIFLBv7nDWO6a9WWgZwqaQdm0aFn1eH8gFfNMFoakBPlKNHTG2/HYXtM17X/BWxrOx+7WUaqJh0coXyTrIVl5KxiwXr0o= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(180628864354917); X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046);SRVR:SN1PR07MB2144;BCL:0;PCL:0;RULEID:;SRVR:SN1PR07MB2144; X-Microsoft-Exchange-Diagnostics: 1;SN1PR07MB2144;4:8j4Qov5yJfIupdlPyUDXL/mJITBDsj107TkT4l7fUd+90EFCKmDzWYtatAnSBQkJqCDfu3FW2IArMnPQ8X2c84siuUIkaXvouh5DVZUd/9zV6iO8PW4y7pr4Acmni5Xjo6M/qkSA9m06nb716wPo1gbth2rQZV6BrW5u2bbXfBUq/iKHTq2Gw7yn7dwuFGVbT/zJ6GrKmW3g22ozh4dckF203FJBXye9Gd+49Qzkp6yl+B6vEIcs3athBmdDuDp+ieCF+EYfeJU4NePhSdkjIJI1kkxj4S+sirSW/D8GnEecf4+h1zYOAqn607IL90PE/K1y+3oJY6Wa+QA2SS+a678ofvs3K+ds6AzbVw2ximNp0UwDfUAv5/CK6EnIE2K6kpo/io8G6ttolJY00CleLSrn3572HCRbJkGpNp2fXYqgd9K9E3SfpRmX2nZToJti X-Forefront-PRVS: 078310077C X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10009020)(6009001)(164054003)(199003)(479174004)(51914003)(377454003)(189002)(24454002)(80316001)(65816999)(5004730100002)(6116002)(47776003)(40100003)(50466002)(3846002)(33656002)(586003)(122386002)(1096002)(106356001)(101416001)(105586002)(77096005)(59896002)(15975445007)(2950100001)(69596002)(189998001)(42186005)(19580395003)(65956001)(5001960100002)(50986999)(87976001)(65806001)(4001350100001)(76176999)(97736004)(53416004)(81156007)(92566002)(83506001)(64126003)(66066001)(87266999)(54356999)(99136001)(36756003)(110136002)(5008740100001)(23756003)(19580405001)(575784001)(230700001)(41533002)(422495003);DIR:OUT;SFP:1101;SCL:1;SRVR:SN1PR07MB2144;H:dl.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: =?iso-8859-1?Q?1;SN1PR07MB2144;23:ByAOf2s2gPeYOxnWDduPLGwbOM8apOtpYBQS7bB?= =?iso-8859-1?Q?5WNNp8oZ/3g2XhgLMQduW09jRZQt9UjElmEK0D4z3JX5L2zIT6le0pRnew?= =?iso-8859-1?Q?pdXsGCgARZrvVr9zAfFRfH6hnMoXRoe0+TbvUumlkdwOs4PPIp5ZaUKdwU?= =?iso-8859-1?Q?QtyQVmwCLJ7CwGIDh2EoDuoKqUJk6c/REEY/9O3PhEGgtza+LJp057btTJ?= =?iso-8859-1?Q?heo7po00ZrqJu5fzq+JWDJDOCgxnpx8E4mwSIHROMrxn5oA8m+vS+24gVf?= =?iso-8859-1?Q?z8zaVPqTKRONI9FMF29UjuhamC5IxOeUPlv4n6ii/bhVUC7ZrL96qPaEC0?= =?iso-8859-1?Q?A+1ZZnmnLRPxRWvsINUJNgayvabMZl65QQAO/AhpwnMjeQDiffBwRO1/7N?= =?iso-8859-1?Q?0Y25YM9me0nGokewejv0qPjKKIFYFg29I6Dvf1Pa3qrvqtffzOknPV9DF7?= =?iso-8859-1?Q?R+1/Rr3RCOzgsgvt13S6RWchXnC3n6ceWefpUZuv00WXukjgjkdqlAUmm5?= =?iso-8859-1?Q?fJ1CnsO8MbVvnUae5pDAGlBB8X5i68haEe5tHiaRyJKXZqW/AAVTGlgg9A?= =?iso-8859-1?Q?gTtiCP+lsvWHT4iNZjQsQMgV3V4XP5m4MBwbeHWNAAiVWceneMJSy/jDJ5?= =?iso-8859-1?Q?8fZNDsZ3TZe1BLY15wnIvXjqfrQdn5gNTFjc0y39nsVSkyp/hOPBwiAHxT?= =?iso-8859-1?Q?MTlUPYLASV7IkqtNRnJEczaz1Inso8GjgEdIQPpTncTs1JmAPlU7hLf5lg?= =?iso-8859-1?Q?DfKvlPe4k+hzYNEU6nmCtjrxvONrT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QKBDqjQbcV+JbMwZmMFyL5iiOg2ScgzoEMQXNfN0FIlg2Q1Kkrg99tow0NO673X4ZvICX1nNZrpoCtfwKnCZBXRhaE4HYdmERd208+N0= SpamDiagnosticOutput: 1:23 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 07 Dec 2015 23:22:45.3154 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN1PR07MB2144 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5178 Lines: 138 On 12/07/2015 02:43 PM, Bjorn Helgaas wrote: > Hi David, > > On Tue, Sep 22, 2015 at 05:16:55PM -0700, David Daney wrote: >> From: David Daney >> >> The config space for external PCIe root complexes on some Cavium >> ThunderX SoCs is very similar to CAM and ECAM, but differs in the >> shift values that have to be applied to the bus and devfn numbers to >> compose that address window offset. These root complexes also have >> the interesting property that there is no root bridge, so the standard >> manner of limiting scanning to only the first device doesn't work. We >> can use the standard pci-host-generic driver if we make a minor >> addition to handle these differences, so we... >> >> Add a mapping function for ThunderX PCIe root complexes with a bus >> shift of 24 and devfn shift of 16. Ignore accesses for devices other >> than the first device on the primary bus. >> >> Document the whole thing in devicetree/bindings/pci/host-generic-pci.txt >> >> Signed-off-by: David Daney >> Acked-by: Will Deacon > > I'm trying to sort the ThunderX stuff out. Can you repost the current > stuff so we can see it all together? > Yes, I will post something soon. Let's not merge this version. There are more improvements that I want to make. We are working through how to cleanly implement the use of both pci-host-generic when using OF device tree as well as the ACPI root complex code when ACPI is in use. Ideally the same config accessor functions would be used in both cases. Thanks for the follow up, David Daney > Thanks, > Bjorn > >> --- >> >> This patch depends on: >> https://lkml.org/lkml/2015/9/22/1189 >> >> Changes from v1: >> >> - Added Acked-by: >> >> - Removed two patches from the set that were somewhat unrelated. >> >> .../devicetree/bindings/pci/host-generic-pci.txt | 8 +++--- >> drivers/pci/host/pci-host-generic.c | 29 ++++++++++++++++++++++ >> 2 files changed, 34 insertions(+), 3 deletions(-) >> >> diff --git a/Documentation/devicetree/bindings/pci/host-generic-pci.txt b/Documentation/devicetree/bindings/pci/host-generic-pci.txt >> index 105a968..a5aed0f 100644 >> --- a/Documentation/devicetree/bindings/pci/host-generic-pci.txt >> +++ b/Documentation/devicetree/bindings/pci/host-generic-pci.txt >> @@ -14,9 +14,11 @@ tree bindings communicated in pci.txt: >> >> Properties of the host controller node: >> >> -- compatible : Must be "pci-host-cam-generic" or "pci-host-ecam-generic" >> - depending on the layout of configuration space (CAM vs >> - ECAM respectively). >> +- compatible : One of the following with bus:devfn:reg mapped to the >> + PCI config space address window in the bit positions shown: >> + "pci-host-cam-generic" -- 'CAM' bits 16:8:0 >> + "pci-host-ecam-generic" -- 'ECAM' bits 20:12:0 >> + "cavium,pci-host-thunder-pem" -- bits 24:16:0 >> >> - device_type : Must be "pci". >> >> diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c >> index b163fdc..853f6f6 100644 >> --- a/drivers/pci/host/pci-host-generic.c >> +++ b/drivers/pci/host/pci-host-generic.c >> @@ -91,6 +91,32 @@ static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = { >> } >> }; >> >> +static void __iomem *gen_pci_map_cfg_bus_thunder_pem(struct pci_bus *bus, >> + unsigned int devfn, >> + int where) >> +{ >> + struct gen_pci *pci = bus->sysdata; >> + resource_size_t idx = bus->number - pci->cfg.bus_range->start; >> + >> + /* >> + * Thunder PEM is a PCIe RC, but without a root bridge. On >> + * the primary bus, ignore accesses for devices other than >> + * the first device. >> + */ >> + if (idx == 0 && (devfn & ~7u)) >> + return NULL; >> + return pci->cfg.win[idx] + ((devfn << 16) | where); >> +} >> + >> +static struct gen_pci_cfg_bus_ops gen_pci_cfg_thunder_pem_bus_ops = { >> + .bus_shift = 24, >> + .ops = { >> + .map_bus = gen_pci_map_cfg_bus_thunder_pem, >> + .read = pci_generic_config_read, >> + .write = pci_generic_config_write, >> + } >> +}; >> + >> static const struct of_device_id gen_pci_of_match[] = { >> { .compatible = "pci-host-cam-generic", >> .data = &gen_pci_cfg_cam_bus_ops }, >> @@ -98,6 +124,9 @@ static const struct of_device_id gen_pci_of_match[] = { >> { .compatible = "pci-host-ecam-generic", >> .data = &gen_pci_cfg_ecam_bus_ops }, >> >> + { .compatible = "cavium,pci-host-thunder-pem", >> + .data = &gen_pci_cfg_thunder_pem_bus_ops }, >> + >> { }, >> }; >> MODULE_DEVICE_TABLE(of, gen_pci_of_match); >> -- >> 1.9.1 >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-pci" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/