From patchwork Tue Dec 19 08:36:27 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: 122343 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp3865820qgn; Tue, 19 Dec 2017 00:36:59 -0800 (PST) X-Google-Smtp-Source: ACJfBovggXN4Ei3CflYml7aI1vgopUtKcsEdAb5BivAyyV6BHf6jvs6zOU1sPlADIOX60cZS0iBE X-Received: by 10.159.218.12 with SMTP id v12mr2567016plp.224.1513672619831; Tue, 19 Dec 2017 00:36:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1513672619; cv=none; d=google.com; s=arc-20160816; b=sM3dI+PdNfqkMSZlPLgjXtAJ/ldTTzIwAyFmwY3xnZNy27byOyOUX0EOM9wPiQAsM0 tp/dl4DhyEBzxEzB4qEDE/zlZkxCWy2t+Gyfa0u88xEZjPCtsgXdfXWD/CQB3i9U7/yy PoFevGPK1fJIFG3Q26nUL6ZgRmd0aYc5yyDFR13GEUi9Hkj1cOpdUarL4QWyuvVWU/1y rqPBMM0+AVp07eJxPnSv7HuJTg6PcS51gSmRsgKsQeGrKQ0LK5VvKawGZFAybVJPdm1u GOZSZlRS15YfpQJb7JyiWxClrd+OOBz7fCLTtettdE+5mdKYdKcTbzt5aFrks7VjxKpT 08fQ== 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=xLDoKVNeXK8enJ+/kphAsXM03EKEEy4T2aGxLf6xZGI=; b=I8SDf0N5yWjkWi6pXi5JRHUUck+O0F2NjhKh8SwfJcSVdi6+5ETLlUpkXm7AbBM0r5 bsDcz3P+2wMbIxSh9ib5RU9YaW/dHeDlzSFg9X+zk8NhLLp2VL4ydIYZqB2qsmORFJIg lQxUFyFW1Key7env1R3LLfSkCHHsqGid2N0KFN0Xh0e76+Khd6TWsgbX2lZItjGH+OZh QN15zBWwHn9MwCo4UYqwRASIlY1/v9g05W4Ibb3ZltD78rqemxuZhvnBM3fy9fvGAVfC vK23YDYmX1zZypG2cCJVjdtzlhsY+cCiIW56cBw3tTcUpnfgq6yT8NG0JluaFr71boAT NYGg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=X8JiXgQ0; 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 r1si9683610pgp.308.2017.12.19.00.36.59; Tue, 19 Dec 2017 00:36:59 -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=X8JiXgQ0; 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 S1761466AbdLSIgz (ORCPT + 28 others); Tue, 19 Dec 2017 03:36:55 -0500 Received: from lelnx194.ext.ti.com ([198.47.27.80]:14790 "EHLO lelnx194.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1759093AbdLSIgx (ORCPT ); Tue, 19 Dec 2017 03:36:53 -0500 Received: from dflxv15.itg.ti.com ([128.247.5.124]) by lelnx194.ext.ti.com (8.15.1/8.15.1) with ESMTP id vBJ8aiJF015688; Tue, 19 Dec 2017 02:36:44 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1513672604; bh=WUIObvVKIpICdYXn5qVr668JG4lM+jahXKcviqoNwxw=; h=From:To:CC:Subject:Date; b=X8JiXgQ078gzoQnVNpW893Ruz67FJZbXSwz0KJXPv8w+KQO5/S+J6oZ6pV5vn33zi 0EtEuZjwhb0GT58+PtJ173qiB8ZDp3exR5MT6zxbAhq7KFTjguAJCFGuJzpa2HqV7A VDf3/zcm96YWsqZnihqe+7uoFEaE/BpsDTRodOxU= Received: from DFLE114.ent.ti.com (dfle114.ent.ti.com [10.64.6.35]) by dflxv15.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ8aiGP009823; Tue, 19 Dec 2017 02:36:44 -0600 Received: from DFLE107.ent.ti.com (10.64.6.28) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Tue, 19 Dec 2017 02:36:43 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DFLE107.ent.ti.com (10.64.6.28) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Tue, 19 Dec 2017 02:36:43 -0600 Received: from a0393678ub.india.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by dflp33.itg.ti.com (8.14.3/8.13.8) with ESMTP id vBJ8aeKh008037; Tue, 19 Dec 2017 02:36:41 -0600 From: Kishon Vijay Abraham I To: Lorenzo Pieralisi , Bjorn Helgaas CC: , , , , Robin Murphy , Rob Herring , Christoph Hellwig Subject: [PATCH v2] PCI: endpoint: Use EPC's device in dma_alloc_coherent/dma_free_coherent Date: Tue, 19 Dec 2017 14:06:27 +0530 Message-ID: <20171219083627.7904-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 Tested-by: Cyrille Pitchen --- No change in patch. Only added "Tested-by" of Cyrille Pitchen. 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: Niklas Cassel Reviewed-by: Robin Murphy 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)