[PATCH v3 24/24] dma-buf: Add kunit tests for mapping type selection
Alistair Popple
apopple at nvidia.com
Sun Nov 22 20:26:57 PST 2026
On 2026-11-21 at 16:58 +1100, sashiko-bot at kernel.org wrote...
> Thank you for your contribution! Sashiko AI review found 3 potential
> issues to consider:
> - [High] dma-buf: build failure from mapping2->type access in selection
> KUnit tests
[ ... ]
> > + /* A second map does not reselect. */
> > + mock_select_idx = 0;
> > + mapping2 = dma_buf_mapping_map(attach, DMA_BIDIRECTIONAL);
> > + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mapping2);
> > + KUNIT_EXPECT_PTR_EQ(test, mapping2->type, &mock_type_b);
>
> [Severity: High]
> Does accessing mapping2->type break the build when CONFIG_DMABUF_KUNIT_TEST
> is enabled?
>
> struct dma_buf_mapping only has a match member, not type, so these two
> checks in test_unmap_uses_own_type() and
> test_select_survives_own_invalidate() should use
> dma_buf_mapping_type_of(mapping2).
Ugh. I made an accessor for the type in my final iteration before sending this
and clearly forgot to do a full module rebuild and retest. It's a trivial fix,
and I just re-tested to ensure the kunit tests pass.
I have also been writing and running some basic tests that exercise the new
dma-buf paths via vfio-pci and iommufd, nvme or nic rdma which are working. I
haven't posted these as part of the series as they are user-space tests that
require fairly specific HW setups. If anyone is interested I can put them
somewhere though.
---
index 42e6748f0ae6..6e88c36d8c9b 100644
--- a/drivers/dma-buf/st-dma-mapping.c
+++ b/drivers/dma-buf/st-dma-mapping.c
@@ -950,7 +950,7 @@ static void test_unmap_uses_own_type(struct kunit *test)
mock_select_idx = 0;
mapping2 = dma_buf_mapping_map(attach, DMA_BIDIRECTIONAL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mapping2);
- KUNIT_EXPECT_PTR_EQ(test, mapping2->type, &mock_type_a);
+ KUNIT_EXPECT_PTR_EQ(test, dma_buf_mapping_type_of(mapping2), &mock_type_a);
KUNIT_EXPECT_TRUE(test, attach->selected);
KUNIT_EXPECT_EQ(test, mock_select_count, 2);
KUNIT_EXPECT_PTR_EQ(test, dma_buf_attach_map_type(attach)->type,
@@ -1043,7 +1043,7 @@ static void test_select_survives_own_invalidate(struct kunit *test)
mock_select_idx = 0;
mapping2 = dma_buf_mapping_map(attach, DMA_BIDIRECTIONAL);
KUNIT_ASSERT_NOT_ERR_OR_NULL(test, mapping2);
- KUNIT_EXPECT_PTR_EQ(test, mapping2->type, &mock_type_b);
+ KUNIT_EXPECT_PTR_EQ(test, dma_buf_mapping_type_of(mapping2), &mock_type_b);
KUNIT_EXPECT_TRUE(test, attach->selected);
KUNIT_EXPECT_EQ(test, mock_select_count, 1);
>
> --
> Sashiko AI review · https://sashiko.dev/#/patchset/20261120-dma_mapping_type_v4-v3-0-c0183a409bdf@nvidia.com?part=24
More information about the Linux-nvme
mailing list