From 8f42de27759940668f2497485795c45e22b4e9b0 Mon Sep 17 00:00:00 2001 From: Peter Daifuku Date: Tue, 8 Oct 2019 14:36:37 -0700 Subject: [PATCH] gpu: nvgpu: channel_setup_bind: must be bound to TSG In nvgpu_channel_setup_bind, return an error if the channel isn't bound to a TSG, as future operations rely on being bound. Update usermode setup_bind test to bind channel to the tsg before calling nvgpu_setup_bind Manual port from rel-32 Bug 200543218 Change-Id: If33b01b8176c7488445c23080ad9d11f341bff43 Signed-off-by: Peter Daifuku Reviewed-on: https://git-master.nvidia.com/r/2215160 (cherry picked from commit 56f8e5b878348d1ac7f0b133d395808e0caed769) Reviewed-on: https://git-master.nvidia.com/r/2218885 Reviewed-by: svc-mobile-coverity Reviewed-by: svc-mobile-misra GVS: Gerrit_Virtual_Submit Reviewed-by: Alex Waterman Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/fifo/channel.c | 10 ++++++++++ userspace/units/fifo/channel/nvgpu-channel.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c index 0fe9f0fbc..61d7fc5c9 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel.c +++ b/drivers/gpu/nvgpu/common/fifo/channel.c @@ -2201,6 +2201,7 @@ int nvgpu_channel_setup_bind(struct nvgpu_channel *c, struct nvgpu_setup_bind_args *args) { struct gk20a *g = c->g; + struct nvgpu_tsg *tsg; int err = 0; #ifdef CONFIG_NVGPU_VPR @@ -2240,6 +2241,15 @@ int nvgpu_channel_setup_bind(struct nvgpu_channel *c, goto clean_up_idle; } + /* The channel needs to be bound to a tsg at this point */ + tsg = nvgpu_tsg_from_ch(c); + if (tsg == NULL) { + nvgpu_err(g, + "not bound to tsg at time of setup_bind"); + err = -EINVAL; + goto clean_up_idle; + } + if (c->usermode_submit_enabled) { nvgpu_err(g, "channel %d : " "usermode buffers allocated", c->chid); diff --git a/userspace/units/fifo/channel/nvgpu-channel.c b/userspace/units/fifo/channel/nvgpu-channel.c index 344db5fa8..cae6b8ebc 100644 --- a/userspace/units/fifo/channel/nvgpu-channel.c +++ b/userspace/units/fifo/channel/nvgpu-channel.c @@ -653,6 +653,9 @@ int test_channel_setup_bind(struct unit_module *m, privileged, getpid(), getpid()); assert(ch != NULL); + err = nvgpu_tsg_bind_channel(tsg, ch); + assert(err == 0); + g->ops.gr.intr.flush_channel_tlb = stub_gr_intr_flush_channel_tlb; g->ops.mm.cache.l2_flush = stub_mm_l2_flush; /* bug 2621189 */