Received: by 2002:a05:6a10:22f:0:0:0:0 with SMTP id 15csp1139308pxk; Fri, 25 Sep 2020 07:14:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxhEJVBfcBaFCFzJMiw4heeX1FW8lfTg6FTWTVhRZI7+WZ3DCmfeHI7+y4aex1iwsQwN5Lp X-Received: by 2002:a17:906:4088:: with SMTP id u8mr3018936ejj.184.1601043257501; Fri, 25 Sep 2020 07:14:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1601043257; cv=none; d=google.com; s=arc-20160816; b=imIlvNhDsjWWjG/EZs5KbdnzONhtJABVWGUBOogkEMy5WyfsaafU9ff9GLJlQHLNTy gaWbUVXTJ/X2xrVnTY1DX47opWRcCJ1cL1XWK1pV5CFwKUlQHXgG/UZMALMg5bav0m2N RUY1j7HaWs21cSaj9IMWyTIS13l7+NOfEruS4eKNpM0BaGLMMVxOXl+J9ir+Z8WjvF53 ura+Mzfibwlmprr4t+68/jog8Y7zv86yLGG2pcnfMF5/bHjyf7kV5o2JdOmpFEwx0B8Q EkS7oEEEhDu4aIgt/MKiF3ONWRDRngpSZP0flO6foCsvTOMtDWPRAsUA6Kan3nDy0x9z XZtQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:cms-type:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:dkim-filter; bh=A2laEXZodce4y5WBoAT6Pjadi2R3gn3tegjGhZC+nCo=; b=gmEOcYJpnTZqRk6ZaUl3EqhYFhzcABmTUvFQJ6OQ/hTdkoDDx/2Y8yMHzQESbtzfU7 WIrjdDRPKmdQ9dSNUWdlstu4wmxYANJyGAPMsHRF0W3kVdg/rqDiPl4gwAAhxxgAiGF8 2W1KI5O4Ct/0kOxWPwBs3k7EbqauHRvQu5LbA19S3NvWPFtLGdN3OBTgU6TRnL3WnxB5 oJ0GEltq6f87XClZ0wTE0ioquhacmTXfKmJ4tFjsvTuVi4jexDjDBmCfa9aMHGOeiXZg D4ye8xca9JMBGROYaF88YQkIjz1Tk1lIr2rnxuu5Tr6CTa2wZfVy/P5OOJM608HXHGK3 I8uA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=c5dlImAA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id pk27si1903607ejb.715.2020.09.25.07.13.53; Fri, 25 Sep 2020 07:14:17 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@samsung.com header.s=mail20170921 header.b=c5dlImAA; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=samsung.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729102AbgIYOMl (ORCPT + 99 others); Fri, 25 Sep 2020 10:12:41 -0400 Received: from mailout1.w1.samsung.com ([210.118.77.11]:50612 "EHLO mailout1.w1.samsung.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729077AbgIYOMh (ORCPT ); Fri, 25 Sep 2020 10:12:37 -0400 Received: from eucas1p1.samsung.com (unknown [182.198.249.206]) by mailout1.w1.samsung.com (KnoxPortal) with ESMTP id 20200925141236euoutp0161cddad9e811f917aa717a76e59fdbb7~4DESh5pOV1106011060euoutp01q for ; Fri, 25 Sep 2020 14:12:36 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout1.w1.samsung.com 20200925141236euoutp0161cddad9e811f917aa717a76e59fdbb7~4DESh5pOV1106011060euoutp01q DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1601043156; bh=A2laEXZodce4y5WBoAT6Pjadi2R3gn3tegjGhZC+nCo=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=c5dlImAAGjXOLALkzLSxco9t+hTfogWjaJOeNlQGh/CgYJrjw6R1p5pLqLivUlPcX Kt6aPDPww8d7smnGyynpZya+ZyDxqhiLYVK8fJtXndWO6fLSJOiWe4u3ZoLiMfilnp Q/cnMeLsA4XspYMcPoV9wWiYMaLush7x3iSeRnkM= Received: from eusmges2new.samsung.com (unknown [203.254.199.244]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20200925141235eucas1p2c0fd6d41a1e32313a7f76616c49dff0d~4DERuK1tA3259232592eucas1p24; Fri, 25 Sep 2020 14:12:35 +0000 (GMT) Received: from eucas1p2.samsung.com ( [182.198.249.207]) by eusmges2new.samsung.com (EUCPMTA) with SMTP id 0E.49.05997.3DAFD6F5; Fri, 25 Sep 2020 15:12:35 +0100 (BST) Received: from eusmtrp2.samsung.com (unknown [182.198.249.139]) by eucas1p1.samsung.com (KnoxPortal) with ESMTPA id 20200925141235eucas1p17c6aceae82acfc424cdc7521938c1510~4DERWTSVx1940819408eucas1p1q; Fri, 25 Sep 2020 14:12:35 +0000 (GMT) Received: from eusmgms1.samsung.com (unknown [182.198.249.179]) by eusmtrp2.samsung.com (KnoxPortal) with ESMTP id 20200925141235eusmtrp2e2c691b27fc90284bfacfb0221b2003a~4DERVo8Ja2568825688eusmtrp2K; Fri, 25 Sep 2020 14:12:35 +0000 (GMT) X-AuditID: cbfec7f4-65dff7000000176d-0a-5f6dfad3ea5b Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms1.samsung.com (EUCPMTA) with SMTP id D3.49.06314.3DAFD6F5; Fri, 25 Sep 2020 15:12:35 +0100 (BST) Received: from AMDC2765.digital.local (unknown [106.120.51.73]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20200925141234eusmtip1f8fd73db4a18c7c8418ebe0d2e207e9a~4DEQwxQIX1229912299eusmtip10; Fri, 25 Sep 2020 14:12:34 +0000 (GMT) From: Marek Szyprowski To: Linux IOMMU , linux-media@vger.kernel.org, linux-samsung-soc@vger.kernel.org Cc: Marek Szyprowski , Robin Murphy , Joerg Roedel , Christoph Hellwig , Sylwester Nawrocki , Krzysztof Kozlowski , Bartlomiej Zolnierkiewicz , Tomasz Figa , linux-kernel@vger.kernel.org Subject: [PATCH 8/8] media: platform: s5p-mfc: use DMA_ATTR_LOW_ADDRESS Date: Fri, 25 Sep 2020 16:12:18 +0200 Message-Id: <20200925141218.13550-9-m.szyprowski@samsung.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200925141218.13550-1-m.szyprowski@samsung.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrIKsWRmVeSWpSXmKPExsWy7djP87qXf+XGGyw/KG+xccZ6VouVq48y WSzYb23ROXsDu8X580Di8q45bBY9G7ayWsw4v4/JYu2Ru+wWBz88YbVof/qS2eJz6z82Bx6P JwfnMXmsmbeG0WN2w0UWj02rOtk8Jt9Yzuix+2YDm0ffllWMHp83yQVwRHHZpKTmZJalFunb JXBlTLg6kblgO0/FrKM2DYzbuLoYOTkkBEwkrq87wdTFyMUhJLCCUeLp8pmsEM4XRomrv/qZ IZzPjBKPfs5nhGnZfHEpG0RiOaPE8lkHGOFaXu6fyA5SxSZgKNH1tguoioNDRKBEYtkJPpAa ZoEnTBJ7/i5kAqkRFnCX2Nj/Hmwqi4CqxKZPk1lAbF4BW4lHr0B6QbbJS6zecIAZxOYUsJN4 eBFimYTAKnaJn4ufMEMUuQAl/rBC2MISr45vYYewZST+75zPBNHQzCjx8Nxadginh1HictMM qIesJe6c+wV2KrOApsT6XfoQYUeJfY9fsoOEJQT4JG68FQQJMwOZk7ZNZ4YI80p0tAlBVKtJ zDq+Dm7twQuXoEo8JJ7O8QcJCwlMZJSYNN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g2MDi373oU+l+O6xWgu3sz0qKb1hZG7OG/0PLVf7tFsfbduWpps fdvqHs2zSrYx5jdHnMK6OCNDq2NRUx+sr2iZart96jEBw7RPH39P310/Kf/q9kz3QM+nNoHG 8W0skjWztdI4V02Mqzf6pXzP656faeHd7i3vrp8ItZ9luUXweHrshemlLzuVWIozEg21mIuK EwHdk2WglgIAAA== X-CMS-MailID: 20200925141235eucas1p17c6aceae82acfc424cdc7521938c1510 X-Msg-Generator: CA Content-Type: text/plain; charset="utf-8" X-RootMTR: 20200925141235eucas1p17c6aceae82acfc424cdc7521938c1510 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20200925141235eucas1p17c6aceae82acfc424cdc7521938c1510 References: <20200925141218.13550-1-m.szyprowski@samsung.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org S5P-MFC driver relied on the way the ARM DMA-IOMMU glue code worked - mainly it relied on the fact that the allocator used first-fit algorithm and the first allocated buffer were at 0x0 DMA/IOVA address. This is not true for the generic IOMMU-DMA glue code that will be used for ARM architecture soon, so limit the dma_mask to size of the DMA window the hardware can use and add the needed DMA attribute to force proper IOVA allocation of the firmware buffer. Signed-off-by: Marek Szyprowski --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index eba2b9f040df..171fd9fd22e4 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1199,8 +1199,12 @@ static int s5p_mfc_configure_common_memory(struct s5p_mfc_dev *mfc_dev) if (!mfc_dev->mem_bitmap) return -ENOMEM; - mfc_dev->mem_virt = dma_alloc_coherent(dev, mem_size, - &mfc_dev->mem_base, GFP_KERNEL); + /* MFC v5 can access memory only via the 256M window */ + if (exynos_is_iommu_available(dev) && !IS_MFCV6_PLUS(mfc_dev)) + dma_set_mask_and_coherent(dev, SZ_256M - 1); + + mfc_dev->mem_virt = dma_alloc_attrs(dev, mem_size, &mfc_dev->mem_base, + GFP_KERNEL, DMA_ATTR_LOW_ADDRESS); if (!mfc_dev->mem_virt) { kfree(mfc_dev->mem_bitmap); dev_err(dev, "failed to preallocate %ld MiB for the firmware and context buffers\n", -- 2.17.1