From patchwork Thu Nov 27 05:41:31 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ming Lei X-Patchwork-Id: 5391831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 6DAC89F319 for ; Thu, 27 Nov 2014 05:44:41 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id AA2F1201EC for ; Thu, 27 Nov 2014 05:44:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id C9EB6201E4 for ; Thu, 27 Nov 2014 05:44:39 +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 1XtrqF-0007St-8P; Thu, 27 Nov 2014 05:42:11 +0000 Received: from mail-pd0-f172.google.com ([209.85.192.172]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XtrqD-0007RO-4N for linux-arm-kernel@lists.infradead.org; Thu, 27 Nov 2014 05:42:09 +0000 Received: by mail-pd0-f172.google.com with SMTP id y13so4237579pdi.17 for ; Wed, 26 Nov 2014 21:41:47 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=from:to:cc:subject:date:message-id; bh=c+hC6oDTh1r8Qjs34Ijov6r7CANfoYMRebGoYaY5AlU=; b=gGrGMER1qgkh2eE3QKsuWntEGgPyCnaDZzSoEvg5fJVLNziLJ0k/xsrZ4vrmGwIC/F +E61+a516zvDx0h78W+t33iOBrpTj+LPxZEudBYDYgrjpEHiYxWgWYkOfbEtAWSMewuU OjqvU4R7Ivs/qn2biwsFt45yQMdjcpEQz2Z3n9CBDygwF6iXy84OqyoVHp5D0XqeMXP4 zMVXHpLE+d4c0E6Q4DQGlPgwB+rsRgz5prbJzJ61hQYfjFzN7ejD+421B9IewrBu2ndJ v6yuSK658srna+k8Xt5RVzmqxLlNFfSlRQSgxU+7DTY+qiOUIQ+tvZlQUgFv4D8IxWr5 55GA== X-Received: by 10.67.24.99 with SMTP id ih3mr59911531pad.101.1417066907588; Wed, 26 Nov 2014 21:41:47 -0800 (PST) Received: from localhost ([183.13.121.224]) by mx.google.com with ESMTPSA id ps2sm5887220pdb.62.2014.11.26.21.41.46 for (version=TLSv1.2 cipher=RC4-SHA bits=128/128); Wed, 26 Nov 2014 21:41:46 -0800 (PST) From: Ming Lei To: Catalin Marinas , linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH] ARM64: PCI: inherit root controller's dma-coherent Date: Thu, 27 Nov 2014 13:41:31 +0800 Message-Id: <1417066891-16789-1-git-send-email-ming.lei@canonical.com> 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-20141126_214209_201656_2A808935 X-CRM114-Status: GOOD ( 11.27 ) X-Spam-Score: -0.7 (/) Cc: Catalin Marinas , Ming Lei , Dann Frazier , Jon Masters X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_LOW, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch sets pci device's dma ops as coherent if the root controller is dma-coherent. This patch fixes the bug in below link: https://bugs.launchpad.net/bugs/1386490 Cc: Catalin Marinas Cc: Jon Masters Cc: Dann Frazier Signed-off-by: Ming Lei --- arch/arm64/kernel/pci.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c index ce5836c..4b6444a 100644 --- a/arch/arm64/kernel/pci.c +++ b/arch/arm64/kernel/pci.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include @@ -37,6 +38,21 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res, return res->start; } +/* Inherit root controller's dma coherent ops */ +static void pci_dma_config(struct pci_dev *dev) +{ + struct pci_bus *bus = dev->bus; + struct device *host; + + while (!pci_is_root_bus(bus)) { + bus = bus->parent; + } + + host = bus->dev.parent->parent; + if (of_dma_is_coherent(host->of_node)) + set_arch_dma_coherent_ops(&dev->dev); +} + /* * Try to assign the IRQ number from DT when adding a new device */ @@ -44,6 +60,7 @@ int pcibios_add_device(struct pci_dev *dev) { dev->irq = of_irq_parse_and_map_pci(dev, 0, 0); + pci_dma_config(dev); return 0; }