mirror of
git://nv-tegra.nvidia.com/linux-nvgpu.git
synced 2025-12-24 02:22:34 +03:00
gpu: nvgpu: unify nvgpu and pci probe
We have completely different versions of probe for nvgpu and pci device Extract out common steps into nvgpu_probe() function and separate it out in new file nvgpu_common.c Divide task of nvgpu_probe() into further smaller functions Do platform specific things (like irq handling, memresource management, power management) only in individual probes and then call nvgpu_probe() to complete the common initialization Move all debugfs initialization to common gk20a_debug_init() This also helps to bringup all debug nodes to pci device Pass debugfs_symlink name as a parameter to gk20a_debug_init() This allows us to set separate debugfs symlink for nvgpu and pci device In case of railgating, cde and ce debugfs, check if platform supports them or not Copy vidmem_is_vidmem from platform to mm structure and set it to true for pci device Return from gk20a_scale_init() if we don't have either of governor or qos_notifier Fix gk20a_alloc_debugfs_init() and gk20a_secure_page_alloc() to receive device pointer instead of platform_device Export gk20a_railgating_debugfs_init() so that we can call it from gk20a_debug_init() Jira DNVGPU-56 Jira DNVGPU-58 Change-Id: I3cc048082b0a1e57415a9fb8bfb9eec0f0a280cd Signed-off-by: Deepak Nibade <dnibade@nvidia.com> Reviewed-on: http://git-master/r/1204207 (cherry picked from commit add6bb0a3d5bd98131bbe6f62d4358d4d722b0fe) Reviewed-on: http://git-master/r/1204462 GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com>
This commit is contained in:
committed by
mobile promotions
parent
f31e575ed6
commit
70cad5fbb5
@@ -18,6 +18,7 @@
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/pm_runtime.h>
|
||||
#include "pci.h"
|
||||
#include "nvgpu_common.h"
|
||||
#include "gk20a/gk20a.h"
|
||||
#include "gk20a/platform_gk20a.h"
|
||||
|
||||
@@ -58,6 +59,8 @@ static struct gk20a_platform nvgpu_pci_device = {
|
||||
.ch_wdt_timeout_ms = 7000,
|
||||
|
||||
.has_ce = true,
|
||||
|
||||
.vidmem_is_vidmem = true,
|
||||
};
|
||||
|
||||
static struct pci_device_id nvgpu_pci_table[] = {
|
||||
@@ -113,19 +116,9 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev)
|
||||
goto fail;
|
||||
}
|
||||
|
||||
g->regs_saved = g->regs;
|
||||
g->bar1_saved = g->bar1;
|
||||
|
||||
mutex_init(&g->dbg_sessions_lock);
|
||||
mutex_init(&g->client_lock);
|
||||
mutex_init(&g->ch_wdt_lock);
|
||||
mutex_init(&g->poweroff_lock);
|
||||
|
||||
g->remove_support = gk20a_remove_support;
|
||||
return 0;
|
||||
|
||||
fail:
|
||||
gk20a_remove_support(&pdev->dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
@@ -200,9 +193,6 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
init_waitqueue_head(&g->sw_irq_stall_last_handled_wq);
|
||||
init_waitqueue_head(&g->sw_irq_nonstall_last_handled_wq);
|
||||
|
||||
platform->g = g;
|
||||
g->dev = &pdev->dev;
|
||||
|
||||
@@ -215,6 +205,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
||||
g->irq_nonstall = pdev->irq;
|
||||
if (g->irq_stall < 0)
|
||||
return -ENXIO;
|
||||
|
||||
err = devm_request_threaded_irq(&pdev->dev,
|
||||
g->irq_stall,
|
||||
nvgpu_pci_isr,
|
||||
@@ -227,6 +218,10 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
||||
}
|
||||
disable_irq(g->irq_stall);
|
||||
|
||||
err = nvgpu_pci_init_support(pdev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
if (strchr(dev_name(&pdev->dev), '%')) {
|
||||
gk20a_err(&pdev->dev, "illegal character in device name");
|
||||
return -EINVAL;
|
||||
@@ -236,57 +231,12 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
||||
if (!nodefmt)
|
||||
return -ENOMEM;
|
||||
|
||||
err = gk20a_user_init(&pdev->dev, nodefmt, &nvgpu_pci_class);
|
||||
err = nvgpu_probe(g, "gpu_pci", nodefmt, &nvgpu_pci_class);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
kfree(nodefmt);
|
||||
nodefmt = NULL;
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
err = nvgpu_pci_init_support(pdev);
|
||||
if (err)
|
||||
return err;
|
||||
|
||||
init_rwsem(&g->busy_lock);
|
||||
mutex_init(&platform->railgate_lock);
|
||||
|
||||
spin_lock_init(&g->mc_enable_lock);
|
||||
|
||||
gk20a_debug_init(&pdev->dev);
|
||||
|
||||
/* Initialize the platform interface. */
|
||||
err = platform->probe(&pdev->dev);
|
||||
if (err) {
|
||||
gk20a_err(&pdev->dev, "platform probe failed");
|
||||
return err;
|
||||
}
|
||||
|
||||
/* Set DMA parameters to allow larger sgt lists */
|
||||
pdev->dev.dma_parms = &g->dma_parms;
|
||||
dma_set_max_seg_size(&pdev->dev, UINT_MAX);
|
||||
|
||||
g->gr_idle_timeout_default =
|
||||
CONFIG_GK20A_DEFAULT_TIMEOUT;
|
||||
if (tegra_platform_is_silicon())
|
||||
g->timeouts_enabled = true;
|
||||
|
||||
g->runlist_interleave = true;
|
||||
|
||||
g->timeslice_low_priority_us = 1300;
|
||||
g->timeslice_medium_priority_us = 2600;
|
||||
g->timeslice_high_priority_us = 5200;
|
||||
|
||||
gk20a_create_sysfs(&pdev->dev);
|
||||
|
||||
g->mm.has_physical_mode = false;
|
||||
g->mm.vidmem_is_vidmem = true;
|
||||
#ifdef CONFIG_DEBUG_FS
|
||||
g->mm.ltc_enabled = true;
|
||||
g->mm.ltc_enabled_debug = true;
|
||||
#endif
|
||||
g->mm.bypass_smmu = platform->bypass_smmu;
|
||||
g->mm.disable_bigpage = platform->disable_bigpage;
|
||||
|
||||
gk20a_init_gr(g);
|
||||
|
||||
err = nvgpu_pci_pm_init(&pdev->dev);
|
||||
if (err) {
|
||||
@@ -294,6 +244,8 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
|
||||
return err;
|
||||
}
|
||||
|
||||
g->mm.has_physical_mode = false;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user