summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/pci.c
diff options
context:
space:
mode:
authorDeepak Nibade <dnibade@nvidia.com>2016-08-17 12:31:43 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2016-09-08 12:43:51 -0400
commit70cad5fbb593602a49f91e57c04d1da0334b3a49 (patch)
tree12db73aa8275b15b8b9771d6d39590e2228db24f /drivers/gpu/nvgpu/pci.c
parentf31e575ed6b048f2139eab0433cce7f18e670b28 (diff)
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>
Diffstat (limited to 'drivers/gpu/nvgpu/pci.c')
-rw-r--r--drivers/gpu/nvgpu/pci.c74
1 files changed, 13 insertions, 61 deletions
diff --git a/drivers/gpu/nvgpu/pci.c b/drivers/gpu/nvgpu/pci.c
index cbf444ad..a67bbd54 100644
--- a/drivers/gpu/nvgpu/pci.c
+++ b/drivers/gpu/nvgpu/pci.c
@@ -18,6 +18,7 @@
18#include <linux/interrupt.h> 18#include <linux/interrupt.h>
19#include <linux/pm_runtime.h> 19#include <linux/pm_runtime.h>
20#include "pci.h" 20#include "pci.h"
21#include "nvgpu_common.h"
21#include "gk20a/gk20a.h" 22#include "gk20a/gk20a.h"
22#include "gk20a/platform_gk20a.h" 23#include "gk20a/platform_gk20a.h"
23 24
@@ -58,6 +59,8 @@ static struct gk20a_platform nvgpu_pci_device = {
58 .ch_wdt_timeout_ms = 7000, 59 .ch_wdt_timeout_ms = 7000,
59 60
60 .has_ce = true, 61 .has_ce = true,
62
63 .vidmem_is_vidmem = true,
61}; 64};
62 65
63static struct pci_device_id nvgpu_pci_table[] = { 66static struct pci_device_id nvgpu_pci_table[] = {
@@ -113,19 +116,9 @@ static int nvgpu_pci_init_support(struct pci_dev *pdev)
113 goto fail; 116 goto fail;
114 } 117 }
115 118
116 g->regs_saved = g->regs;
117 g->bar1_saved = g->bar1;
118
119 mutex_init(&g->dbg_sessions_lock);
120 mutex_init(&g->client_lock);
121 mutex_init(&g->ch_wdt_lock);
122 mutex_init(&g->poweroff_lock);
123
124 g->remove_support = gk20a_remove_support;
125 return 0; 119 return 0;
126 120
127 fail: 121 fail:
128 gk20a_remove_support(&pdev->dev);
129 return err; 122 return err;
130} 123}
131 124
@@ -200,9 +193,6 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
200 return -ENOMEM; 193 return -ENOMEM;
201 } 194 }
202 195
203 init_waitqueue_head(&g->sw_irq_stall_last_handled_wq);
204 init_waitqueue_head(&g->sw_irq_nonstall_last_handled_wq);
205
206 platform->g = g; 196 platform->g = g;
207 g->dev = &pdev->dev; 197 g->dev = &pdev->dev;
208 198
@@ -215,6 +205,7 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
215 g->irq_nonstall = pdev->irq; 205 g->irq_nonstall = pdev->irq;
216 if (g->irq_stall < 0) 206 if (g->irq_stall < 0)
217 return -ENXIO; 207 return -ENXIO;
208
218 err = devm_request_threaded_irq(&pdev->dev, 209 err = devm_request_threaded_irq(&pdev->dev,
219 g->irq_stall, 210 g->irq_stall,
220 nvgpu_pci_isr, 211 nvgpu_pci_isr,
@@ -227,6 +218,10 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
227 } 218 }
228 disable_irq(g->irq_stall); 219 disable_irq(g->irq_stall);
229 220
221 err = nvgpu_pci_init_support(pdev);
222 if (err)
223 return err;
224
230 if (strchr(dev_name(&pdev->dev), '%')) { 225 if (strchr(dev_name(&pdev->dev), '%')) {
231 gk20a_err(&pdev->dev, "illegal character in device name"); 226 gk20a_err(&pdev->dev, "illegal character in device name");
232 return -EINVAL; 227 return -EINVAL;
@@ -236,57 +231,12 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
236 if (!nodefmt) 231 if (!nodefmt)
237 return -ENOMEM; 232 return -ENOMEM;
238 233
239 err = gk20a_user_init(&pdev->dev, nodefmt, &nvgpu_pci_class); 234 err = nvgpu_probe(g, "gpu_pci", nodefmt, &nvgpu_pci_class);
240 kfree(nodefmt);
241 nodefmt = NULL;
242 if (err)
243 return err;
244
245 err = nvgpu_pci_init_support(pdev);
246 if (err) 235 if (err)
247 return err; 236 return err;
248 237
249 init_rwsem(&g->busy_lock); 238 kfree(nodefmt);
250 mutex_init(&platform->railgate_lock); 239 nodefmt = NULL;
251
252 spin_lock_init(&g->mc_enable_lock);
253
254 gk20a_debug_init(&pdev->dev);
255
256 /* Initialize the platform interface. */
257 err = platform->probe(&pdev->dev);
258 if (err) {
259 gk20a_err(&pdev->dev, "platform probe failed");
260 return err;
261 }
262
263 /* Set DMA parameters to allow larger sgt lists */
264 pdev->dev.dma_parms = &g->dma_parms;
265 dma_set_max_seg_size(&pdev->dev, UINT_MAX);
266
267 g->gr_idle_timeout_default =
268 CONFIG_GK20A_DEFAULT_TIMEOUT;
269 if (tegra_platform_is_silicon())
270 g->timeouts_enabled = true;
271
272 g->runlist_interleave = true;
273
274 g->timeslice_low_priority_us = 1300;
275 g->timeslice_medium_priority_us = 2600;
276 g->timeslice_high_priority_us = 5200;
277
278 gk20a_create_sysfs(&pdev->dev);
279
280 g->mm.has_physical_mode = false;
281 g->mm.vidmem_is_vidmem = true;
282#ifdef CONFIG_DEBUG_FS
283 g->mm.ltc_enabled = true;
284 g->mm.ltc_enabled_debug = true;
285#endif
286 g->mm.bypass_smmu = platform->bypass_smmu;
287 g->mm.disable_bigpage = platform->disable_bigpage;
288
289 gk20a_init_gr(g);
290 240
291 err = nvgpu_pci_pm_init(&pdev->dev); 241 err = nvgpu_pci_pm_init(&pdev->dev);
292 if (err) { 242 if (err) {
@@ -294,6 +244,8 @@ static int nvgpu_pci_probe(struct pci_dev *pdev,
294 return err; 244 return err;
295 } 245 }
296 246
247 g->mm.has_physical_mode = false;
248
297 return 0; 249 return 0;
298} 250}
299 251