From patchwork Fri Sep 19 15:51:26 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mark Salter X-Patchwork-Id: 37643 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wg0-f71.google.com (mail-wg0-f71.google.com [74.125.82.71]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 15BA12054D for ; Fri, 19 Sep 2014 15:52:05 +0000 (UTC) Received: by mail-wg0-f71.google.com with SMTP id x13sf337034wgg.2 for ; Fri, 19 Sep 2014 08:52:04 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:from:to:cc:subject :date:message-id:sender:precedence:list-id:x-original-sender :x-original-authentication-results:mailing-list:list-post:list-help :list-archive:list-unsubscribe; bh=XrFSSaJRtXNGA+a4pGD32zleVhMHdRfQWjeR6G/+ZsI=; b=LOFKo46tWkhMgNcgjovmkhDgb9ziI2H+xYuTpj4H/zfyTeF5AOv75JPybVAfI5/tDL GrKNad12ZAFB55BF11ppFCnOSj6etChPQapiWqSRd+zsOcj6VcQ+gKHN1L/8PAg9ocxd KwmppO50T/VXEpEa0OPSJw0SZZwmJ2AnZPfg9gwpWRO4nX/CY4PUfDD6ISjIy6IgxMa2 r5ZBf0ryxeVn6MERGUgGXHBCu0hCw0fbCllHW9o0V/fbVKbeXB8G/WTCIO4/h4bfFS7y GdVyiBMPTO/Aodf8RCemDB+tLrtLvLg0pgzhGCdI2fOzM7pKC2q0sr2R+Iv4v4FgN5+l SYXg== X-Gm-Message-State: ALoCoQmKAD6WZEaRqZtf2XbvM0+/BiQ3pv8HnC60SwfffK1Og/3AVvhdomrBNEBdACVh4fFErTFv X-Received: by 10.152.21.137 with SMTP id v9mr2130945lae.1.1411141924275; Fri, 19 Sep 2014 08:52:04 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.246.35 with SMTP id xt3ls309144lac.67.gmail; Fri, 19 Sep 2014 08:52:04 -0700 (PDT) X-Received: by 10.152.7.145 with SMTP id j17mr7433185laa.77.1411141924074; Fri, 19 Sep 2014 08:52:04 -0700 (PDT) Received: from mail-la0-f50.google.com (mail-la0-f50.google.com [209.85.215.50]) by mx.google.com with ESMTPS id j15si3116494lbg.30.2014.09.19.08.52.04 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Fri, 19 Sep 2014 08:52:04 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) client-ip=209.85.215.50; Received: by mail-la0-f50.google.com with SMTP id ty20so3392064lab.23 for ; Fri, 19 Sep 2014 08:52:04 -0700 (PDT) X-Received: by 10.152.179.226 with SMTP id dj2mr7810577lac.40.1411141924012; Fri, 19 Sep 2014 08:52:04 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp962084lbb; Fri, 19 Sep 2014 08:52:03 -0700 (PDT) X-Received: by 10.66.158.130 with SMTP id wu2mr2736951pab.59.1411141922536; Fri, 19 Sep 2014 08:52:02 -0700 (PDT) Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id xx3si3580179pab.116.2014.09.19.08.52.01 for ; Fri, 19 Sep 2014 08:52:02 -0700 (PDT) Received-SPF: none (google.com: linux-kernel-owner@vger.kernel.org does not designate permitted sender hosts) client-ip=209.132.180.67; Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757056AbaISPv7 (ORCPT + 27 others); Fri, 19 Sep 2014 11:51:59 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50652 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754306AbaISPv6 (ORCPT ); Fri, 19 Sep 2014 11:51:58 -0400 Received: from int-mx13.intmail.prod.int.phx2.redhat.com (int-mx13.intmail.prod.int.phx2.redhat.com [10.5.11.26]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s8JFpV77008765 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Fri, 19 Sep 2014 11:51:32 -0400 Received: from deneb.redhat.com (ovpn-113-98.phx2.redhat.com [10.3.113.98]) by int-mx13.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s8JFpUZ8027032; Fri, 19 Sep 2014 11:51:30 -0400 From: Mark Salter To: Catalin Marinas , Will Deacon Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Mark Salter , Jon Masters Subject: [PATCH] arm64/pci: fix dma coherency inheritance for PCI devices Date: Fri, 19 Sep 2014 11:51:26 -0400 Message-Id: <1411141886-11310-1-git-send-email-msalter@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.26 Sender: linux-kernel-owner@vger.kernel.org Precedence: list List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: msalter@redhat.com X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.50 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 List-Post: , List-Help: , List-Archive: List-Unsubscribe: , The default dma_ops for devices on arm64 systems are noncoherent in nature and rely upon special operations and bounce buffers to perform a device DMA operation to/from memory. Some drivers rely upon coherent operations involving suitably capable hardware. In this case, a "dma-coherent" property will exist on the corresponding Device Tree node for the bridge device, or one of its ancestors. This patch adds support for applying a DMA coherent dma_ops for PCI devices in the case of such a property. Signed-off-by: Jon Masters [added search for device with of_node] Signed-off-by: Mark Salter --- arch/arm64/mm/dma-mapping.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 4164c5a..0e26bd7 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -23,10 +23,12 @@ #include #include #include +#include #include #include #include #include +#include #include @@ -316,8 +318,18 @@ static int dma_bus_notifier(struct notifier_block *nb, if (event != BUS_NOTIFY_ADD_DEVICE) return NOTIFY_DONE; - if (of_property_read_bool(dev->of_node, "dma-coherent")) - set_dma_ops(dev, &coherent_swiotlb_dma_ops); + /* + * Some devices won't have an of_node but a bus controller/bridge will. + * Search up the device chain until we find an of_node to check. + */ + while (dev) { + if (dev->of_node) { + if (of_dma_is_coherent(dev->of_node)) + set_dma_ops(_dev, &coherent_swiotlb_dma_ops); + break; + } + dev = dev->parent; + } return NOTIFY_OK; } @@ -330,6 +342,10 @@ static struct notifier_block amba_bus_nb = { .notifier_call = dma_bus_notifier, }; +static struct notifier_block pci_bus_nb = { + .notifier_call = dma_bus_notifier, +}; + extern int swiotlb_late_init_with_default_size(size_t default_size); static int __init swiotlb_late_init(void) @@ -341,6 +357,7 @@ static int __init swiotlb_late_init(void) */ bus_register_notifier(&platform_bus_type, &platform_bus_nb); bus_register_notifier(&amba_bustype, &amba_bus_nb); + bus_register_notifier(&pci_bus_type, &pci_bus_nb); dma_ops = &noncoherent_swiotlb_dma_ops;