diff --git a/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c b/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c index 81f00c792..eb64eb1fb 100644 --- a/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c +++ b/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.c @@ -145,6 +145,9 @@ int test_gm20b_pbdma_acquire_val(struct unit_module *m, int i; int err; + timeout = gm20b_pbdma_acquire_val(0); + assert(is_timeout_valid(m, timeout, 0)); + for (i = 0; i < 32; i++) { ms = (1ULL << i); timeout = gm20b_pbdma_acquire_val(ms); @@ -300,6 +303,7 @@ int test_gm20b_pbdma_handle_intr_0(struct unit_module *m, u32 err_notifier; bool recover; int i; + int err; assert((f->intr.pbdma.device_fatal_0 & pbdma_intr_0_memreq_pending_f()) != 0); @@ -367,9 +371,19 @@ int test_gm20b_pbdma_handle_intr_0(struct unit_module *m, assert(nvgpu_readl(g, pbdma_method2_r(pbdma_id)) != METHOD_SUBCH6); assert(nvgpu_readl(g, pbdma_method3_r(pbdma_id)) != METHOD_SUBCH7); } - } + + /* trigger assert in pbdma_method1_r() */ + pbdma_id = (0x100000000ULL - (u64)pbdma_method1_r(0) + 8191ULL) / 8192ULL; + err = EXPECT_BUG( + recover = gm20b_pbdma_handle_intr_0(g, + pbdma_id, /* invalid pbdma_id */ + pbdma_intr_0_device_pending_f(), + &err_notifier) + ); + assert(err != 0); + ret = UNIT_SUCCESS; done: if (ret != UNIT_SUCCESS) { diff --git a/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.h b/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.h index b5fecc9c9..e38b3936d 100644 --- a/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.h +++ b/userspace/units/fifo/pbdma/gm20b/nvgpu-pbdma-gm20b.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, NVIDIA CORPORATION. All rights reserved. + * Copyright (c) 2019-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"), @@ -53,6 +53,8 @@ struct gk20a; * - Check that delta between expected and actual values is lower than * 1024 * (1 << exponent). * - Check that BUG_ON occurs on overflow while converting ms to ns. + * - Check that enable bit is not set when 0 is passed to + * gm20b_pbdma_acquire_val. * * Output: Returns PASS if all branches gave expected results. FAIL otherwise. */ @@ -116,6 +118,8 @@ int test_gm20b_pbdma_handle_intr(struct unit_module *m, * - pbdma_intr_0_device: Check that all pbdma subch methods and header * have been reset and that recover is true. * - Check that recover is false, when none of above interrupt is raised. + * - Check that BUG() occurs when passing an invalid pbdma_id that + * causes an overflow in register computation. * * Output: Returns PASS if all branches gave expected results. FAIL otherwise. */