From patchwork Tue Jun 7 08:29:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "(Exiting) Baolin Wang" X-Patchwork-Id: 9160123 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 AB36060467 for ; Tue, 7 Jun 2016 08:32:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9CD8326861 for ; Tue, 7 Jun 2016 08:32:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 912412823D; Tue, 7 Jun 2016 08:32:03 +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=-4.1 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_MED,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 31C2826861 for ; Tue, 7 Jun 2016 08:32:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1bACP5-0000u3-3b; Tue, 07 Jun 2016 08:30:27 +0000 Received: from mail-pf0-x235.google.com ([2607:f8b0:400e:c00::235]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1bACP2-0008Gi-L6 for linux-arm-kernel@lists.infradead.org; Tue, 07 Jun 2016 08:30:25 +0000 Received: by mail-pf0-x235.google.com with SMTP id 62so75789883pfd.1 for ; Tue, 07 Jun 2016 01:30:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=HVWjU3SLnRYhc7MEHSJhopxEckeoAC6endNqo0Hv3P8=; b=THt3CkaYkYjbbKoVlpT14PiRlVX0QPmA1RuyGYJhfYt5R+agyug9NqvhAWAZgXkbw6 uHUXGGEylaPnflb92bBSDsLZ5FVF8MkW+dwVd8k4c34QWj/nteOANkbRjoVx1xRB5nnL 0A2AuZorbT10MoggyODHGqtTKgWT6Ld5M6aFw= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=HVWjU3SLnRYhc7MEHSJhopxEckeoAC6endNqo0Hv3P8=; b=kJBPG3jf1S+dPMpaFdYcbwIYRK8HEOEXwJuZ5zKBElx+oUhpqa6Mgk/dngzLCi6jKy ILi+fQ3mApU27F+tgwOKEPATZIcL4BBfaP59JcwC2bahv0u565k5/Op7Rbd6YRK/Vpe1 ceORr+oetHcSAgZhQiQ8GFtsjlKamcxOq+mimcogt/039/mTWh99Ph98YzTpuOVBAleO lRfUeHCyzQfWFJGJhBRD2FElD1lavCxdDUYGtm50PLltCfXF+FtvuPVfpGkHbwE5kWAd L9f0PODuJwKL90lJoHf2uQBqd/xrILiGiMcqLT9ISIcxyYwU3Mh554LxgBsqksD0UN5Q zlcw== X-Gm-Message-State: ALyK8tLBOfbQRQE0xOEaT1hcZZJzJw7wc5/QXl8A9WTgZpD1/VVSOUrFxc+aG98J6+dLKrOT X-Received: by 10.98.85.66 with SMTP id j63mr30261532pfb.90.1465288203014; Tue, 07 Jun 2016 01:30:03 -0700 (PDT) Received: from baolinwangubtpc.spreadtrum.com ([175.111.195.49]) by smtp.gmail.com with ESMTPSA id n10sm30908215pax.18.2016.06.07.01.29.57 (version=TLS1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 07 Jun 2016 01:30:02 -0700 (PDT) From: Baolin Wang To: catalin.marinas@arm.com, will.deacon@arm.com Subject: [PATCH] arm64: Implement arch_setup_pdev_archdata hook Date: Tue, 7 Jun 2016 16:29:21 +0800 Message-Id: X-Mailer: git-send-email 1.7.9.5 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20160607_013024_734309_23288924 X-CRM114-Status: GOOD ( 12.81 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jszhang@marvell.com, balbi@kernel.org, jroedel@suse.de, arnd@arndb.de, baolin.wang@linaro.org, linux-kernel@vger.kernel.org, broonie@kernel.org, Suravee.Suthikulpanit@amd.com, akpm@linux-foundation.org, robin.murphy@arm.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 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 Now on ARM64 platform, it will set 'dummy_dma_ops' for device dma_ops if it did not call 'arch_setup_dma_ops' at device creation time by issuing platform_device_alloc() function, that will cause failure when setting the dma mask for device. Hence We need to hook the archdata to setup proper dma_ops for these devices. Signed-off-by: Baolin Wang --- arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index c566ec8..04e057b 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -26,6 +26,7 @@ #include #include #include +#include #include @@ -961,3 +962,23 @@ void arch_setup_dma_ops(struct device *dev, u64 dma_base, u64 size, dev->archdata.dma_coherent = coherent; __iommu_setup_dma_ops(dev, dma_base, size, iommu); } + +void arch_setup_pdev_archdata(struct platform_device *pdev) +{ + if (!pdev->dev.archdata.dma_ops) + pdev->dev.archdata.dma_ops = &swiotlb_dma_ops; + + /* + * Set default coherent_dma_mask to 32 bit. Drivers are expected to + * setup the correct supported mask. + */ + if (!pdev->dev.coherent_dma_mask) + pdev->dev.coherent_dma_mask = DMA_BIT_MASK(32); + + /* + * Set it to coherent_dma_mask by default if the architecture + * code has not set it. + */ + if (!pdev->dev.dma_mask) + pdev->dev.dma_mask = &pdev->dev.coherent_dma_mask; +}