diff --git a/drivers/gpu/nvgpu/os/linux/module.c b/drivers/gpu/nvgpu/os/linux/module.c index a81d837bd..ebe2e6505 100644 --- a/drivers/gpu/nvgpu/os/linux/module.c +++ b/drivers/gpu/nvgpu/os/linux/module.c @@ -680,6 +680,16 @@ void __iomem *nvgpu_devm_ioremap(struct device *dev, resource_size_t offset, return devm_ioremap(dev, offset, size); } +u64 nvgpu_resource_addr(struct platform_device *dev, int i) +{ + struct resource *r = platform_get_resource(dev, IORESOURCE_MEM, i); + + if (!r) + return 0; + + return r->start; +} + static irqreturn_t gk20a_intr_isr_stall(int irq, void *dev_id) { struct gk20a *g = dev_id; @@ -764,6 +774,14 @@ static int gk20a_init_support(struct platform_device *pdev) goto fail; } + l->regs_bus_addr = nvgpu_resource_addr(pdev, + GK20A_BAR0_IORESOURCE_MEM); + if (!l->regs_bus_addr) { + nvgpu_err(g, "failed to read register bus offset"); + err = -ENODEV; + goto fail; + } + l->bar1 = nvgpu_devm_ioremap_resource(pdev, GK20A_BAR1_IORESOURCE_MEM, &l->bar1_mem); diff --git a/drivers/gpu/nvgpu/os/linux/module.h b/drivers/gpu/nvgpu/os/linux/module.h index da61425d0..76c727481 100644 --- a/drivers/gpu/nvgpu/os/linux/module.h +++ b/drivers/gpu/nvgpu/os/linux/module.h @@ -29,6 +29,7 @@ void __iomem *nvgpu_devm_ioremap_resource(struct platform_device *dev, int i, struct resource **out); void __iomem *nvgpu_devm_ioremap(struct device *dev, resource_size_t offset, resource_size_t size); +u64 nvgpu_resource_addr(struct platform_device *dev, int i); extern struct class nvgpu_class; #endif diff --git a/drivers/gpu/nvgpu/os/linux/os_linux.h b/drivers/gpu/nvgpu/os/linux/os_linux.h index 5f636f491..d4b5a770c 100644 --- a/drivers/gpu/nvgpu/os/linux/os_linux.h +++ b/drivers/gpu/nvgpu/os/linux/os_linux.h @@ -128,6 +128,8 @@ struct nvgpu_os_linux { void __iomem *usermode_regs; void __iomem *usermode_regs_saved; + u64 regs_bus_addr; + struct nvgpu_os_linux_ops ops; #ifdef CONFIG_DEBUG_FS diff --git a/drivers/gpu/nvgpu/os/linux/pci.c b/drivers/gpu/nvgpu/os/linux/pci.c index 2e456abc6..61e412f29 100644 --- a/drivers/gpu/nvgpu/os/linux/pci.c +++ b/drivers/gpu/nvgpu/os/linux/pci.c @@ -536,6 +536,13 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev) goto fail; } + l->regs_bus_addr = pci_resource_start(pdev, 0); + if (!l->regs_bus_addr) { + nvgpu_err(g, "failed to read register bus offset"); + err = -ENODEV; + goto fail; + } + l->bar1 = nvgpu_devm_ioremap(dev, pci_resource_start(pdev, 1), pci_resource_len(pdev, 1)); if (IS_ERR(l->bar1)) {