From patchwork Thu Jan 11 08:30:57 2018 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: 124153 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp365439qgn; Thu, 11 Jan 2018 00:31:18 -0800 (PST) X-Google-Smtp-Source: ACJfBotgefWm23yui4j7ZoQ7vlOMPT7sWcyhALQJcoM8IuKrbZyuJM+BpSuVmkSn/Zth/D8t8O0b X-Received: by 10.84.138.193 with SMTP id 59mr21503746plp.254.1515659478216; Thu, 11 Jan 2018 00:31:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1515659478; cv=none; d=google.com; s=arc-20160816; b=UhZWaBsAPHT49vqcVQAEbQzP4e2t1Or/dmN+MY+U8WHsszxa/V4h8uNIb6tV7OGLr7 5foBxtjLTgY/uTLKvCvEUsRsJI9IfhzEaUuQ/iURcqOiQgwx2sSjPePsZPu00rkrKKsA NHuWZysAwJCIMikSKl69LLY1xkJHm7U1qinwooomljilc+rbv1QeZ1mzyQfVKij5DZkI j/bIED0A2rFz1QbFJ5gnLuXPNoKOX5sI1fS5HtnxRLhP7wUzIxwgULqx2VCKppUK3FVZ VlrN4rZrGZ9DteAqe9js5YHBteIhkOWXIPlVMEHHD4VuL63GNHB0ya4C8VErNsq+OLbT 5IFw== 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=2mIDqreZW1cX2ywC7iTwKwpjV/nlNd1ufKvhC0Y1DQU=; b=zX2glqVQqOf01PFvl2u5SN4wEf31zv/dJlQ2GWt1UOLA09G3NnMYll5lu+9nuIIIMR 6HlJ2fK2QCIurOlNw8/uiuc1B7H4Tpwvk7lBzMh4kLrJQ5Zmu/Rdp19X6I8OnoTikvAz jP+HUc3urp1Qo1Q5gOUbPNzv4V9jL76POPiRwZ8iiv+d44SSPCCClGyx345m0W8jDFRH n26KP3bdqIm3CasPpEcdpPBOExYe5WzKzdQN/a8vEjtDXcpZsA1o8ny4dCpK4AMW6tVP 0F23niDJgJccqM+yf5L/VIkkfNi/QTAH9KSw6e0dI7CnFKOfGqdtcV3w/PRKJuOI0tZo 1Gkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=OagGoedX; 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 q126si13127646pfc.106.2018.01.11.00.31.17; Thu, 11 Jan 2018 00:31:18 -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=OagGoedX; 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 S932283AbeAKIbQ (ORCPT + 28 others); Thu, 11 Jan 2018 03:31:16 -0500 Received: from fllnx210.ext.ti.com ([198.47.19.17]:32879 "EHLO fllnx210.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753660AbeAKIbP (ORCPT ); Thu, 11 Jan 2018 03:31:15 -0500 Received: from dlelxv90.itg.ti.com ([172.17.2.17]) by fllnx210.ext.ti.com (8.15.1/8.15.1) with ESMTP id w0B8V52X002059; Thu, 11 Jan 2018 02:31:05 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ti.com; s=ti-com-17Q1; t=1515659465; bh=GksURMGeaCaaXVerg4H0/GgDFWxmpPa+2sGuJGKn4/A=; h=From:To:CC:Subject:Date; b=OagGoedX4/v1ZoaVcpRedtwKJx4un9kGgPaQ7JhI+Zz6OB+x/tcnRQKVJWzll+4yA VjrRXEvKUwmA20Tymj09TSL1QtinNuCzN3k3uGED47wrehJ5x45TwTSe5YNizQqPno AQLalwV0ZDfGDLyi9HCDVe2om9fpCdM6AvLu+GJA= Received: from DLEE101.ent.ti.com (dlee101.ent.ti.com [157.170.170.31]) by dlelxv90.itg.ti.com (8.14.3/8.13.8) with ESMTP id w0B8V5WJ026964; Thu, 11 Jan 2018 02:31:05 -0600 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE101.ent.ti.com (157.170.170.31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1261.35; Thu, 11 Jan 2018 02:31:05 -0600 Received: from dflp33.itg.ti.com (10.64.6.16) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1261.35 via Frontend Transport; Thu, 11 Jan 2018 02:31:04 -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 w0B8V1IR006401; Thu, 11 Jan 2018 02:31:02 -0600 From: Kishon Vijay Abraham I To: Lorenzo Pieralisi , Bjorn Helgaas , CC: , , , Robin Murphy , Rob Herring , Christoph Hellwig Subject: [PATCH v3] PCI: endpoint: Use EPC's device in dma_alloc_coherent/dma_free_coherent Date: Thu, 11 Jan 2018 14:00:57 +0530 Message-ID: <20180111083057.1134-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. Link: http://lkml.kernel.org/r/64d63468-d28f-8fcd-a6f3-cf2a6401c8cb@ti.com Signed-off-by: Kishon Vijay Abraham I Cc: Robin Murphy Cc: Rob Herring Cc: Christoph Hellwig Tested-by: Cyrille Pitchen Tested-by: Niklas Cassel Reviewed-by: Robin Murphy --- Changes from v2: No change in patch. Added "Link", "Reviewed-by" and "Tested-by" tags Changes from v1: 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 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)