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: 69478 Delivered-To: patch@linaro.org Received: by 10.140.106.246 with SMTP id e109csp1860646qgf; Tue, 7 Jun 2016 01:30:10 -0700 (PDT) X-Received: by 10.66.78.104 with SMTP id a8mr29757191pax.88.1465288210470; Tue, 07 Jun 2016 01:30:10 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id sr4si32013380pab.10.2016.06.07.01.30.10; Tue, 07 Jun 2016 01:30:10 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754156AbcFGIaH (ORCPT + 31 others); Tue, 7 Jun 2016 04:30:07 -0400 Received: from mail-pf0-f176.google.com ([209.85.192.176]:33331 "EHLO mail-pf0-f176.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751547AbcFGIaE (ORCPT ); Tue, 7 Jun 2016 04:30:04 -0400 Received: by mail-pf0-f176.google.com with SMTP id y124so16190732pfy.0 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=fO0W7XIZ9faNjn0w6jt3Fj5ArZVg9HJ7T+sanyRLwFSwkH4ueGKUcNyYZ2Gvw9+oTK djhBrWiyJ45tSHW9QExfbcAXzs7GuPV0y3dbqOrUyB8Jbikub5HdpOnAqNfofJvG0kIO l8J3reqNmw+JG6Y/ejeS4FkDf5v+2buEkvaMUbSuqe/ExluJeqdS1Z5MyfR45kIG4yAC Y8swf3UG2B3OMX516H+xiscomqKddFjyO6Q5YylcP5zBR5f+je107oxEWQ6jCD4aD03/ wKGZooaPi7m/mrehKJfu6JyBjppa5yzQzY9Wa81wRtMXv/+tmquVtMteIDTy8MVeTbxc QCwQ== X-Gm-Message-State: ALyK8tK4dajkLV7qASY7ClCeU9Cz0CyGzOTmWWCuX67O9zMhqAEExFqW7OD3QlaMfJKG6Fn3 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 Cc: robin.murphy@arm.com, jroedel@suse.de, akpm@linux-foundation.org, jszhang@marvell.com, Suravee.Suthikulpanit@amd.com, arnd@arndb.de, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, broonie@kernel.org, balbi@kernel.org, baolin.wang@linaro.org 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 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(+) -- 1.7.9.5 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; +}