From patchwork Tue Jul 25 10:18:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 9861675 X-Patchwork-Delegate: bhelgaas@google.com 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 DA7F66038C for ; Tue, 25 Jul 2017 10:19:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6D5028615 for ; Tue, 25 Jul 2017 10:19:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9B312861B; Tue, 25 Jul 2017 10:19:06 +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=-7.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI 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 4C3A328615 for ; Tue, 25 Jul 2017 10:19:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751655AbdGYKTE (ORCPT ); Tue, 25 Jul 2017 06:19:04 -0400 Received: from lelnx194.ext.ti.com ([198.47.27.80]:24025 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751632AbdGYKTC (ORCPT ); Tue, 25 Jul 2017 06:19:02 -0400 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id v6PAIwqJ024141; Tue, 25 Jul 2017 05:18:58 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1500977938; bh=j9cb2R3qMrn2L0Kne3f9DMB2/wmt1T0ioxoy6uYxkhQ=; h=Subject:To:References:From:Date:In-Reply-To; b=fxmtizuj6i0FGyqlIjT9x8UoOXVkGZ/KpWU9ZF5N9R4II5dM0+4McNMpXIlciX9fh EVCiRmgFd7M8EKNJjqw1KW/4EL4vo3dQqgM7hjjoKh6UqyYfucc1fRzkCtdQCSUipr xRTJ3sNeJNawh0Ujd/xsOUbb0fR1AraLcfgLYT/I= Received: from DLEE71.ent.ti.com (dlee71.ent.ti.com [157.170.170.114]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id v6PAIwhI024543; Tue, 25 Jul 2017 05:18:58 -0500 Received: from dflp32.itg.ti.com (10.64.6.15) by DLEE71.ent.ti.com (157.170.170.114) with Microsoft SMTP Server id 14.3.294.0; Tue, 25 Jul 2017 05:18:57 -0500 Received: from [172.24.190.233] (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp32.itg.ti.com (8.14.3/8.13.8) with ESMTP id v6PAIuO8008409; Tue, 25 Jul 2017 05:18:57 -0500 Subject: Re: dma_alloc_coherent fail for arm64 in pci ep framework To: Eric Yang , "linux-pci@vger.kernel.org" References: From: Kishon Vijay Abraham I Message-ID: <0525e3da-fd81-5289-7065-dc684c793d35@ti.com> Date: Tue, 25 Jul 2017 15:48:56 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.7.0 MIME-Version: 1.0 In-Reply-To: Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Hi, On Tuesday 25 July 2017 03:41 PM, Eric Yang wrote: > Hi, all > > > > I test the ep framework in qoriq ls2088a recently in 4.12, and find > pci_epf_alloc_space() always fail, after debug > > I found that when a EPF device is created by pci_epf_create(), if not invoke > the arch_setup_dma_ops() manually > > the dev->dma_ops will be NULL, so when dma_alloc occures, it will use the > default dummy_dma_ops of arm64, > > and will cause the failure. > > > > For I haven’t test the ep driver entirely, I’m not sure whether this is a bug > or not. I think that's a bug. I faced a issue while using pci_epf_alloc_space and I used a fix like below. Can you try if that helps? Thanks Kishon 8<--------------------------------- From 358257b8a5513d86dd44d376805da9b5b05e819e Mon Sep 17 00:00:00 2001 From: Kishon Vijay Abraham I Date: Wed, 5 Jul 2017 19:50:41 +0530 Subject: [PATCH] PCI: endpoint: pci-epc-core: use of_dma_configure() to set initial dma mask Use of_dma_configure() to set the initial dma mask of epf device. This helps to get rid of "Coherent DMA mask 0x0 (pfn 0x0-0x1) covers a smaller range of system memory than the DMA zone pfn" warning in certain platforms like TI's K2G resulting in coherent dma mask not being set. Signed-off-by: Kishon Vijay Abraham I --- drivers/pci/endpoint/pci-epc-core.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) ret = dev_set_name(&epc->dev, "%s", dev_name(dev)); diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 44ad93ff0f98..78ea9de4987c 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -368,6 +369,7 @@ EXPORT_SYMBOL_GPL(pci_epc_write_header); int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) { unsigned long flags; + struct device *dev = epc->dev.parent; if (IS_ERR(epc)) return -EINVAL; @@ -375,8 +377,12 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) if (epf->func_no > epc->max_functions - 1) return -EINVAL; - dma_set_coherent_mask(&epf->dev, epc->dev.coherent_dma_mask); - epf->dev.dma_mask = epc->dev.dma_mask; + if (dev->of_node) { + of_dma_configure(&epf->dev, dev->of_node); + } else { + dma_set_coherent_mask(&epf->dev, epc->dev.coherent_dma_mask); + epf->dev.dma_mask = epc->dev.dma_mask; + } spin_lock_irqsave(&epc->lock, flags); list_add_tail(&epf->list, &epc->pci_epf); @@ -493,6 +499,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, dma_set_coherent_mask(&epc->dev, dev->coherent_dma_mask); epc->dev.class = pci_epc_class; epc->dev.dma_mask = dev->dma_mask; + epc->dev.parent = dev; epc->ops = ops;