diff --git a/arch/nvgpu-common.yaml b/arch/nvgpu-common.yaml index fae1ae6f4..320aec002 100644 --- a/arch/nvgpu-common.yaml +++ b/arch/nvgpu-common.yaml @@ -196,7 +196,8 @@ utils: common/utils/string.c, common/utils/worker.c, common/utils/rbtree.c, - common/utils/enabled.c ] + common/utils/enabled.c, + common/utils/assert.c ] ## ## Common elements. diff --git a/drivers/gpu/nvgpu/Makefile b/drivers/gpu/nvgpu/Makefile index 2db19565c..6a4d06b28 100644 --- a/drivers/gpu/nvgpu/Makefile +++ b/drivers/gpu/nvgpu/Makefile @@ -68,6 +68,7 @@ obj-$(CONFIG_GK20A) := nvgpu.o # is in progress. nvgpu-y += \ + common/utils/assert.o \ common/utils/enabled.o \ common/utils/rbtree.o \ common/utils/string.o \ diff --git a/drivers/gpu/nvgpu/Makefile.sources b/drivers/gpu/nvgpu/Makefile.sources index 16532a6d4..87a29427f 100644 --- a/drivers/gpu/nvgpu/Makefile.sources +++ b/drivers/gpu/nvgpu/Makefile.sources @@ -80,7 +80,8 @@ srcs += os/posix/bug.c \ os/posix/bitmap.c \ os/posix/kmem.c -srcs += common/utils/enabled.c \ +srcs += common/utils/assert.c \ + common/utils/enabled.c \ common/utils/rbtree.c \ common/utils/string.c \ common/utils/worker.c \ diff --git a/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gm20b.c b/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gm20b.c index 132877ef7..11caa163d 100644 --- a/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gm20b.c +++ b/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gm20b.c @@ -22,6 +22,7 @@ #include +#include #include "pmu_perfmon_sw_gm20b.h" void nvgpu_gm20b_perfmon_sw_init(struct gk20a *g, diff --git a/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gv11b.c b/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gv11b.c index fbb344adb..78e89529b 100644 --- a/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gv11b.c +++ b/drivers/gpu/nvgpu/common/pmu/perfmon/pmu_perfmon_sw_gv11b.c @@ -21,6 +21,7 @@ */ #include +#include #include "pmu_perfmon_sw_gv11b.h" void nvgpu_gv11b_perfmon_sw_init(struct gk20a *g, diff --git a/drivers/gpu/nvgpu/common/utils/assert.c b/drivers/gpu/nvgpu/common/utils/assert.c new file mode 100644 index 000000000..829390fa0 --- /dev/null +++ b/drivers/gpu/nvgpu/common/utils/assert.c @@ -0,0 +1,37 @@ +/* + * Copyright (c) 2018-2019, 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"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +#include +#include +#include + +void nvgpu_do_assert_print(struct gk20a *g, const char *fmt, ...) +{ +#ifdef CONFIG_NVGPU_LOGGING + va_list args; + + va_start(args, fmt); + nvgpu_err(g, fmt, args); + va_end(args); +#endif + nvgpu_do_assert(); +} diff --git a/drivers/gpu/nvgpu/include/nvgpu/bug.h b/drivers/gpu/nvgpu/include/nvgpu/bug.h index 0fa2d76f2..3ccb8eb1d 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/bug.h +++ b/drivers/gpu/nvgpu/include/nvgpu/bug.h @@ -28,8 +28,6 @@ #include #endif -#include - /* * Define an assert macro that code within nvgpu can use. * @@ -69,10 +67,7 @@ static inline void nvgpu_assert(bool cond) */ #define nvgpu_do_assert() nvgpu_assert(false) -#define nvgpu_do_assert_print(g, fmt, ...) \ - do { \ - nvgpu_err(g, fmt, ##__VA_ARGS__); \ - nvgpu_do_assert(); \ - } while (false) +struct gk20a; +void nvgpu_do_assert_print(struct gk20a *g, const char *fmt, ...); #endif /* NVGPU_BUG_H */ diff --git a/drivers/gpu/nvgpu/include/nvgpu/posix/atomic.h b/drivers/gpu/nvgpu/include/nvgpu/posix/atomic.h index 35ec2c310..afa0538ff 100644 --- a/drivers/gpu/nvgpu/include/nvgpu/posix/atomic.h +++ b/drivers/gpu/nvgpu/include/nvgpu/posix/atomic.h @@ -26,6 +26,7 @@ #include #include #include +#include /* * Note: this code uses the GCC builtins to implement atomics. diff --git a/drivers/gpu/nvgpu/os/posix/cond.c b/drivers/gpu/nvgpu/os/posix/cond.c index 77d835c89..6cab620f8 100644 --- a/drivers/gpu/nvgpu/os/posix/cond.c +++ b/drivers/gpu/nvgpu/os/posix/cond.c @@ -21,6 +21,7 @@ */ #include +#include int nvgpu_cond_init(struct nvgpu_cond *cond) { diff --git a/drivers/gpu/nvgpu/os/posix/kmem.c b/drivers/gpu/nvgpu/os/posix/kmem.c index aaec66b8b..79f2b91de 100644 --- a/drivers/gpu/nvgpu/os/posix/kmem.c +++ b/drivers/gpu/nvgpu/os/posix/kmem.c @@ -23,6 +23,7 @@ #include #include +#include #include #include #include