From: Janghyuck Kim Date: Sat, 6 May 2017 09:09:33 +0000 (+0900) Subject: [COMMON] media: scaler: move ion_client from int_frame to dev X-Git-Url: https://git.stricted.de/?a=commitdiff_plain;h=ecbf9ac1c03413c3f960d292cf63ed05035da4e8;p=GitHub%2FLineageOS%2Fandroid_kernel_motorola_exynos9610.git [COMMON] media: scaler: move ion_client from int_frame to dev ion_client is used for internal buffer allocation, but it would be complicated and hard to manage when it is used for int_frame and mid_buf. So it is moved to sc_dev. Change-Id: Ie16119f2871246d0dc886b31d27d689197e50ca4 Signed-off-by: Janghyuck Kim --- diff --git a/drivers/media/platform/exynos/scaler/scaler-core.c b/drivers/media/platform/exynos/scaler/scaler-core.c index a5313ebec64e..58fbd3eef764 100644 --- a/drivers/media/platform/exynos/scaler/scaler-core.c +++ b/drivers/media/platform/exynos/scaler/scaler-core.c @@ -1065,7 +1065,7 @@ static void free_intermediate_frame(struct sc_ctx *ctx) ctx->i_frame->sgt[i], DMA_BIDIRECTIONAL); dma_buf_detach(ctx->i_frame->dma_buf[i], ctx->i_frame->attachment[i]); dma_buf_put(ctx->i_frame->dma_buf[i]); - ion_free(ctx->i_frame->client, ctx->i_frame->handle[i]); + ion_free(ctx->sc_dev->client, ctx->i_frame->handle[i]); } } @@ -1078,7 +1078,6 @@ static void destroy_intermediate_frame(struct sc_ctx *ctx) { if (ctx->i_frame) { free_intermediate_frame(ctx); - ion_client_destroy(ctx->i_frame->client); kfree(ctx->i_frame); ctx->i_frame = NULL; clear_bit(CTX_INT_FRAME, &ctx->flags); @@ -1122,7 +1121,7 @@ static bool initialize_initermediate_frame(struct sc_ctx *ctx) if (!frame->addr.size[i]) break; - ctx->i_frame->handle[i] = ion_alloc(ctx->i_frame->client, + ctx->i_frame->handle[i] = ion_alloc(ctx->sc_dev->client, frame->addr.size[i], 0, ion_mask, flag); if (IS_ERR(ctx->i_frame->handle[i])) { dev_err(sc->dev, @@ -1132,7 +1131,7 @@ static bool initialize_initermediate_frame(struct sc_ctx *ctx) goto err_ion_alloc; } - ctx->i_frame->dma_buf[i] = ion_share_dma_buf(ctx->i_frame->client, + ctx->i_frame->dma_buf[i] = ion_share_dma_buf(ctx->sc_dev->client, ctx->i_frame->handle[i]); if (IS_ERR(ctx->i_frame->dma_buf[i])) { dev_err(sc->dev, @@ -1201,17 +1200,6 @@ static bool allocate_intermediate_frame(struct sc_ctx *ctx) "Failed to allocate intermediate frame\n"); return false; } - - ctx->i_frame->client = exynos_ion_client_create("scaler-int"); - if (IS_ERR(ctx->i_frame->client)) { - dev_err(ctx->sc_dev->dev, - "Failed to create ION client for int.buf.(err %ld)\n", - PTR_ERR(ctx->i_frame->client)); - ctx->i_frame->client = NULL; - kfree(ctx->i_frame); - ctx->i_frame = NULL; - return false; - } } return true; @@ -3417,6 +3405,14 @@ static int sc_probe(struct platform_device *pdev) goto err_qch_dbg; } + sc->client = exynos_ion_client_create("scaler-int"); + if (IS_ERR(sc->client)) { + ret = PTR_ERR(sc->client); + dev_err(&pdev->dev, + "Failed to create ION client for int.buf.(err %d)\n", ret); + goto err_ion_client_create; + } + sc->version = SCALER_VERSION(2, 0, 0); hwver = __raw_readl(sc->regs + SCALER_VER); @@ -3448,6 +3444,9 @@ static int sc_probe(struct platform_device *pdev) hwver, sc->version); return 0; + +err_ion_client_create: + kfree(sc->qch_dbg); err_qch_dbg: iounmap(sc->q_reg); err_qch_reg: @@ -3474,6 +3473,7 @@ static int sc_remove(struct platform_device *pdev) { struct sc_dev *sc = platform_get_drvdata(pdev); + ion_client_destroy(sc->client); iounmap(sc->q_reg); kfree(sc->qch_dbg); diff --git a/drivers/media/platform/exynos/scaler/scaler.h b/drivers/media/platform/exynos/scaler/scaler.h index 0f79b8ea20b4..5eb4e291e63d 100644 --- a/drivers/media/platform/exynos/scaler/scaler.h +++ b/drivers/media/platform/exynos/scaler/scaler.h @@ -299,7 +299,6 @@ struct sc_frame { struct sc_int_frame { struct sc_frame frame; - struct ion_client *client; struct ion_handle *handle[3]; struct sc_addr src_addr; struct sc_addr dst_addr; @@ -417,6 +416,7 @@ struct sc_dev { u32 cfw; int dbg_idx; struct sc_qch_dbg *qch_dbg; + struct ion_client *client; }; enum SC_CONTEXT_TYPE {