From patchwork Mon Feb 20 13:38:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marek Szyprowski X-Patchwork-Id: 94209 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp1326938qgi; Mon, 20 Feb 2017 05:39:21 -0800 (PST) X-Received: by 10.99.212.69 with SMTP id i5mr1572228pgj.115.1487597961563; Mon, 20 Feb 2017 05:39:21 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m39si161270plg.44.2017.02.20.05.39.21; Mon, 20 Feb 2017 05:39:21 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-media-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-media-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-media-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753108AbdBTNjT (ORCPT + 4 others); Mon, 20 Feb 2017 08:39:19 -0500 Received: from mailout1.w1.samsung.com ([210.118.77.11]:21738 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752520AbdBTNjP (ORCPT ); Mon, 20 Feb 2017 08:39:15 -0500 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout1.w1.samsung.com (Oracle Communications Messaging Server 7.0.5.31.0 64bit (built May 5 2014)) with ESMTP id <0OLO008ZBDXCPR40@mailout1.w1.samsung.com>; Mon, 20 Feb 2017 13:39:12 +0000 (GMT) Received: from eusmges5.samsung.com (unknown [203.254.199.245]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20170220133911eucas1p218fa9a650c7b17ae14ecf3c75899fd87~lAnSNlQgC2257122571eucas1p2_; Mon, 20 Feb 2017 13:39:11 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges5.samsung.com (EUCPMTA) with SMTP id 1C.43.17477.F71FAA85; Mon, 20 Feb 2017 13:39:11 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eucas1p1.samsung.com (KnoxPortal) with ESMTP id 20170220133910eucas1p10f347d7688dd51ea70d15994c9d5d1f1~lAnRnHx6z0280202802eucas1p1k; Mon, 20 Feb 2017 13:39:10 +0000 (GMT) X-AuditID: cbfec7f5-f79d06d000004445-d1-58aaf17f837f Received: from eusync1.samsung.com ( [203.254.199.211]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id E0.FA.10233.481FAA85; Mon, 20 Feb 2017 13:39:16 +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:10 +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 00/15] Exynos MFC v6+ - remove the need for the reserved memory Date: Mon, 20 Feb 2017 14:38:49 +0100 Message-id: <1487597944-2000-1-git-send-email-m.szyprowski@samsung.com> X-Mailer: git-send-email 1.9.1 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFtrOIsWRmVeSWpSXmKPExsWy7djP87r1H1dFGNy+LWBxa905VotJ9yew WJw/v4HdomfDVlaLGef3MVmsPXKX3eLwm3Ygd/JLNgcOj02rOtk8+rasYvT4vEkugDmKyyYl NSezLLVI3y6BK2Pm7m+sBU2aFdvPqzUwNit2MXJySAiYSNzt/8kEYYtJXLi3nq2LkYtDSGAp o8T9vRuZIJzPjBKfr7xnhOl4NrGPFSKxjFFiRhdIAsRpYJJo7XwEVsUmYCjR9baLDcQ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vv1wVIcSbklhZlVqUH19U mpNafIjRFGj5RGYp0eR8YLTklcQbmhiaWxoaGVtYmBsZKYnzTv1wJVxIID2xJDU7NbUgtQim j4mDU6qB8VDHpIc1upUf59zmmxjWdDh/WlXrDtfXknuyei6sNPtVG2EpH3Nd5nSa7PuiizvK 7G+HfjDTLOM++9PDj4/PzWXHQRXuSdzh/Yd9HjecsHBed/r50WZr2yPXj1zV5xL7eXNets7x BYtW1ro+EVP31i28knWRnyFWVP7gF66ohCdmaxw+9TzrUGIpzkg01GIuKk4EANpcxXNeAgAA X-MTR: 20000000000000000@CPGS X-CMS-MailID: 20170220133910eucas1p10f347d7688dd51ea70d15994c9d5d1f1 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: 20170220133910eucas1p10f347d7688dd51ea70d15994c9d5d1f1 X-RootMTR: 20170220133910eucas1p10f347d7688dd51ea70d15994c9d5d1f1 References: Sender: linux-media-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-media@vger.kernel.org Dear All, This patchset is a result of my work on enabling full support for MFC device (multimedia codec) on Exynos 5433 on ARM64 architecture. Initially I thought that to let it working on ARM64 architecture with IOMMU, I would need to solve the issue related to the fact that s5p-mfc driver was depending on the first-fit allocation method in the DMA-mapping / IOMMU glue code (ARM64 use different algorithm). It turned out, that there is a much simpler way. During my research I found that some of the requirements for the memory buffers for MFC v6+ devices were blindly copied from the previous hardware (v5) version and simply turned out to be excessive. It turned out that there is no strict requirement for ALL buffers to be allocated on the higher addresses than the firmware base. This requirement is true only for the device and per-context buffers. All video data buffers can be allocated anywhere for all MFC v6+ versions. This heavily simplifies memory management in the driver. Such relaxed requirements for the memory buffers can be easily fulfilled by allocating firmware, device and per-context buffers from the probe-time preallocated larger buffer. There is no need to create special reserved memory regions. The only case, when those memory regions are needed is an oldest Exynos series - Exynos4210 or Exyno4412, which both have MFC v5 hardware, and only when IOMMU is disabled. This patchset has been tested on Odroid U3 (Exynos4412 with MFC v5), Google Snow (Exynos5250 with MFC v6), Odroid XU3 (Exynos5422 with MFC v8) and TM2 (Exynos5433 with MFC v8, ARM64) boards. To get it working on TM2/Exynos5433 with IOMMU enabled, the 'architectural clock gating' in SYSMMU has to be disabled. Fixing this will be handled separately. As a temporary solution, one need to clear CFG_ACGEN bit in REG_MMU_CFG of the SYSMMU, see __sysmmu_init_config function in drivers/iommu/exynos-iommu.c. Patches are based on linux-next from 20th February 2017 with "media: s5p-mfc: Fix initialization of internal structures" patch applied: https://patchwork.linuxtv.org/patch/39198/ I've tried to split changes into small pieces to make it easier to review the code. I've also did a bit of cleanup while touching the driver. Best regards Marek Szyprowski Samsung R&D Institute Poland Changelog: v2: - fixed issues pointed by Javier Martinez Canillas: code compiles now after applying each patch, added missing cleanup - added tags v1: https://www.spinics.net/lists/linux-media/msg111156.html - initial version Patch summary: Marek Szyprowski (15): media: s5p-mfc: Remove unused structures and dead code media: s5p-mfc: Use generic of_device_get_match_data helper media: s5p-mfc: Replace mem_dev_* entries with an array media: s5p-mfc: Replace bank1/bank2 entries with an array media: s5p-mfc: Simplify alloc/release private buffer functions media: s5p-mfc: Move setting DMA max segment size to DMA configure function media: s5p-mfc: Put firmware to private buffer structure media: s5p-mfc: Move firmware allocation to DMA configure function media: s5p-mfc: Allocate firmware with internal private buffer alloc function media: s5p-mfc: Reduce firmware buffer size for MFC v6+ variants media: s5p-mfc: Split variant DMA memory configuration into separate functions media: s5p-mfc: Add support for probe-time preallocated block based allocator media: s5p-mfc: Remove special configuration of IOMMU domain media: s5p-mfc: Use preallocated block allocator always for MFC v6+ ARM: dts: exynos: Remove MFC reserved buffers .../devicetree/bindings/media/s5p-mfc.txt | 2 +- arch/arm/boot/dts/exynos5250-arndale.dts | 1 - arch/arm/boot/dts/exynos5250-smdk5250.dts | 1 - arch/arm/boot/dts/exynos5250-spring.dts | 1 - arch/arm/boot/dts/exynos5420-arndale-octa.dts | 1 - arch/arm/boot/dts/exynos5420-peach-pit.dts | 1 - arch/arm/boot/dts/exynos5420-smdk5420.dts | 1 - arch/arm/boot/dts/exynos5422-odroidxu3-common.dtsi | 1 - arch/arm/boot/dts/exynos5800-peach-pi.dts | 1 - drivers/media/platform/s5p-mfc/regs-mfc-v6.h | 2 +- drivers/media/platform/s5p-mfc/regs-mfc-v7.h | 2 +- drivers/media/platform/s5p-mfc/regs-mfc-v8.h | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc.c | 214 +++++++++++++-------- drivers/media/platform/s5p-mfc/s5p_mfc_cmd_v5.c | 2 +- drivers/media/platform/s5p-mfc/s5p_mfc_common.h | 43 ++--- drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.c | 71 ++----- drivers/media/platform/s5p-mfc/s5p_mfc_ctrl.h | 1 - drivers/media/platform/s5p-mfc/s5p_mfc_dec.c | 8 +- drivers/media/platform/s5p-mfc/s5p_mfc_enc.c | 10 +- drivers/media/platform/s5p-mfc/s5p_mfc_iommu.h | 51 +---- drivers/media/platform/s5p-mfc/s5p_mfc_opr.c | 65 +++++-- drivers/media/platform/s5p-mfc/s5p_mfc_opr.h | 8 +- drivers/media/platform/s5p-mfc/s5p_mfc_opr_v5.c | 48 ++--- drivers/media/platform/s5p-mfc/s5p_mfc_opr_v6.c | 14 +- 24 files changed, 268 insertions(+), 283 deletions(-) -- 1.9.1 Acked-by: Andrzej Hajda