[COMMON] media: scaler: move ion_client from int_frame to dev
authorJanghyuck Kim <janghyuck.kim@samsung.com>
Sat, 6 May 2017 09:09:33 +0000 (18:09 +0900)
committerSeungchul Kim <sc377.kim@samsung.com>
Mon, 28 May 2018 05:28:28 +0000 (14:28 +0900)
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 <janghyuck.kim@samsung.com>
drivers/media/platform/exynos/scaler/scaler-core.c
drivers/media/platform/exynos/scaler/scaler.h

index a5313ebec64e4114492362da9ec9310b546773e6..58fbd3eef764acbebf8084ecd3bcffc804a65424 100644 (file)
@@ -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);
 
index 0f79b8ea20b45d2e4285c534bd46b678ff84d559..5eb4e291e63d171eb1cc13f8b714363f148d88f8 100644 (file)
@@ -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 {