From patchwork Wed Sep 12 16:45:51 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Robin Murphy X-Patchwork-Id: 10598087 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EDFE14E5 for ; Wed, 12 Sep 2018 16:46:36 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0CF932A812 for ; Wed, 12 Sep 2018 16:46:36 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F28222A81C; Wed, 12 Sep 2018 16:46:35 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 961A22A812 for ; Wed, 12 Sep 2018 16:46:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=NXXG9qMWchSGivolAuueWhsLqsY7jIBcAOtYmoE4E9k=; b=cSIiQcAAUj8X2N AXeaBN61anlNLevAgQEclISEIPFFWt6s8/KXNsmbkPQLS/0kbNixGAOa3fd1u//RQcEag2SkDVTMV GlmwINZ49AC4CkjBM6XXQbRMfxjOxMUZLaS0MAILyzFsabkeY05qWbdnJPypPyBPXHc8KqQH+YzG0 a7tP3YzA6UGGkqahJVcZ5WUoLFblrOYfiKL/U9E7/EBxow7LNlaIkR7P4pjBeIRIrNNN3O/34mZVX QA+sgeo/2XssQyNOaqCzGdjMWB5JgunIZDby73JQBV3t9YjAu7XVQahoxz3CmosMZCWU4Lwq+KebV 1aZjUrGa7qDxMfc1x84w==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g08HY-0008KU-TV; Wed, 12 Sep 2018 16:46:24 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1g08HP-0008H5-1U for linux-arm-kernel@lists.infradead.org; Wed, 12 Sep 2018 16:46:22 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id C56767A9; Wed, 12 Sep 2018 09:46:01 -0700 (PDT) Received: from e110467-lin.cambridge.arm.com (e110467-lin.emea.arm.com [10.4.12.131]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 057B93F557; Wed, 12 Sep 2018 09:45:59 -0700 (PDT) From: Robin Murphy To: kyungmin.park@samsung.com, kamil@wypas.org, jtp.park@samsung.com, a.hajda@samsung.com Subject: [PATCH] media: s5p-mfc: Fix memdev DMA configuration Date: Wed, 12 Sep 2018 17:45:51 +0100 Message-Id: X-Mailer: git-send-email 2.19.0.dirty MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180912_094615_124687_EE5DBF33 X-CRM114-Status: GOOD ( 15.10 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Rob Herring , Smitha T Murthy , iommu@lists.linux-foundation.org, linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Marek Szyprowski Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Having of_reserved_mem_device_init() forcibly reconfigure DMA for all callers, potentially overriding the work done by a bus-specific .dma_configure method earlier, is at best a bad idea and at worst actively harmful. If drivers really need virtual devices to own dma-coherent memory, they should explicitly configure those devices based on the appropriate firmware node as they create them. It looks like the only driver not passing in a proper OF platform device is s5p-mfc, so move the rogue of_dma_configure() call into that driver where it logically belongs. CC: Smitha T Murthy CC: Marek Szyprowski CC: Rob Herring Signed-off-by: Robin Murphy Reviewed-by: Marek Szyprowski Acked-by: Mauro Carvalho Chehab --- drivers/media/platform/s5p-mfc/s5p_mfc.c | 7 +++++++ drivers/of/of_reserved_mem.c | 4 ---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/media/platform/s5p-mfc/s5p_mfc.c b/drivers/media/platform/s5p-mfc/s5p_mfc.c index 927a1235408d..77eb4a4511c1 100644 --- a/drivers/media/platform/s5p-mfc/s5p_mfc.c +++ b/drivers/media/platform/s5p-mfc/s5p_mfc.c @@ -1094,6 +1094,13 @@ static struct device *s5p_mfc_alloc_memdev(struct device *dev, child->dma_mask = dev->dma_mask; child->release = s5p_mfc_memdev_release; + /* + * The memdevs are not proper OF platform devices, so in order for them + * to be treated as valid DMA masters we need a bit of a hack to force + * them to inherit the MFC node's DMA configuration. + */ + of_dma_configure(child, dev->of_node, true); + if (device_add(child) == 0) { ret = of_reserved_mem_device_init_by_idx(child, dev->of_node, idx); diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 895c83e0c7b6..4ef6f4485335 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -350,10 +350,6 @@ int of_reserved_mem_device_init_by_idx(struct device *dev, mutex_lock(&of_rmem_assigned_device_mutex); list_add(&rd->list, &of_rmem_assigned_device_list); mutex_unlock(&of_rmem_assigned_device_mutex); - /* ensure that dma_ops is set for virtual devices - * using reserved memory - */ - of_dma_configure(dev, np, true); dev_info(dev, "assigned reserved memory node %s\n", rmem->name); } else {