Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1277633
| Path | csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod |
|---|---|
| From | David Daney <ddaney@caviumnetworks.com> |
| Newsgroups | linux.kernel |
| Subject | Re: [RFC PATCH] PCI/pci-host-generic: Add support for Cavium Thunder fixed BARs. |
| Date | Wed, 25 Nov 2015 18:30:03 +0100 |
| Message-ID | <qyM3h-RQ-27@gated-at.bofh.it> (permalink) |
| References | <qdRqW-7CL-5@gated-at.bofh.it> <qyLJV-K2-13@gated-at.bofh.it> |
| X-Original-To | Bjorn Helgaas <helgaas@kernel.org> |
| Authentication-Results | spf=none (sender IP is ) smtp.mailfrom=David.Daney@caviumnetworks.com; |
| User-Agent | Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130625 Thunderbird/17.0.7 |
| MIME-Version | 1.0 |
| Content-Type | text/plain; charset="ISO-8859-1"; format=flowed |
| Content-Transfer-Encoding | 7bit |
| X-Originating-IP | [64.2.3.194] |
| X-Clientproxiedby | DM2PR07CA0027.namprd07.prod.outlook.com (10.141.52.155) To BN4PR07MB2129.namprd07.prod.outlook.com (25.164.63.11) |
| X-Microsoft-Exchange-Diagnostics | 1;BN4PR07MB2129;2:UyOGmTYqn3l0sa8ZRPDCN8PgZ3fQymP8jqnpADmnTCFMjXZmv7c1vvELWP4r2OUr4VJy2TjhKKV8IczMXlZrJ34xBRnLMDIZOwoSQqu03bs3UfKsZAIssE1jY4AmjxatuojUjRaCwl4WToooi+GXsA==;3:PAMTo9D8MMhW9t8eh/EmH7KL5wTraEibQhIokbsxtBPXZ1K0CLgICriqNWc7nGYBxHrmGhGC099Nqti6DygafDjCF0mmapr715634rQY491a2+2JsbS0v9BcW6NCg7lOOIOX5zT24AJ4OgiDgpLmOSZvIfIsuxlkUT/ScX9m5V9OyG3cMwh1RuA1C2GRRAaa;25:ltNEPQm/PO80mlC0itycKCpreo7cZwet10dj5QsEikrIQh5kOYuCkNpUixjXIgwTbtmuVfTutyghwoN2Uuwa0lTTYM7AKIsvfRU3lMAO/bcPlWHu6MnpTi4ZYNHg6tvRUS+SwXFQBtC9eBMOVvuZ7v2rCKYbqDsjUupjrdpaAxShiug4eT2tNAleSCMhr8PgUcav5WwTj6stGdDzCWYPFZyPr97nE0fLvfjch+qWPztggtD3RdYl03xUjPVrrgAVyD3008/YO9KMrrUI5snWPA== |
| X-Microsoft-Antispam | UriScan:;BCL:0;PCL:0;RULEID:(42134001)(42139001);SRVR:BN4PR07MB2129; |
| X-Microsoft-Exchange-Diagnostics | 1;BN4PR07MB2129;20:1U2vFATjDcptHD9YpP3vrDzXEpLK/443onGVqag5y0TrzbS4lj3mQNdvsgR6MSP0MuCXkPkw8dslyvj+4uUjaa6f+5oaEMzTj3cS0dnjt8aYPsd6wqM5vp8t3ZDUo1kPpMYMfTin6wYxT+UNboZX+pjuQbc5gX/AHTJdrqVrseDAggRRG8KuGjvCMg8ma6XlicR64y90dKRvcs7WrKMSfI3ZR7GVVXwvLuMF5Si0PIlAMEkPZBAX8sgQAlNWje0n6aV8MDe+IbweByWyvHT7cyZXxJpmp/Ns8EuyahuPPgG/AZWUDl/Gxaw8ogCTOVy92XCz/nmrPMkE4aHqwKslOCz26NdhHgbP9oPDQK5wX/Qt1bhbdiux3NEgugMKk97lMkyBU71Lxe/X1Kcqc8yGl0wPouYWSSVOWx/uvZgHcnU/ySSRuF7jGR+X8ML1271lfDP+hUq1RSZEkhLii+7lH693ZdFEiL48ZdKHCHaO3L44/5iHcLrkpv4G6x2MAwO9yyt2LD3CgXM+IJtRc7jGZ0LVZ51O5yqmHz98wcNP1qSffkhEOHKSJGW07BFe+VXEJKZZRAZu8LE7IvPPvinUA08Zr9s9OfiHaFKB8rej9Ko= |
| X-Microsoft-Antispam-Prvs | <BN4PR07MB2129BF69B532CC55C98296229A050@BN4PR07MB2129.namprd07.prod.outlook.com> |
| X-Exchange-Antispam-Report-Test | UriScan:; |
| X-Exchange-Antispam-Report-Cfa-Test | BCL:0;PCL:0;RULEID:(601004)(2401047)(5005006)(520078)(8121501046)(3002001)(10201501046);SRVR:BN4PR07MB2129;BCL:0;PCL:0;RULEID:;SRVR:BN4PR07MB2129; |
| X-Microsoft-Exchange-Diagnostics | 1;BN4PR07MB2129;4:8ov7N/fOTof+jhQICqvDdjIEZG/L+6FkfSrOpqhz1LR4hqY2IslYJV2O8sWRwFUuf7QVTj7J2gTu+icMHD8FIBybxqWzTdFRDozbuJs+7cG+EwwRfeYQ33TPVUg9AtD69TBlv1J4+mQ0FHG/eNJrt/3ohiDba5YulroANugjVdNYps2riTx2h/9mTPqNnNZsWP13csMO4o18khqesVXJ6tqL4C/TAJhUGORhUqKt6xb08J/OS/O94uT/wpaq25aU8JPXL1eiGNiOsPj0kftJBPAMG80zNhH9fbfVLdgzAm24zSpSHesYLd5s53WoYDG8owdjDCjnIM+cnhClSxCBqL6uAR0mq9MrM17Yo1vu8LloJ/eJ3G4JJKZACYNmEX5Q |
| X-Forefront-Prvs | 0771670921 |
| X-Forefront-Antispam-Report | SFV:NSPM;SFS:(10009020)(6009001)(189002)(377454003)(52604005)(479174004)(199003)(24454002)(83506001)(40100003)(586003)(87976001)(76176999)(65816999)(122386002)(69596002)(54356999)(101416001)(80316001)(19580395003)(19580405001)(87266999)(33656002)(50986999)(3846002)(6116002)(5007970100001)(50466002)(5004730100002)(92566002)(36756003)(47776003)(66066001)(230700001)(65806001)(77096005)(2950100001)(15975445007)(65956001)(64126003)(106356001)(23756003)(5008740100001)(230783001)(59896002)(105586002)(53416004)(97736004)(110136002)(42186005)(5001960100002)(189998001)(5001920100001)(81156007)(4001350100001)(41533002);DIR:OUT;SFP:1101;SCL:1;SRVR:BN4PR07MB2129;H:dl.caveonetworks.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; |
| Received-Spf | None (protection.outlook.com: caviumnetworks.com does not designate permitted sender hosts) |
| X-Microsoft-Exchange-Diagnostics | 1;BN4PR07MB2129;23:LpPO34mgebSXMW1dN2CBsNLHaQtR52NJ/pvkPC9vO3W/Qd0RxtJXYw6Ej7PTXh+fnUSo6fN4juX6JQhQnyon5fLiWVWLNIQCgXS0kN8doCqwLsrS+jeMSNaUrBBWVXkDQ5qd2OGSwP8TmU9k7v7qMnLxTO1eAL8qGgcZYMmO2VpKlxc/ywX0l+vkSkxVbBhb60cS4CEHZ78r+xAvS5h2ELYLqWO3Azz7QwilOlTvGqo0klL/c7nUb14E5UIb/pM40BbxUqboOGe3YpRP/hhoMGDq/+aNtsOyaUDdxQQaOrQpvwmSHOP5ETU5FjTKtsmbtzsPuxq8C/jDbqsFwAeYOWUVyIOWP7GACOYuskFkA+aUGVIRsBTu1Y8+VuB4FursmIVuMGm83taXsqG8xC1ei3KXvDywSYahDxlSKBU7HYJtiOA+wxjS3moyXWknMf+Xu/svtL/8Ufm3QpYHnWFegszFf6oz5x+35hIKUcaOwP1/Ihe+FPuNUyjKWIotOVCWJ3x3lBtod1Up8/xEIZzaamaaLeJBnFalZxXDsbRC4Az0LhgBlOauRw1xWmPr8kbyzCd4yJ49UOeOVyZdWmVeuZWbAA1XN/4JKAwhfjfsC68wumKZnI9VLcrYmaltX2nZ5V/xCVM00J24MLtTyv9QE4tRq/il2fqb3IxhMA/Rh8xQdU7gBC9J/V9+ORPmX8ilUe25w4Pdqht3+DkVVUI3iDxBGgRFikG2rw7gEWdqXRlhL289PeRjm+0CTxe3keKq+bT475D9hQ2bztTZkFPFHE+g8WNt5KzUxdlQbnygYmyoOWD7jL9Ii6VXX4XtugcdAvygQiTskaNU0sa/8giWkmclhxGcM6FP8HmUlA9ZP05aGfZr5HOiPZnnmNvud4mIhBd4GvvBsr/qPwOWKA46nw0jOxE5HTaWqS5Xz0+1dln3wigD0WpRmcyY7GLd4kf3d6yl00VD+HZOLnB2K75+CBZ5DoLTxa4yJr4Xz83xCFDGVgH/MazgMviNJluChH9SRTpi7Fwi4mmUTEJO0CDAHLwjzbdDHyfT0FtMT9nRtDPx+TlcDm/KypjLQA4BjJmtMGLUozUCVRPuw7qzmPxfI4sANo76yFe64IPMBwwNkwMr9yhhbV6gIJYZ3ipZNkb/G8rFg/Slii2gdFlSbQPcoLdsPgLtTxdQgWITk0Bxbn5fJrmgxXiMFWVdgo5Wuhs08SwwOBlVw+WKxo5F0BV7nDGF39+kaKVlUSNJU7SpWBnP8QcFMLExm/rUVD+jKYSeBhhFg/xsuAYgmlSuJ2Gc8gAY6SVTBJme/88y7gaORDMZv/VQPxNvsUthIplCknKkVzfB8O5ij04+whvqLXSaL+S9gJjSZ8A3WZMz8IfyoSKRYOO+NcQGMzwRgVxcVabKQxzZUuIjB4h3gAUqjNG0kg== |
| X-Microsoft-Exchange-Diagnostics | 1;BN4PR07MB2129;5:8i9QgKYmW5ZJ4+MzUyLmitgWyVY9KHXH+jMrFRDGmEoWjWqYFhUKn0TaBNtFgcAFGwvCgCbqi6x/lSoed3yMg7wTVoSB8cjaTCylxskUGea8htQUJkS7LwmEv/PFdhW9HAY+wvn0MEFjC1hTfjL+Zw==;24:qLmFUyKcFm4exdaTq8JbVGa8okB4ZOLDCaPtCHAfxIHcVSMZ2q3qDGciI04tEM5NBpV7t5elubTmJnW4Q5yMIAcxOUImEylZSHE42iOd9RQ= |
| Spamdiagnosticoutput | 1:23 |
| Spamdiagnosticmetadata | NSPM |
| X-Originatororg | caviumnetworks.com |
| X-Ms-Exchange-Crosstenant-Originalarrivaltime | 25 Nov 2015 17:26:03.5908 (UTC) |
| X-Ms-Exchange-Crosstenant-Fromentityheader | Hosted |
| X-Ms-Exchange-Transport-Crosstenantheadersstamped | BN4PR07MB2129 |
| Sender | robomod@news.nic.it |
| List-ID | <linux-kernel.vger.kernel.org> |
| X-Mailing-List | linux-kernel@vger.kernel.org |
| Approved | robomod@news.nic.it |
| Lines | 441 |
| Organization | linux.* mail to news gateway |
| X-Original-Cc | David Daney <ddaney.cavm@gmail.com>, <linux-kernel@vger.kernel.org>, Will Deacon <will.deacon@arm.com>, <linux-arm-kernel@lists.infradead.org>, Marc Zyngier <marc.zyngier@arm.com>, Catalin Marinas <catalin.marinas@arm.com>, Bjorn Helgaas <bhelgaas@google.com>, <linux-pci@vger.kernel.org>, "Sean O. Stalley" <sean.stalley@intel.com>, David Daney <david.daney@cavium.com> |
| X-Original-Date | Wed, 25 Nov 2015 09:26:00 -0800 |
| X-Original-Message-ID | <5655EF28.1030509@caviumnetworks.com> |
| X-Original-References | <1443488184-12633-1-git-send-email-ddaney.cavm@gmail.com> <20151125170652.GC1380@localhost> |
| X-Original-Sender | linux-kernel-owner@vger.kernel.org |
| Xref | csiph.com linux.kernel:1277633 |
Show key headers only | View raw
On 11/25/2015 09:06 AM, Bjorn Helgaas wrote:
> Hi David,
>
> On Mon, Sep 28, 2015 at 05:56:24PM -0700, David Daney wrote:
>> From: David Daney <david.daney@cavium.com>
>>
>> Early versions of the Cavium Thunder CN88XX processor are missing
>> Enhanced Allocation (EA) capabilities for the fixed BAR addresses used
>> by the on-SoC hardware blocks.
>>
>> Add config access functions that synthesize the missing EA
>> capabilities for versions that are missing that information. Since
>> this is a little hacky, gate the inclusion of the code with a new
>> Kconfig variable.
>>
>> Signed-off-by: David Daney <david.daney@cavium.com>
>
> What about this one? Do we still need it?
Yes, we still need this. However ...
> This version looks like it
> still has some debug code and it feels like a lot of hard-coding of
> config offsets;
... I have a new version that removes the debugging code, and adds a
couple of corrections.
> it'd be nice if it could be more table-driven.
There is and will only ever be a single silicon revision where this code
would be needed. So, I think the hard coding is the easiest solution,
and not really any worse than a table driver infrastructure.
I will send a new version of the patch.
Thanks for looking at this.
David
> But
> maybe this isn't needed anymore anyway.
>
> Bjorn
>
>> ---
>>
>> As suggested by Bjorn Helgaas... It is RFC at this point, but this is
>> working well for me.
>>
>> Depends on:
>>
>> https://lkml.org/lkml/2015/9/28/796
>>
>> drivers/pci/host/Kconfig | 9 +
>> drivers/pci/host/Makefile | 1 +
>> drivers/pci/host/pci-host-generic.c | 22 ++-
>> drivers/pci/host/thunder_ecam_config_io.c | 273 ++++++++++++++++++++++++++++++
>> 4 files changed, 304 insertions(+), 1 deletion(-)
>> create mode 100644 drivers/pci/host/thunder_ecam_config_io.c
>>
>> diff --git a/drivers/pci/host/Kconfig b/drivers/pci/host/Kconfig
>> index d5e58ba..9f3a9cd 100644
>> --- a/drivers/pci/host/Kconfig
>> +++ b/drivers/pci/host/Kconfig
>> @@ -58,6 +58,15 @@ config PCI_HOST_GENERIC
>> Say Y here if you want to support a simple generic PCI host
>> controller, such as the one emulated by kvmtool.
>>
>> +config PCI_HOST_THUNDER
>> + bool "Extensions to Generic PCI host controller for Cavium Thunder"
>> + depends on PCI_HOST_GENERIC && ARM64
>> + help
>> + Say Y here to enable PCI config access methods needed by
>> + CN88XX Cavium Thunder SoCs. The access is standard ECAM,
>> + but Enhanced Allocation (EA) capability structures are
>> + synthesized for on-SoC devices with fixed BARs.
>> +
>> config PCIE_SPEAR13XX
>> bool "STMicroelectronics SPEAr PCIe controller"
>> depends on ARCH_SPEAR13XX
>> diff --git a/drivers/pci/host/Makefile b/drivers/pci/host/Makefile
>> index 140d66f..8b77d62 100644
>> --- a/drivers/pci/host/Makefile
>> +++ b/drivers/pci/host/Makefile
>> @@ -7,6 +7,7 @@ obj-$(CONFIG_PCI_TEGRA) += pci-tegra.o
>> obj-$(CONFIG_PCI_RCAR_GEN2) += pci-rcar-gen2.o
>> obj-$(CONFIG_PCI_RCAR_GEN2_PCIE) += pcie-rcar.o
>> obj-$(CONFIG_PCI_HOST_GENERIC) += pci-host-generic.o
>> +obj-$(CONFIG_PCI_HOST_THUNDER) += thunder_ecam_config_io.o
>> obj-$(CONFIG_PCIE_SPEAR13XX) += pcie-spear13xx.o
>> obj-$(CONFIG_PCI_KEYSTONE) += pci-keystone-dw.o pci-keystone.o
>> obj-$(CONFIG_PCIE_XILINX) += pcie-xilinx.o
>> diff --git a/drivers/pci/host/pci-host-generic.c b/drivers/pci/host/pci-host-generic.c
>> index 6f12830..64558e5 100644
>> --- a/drivers/pci/host/pci-host-generic.c
>> +++ b/drivers/pci/host/pci-host-generic.c
>> @@ -91,6 +91,21 @@ static struct gen_pci_cfg_bus_ops gen_pci_cfg_ecam_bus_ops = {
>> }
>> };
>>
>> +#ifdef CONFIG_PCI_HOST_THUNDER
>> +int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
>> + int where, int size, u32 *val);
>> +int thunder_ecam_config_write(struct pci_bus *bus, unsigned int devfn,
>> + int where, int size, u32 val);
>> +static struct gen_pci_cfg_bus_ops gen_pci_cfg_thunder_ecam_bus_ops = {
>> + .bus_shift = 20,
>> + .ops = {
>> + .map_bus = gen_pci_map_cfg_bus_ecam,
>> + .read = thunder_ecam_config_read,
>> + .write = thunder_ecam_config_write,
>> + }
>> +};
>> +#endif
>> +
>> static void __iomem *gen_pci_map_cfg_bus_thunder_pem(struct pci_bus *bus,
>> unsigned int devfn,
>> int where)
>> @@ -108,6 +123,7 @@ static void __iomem *gen_pci_map_cfg_bus_thunder_pem(struct pci_bus *bus,
>> return pci->cfg.win[idx] + ((devfn << 16) | where);
>> }
>>
>> +#ifdef CONFIG_PCI_HOST_THUNDER
>> static struct gen_pci_cfg_bus_ops gen_pci_cfg_thunder_pem_bus_ops = {
>> .bus_shift = 24,
>> .ops = {
>> @@ -116,6 +132,7 @@ static struct gen_pci_cfg_bus_ops gen_pci_cfg_thunder_pem_bus_ops = {
>> .write = pci_generic_config_write,
>> }
>> };
>> +#endif
>>
>> static const struct of_device_id gen_pci_of_match[] = {
>> { .compatible = "pci-host-cam-generic",
>> @@ -126,7 +143,10 @@ static const struct of_device_id gen_pci_of_match[] = {
>>
>> { .compatible = "cavium,pci-host-thunder-pem",
>> .data = &gen_pci_cfg_thunder_pem_bus_ops },
>> -
>> +#ifdef CONFIG_PCI_HOST_THUNDER
>> + { .compatible = "cavium,pci-host-thunder-ecam",
>> + .data = &gen_pci_cfg_thunder_ecam_bus_ops },
>> +#endif
>> { },
>> };
>> MODULE_DEVICE_TABLE(of, gen_pci_of_match);
>> diff --git a/drivers/pci/host/thunder_ecam_config_io.c b/drivers/pci/host/thunder_ecam_config_io.c
>> new file mode 100644
>> index 0000000..58c3109
>> --- /dev/null
>> +++ b/drivers/pci/host/thunder_ecam_config_io.c
>> @@ -0,0 +1,273 @@
>> +/*
>> + *
>> + * This file is subject to the terms and conditions of the GNU General Public
>> + * License. See the file "COPYING" in the main directory of this archive
>> + * for more details.
>> + *
>> + * Copyright (C) 2015 Cavium, Inc.
>> + *
>> + */
>> +
>> +#include <linux/pci.h>
>> +#include <linux/ioport.h>
>> +#include <linux/printk.h>
>> +
>> +static void set_val(u32 v, int where, int size, u32 *val)
>> +{
>> + int shift = (where & 3) * 8;
>> +
>> + pr_debug("set_val %04x: %08x\n", (unsigned)(where & ~3), v);
>> + v >>= shift;
>> + if (size == 1)
>> + v &= 0xff;
>> + else if (size == 2)
>> + v &= 0xffff;
>> + *val = v;
>> +}
>> +
>> +static int handle_ea_bar(u32 e0, int bar, struct pci_bus *bus,
>> + unsigned int devfn, int where, int size, u32 *val)
>> +{
>> + void __iomem *addr;
>> + u32 v;
>> + /*
>> + * Each entry is 16-byte aligned bits[2,3] select which word
>> + * in the entry
>> + */
>> + int where_a = where & 0xc;
>> +
>> + if (where_a == 0) {
>> + set_val(e0, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0x4) {
>> + addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> + v = readl(addr);
>> + v &= ~0xf;
>> + v |= 2; /* EA entry-1. Base-L */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0x8) {
>> + u32 barl_orig;
>> + u32 barl_rb;
>> +
>> + addr = bus->ops->map_bus(bus, devfn, bar); /* BAR 0 */
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> + barl_orig = readl(addr + 0);
>> + writel(0xffffffff, addr + 0);
>> + barl_rb = readl(addr + 0);
>> + writel(barl_orig, addr + 0);
>> + /* zeros in unsettable bits. */
>> + v = ~barl_rb & ~3;
>> + v |= 0xc; /* EA entry-2. Offset-L */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xc) {
>> + addr = bus->ops->map_bus(bus, devfn, bar + 4); /* BAR 1 */
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> + v = readl(addr); /* EA entry-3. Base-H */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> +}
>> +int thunder_ecam_config_write(struct pci_bus *bus, unsigned int devfn,
>> + int where, int size, u32 val)
>> +{
>> + /*
>> + * All BARs have fixed addresses, ignore BAR writes so they
>> + * don't get corrupted.
>> + */
>> + if ((where >= 0x10 && where < 0x2c) || (where >= 0x1a4 && where < 0x1bc))
>> + /* BAR or SRIOV BAR */
>> + return PCIBIOS_SUCCESSFUL;
>> +
>> + return pci_generic_config_write(bus, devfn, where, size, val);
>> +}
>> +
>> +int thunder_ecam_config_read(struct pci_bus *bus, unsigned int devfn,
>> + int where, int size, u32 *val)
>> +{
>> + u32 v;
>> + u32 vendor_device;
>> + void __iomem *addr;
>> + int cfg_type;
>> + int where_a = where & ~3;
>> +
>> + /*
>> + * All BARs have fixed addresses specified by the EA
>> + * capability, they must return zero on read.
>> + */
>> + if ((where >= 0x10 && where < 0x2c) || (where >= 0x1a4 && where < 0x1bc)) {
>> + /* BAR or SRIOV BAR */
>> + *val = 0;
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> +
>> + addr = bus->ops->map_bus(bus, devfn, 0);
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> +
>> + vendor_device = readl(addr);
>> + if (vendor_device == 0xffffffff)
>> + goto no_emulation;
>> +
>> + addr = bus->ops->map_bus(bus, devfn, 8);
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> +
>> + v = readl(addr);
>> + if (v == 0xffffffff)
>> + goto no_emulation;
>> +
>> + if ((v & 0xff) < 8) {
>> + pr_debug("%04x:%04x - Fix pass#: %08x, where: %03x, devfn: %03x\n",
>> + vendor_device & 0xffff, vendor_device >> 16, v, (unsigned) where, devfn);
>> + /* pass 1.x*/
>> + } else {
>> + pr_debug("%04x:%04x - OK pass#: %08x, devfn: %03x\n",
>> + vendor_device & 0xffff, vendor_device >> 16, v, devfn);
>> + goto no_emulation;
>> + }
>> +
>> + addr = bus->ops->map_bus(bus, devfn, 0xc);
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> +
>> + v = readl(addr);
>> + /* Check for non type-00 header. */
>> + cfg_type = (v >> 16) & 0x7f;
>> + if (cfg_type == 0) {
>> + bool has_msix;
>> + bool is_nic = (vendor_device == 0xa01e177d);
>> + bool is_tns = (vendor_device == 0xa01f177d);
>> +
>> + addr = bus->ops->map_bus(bus, devfn, 0x70);
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> + /* E_CAP */
>> + v = readl(addr);
>> + has_msix = (v & 0xff00) != 0;
>> +
>> + if (!has_msix && where_a == 0x70) {
>> + v |= 0xbc00; /* next capability is EA at 0xbc */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xb0) {
>> + addr = bus->ops->map_bus(bus, devfn, where_a);
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> + v = readl(addr);
>> + if (v & 0xff00)
>> + pr_err("Bad MSIX cap header: %08x\n", v);
>> + v |= 0xbc00; /* next capability is EA at 0xbc */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xbc) {
>> + if (is_nic)
>> + v = 0x40014; /* EA last in chain, 4 entries. */
>> + else if (is_tns)
>> + v = 0x40014; /* EA last in chain, 3 entries. */
>> + else if (has_msix)
>> + v = 0x20014; /* EA last in chain, 2 entries. */
>> + else
>> + v = 0x10014; /* EA last in chain, 1 entry. */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a >= 0xc0 && where_a < 0xd0)
>> + return handle_ea_bar(0x80ff0003, /* EA entry-0. PP=0, BAR0 Size:3 */
>> + 0x10, bus, devfn, where, size, val);
>> + if (where_a >= 0xd0 && where_a < 0xe0 && has_msix)
>> + return handle_ea_bar(0x80ff0043, /* EA entry-1. PP=0, BAR4 Size:3 */
>> + 0x20, bus, devfn, where, size, val);
>> + if (where_a >= 0xe0 && where_a < 0xf0 && is_tns)
>> + return handle_ea_bar(0x80ff0023, /* EA entry-2. PP=0, BAR2, Size:3 */
>> + 0x18, bus, devfn, where, size, val);
>> + if (where_a >= 0xe0 && where_a < 0xf0 && is_nic)
>> + return handle_ea_bar(0x80ff0493, /* EA entry-2. PP=4, VF_BAR0 (9), Size:3 */
>> + 0x1a4, bus, devfn, where, size, val);
>> + if (where_a >= 0xf0 && where_a < 0x100 && is_nic)
>> + return handle_ea_bar(0x80ff04d3, /* EA entry-3. PP=4, VF_BAR4 (d), Size:3 */
>> + 0x1b4, bus, devfn, where, size, val);
>> + } else if (cfg_type == 1) {
>> + if (where_a == 0x70) {
>> + addr = bus->ops->map_bus(bus, devfn, where_a);
>> + if (!addr) {
>> + *val = ~0;
>> + return PCIBIOS_DEVICE_NOT_FOUND;
>> + }
>> + v = readl(addr);
>> + if (v & 0xff00)
>> + pr_err("Bad PCIe cap header: %08x\n", v);
>> + v |= 0xbc00; /* next capability is EA at 0xbc */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xbc) {
>> + v = 0x10014; /* EA last in chain, 1 entry. */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xc0) {
>> + v = 0x0101; /* subordinate:secondary = 1:1 */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xc4) {
>> + v = 0x80ff0564; /* Enabled, not-Write, SP=ff, PP=05, BEI=6, ES=4 */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xc8) {
>> + v = 0x00000002; /* Base-L 64-bit */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xcc) {
>> + v = 0xfffffffe; /* MaxOffset-L 64-bit */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xd0) {
>> + if (devfn == 8)
>> + v = 0x000087e0; /* RSL Base-H */
>> + else
>> + v = 0x00008430; /* NIC Base-H */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> + if (where_a == 0xd4) {
>> + v = 0x0000000f; /* MaxOffset-H */
>> + set_val(v, where, size, val);
>> + return PCIBIOS_SUCCESSFUL;
>> + }
>> +
>> + }
>> +no_emulation:
>> + return pci_generic_config_read(bus, devfn, where, size, val);
>> +}
>> --
>> 1.9.1
>>
>> --
>> 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/
--
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/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [RFC PATCH] PCI/pci-host-generic: Add support for Cavium Thunder fixed BARs. Bjorn Helgaas <helgaas@kernel.org> - 2015-11-25 18:10 +0100
Re: [RFC PATCH] PCI/pci-host-generic: Add support for Cavium Thunder fixed BARs. David Daney <ddaney@caviumnetworks.com> - 2015-11-25 18:30 +0100
Re: [RFC PATCH] PCI/pci-host-generic: Add support for Cavium Thunder fixed BARs. Arnd Bergmann <arnd@arndb.de> - 2015-11-25 21:00 +0100
Re: [RFC PATCH] PCI/pci-host-generic: Add support for Cavium Thunder fixed BARs. David Daney <ddaney@caviumnetworks.com> - 2015-11-25 21:10 +0100
Re: [RFC PATCH] PCI/pci-host-generic: Add support for Cavium Thunder fixed BARs. Arnd Bergmann <arnd@arndb.de> - 2015-11-25 21:20 +0100
csiph-web