From 1d8a77a7f9c7192db8562ecd303fe47c30bde3fd Mon Sep 17 00:00:00 2001 From: Alex Waterman Date: Tue, 8 Nov 2016 11:22:25 -0800 Subject: gpu: nvgpu: Close channels before freeing them Ensure that any open channel is definitely closed before freeing it. Bug 1816516 Bug 1807277 Change-Id: I7f100db5ab6834176ec97d22374646d3336f2856 Signed-off-by: Alex Waterman Reviewed-on: http://git-master/r/1250023 (cherry picked from commit 56f1b4b4312c5900f1c27eba55ad970c4b264f24) Reviewed-on: http://git-master/r/1261919 Reviewed-by: Automatic_Commit_Validation_User GVS: Gerrit_Virtual_Submit Reviewed-by: Terje Bergstrom --- drivers/gpu/nvgpu/gk20a/fifo_gk20a.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c index 99d5fd4c..1818a57e 100644 --- a/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/fifo_gk20a.c @@ -486,9 +486,24 @@ void gk20a_fifo_delete_runlist(struct fifo_gk20a *f) static void gk20a_remove_fifo_support(struct fifo_gk20a *f) { struct gk20a *g = f->g; + unsigned int i = 0; gk20a_dbg_fn(""); + /* + * Make sure all channels are closed before deleting them. + */ + for (; i < f->num_channels; i++) { + struct channel_gk20a *c = f->channel + i; + + /* + * Could race but worst that happens is we get an error message + * from gk20a_free_channel() complaining about multiple closes. + */ + if (c->referenceable) + __gk20a_channel_kill(c); + } + vfree(f->channel); vfree(f->tsg); if (g->ops.mm.is_bar1_supported(g)) -- cgit v1.2.2