From patchwork Tue Oct 4 17:03:45 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sricharan Ramabadhran X-Patchwork-Id: 9362113 X-Patchwork-Delegate: agross@codeaurora.org Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 74929600C8 for ; Tue, 4 Oct 2016 17:04:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 52BF92871F for ; Tue, 4 Oct 2016 17:04:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4760E289C1; Tue, 4 Oct 2016 17:04:18 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 24C3E2871F for ; Tue, 4 Oct 2016 17:04:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752702AbcJDREP (ORCPT ); Tue, 4 Oct 2016 13:04:15 -0400 Received: from smtp.codeaurora.org ([198.145.29.96]:36746 "EHLO smtp.codeaurora.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752452AbcJDREO (ORCPT ); Tue, 4 Oct 2016 13:04:14 -0400 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 0571761B04; Tue, 4 Oct 2016 17:04:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475600654; bh=0DPb8ebQAU3sEMBTf87lJr6Vli8dmtQJZ5X/uUcNbqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=TQSA9mEqQk5jQelGdDOhdEiA8AZFiqm0Q+hHmnqm++yYozwdmttisqBzcKHP1Gz3g sOkSVAjQKJ8GmQS2HtMyYfNnwwzKeeBCiO4WgD1/WLYNS7igu/CFgOHZHq9gi0XJVw ik3B4GjHnLOOsu2HJYEqTVI9h5EVvWalITY9V0qo= Received: from blr-ubuntu-32.ap.qualcomm.com (unknown [202.46.23.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: sricharan@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 1A47161AF6; Tue, 4 Oct 2016 17:04:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1475600648; bh=0DPb8ebQAU3sEMBTf87lJr6Vli8dmtQJZ5X/uUcNbqg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=owdHmiJtC6nSChXnxSQY6rOhjKowrVqeGn5faYP4yISMc5uJ3vhXNFX+Xt9NT7dg0 H3WnB4ACDx7bGawPTVwTIPkxPsvDp0+PqD396CrwaEGrjsNhFFmcFsEQKYbEaTLTDX Z5TSSLMfVmOOD+6lp/37FPcv4ypcR96uoE2ASwN8= DMARC-Filter: OpenDMARC Filter v1.3.1 smtp.codeaurora.org 1A47161AF6 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=pass smtp.mailfrom=sricharan@codeaurora.org From: Sricharan R To: will.deacon@arm.com, robin.murphy@arm.com, joro@8bytes.org, iommu@lists.linux-foundation.org, linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, laurent.pinchart@ideasonboard.com, m.szyprowski@samsung.com, tfiga@chromium.org, srinivas.kandagatla@linaro.org Cc: sricharan@codeaurora.org Subject: [PATCH V3 1/8] arm: dma-mapping: Don't override dma_ops in arch_setup_dma_ops() Date: Tue, 4 Oct 2016 22:33:45 +0530 Message-Id: <1475600632-21289-2-git-send-email-sricharan@codeaurora.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1475600632-21289-1-git-send-email-sricharan@codeaurora.org> References: <1475600632-21289-1-git-send-email-sricharan@codeaurora.org> Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Laurent Pinchart The arch_setup_dma_ops() function is in charge of setting dma_ops with a call to set_dma_ops(). set_dma_ops() is also called from - highbank and mvebu bus notifiers - dmabounce (to be replaced with swiotlb) - arm_iommu_attach_device (arm_iommu_attach_device is itself called from IOMMU and bus master device drivers) To allow the arch_setup_dma_ops() call to be moved from device add time to device probe time we must ensure that dma_ops already setup by any of the above callers will not be overridden. Aftering replacing dmabounce with swiotlb, converting IOMMU drivers to of_xlate and taking care of highbank and mvebu, the workaround should be removed. Signed-off-by: Laurent Pinchart --- arch/arm/mm/dma-mapping.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index c6834c0..dde6514 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -2322,6 +2322,15 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, struct dma_map_ops *dma_ops; dev->archdata.dma_coherent = coherent; + + /* + * Don't override the dma_ops if they have already been set. Ideally + * this should be the only location where dma_ops are set, remove this + * check when all other callers of set_dma_ops will have disappeared. + */ + if (dev->archdata.dma_ops) + return; + if (arm_setup_iommu_dma_ops(dev, dma_base, size, iommu)) dma_ops = arm_get_iommu_dma_map_ops(coherent); else