From 17fa44836baa351b4a16f0185e38dbbd98a190bf Mon Sep 17 00:00:00 2001 From: Jeffery Yu Date: Wed, 10 Oct 2018 19:04:17 +0800 Subject: [PATCH] gpu: nvgpu: add a reboot notifier In some case, CDE is keeping require FW during device shutdown. So add a reboot notifier to set driver_is_dying during shutdown. Bug 200455178 Change-Id: Iec324855b15f5f3432ac9358d08ed7cfe4640bf6 Signed-off-by: Jeffery Yu Reviewed-on: https://git-master.nvidia.com/r/1928717 GVS: Gerrit_Virtual_Submit Reviewed-by: Hayden Du Reviewed-by: mobile promotions Tested-by: mobile promotions --- drivers/gpu/nvgpu/gk20a/gk20a.c | 24 ++++++++++++++++++++++++ drivers/gpu/nvgpu/gk20a/platform_gk20a.h | 3 +++ 2 files changed, 27 insertions(+) diff --git a/drivers/gpu/nvgpu/gk20a/gk20a.c b/drivers/gpu/nvgpu/gk20a/gk20a.c index b173b1ff7..8c7bd40ce 100644 --- a/drivers/gpu/nvgpu/gk20a/gk20a.c +++ b/drivers/gpu/nvgpu/gk20a/gk20a.c @@ -1598,6 +1598,21 @@ int gk20a_secure_page_alloc(struct device *dev) return err; } +static int gk20a_reboot_cb(struct notifier_block *nb, + unsigned long event, void *unused) +{ + struct gk20a_platform *platform = NULL; + + platform = container_of(nb, struct gk20a_platform, + reboot_notifier); + + down_write(&platform->g->busy_lock); + platform->g->driver_is_dying = 1; + up_write(&platform->g->busy_lock); + + return NOTIFY_DONE; +} + static int gk20a_probe(struct platform_device *dev) { struct gk20a *gk20a; @@ -1635,6 +1650,15 @@ static int gk20a_probe(struct platform_device *dev) } set_gk20a(dev, gk20a); + + platform->reboot_notifier.notifier_call = gk20a_reboot_cb; + err = register_reboot_notifier(&platform->reboot_notifier); + if (err) { + dev_err(&dev->dev, + "failed to register reboot notifier\n"); + return err; + } + gk20a->dev = &dev->dev; nvgpu_kmem_init(gk20a); diff --git a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h index a969a54c3..2599ccecd 100644 --- a/drivers/gpu/nvgpu/gk20a/platform_gk20a.h +++ b/drivers/gpu/nvgpu/gk20a/platform_gk20a.h @@ -43,6 +43,9 @@ struct gk20a_platform { /* Populated by the gk20a driver before probing the platform. */ struct gk20a *g; + /* Make gpu be "can't be busy" during system shutdown. */ + struct notifier_block reboot_notifier; + /* Should be populated at probe. */ bool is_fmodel;