From patchwork Wed Nov 22 08:54:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Kishon Vijay Abraham I X-Patchwork-Id: 119438 Delivered-To: patch@linaro.org Received: by 10.140.22.164 with SMTP id 33csp6418368qgn; Wed, 22 Nov 2017 00:54:37 -0800 (PST) X-Google-Smtp-Source: AGs4zMaEg2qug+MCIjgyaw3TG/ufsdHEhYL1xZBa6RLrOFUUShZ/0ENz5sKIn95cqSCafqzGGvOL X-Received: by 10.84.218.143 with SMTP id r15mr20373781pli.53.1511340877152; Wed, 22 Nov 2017 00:54:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1511340877; cv=none; d=google.com; s=arc-20160816; b=iRFRM1rxBAIIMVsG4WWl+LybQAJ+y2DbDzD9xHJash9id4MQlzyi3r+SJbOKbLadM8 7nneqm3Jhh7aBwnkVflMadOzjd1Z1gajuk5peTHT7aHgKpW7iNEfD+tOWCBnz36BlGfb lkwA7WtNFsjIzeS3twmntrX96xEcwA824UErgyP8nVtHaZhNPJl+QkoC1NVrAOs47JLw SMephRGSaYhkmyt2Idfr4PUVM7VcsdoB9NO9Fj+yGiu7a6W6wbF4AZ3nwbaZ348o2JIJ PPlgpjGppoX/9PxyPzgEEwhAfwbxtBmubjczLZO8uLJtcwxj1PKADkg8zZ6RkIwuyZU7 Tx8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from:dkim-signature:arc-authentication-results; bh=L9eRLWIGznlSU5XeYsajrJNlgj/BzqHRm3uLPjmx9xs=; b=y+22PNGiUbkKnOzoxLMzvjyg3FondnXfg8JHV3nvxd/P9R2eE60/TYvpDmZF7iJ+p0 qtr2uzA8bCzKNlEVEnXx3OcZ/NruY2deRocO3/lfwMwHETEDvVGLiLIBJke/oXRtDJ3s FVtnq1YKaZvONu+DZ6iWbWaRej5PsEy+DouKPUsyIO4kHFzKeX1e5Hi+qT6+uD28t31y cQ8uUE1sx6vqcLm4KiKuyufpWAazWjoei3wDW7mkgjoqA+Xb62EbOHA0r9l1siBOkgKx QY6eZJuLnNJ8y9/RLA7MTkf79PWHUimE8hikYCqZl1HJdBtgEGE64Ia3j36l7fJiNSJx laJg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=WxpCy4GI; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 39si12380068plc.68.2017.11.22.00.54.36; Wed, 22 Nov 2017 00:54:37 -0800 (PST) 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=@ti.com header.s=ti-com-17Q1 header.b=WxpCy4GI; 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=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751921AbdKVIyf (ORCPT + 28 others); Wed, 22 Nov 2017 03:54:35 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:23216 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751777AbdKVIye (ORCPT ); Wed, 22 Nov 2017 03:54:34 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id vAM8sJLj024983; Wed, 22 Nov 2017 02:54:19 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1511340859; bh=Xnp9xAz7kMb9L/6/4dVytcSscjVhuqNa7Ahc7s4cAxA=; h=From:To:CC:Subject:Date; b=WxpCy4GIiuGJeMyHXAIPcvjMUMv1Pcv3mv+4r8tW6iD5xgAApiGcpIpKqpc8Fwvtn q+t2QTElR87Q0exBmoRBIhDX8NPdjrCizA7pf2A/oZCpRnOkC5mRbmrcn8T7G0LS73 OFn29qjMRFT+X6SN9mprmSWWokeL58DmFjfixqec= Received: from DLEE115.ent.ti.com (dlee115.ent.ti.com [157.170.170.26]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAM8sJZn031221; Wed, 22 Nov 2017 02:54:19 -0600 Received: from DLEE105.ent.ti.com (157.170.170.35) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.1.845.34; Wed, 22 Nov 2017 02:54:18 -0600 Received: from dlep33.itg.ti.com (157.170.170.75) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.845.34 via Frontend Transport; Wed, 22 Nov 2017 02:54:18 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dlep33.itg.ti.com (8.14.3/8.13.8) with ESMTP id vAM8sEYi003236; Wed, 22 Nov 2017 02:54:15 -0600 From: Kishon Vijay Abraham I To: Kishon Vijay Abraham I , Lorenzo Pieralisi , Bjorn Helgaas CC: , , , Xiaowei Bao , Niklas Cassel , Robin Murphy , Rob Herring , Christoph Hellwig Subject: [PATCH] PCI: endpoint: Use EPC's device in dma_alloc_coherent/dma_free_coherent Date: Wed, 22 Nov 2017 14:24:12 +0530 Message-ID: <20171122085412.12024-1-kishon@ti.com> X-Mailer: git-send-email 2.11.0 MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After commit 723288836628bc1c08 ("of: restrict DMA configuration"), of_dma_configure doesn't configure the coherent_dma_mask/dma_mask of endpoint function device (since it doesn't have a dt node associated with and hence no dma-ranges property), resulting in dma_alloc_coherent (used in pci_epf_alloc_space) to fail. Fix it by making dma_alloc_coherent use EPC's device for allocating memory address as per discussion in [1] [1] https://lkml.org/lkml/2017/10/24/26 Signed-off-by: Kishon Vijay Abraham I Cc: Robin Murphy Cc: Rob Herring Cc: Christoph Hellwig --- drivers/pci/endpoint/pci-epc-core.c | 10 ---------- drivers/pci/endpoint/pci-epf-core.c | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) -- 2.11.0 Tested-by: Cyrille Pitchen diff --git a/drivers/pci/endpoint/pci-epc-core.c b/drivers/pci/endpoint/pci-epc-core.c index 42c2a1156325..cd7d4788b94d 100644 --- a/drivers/pci/endpoint/pci-epc-core.c +++ b/drivers/pci/endpoint/pci-epc-core.c @@ -18,7 +18,6 @@ */ #include -#include #include #include #include @@ -371,7 +370,6 @@ 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 (epf->epc) return -EBUSY; @@ -383,12 +381,6 @@ int pci_epc_add_epf(struct pci_epc *epc, struct pci_epf *epf) return -EINVAL; epf->epc = epc; - 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); @@ -503,9 +495,7 @@ __pci_epc_create(struct device *dev, const struct pci_epc_ops *ops, INIT_LIST_HEAD(&epc->pci_epf); device_initialize(&epc->dev); - 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; diff --git a/drivers/pci/endpoint/pci-epf-core.c b/drivers/pci/endpoint/pci-epf-core.c index ae1611a62808..95ccc4b8a0a2 100644 --- a/drivers/pci/endpoint/pci-epf-core.c +++ b/drivers/pci/endpoint/pci-epf-core.c @@ -99,7 +99,7 @@ EXPORT_SYMBOL_GPL(pci_epf_bind); */ void pci_epf_free_space(struct pci_epf *epf, void *addr, enum pci_barno bar) { - struct device *dev = &epf->dev; + struct device *dev = epf->epc->dev.parent; if (!addr) return; @@ -122,7 +122,7 @@ EXPORT_SYMBOL_GPL(pci_epf_free_space); void *pci_epf_alloc_space(struct pci_epf *epf, size_t size, enum pci_barno bar) { void *space; - struct device *dev = &epf->dev; + struct device *dev = epf->epc->dev.parent; dma_addr_t phys_addr; if (size < 128)