From 726900b8433294fd89a6d730d2fec9de8e33afda Mon Sep 17 00:00:00 2001 From: Terje Bergstrom Date: Thu, 11 May 2017 13:12:03 -0700 Subject: gpu: nvgpu: Split stalling interrupt handling Split handling of stalling interrupt to Linux specific chip agnostic and OS independent chip specific parts. Linux specific chip independent part contains handler for ISR and passing the control to a bottom half. It uses the new MC HALs intr_stall (query interrupt status), intr_pause (pause interrupts) and intr_resume (resume interrupts). MC HAL isr_stall now returns void and gets called in thread context and thus remove isr_thread_stall and replace the implementation with isr_stall. JIRA NVGPU-26 Change-Id: I206f330f6fc4a1f4def47c5f986585ac4080216d Signed-off-by: Terje Bergstrom Reviewed-on: http://git-master/r/1480243 Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/common/linux/intr.c | 58 +++++++++++++++++++++++++++++++++ drivers/gpu/nvgpu/common/linux/intr.h | 20 ++++++++++++ drivers/gpu/nvgpu/common/linux/module.c | 5 +-- drivers/gpu/nvgpu/common/linux/pci.c | 7 ++-- 4 files changed, 84 insertions(+), 6 deletions(-) create mode 100644 drivers/gpu/nvgpu/common/linux/intr.c create mode 100644 drivers/gpu/nvgpu/common/linux/intr.h (limited to 'drivers/gpu/nvgpu/common') diff --git a/drivers/gpu/nvgpu/common/linux/intr.c b/drivers/gpu/nvgpu/common/linux/intr.c new file mode 100644 index 00000000..77e44dd9 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/intr.c @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#include + +#include "gk20a/gk20a.h" + +#include + +irqreturn_t nvgpu_intr_stall(struct gk20a *g) +{ + u32 mc_intr_0; + + trace_mc_gk20a_intr_stall(g->name); + + if (!g->power_on) + return IRQ_NONE; + + /* not from gpu when sharing irq with others */ + mc_intr_0 = g->ops.mc.intr_stall(g); + if (unlikely(!mc_intr_0)) + return IRQ_NONE; + + g->ops.mc.intr_stall_pause(g); + + atomic_inc(&g->hw_irq_stall_count); + + trace_mc_gk20a_intr_stall_done(g->name); + + return IRQ_WAKE_THREAD; +} + +irqreturn_t nvgpu_intr_thread_stall(struct gk20a *g) +{ + gk20a_dbg(gpu_dbg_intr, "interrupt thread launched"); + + trace_mc_gk20a_intr_thread_stall(g->name); + + g->ops.mc.isr_stall(g); + g->ops.mc.intr_stall_resume(g); + + wake_up_all(&g->sw_irq_stall_last_handled_wq); + + trace_mc_gk20a_intr_thread_stall_done(g->name); + + return IRQ_HANDLED; +} + diff --git a/drivers/gpu/nvgpu/common/linux/intr.h b/drivers/gpu/nvgpu/common/linux/intr.h new file mode 100644 index 00000000..243d8f51 --- /dev/null +++ b/drivers/gpu/nvgpu/common/linux/intr.h @@ -0,0 +1,20 @@ +/* + * Copyright (c) 2014-2017, NVIDIA CORPORATION. All rights reserved. + * + * This program is free software; you can redistribute it and/or modify it + * under the terms and conditions of the GNU General Public License, + * version 2, as published by the Free Software Foundation. + * + * This program is distributed in the hope it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for + * more details. + */ + +#ifndef __NVGPU_LINUX_INTR_H__ +#define __NVGPU_LINUX_INTR_H__ +struct gk20a; + +irqreturn_t nvgpu_intr_stall(struct gk20a *g); +irqreturn_t nvgpu_intr_thread_stall(struct gk20a *g); +#endif diff --git a/drivers/gpu/nvgpu/common/linux/module.c b/drivers/gpu/nvgpu/common/linux/module.c index ab99bef0..5e8af065 100644 --- a/drivers/gpu/nvgpu/common/linux/module.c +++ b/drivers/gpu/nvgpu/common/linux/module.c @@ -36,6 +36,7 @@ #include "gk20a/ctxsw_trace_gk20a.h" #include "pci.h" #include "module.h" +#include "intr.h" #ifdef CONFIG_TEGRA_19x_GPU #include "nvgpu_gpuid_t19x.h" #endif @@ -482,7 +483,7 @@ static irqreturn_t gk20a_intr_isr_stall(int irq, void *dev_id) { struct gk20a *g = dev_id; - return g->ops.mc.isr_stall(g); + return nvgpu_intr_stall(g); } static irqreturn_t gk20a_intr_isr_nonstall(int irq, void *dev_id) @@ -496,7 +497,7 @@ static irqreturn_t gk20a_intr_thread_stall(int irq, void *dev_id) { struct gk20a *g = dev_id; - return g->ops.mc.isr_thread_stall(g); + return nvgpu_intr_thread_stall(g); } void gk20a_remove_support(struct gk20a *g) diff --git a/drivers/gpu/nvgpu/common/linux/pci.c b/drivers/gpu/nvgpu/common/linux/pci.c index d729d273..767e9d47 100644 --- a/drivers/gpu/nvgpu/common/linux/pci.c +++ b/drivers/gpu/nvgpu/common/linux/pci.c @@ -25,6 +25,7 @@ #include "gk20a/platform_gk20a.h" #include "clk/clk.h" #include "module.h" +#include "intr.h" #include "pci.h" @@ -232,7 +233,7 @@ static irqreturn_t nvgpu_pci_isr(int irq, void *dev_id) irqreturn_t ret_stall; irqreturn_t ret_nonstall; - ret_stall = g->ops.mc.isr_stall(g); + ret_stall = nvgpu_intr_stall(g); ret_nonstall = g->ops.mc.isr_nonstall(g); #if defined(CONFIG_PCI_MSI) @@ -248,9 +249,7 @@ static irqreturn_t nvgpu_pci_intr_thread(int irq, void *dev_id) { struct gk20a *g = dev_id; - g->ops.mc.isr_thread_stall(g); - - return IRQ_HANDLED; + return nvgpu_intr_thread_stall(g); } static int nvgpu_pci_init_support(struct pci_dev *pdev) -- cgit v1.2.2