Skip to content

Commit

Permalink
media/rpivid: Allow use of iommu in rpivid
Browse files Browse the repository at this point in the history
In order to use iommu on hevc set dma mask_and_coherent in probe.
I am assured dma_set_mask_and_coherent is benign on Pi4 (which has
no iommu) and it seems to be so in practice.
Also adds a bit of debug to make internal buffer allocation failure
easier to spot in future

Signed-off-by: John Cox <[email protected]>
  • Loading branch information
jc-kynesim committed Oct 2, 2023
1 parent 2ff65ff commit 89b918c
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
7 changes: 7 additions & 0 deletions drivers/staging/media/rpivid/rpivid.c
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,13 @@ static int rpivid_probe(struct platform_device *pdev)
snprintf(vfd->name, sizeof(vfd->name), "%s", rpivid_video_device.name);
video_set_drvdata(vfd, dev);

ret = dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(36));
if (ret) {
v4l2_err(&dev->v4l2_dev,
"Failed dma_set_mask_and_coherent\n");
goto err_v4l2;
}

dev->m2m_dev = v4l2_m2m_init(&rpivid_m2m_ops);
if (IS_ERR(dev->m2m_dev)) {
v4l2_err(&dev->v4l2_dev,
Expand Down
12 changes: 10 additions & 2 deletions drivers/staging/media/rpivid/rpivid_h265.c
Original file line number Diff line number Diff line change
Expand Up @@ -2495,11 +2495,19 @@ static int rpivid_h265_start(struct rpivid_ctx *ctx)
for (i = 0; i != ARRAY_SIZE(ctx->pu_bufs); ++i) {
// Don't actually need a kernel mapping here
if (gptr_alloc(dev, ctx->pu_bufs + i, pu_alloc,
DMA_ATTR_NO_KERNEL_MAPPING))
DMA_ATTR_NO_KERNEL_MAPPING)) {
v4l2_err(&dev->v4l2_dev,
"Failed to alloc %#zx PU%d buffer\n",
pu_alloc, i);
goto fail;
}
if (gptr_alloc(dev, ctx->coeff_bufs + i, coeff_alloc,
DMA_ATTR_NO_KERNEL_MAPPING))
DMA_ATTR_NO_KERNEL_MAPPING)) {
v4l2_err(&dev->v4l2_dev,
"Failed to alloc %#zx Coeff%d buffer\n",
pu_alloc, i);
goto fail;
}
}
aux_q_init(ctx);

Expand Down

0 comments on commit 89b918c

Please sign in to comment.