summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gk20a/gk20a.c
diff options
context:
space:
mode:
authorDavid Nieto <dmartineznie@nvidia.com>2017-03-13 21:45:37 -0400
committermobile promotions <svcmobile_promotions@nvidia.com>2017-03-24 00:05:35 -0400
commit2a502bdd5f3c93b87286456ca901ad43b0f14906 (patch)
treeaba5c18b07b393e0306588d9ba4707a6c272ae6b /drivers/gpu/nvgpu/gk20a/gk20a.c
parenta84f601fbaf6b40e14a321eda1e83d93e55cebba (diff)
gpu: nvgpu: pass gk20a struct to gk20a_busy
After driver remove, the device structure passed in gk20a_busy can be invalid. To solve this the prototype of the function is modified to pass the gk20a struct instead of the device pointer. bug 200277762 JIRA: EVLR-1023 Change-Id: I08eb74bd3578834d45115098ed9936ebbb436fdf Signed-off-by: David Nieto <dmartineznie@nvidia.com> Reviewed-on: http://git-master/r/1320194 Reviewed-by: Automatic_Commit_Validation_User Reviewed-by: svccoveritychecker <svccoveritychecker@nvidia.com> Reviewed-by: Terje Bergstrom <tbergstrom@nvidia.com> GVS: Gerrit_Virtual_Submit
Diffstat (limited to 'drivers/gpu/nvgpu/gk20a/gk20a.c')
-rw-r--r--drivers/gpu/nvgpu/gk20a/gk20a.c41
1 files changed, 22 insertions, 19 deletions
diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c
index 72528758..59f16bf6 100644
--- a/drivers/gpu/nvgpu/gk20a/gk20a.c
+++ b/drivers/gpu/nvgpu/gk20a/gk20a.c
@@ -1434,24 +1434,26 @@ static int gk20a_can_busy(struct gk20a *g)
1434 return 1; 1434 return 1;
1435} 1435}
1436 1436
1437int gk20a_busy(struct device *dev) 1437int gk20a_busy(struct gk20a *g)
1438{ 1438{
1439 int ret = 0; 1439 int ret = 0;
1440 struct gk20a *g; 1440 struct device *dev;
1441 struct gk20a_platform *platform;
1442
1443 if (!dev)
1444 return -ENODEV;
1445 1441
1446 g = get_gk20a(dev); 1442 if (!g)
1447 platform = gk20a_get_platform(dev);
1448
1449 if (!g || !gk20a_can_busy(g))
1450 return -ENODEV; 1443 return -ENODEV;
1451 1444
1452 atomic_inc(&g->usage_count); 1445 atomic_inc(&g->usage_count);
1453 1446
1454 down_read(&g->busy_lock); 1447 down_read(&g->busy_lock);
1448
1449 if (!gk20a_can_busy(g)) {
1450 ret = -ENODEV;
1451 atomic_dec(&g->usage_count);
1452 goto fail;
1453 }
1454
1455 dev = g->dev;
1456
1455 if (pm_runtime_enabled(dev)) { 1457 if (pm_runtime_enabled(dev)) {
1456 ret = pm_runtime_get_sync(dev); 1458 ret = pm_runtime_get_sync(dev);
1457 if (ret < 0) { 1459 if (ret < 0) {
@@ -1484,22 +1486,21 @@ void gk20a_idle_nosuspend(struct device *dev)
1484 pm_runtime_put_noidle(dev); 1486 pm_runtime_put_noidle(dev);
1485} 1487}
1486 1488
1487void gk20a_idle(struct device *dev) 1489void gk20a_idle(struct gk20a *g)
1488{ 1490{
1489 struct gk20a_platform *platform; 1491 struct device *dev;
1490 struct gk20a *g;
1491 1492
1492 if (!dev) 1493 atomic_dec(&g->usage_count);
1493 return; 1494 down_read(&g->busy_lock);
1494 1495
1495 g = get_gk20a(dev); 1496 dev = g->dev;
1496 platform = gk20a_get_platform(dev);
1497 1497
1498 atomic_dec(&g->usage_count); 1498 if (!(dev && gk20a_can_busy(g)))
1499 goto fail;
1499 1500
1500 if (pm_runtime_enabled(dev)) { 1501 if (pm_runtime_enabled(dev)) {
1501#ifdef CONFIG_PM 1502#ifdef CONFIG_PM
1502 if (atomic_read(&dev->power.usage_count) == 1) 1503 if (atomic_read(&g->dev->power.usage_count) == 1)
1503 gk20a_scale_notify_idle(dev); 1504 gk20a_scale_notify_idle(dev);
1504#endif 1505#endif
1505 1506
@@ -1509,6 +1510,8 @@ void gk20a_idle(struct device *dev)
1509 } else { 1510 } else {
1510 gk20a_scale_notify_idle(dev); 1511 gk20a_scale_notify_idle(dev);
1511 } 1512 }
1513fail:
1514 up_read(&g->busy_lock);
1512} 1515}
1513 1516
1514void gk20a_disable(struct gk20a *g, u32 units) 1517void gk20a_disable(struct gk20a *g, u32 units)