summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/nvgpu/gp10b
diff options
context:
space:
mode:
authorKonsta Holtta <kholtta@nvidia.com>2018-11-13 08:36:19 -0500
committermobile promotions <svcmobile_promotions@nvidia.com>2019-02-05 12:04:20 -0500
commit3794afbeb177ed0932d166d30bb2af9d9859dff9 (patch)
treeddec116ed6ebee65f14108aaa54b84e3869589d4 /drivers/gpu/nvgpu/gp10b
parented6e3960903b9e2ba82ded06d1abfe3dec0ac865 (diff)
gpu: nvgpu: add safe channel id lookup
Add gk20a_channel_from_id() to retrieve a channel, given a raw channel ID, with a reference taken (or NULL if the channel was dead). This makes it harder to mistakenly use a channel that's dead and thus uncovers bugs sooner. Convert code to use the new lookup when applicable; work remains to convert complex uses where a ref should have been taken but hasn't. The channel ID is also validated against FIFO_INVAL_CHANNEL_ID; NULL is returned for such IDs. This is often useful and does not hurt when unnecessary. However, this does not prevent the case where a channel would be closed and reopened again when someone would hold a stale channel number. In all such conditions the caller should hold a reference already. The only conditions where a channel can be safely looked up by an id and used without taking a ref are when initializing or deinitializing the list of channels. Jira NVGPU-1460 Change-Id: I0a30968d17c1e0784d315a676bbe69c03a73481c Signed-off-by: Konsta Holtta <kholtta@nvidia.com> Reviewed-on: https://git-master.nvidia.com/r/1955400 Signed-off-by: Debarshi Dutta <ddutta@nvidia.com> (cherry picked from commit 7df3d587502c2de997dfbe8ea8ddc114d0a0481e in dev-kernel) Reviewed-on: https://git-master.nvidia.com/r/2008515 Reviewed-by: mobile promotions <svcmobile_promotions@nvidia.com> Tested-by: mobile promotions <svcmobile_promotions@nvidia.com>
Diffstat (limited to 'drivers/gpu/nvgpu/gp10b')
-rw-r--r--drivers/gpu/nvgpu/gp10b/gr_gp10b.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
index f70a5a00..a3655146 100644
--- a/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
+++ b/drivers/gpu/nvgpu/gp10b/gr_gp10b.c
@@ -1961,8 +1961,8 @@ static int gr_gp10b_get_cilp_preempt_pending_chid(struct gk20a *g, int *__chid)
1961 1961
1962 chid = g->gr.cilp_preempt_pending_chid; 1962 chid = g->gr.cilp_preempt_pending_chid;
1963 1963
1964 ch = gk20a_channel_get(gk20a_fifo_channel_from_chid(g, chid)); 1964 ch = gk20a_channel_from_id(g, chid);
1965 if (!ch) { 1965 if (ch == NULL) {
1966 return ret; 1966 return ret;
1967 } 1967 }
1968 1968
@@ -2014,9 +2014,8 @@ int gr_gp10b_handle_fecs_error(struct gk20a *g,
2014 goto clean_up; 2014 goto clean_up;
2015 } 2015 }
2016 2016
2017 ch = gk20a_channel_get( 2017 ch = gk20a_channel_from_id(g, chid);
2018 gk20a_fifo_channel_from_chid(g, chid)); 2018 if (ch == NULL) {
2019 if (!ch) {
2020 goto clean_up; 2019 goto clean_up;
2021 } 2020 }
2022 2021