From b65485c5b4860d6c7d0c0daf14fdf0458e3554dd Mon Sep 17 00:00:00 2001 From: Thomas Fleury Date: Tue, 23 Apr 2019 17:46:26 -0700 Subject: [PATCH] gpu: nvgpu: add internal chip SKUs for PG189 When flashing OBE ROM on PG189 with an internal chip SKU, it ends up enumerating with unsupported device id. Since VBIOS update will be done automatically in PDK, we want to detect such boards, and throw a warning. Use upper bits of driver_data to define some flags for pci device. Added PCI_DEVICE_F_INTERNAL_CHIP_SKU for boards with internal chip SKUs. Allow enumeration of PG189 boards with internal chip SKUs 0x1eae and 0x1eaf, but throw a warning. Bug 2569674 Change-Id: I0261a85139be5e58029f25fcb289f54dfd7c35b3 Signed-off-by: Thomas Fleury Reviewed-on: https://git-master.nvidia.com/r/2103831 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/os/linux/pci.c | 31 +++++++++++++++++++++++++++++-- 1 file changed, 29 insertions(+), 2 deletions(-) diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c index 4a1a62927..92db603bb 100644 --- a/drivers/gpu/nvgpu/os/linux/pci.c +++ b/drivers/gpu/nvgpu/os/linux/pci.c @@ -254,6 +254,7 @@ static struct gk20a_platform nvgpu_pci_device[] = { .unified_memory = false, }, { /* 0x1eba, 0x1efa, 0x1ebb, 0x1efb */ + /* 0x1eae, 0x1eaf (internal chip SKUs) */ /* ptimer src frequency in hz */ .ptimer_src_freq = 31250000, @@ -292,6 +293,11 @@ static struct gk20a_platform nvgpu_pci_device[] = { }, }; +#define PCI_DEVICE_INDEX(driver_data) ((driver_data) & 0x0000FFFFU) +#define PCI_DEVICE_FLAGS(driver_data) ((driver_data) & 0xFFFF0000U) + +#define PCI_DEVICE_F_INTERNAL_CHIP_SKU BIT(31) + static struct pci_device_id nvgpu_pci_table[] = { { PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x1db1), @@ -347,6 +353,19 @@ static struct pci_device_id nvgpu_pci_table[] = { .class_mask = 0xff << 16, .driver_data = 5, }, + { + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x1eae), + .class = PCI_BASE_CLASS_DISPLAY << 16, + .class_mask = 0xff << 16, + .driver_data = 5 | PCI_DEVICE_F_INTERNAL_CHIP_SKU, + }, + { + PCI_DEVICE(PCI_VENDOR_ID_NVIDIA, 0x1eaf), + .class = PCI_BASE_CLASS_DISPLAY << 16, + .class_mask = 0xff << 16, + .driver_data = 5 | PCI_DEVICE_F_INTERNAL_CHIP_SKU, + }, + {} }; @@ -525,9 +544,11 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, int err; char nodefmt[64]; struct device_node *np; + u32 device_index = PCI_DEVICE_INDEX(pent->driver_data); + u32 device_flags = PCI_DEVICE_FLAGS(pent->driver_data); /* make sure driver_data is a sane index */ - if (pent->driver_data >= sizeof(nvgpu_pci_device) / + if (device_index >= sizeof(nvgpu_pci_device) / sizeof(nvgpu_pci_device[0])) { return -EINVAL; } @@ -559,7 +580,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, /* copy detected device data to allocated platform space*/ nvgpu_memcpy((u8 *)platform, - (u8 *)&nvgpu_pci_device[pent->driver_data], + (u8 *)&nvgpu_pci_device[device_index], sizeof(struct gk20a_platform)); pci_set_drvdata(pdev, platform); @@ -589,6 +610,12 @@ static int nvgpu_pci_probe(struct pci_dev *pdev, g->pci_class = (pdev->class >> 8) & 0xFFFFU; // we only want base/sub g->pci_revision = pdev->revision; + if ((device_flags & PCI_DEVICE_F_INTERNAL_CHIP_SKU) != 0U) { + nvgpu_err(g, "internal chip SKU %08x detected", + g->pci_device_id); + nvgpu_err(g, "replace board, or use at your own risks"); + } + g->ina3221_dcb_index = platform->ina3221_dcb_index; g->ina3221_i2c_address = platform->ina3221_i2c_address; g->ina3221_i2c_port = platform->ina3221_i2c_port;