Skip to content

Commit

Permalink
drm/mediatek: Drop local dma_parms
Browse files Browse the repository at this point in the history
Since commit 9495b7e ("driver core: platform: Initialize dma_parms
for platform devices"), struct platform_device already provides a
dma_parms structure, so we can save allocating another one.

Also the DMA segment size is simply a size, not a bitmask.

Signed-off-by: Robin Murphy <robin.murphy@arm.com>
Signed-off-by: Chun-Kuang Hu <chunkuang.hu@kernel.org>
  • Loading branch information
Robin Murphy authored and Chun-Kuang Hu committed Nov 22, 2020
1 parent 9273cf7 commit 31855cf
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 26 deletions.
27 changes: 3 additions & 24 deletions drivers/gpu/drm/mediatek/mtk_drm_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,21 +241,10 @@ static int mtk_drm_kms_init(struct drm_device *drm)
* Configure the DMA segment size to make sure we get contiguous IOVA
* when importing PRIME buffers.
*/
if (!dma_dev->dma_parms) {
private->dma_parms_allocated = true;
dma_dev->dma_parms =
devm_kzalloc(drm->dev, sizeof(*dma_dev->dma_parms),
GFP_KERNEL);
}
if (!dma_dev->dma_parms) {
ret = -ENOMEM;
goto put_dma_dev;
}

ret = dma_set_max_seg_size(dma_dev, (unsigned int)DMA_BIT_MASK(32));
ret = dma_set_max_seg_size(dma_dev, UINT_MAX);
if (ret) {
dev_err(dma_dev, "Failed to set DMA segment size\n");
goto err_unset_dma_parms;
goto err_component_unbind;
}

/*
Expand All @@ -266,18 +255,13 @@ static int mtk_drm_kms_init(struct drm_device *drm)
drm->irq_enabled = true;
ret = drm_vblank_init(drm, MAX_CRTC);
if (ret < 0)
goto err_unset_dma_parms;
goto err_component_unbind;

drm_kms_helper_poll_init(drm);
drm_mode_config_reset(drm);

return 0;

err_unset_dma_parms:
if (private->dma_parms_allocated)
dma_dev->dma_parms = NULL;
put_dma_dev:
put_device(private->dma_dev);
err_component_unbind:
component_unbind_all(drm->dev, drm);
put_mutex_dev:
Expand All @@ -287,14 +271,9 @@ static int mtk_drm_kms_init(struct drm_device *drm)

static void mtk_drm_kms_deinit(struct drm_device *drm)
{
struct mtk_drm_private *private = drm->dev_private;

drm_kms_helper_poll_fini(drm);
drm_atomic_helper_shutdown(drm);

if (private->dma_parms_allocated)
private->dma_dev->dma_parms = NULL;

component_unbind_all(drm->dev, drm);
}

Expand Down
2 changes: 0 additions & 2 deletions drivers/gpu/drm/mediatek/mtk_drm_drv.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,6 @@ struct mtk_drm_private {
struct mtk_ddp_comp *ddp_comp[DDP_COMPONENT_ID_MAX];
const struct mtk_mmsys_driver_data *data;
struct drm_atomic_state *suspend_state;

bool dma_parms_allocated;
};

extern struct platform_driver mtk_ddp_driver;
Expand Down

0 comments on commit 31855cf

Please sign in to comment.