gpu: nvgpu: sim init for iGPU-PCIe

Implement the sim init for the iGPU-PCIe devices.

JIRA NVGPU-9348

Change-Id: I9088308b96c57bb1cea01959326446ccad0a8c24
Signed-off-by: Ramalingam C <ramalingamc@nvidia.com>
Reviewed-on: https://git-master.nvidia.com/r/c/linux-nvgpu/+/2851163
Reviewed-by: svcacv <svcacv@nvidia.com>
Reviewed-by: Sagar Kamble <skamble@nvidia.com>
Reviewed-by: Seema Khowala <seemaj@nvidia.com>
GVS: Gerrit_Virtual_Submit <buildbot_gerritrpt@nvidia.com>
This commit is contained in:
Ramalingam C
2023-01-31 14:48:21 +00:00
committed by mobile promotions
parent d0ed86ab1e
commit b2c4cdb25b
4 changed files with 66 additions and 11 deletions

View File

@@ -2,7 +2,7 @@
*
* nvgpu sim support
*
* Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -21,6 +21,7 @@
#define __SIM_LINUX_H__
struct platform_device;
struct gk20a_platform;
struct sim_nvgpu_linux {
struct sim_nvgpu sim;
@@ -30,5 +31,7 @@ struct sim_nvgpu_linux {
int nvgpu_init_sim_support_linux(struct gk20a *g,
struct platform_device *dev);
int nvgpu_init_sim_support_linux_igpu_pci(struct gk20a *g,
struct gk20a_platform *platform);
void nvgpu_remove_sim_support_linux(struct gk20a *g);
#endif

View File

@@ -38,6 +38,7 @@
#include <nvgpu/string.h>
#include <nvgpu/gr/gr.h>
#include <nvgpu/nvgpu_init.h>
#include <nvgpu/linux/sim.h>
#include "nvlink.h"
#include "module.h"
@@ -394,8 +395,9 @@ static irqreturn_t nvgpu_pci_intr_thread(int irq, void *dev_id)
return IRQ_HANDLED;
}
static int nvgpu_pci_init_support(struct pci_dev *pdev)
static int nvgpu_pci_init_support(struct pci_dev *pdev, bool is_pci_igpu)
{
struct gk20a_platform *platform = pci_get_drvdata(pdev);
int err = 0;
struct gk20a *g = get_gk20a(&pdev->dev);
struct device *dev = &pdev->dev;
@@ -427,16 +429,28 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev)
}
g->bar1 = (uintptr_t)addr;
if (is_pci_igpu) {
err = nvgpu_init_sim_support_linux_igpu_pci(g, platform);
if (err)
goto fail;
err = nvgpu_init_sim_support(g);
if (err)
goto fail_sim;
} else {
err = nvgpu_init_sim_support_linux_pci(g);
if (err)
goto fail;
err = nvgpu_init_sim_support_pci(g);
if (err)
goto fail_sim;
}
return 0;
fail_sim:
if (is_pci_igpu)
nvgpu_remove_sim_support_linux(g);
else
nvgpu_remove_sim_support_linux_pci(g);
fail:
if (g->regs)
@@ -675,7 +689,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
}
nvgpu_disable_irqs(g);
err = nvgpu_pci_init_support(pdev);
err = nvgpu_pci_init_support(pdev, g->is_pci_igpu);
if (err)
goto err_free_irq;

View File

@@ -358,6 +358,11 @@ struct gk20a_platform {
/* Check if igpu is available as pci device. */
bool is_pci_igpu;
#ifdef CONFIG_NVGPU_SIM
u32 fake_rpc_base;
u32 fake_rpc_size;
#endif
};
static inline struct gk20a_platform *gk20a_get_platform(

View File

@@ -1,5 +1,5 @@
/*
* Copyright (c) 2018-2021, NVIDIA CORPORATION. All rights reserved.
* Copyright (c) 2018-2023, NVIDIA CORPORATION. All rights reserved.
*
* This program is free software; you can redistribute it and/or modify it
* under the terms and conditions of the GNU General Public License,
@@ -80,3 +80,36 @@ fail:
nvgpu_remove_sim_support_linux(g);
return err;
}
int nvgpu_init_sim_support_linux_igpu_pci(struct gk20a *g,
struct gk20a_platform *platform)
{
struct device *dev = dev_from_gk20a(g);
struct sim_nvgpu_linux *sim_linux;
void __iomem *addr;
int err = -ENOMEM;
if (!nvgpu_platform_is_simulation(g))
return 0;
sim_linux = nvgpu_kzalloc(g, sizeof(*sim_linux));
if (!sim_linux)
return err;
g->sim = &sim_linux->sim;
g->sim->g = g;
addr = nvgpu_devm_ioremap(dev,
(resource_size_t)platform->fake_rpc_base,
(resource_size_t)platform->fake_rpc_size);
if (IS_ERR(addr)) {
nvgpu_err(g, "failed to remap gpu sim regs");
err = PTR_ERR(addr);
goto fail;
}
g->sim->regs = (uintptr_t)addr;
sim_linux->remove_support_linux = nvgpu_remove_sim_support_linux;
return 0;
fail:
nvgpu_remove_sim_support_linux(g);
return err;
}