diff --git a/drivers/gpu/nvgpu/common/fifo/channel.c b/drivers/gpu/nvgpu/common/fifo/channel.c index ccc57942c..da8dade64 100644 --- a/drivers/gpu/nvgpu/common/fifo/channel.c +++ b/drivers/gpu/nvgpu/common/fifo/channel.c @@ -54,6 +54,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c b/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c index 807e43457..87e8bb702 100644 --- a/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c +++ b/drivers/gpu/nvgpu/common/sync/channel_sync_syncpt.c @@ -354,7 +354,13 @@ nvgpu_channel_sync_syncpt_create(struct nvgpu_channel *c) sp->id = nvgpu_nvhost_get_syncpt_host_managed(sp->nvhost, c->chid, syncpt_name); - if (sp->id == 0U) { + /** + * This is a WAR to handle invalid value of a syncpt. + * Once nvhost update the return value as NVGPU_INVALID_SYNCPT_ID, + * we can remove the zero check. + */ + if ((sp->id == 0U) || + (sp->id == NVGPU_INVALID_SYNCPT_ID)) { nvgpu_kfree(c->g, sp); nvgpu_err(c->g, "failed to get free syncpt"); return NULL; diff --git a/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c b/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c index 518d33fbd..5c0d79e30 100644 --- a/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c +++ b/drivers/gpu/nvgpu/common/sync/channel_user_syncpt.c @@ -88,7 +88,13 @@ nvgpu_channel_user_syncpt_create(struct nvgpu_channel *ch) s->syncpt_id = nvgpu_nvhost_get_syncpt_client_managed(s->nvhost, syncpt_name); - if (s->syncpt_id == 0U) { + /** + * This is a WAR to handle invalid value of a syncpt. + * Once nvhost update the return value as NVGPU_INVALID_SYNCPT_ID, + * we can remove the zero check. + */ + if ((s->syncpt_id == 0U) || + (s->syncpt_id == NVGPU_INVALID_SYNCPT_ID)) { nvgpu_err(g, "failed to get free syncpt"); goto err_free; } diff --git a/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h b/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h index df2bcb9af..9d3bd904c 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h +++ b/drivers/gpu/nvgpu/include/nvgpu/channel_sync_syncpt.h @@ -2,7 +2,7 @@ * * Nvgpu Channel Synchronization Abstraction (Syncpoints) * - * Copyright (c) 2018-2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2018-2020, NVIDIA CORPORATION. All rights reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -29,10 +29,9 @@ #include #include #include +#include #include -#define NVGPU_INVALID_SYNCPT_ID (~U32(0U)) - struct nvgpu_channel; struct nvgpu_channel_sync_syncpt; struct priv_cmd_entry; diff --git a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h index 12a507ed3..811f1c559 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/nvhost.h +++ b/drivers/gpu/nvgpu/include/nvgpu/nvhost.h @@ -26,6 +26,7 @@ #include struct gk20a; +#define NVGPU_INVALID_SYNCPT_ID (~U32(0U)) #ifdef CONFIG_TEGRA_GK20A_NVHOST diff --git a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c index 26bb8af80..00405753d 100644 --- a/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c +++ b/drivers/gpu/nvgpu/os/linux/ioctl_ctrl.c @@ -24,6 +24,7 @@ #include #include +#include #include #include #include