From patchwork Mon Feb 20 13:38:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 94219 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1327226qgi; Mon, 20 Feb 2017 05:40:03 -0800 (PST) X-Received: by 10.98.157.12 with SMTP id i12mr13202694pfd.166.1487598003192; Mon, 20 Feb 2017 05:40:03 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d2si18592166pge.343.2017.02.20.05.40.02; Mon, 20 Feb 2017 05:40:03 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-samsung-soc-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-samsung-soc-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753497AbdBTNkB (ORCPT + 4 others); Mon, 20 Feb 2017 08:40:01 -0500 Received: from mailout2.w1.samsung.com ([210.118.77.12]:21520 "EHLO mailout2.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753039AbdBTNjT (ORCPT ); Mon, 20 Feb 2017 08:39:19 -0500 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout2.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OLO0073HDXFZG50@mailout2.w1.samsung.com>; Mon, 20 Feb 2017 13:39:15 +0000 (GMT) Received: from eusmges2.samsung.com (unknown [203.254.199.241]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170220133914eucas1p290861a6c28cc9b33b7b91566b029b264~lAnVN_keE0836008360eucas1p2u; Mon, 20 Feb 2017 13:39:14 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges2.samsung.com (EUCPMTA) with SMTP id 6D.98.30614.281FAA85; Mon, 20 Feb 2017 13:39:14 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170220133914eucas1p1745bc1bb6a62938ed3cc6d9998bb0102~lAnUkuTtQ0281602816eucas1p1B; Mon, 20 Feb 2017 13:39:14 +0000 (GMT) X-AuditID: cbfec7f1-f793f6d000007796-09-58aaf182a646 Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id A6.FA.10233.781FAA85; Mon, 20 Feb 2017 13:39:19 +0000 (GMT) Received: from AMDC2765.digital.local ([106.116.147.25]) by eusync1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTPA id <0OLO00HBFDX6PK30@eusync1.samsung.com>; Mon, 20 Feb 2017 13:39:13 +0000 (GMT) From: Marek Szyprowski To: linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Sylwester Nawrocki , Andrzej Hajda , Krzysztof Kozlowski , Inki Dae , Seung-Woo Kim Subject: [PATCH v2 07/15] media: s5p-mfc: Put firmware to private buffer structure Date: Mon, 20 Feb 2017 14:38:56 +0100 Message-id: <1487597944-2000-8-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 In-reply-to: <1487597944-2000-1-git-send-email-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrCIsWRmVeSWpSXmKPExsWy7djPc7pNH1dFGBw9LGdxa905VotJ9yew WJw/v4HdomfDVlaLGef3MVmsPXKX3eLwm3Ygd/JLNgcOj02rOtk8+rasYvT4vEkugDmKyyYl NSezLLVI3y6BK+Po/CmsBQvUK5Zf/M7awNiv2MXIySEhYCKx6uwXFghbTOLCvfVsXYxcHEIC SxklnrevYoJwPjNKfHy3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vkv0wRG3gWMDKsYRVJLi3PT c4uN9IoTc4tL89L1kvNzNzECA3jbsZ9bdjB2vQs+xCjAwajEw6sxc2WEEGtiWXFl7iFGCQ5m JRHeyy9XRQjxpiRWVqUW5ccXleakFh9iNAW6aSKzlGhyPjC68kriDU0MzS0NjYwtLMyNjJTE ead+uBIuJJCeWJKanZpakFoE08fEwSnVwGjU919torFfl6K1312OiU/ehV+8Zfy9ofadcd9p G3eBx2evN1Yc2q6xv84ySDbNmvHsGsMDSkLGE9VjdBlCL19nPcrXna7RYPvf+jDj9AnL3vT+ OnL3qN2Opbq6HY2bGv+zq4jFtMy5yJ/dqBtjuDr+9dXgL0vXrb81qWp++P3c35EPiv62z1Ni Kc5INNRiLipOBAAMJuL6dgIAAA== X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170220133914eucas1p1745bc1bb6a62938ed3cc6d9998bb0102 X-Msg-Generator: CA X-Sender-IP: 182.198.249.180 X-Local-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1B?= =?utf-8?b?7IK87ISx7KCE7J6QG1NlbmlvciBTb2Z0d2FyZSBFbmdpbmVlcg==?= X-Global-Sender: =?utf-8?q?Marek_Szyprowski=1BSRPOL-Kernel_=28TP=29=1BSam?= =?utf-8?q?sung_Electronics=1BSenior_Software_Engineer?= X-Sender-Code: =?utf-8?q?C10=1BEHQ=1BC10CD02CD027392?= CMS-TYPE: 201P X-HopCount: 7 X-CMS-RootMailID: 20170220133914eucas1p1745bc1bb6a62938ed3cc6d9998bb0102 X-RootMTR: 20170220133914eucas1p1745bc1bb6a62938ed3cc6d9998bb0102 References: <1487597944-2000-1-git-send-email-m.szyprowski@samsung.com> Sender: linux-samsung-soc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-samsung-soc@vger.kernel.org Use s5p_mfc_priv_buf structure for keeping the firmware image. This will help handling of firmware buffer allocation in the next patches. Signed-off-by: Marek Szyprowski Reviewed-by: Javier Martinez Canillas Tested-by: Javier Martinez Canillas --- drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 3 +-- drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c | 36 ++++++++++++------------- 3 files changed, 20 insertions(+), 21 deletions(-) -- 1.9.1 -- To unsubscribe from this list: send the line "unsubscribe linux-samsung-soc" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c index 8c4739ca16d6..4c80bb4243be 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c @@ -47,7 +47,7 @@ static int s5p_mfc_sys_init_cmd_v5(struct s5p_mfc_dev *dev) struct s5p_mfc_cmd_args h2r_args; memset(&h2r_args, 0, sizeof(struct s5p_mfc_cmd_args)); - h2r_args.arg[0] = dev->fw_size; + h2r_args.arg[0] = dev->fw_buf.size; return s5p_mfc_cmd_host2risc_v5(dev, S5P_FIMV_H2R_CMD_SYS_INIT, &h2r_args); } diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h index 9cf860f34c71..cea17a737ef7 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_common.h +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_common.h @@ -314,8 +314,7 @@ struct s5p_mfc_dev { int int_type; unsigned int int_err; wait_queue_head_t queue; - size_t fw_size; - void *fw_virt_addr; + struct s5p_mfc_priv_buf fw_buf; dma_addr_t dma_base[BANK_CTX_NUM]; unsigned long hw_lock; struct s5p_mfc_ctx *ctx[MFC_NUM_CONTEXTS]; diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c index c9bff3d0655f..50d698968049 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c @@ -29,21 +29,22 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev) void *bank2_virt; dma_addr_t bank2_dma_addr; unsigned int align_size = 1 << MFC_BASE_ALIGN_ORDER; + struct s5p_mfc_priv_buf *fw_buf = &dev->fw_buf; - dev->fw_size = dev->variant->buf_size->fw; + fw_buf->size = dev->variant->buf_size->fw; - if (dev->fw_virt_addr) { + if (fw_buf->virt) { mfc_err("Attempting to allocate firmware when it seems that it is already loaded\n"); return -ENOMEM; } - dev->fw_virt_addr = dma_alloc_coherent(dev->mem_dev[BANK1_CTX], - dev->fw_size, &dev->dma_base[BANK1_CTX], - GFP_KERNEL); - if (!dev->fw_virt_addr) { + fw_buf->virt = dma_alloc_coherent(dev->mem_dev[BANK1_CTX], fw_buf->size, + &fw_buf->dma, GFP_KERNEL); + if (!fw_buf->virt) { mfc_err("Allocating bitprocessor buffer failed\n"); return -ENOMEM; } + dev->dma_base[BANK1_CTX] = fw_buf->dma; if (HAS_PORTNUM(dev) && IS_TWOPORT(dev)) { bank2_virt = dma_alloc_coherent(dev->mem_dev[BANK2_CTX], @@ -51,10 +52,9 @@ int s5p_mfc_alloc_firmware(struct s5p_mfc_dev *dev) if (!bank2_virt) { mfc_err("Allocating bank2 base failed\n"); - dma_free_coherent(dev->mem_dev[BANK1_CTX], dev->fw_size, - dev->fw_virt_addr, - dev->dma_base[BANK1_CTX]); - dev->fw_virt_addr = NULL; + dma_free_coherent(dev->mem_dev[BANK1_CTX], fw_buf->size, + fw_buf->virt, fw_buf->dma); + fw_buf->virt = NULL; return -ENOMEM; } @@ -101,17 +101,17 @@ int s5p_mfc_load_firmware(struct s5p_mfc_dev *dev) mfc_err("Firmware is not present in the /lib/firmware directory nor compiled in kernel\n"); return -EINVAL; } - if (fw_blob->size > dev->fw_size) { + if (fw_blob->size > dev->fw_buf.size) { mfc_err("MFC firmware is too big to be loaded\n"); release_firmware(fw_blob); return -ENOMEM; } - if (!dev->fw_virt_addr) { + if (!dev->fw_buf.virt) { mfc_err("MFC firmware is not allocated\n"); release_firmware(fw_blob); return -EINVAL; } - memcpy(dev->fw_virt_addr, fw_blob->data, fw_blob->size); + memcpy(dev->fw_buf.virt, fw_blob->data, fw_blob->size); wmb(); release_firmware(fw_blob); mfc_debug_leave(); @@ -123,11 +123,11 @@ int s5p_mfc_release_firmware(struct s5p_mfc_dev *dev) { /* Before calling this function one has to make sure * that MFC is no longer processing */ - if (!dev->fw_virt_addr) + if (!dev->fw_buf.virt) return -EINVAL; - dma_free_coherent(dev->mem_dev[BANK1_CTX], dev->fw_size, - dev->fw_virt_addr, dev->dma_base[BANK1_CTX]); - dev->fw_virt_addr = NULL; + dma_free_coherent(dev->mem_dev[BANK1_CTX], dev->fw_buf.size, + dev->fw_buf.virt, dev->fw_buf.dma); + dev->fw_buf.virt = NULL; return 0; } @@ -246,7 +246,7 @@ int s5p_mfc_init_hw(struct s5p_mfc_dev *dev) int ret; mfc_debug_enter(); - if (!dev->fw_virt_addr) { + if (!dev->fw_buf.virt) { mfc_err("Firmware memory is not allocated.\n"); return -EINVAL; }