Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3962437img; Mon, 25 Mar 2019 23:37:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwPQnrbkIyvQCkldCk8vtnqKW2uJas58hQ8JYhZEA6exUe5yGcox0HEv81SHzpIEsL+LBXa X-Received: by 2002:a62:6c43:: with SMTP id h64mr28172267pfc.123.1553582229269; Mon, 25 Mar 2019 23:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553582229; cv=none; d=google.com; s=arc-20160816; b=lBwfMLmpURt9QAhmqege9vMsfbBF/xvZWZTA8doilfXCFcP/RvKsVfE1oN8KJd9lIv rDZTsseWtxLm+Hzk/cSS5W3zXXInaW15nsePvN6nbEEGaEI4IR6RDD8bYO9cuTGe6R5l a6Qw/X8MB1zcEycf1ZmSJfrpmj2LMYqBg5pNrlGzxqaM7nO8THRJqpMARQ2jY+Cm+Fnq wj+kw2jhWvag084gx9NC4idZsaBNo69x7Aq3z08sv2W9TZszNWVllkXwNUTU0ondKV7e c1IR1pHvgMCThx/Ch7Xc0ZHiNBicG6QI4YNGBdkJJPE+RltvFXXPhrbFqx+SYlDVomwg Jlxw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=ySx4oCCVrstR24e96tNsiMV/fHl+iV+KLyPzIo9d+Z8=; b=VdHmRn2v7jKTRj4Trubi8CC4JcBYKjPGBjHluG0AQrhxQB8N5apZeLOfTqHXOIQgbs nuFhPSIwHfYO/KA+6vBiIXRtGzesZC+tG6E+0pIzPCd8R6ghRr3uPQpr1GimxULHHbYV tkRpjZYZ+VbZKXOX/XParzXhNNDrqrG5a5tydyalbJpL2H39hOIeqCQsSiQm3rdhMXxL O+4A7phejdFW+MNkq222ooZqFacfeixc5o0sDE4RrrIrs6h4cFHGAbxR2yZV5lbDepQ9 x1caKtBsry3gCa4h+Bzuzth4JYQUumPM3oHspthzv+ZI2WBx/H7dryfmiVE7HVQxMaVq /XVw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=zINAdVvu; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l2si15437359pfc.287.2019.03.25.23.36.54; Mon, 25 Mar 2019 23:37:09 -0700 (PDT) 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=@kernel.org header.s=default header.b=zINAdVvu; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731889AbfCZGec (ORCPT + 99 others); Tue, 26 Mar 2019 02:34:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:45140 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731869AbfCZGeb (ORCPT ); Tue, 26 Mar 2019 02:34:31 -0400 Received: from localhost (unknown [104.132.152.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 8A84F2070B; Tue, 26 Mar 2019 06:34:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1553582070; bh=k9YLOZZJdChMAYf5tvNnBJDxxUvJz09/vbH+8OEpmCc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=zINAdVvukawfv/ageZFXKpMkrjPqbjGGkSl8gwgjbKD2LubXODtdSKlIAtiSvO5e6 qBEr8ustbRC0gpHoxacYQG9lyxEto729042bSeDTU+hGyaxYmjvgQ1txliFSOOgGi6 Jbv3NMRur3G2oClR/ilXHhnojBnsQah0qnMCkN+I= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Kishon Vijay Abraham I , Lorenzo Pieralisi , Robin Murphy , Rob Herring , Christoph Hellwig , Cyrille Pitchen , Niklas Cassel , Arnd Bergmann Subject: [PATCH 4.14 36/41] PCI: endpoint: Use EPCs device in dma_alloc_coherent()/dma_free_coherent() Date: Tue, 26 Mar 2019 15:30:13 +0900 Message-Id: <20190326042651.858512780@linuxfoundation.org> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190326042649.889479098@linuxfoundation.org> References: <20190326042649.889479098@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review X-Patchwork-Hint: ignore MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Kishon Vijay Abraham I commit b330104fa76df3eae6e199a23791fed5d35f06b4 upstream. After commit 723288836628 ("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 [lorenzo.pieralisi@arm.com: tweaked commit log] Signed-off-by: Lorenzo Pieralisi Cc: Robin Murphy Cc: Rob Herring Cc: Christoph Hellwig Tested-by: Cyrille Pitchen Tested-by: Niklas Cassel Reviewed-by: Robin Murphy Signed-off-by: Arnd Bergmann Signed-off-by: Greg Kroah-Hartman --- drivers/pci/endpoint/pci-epc-core.c | 10 ---------- drivers/pci/endpoint/pci-epf-core.c | 4 ++-- 2 files changed, 2 insertions(+), 12 deletions(-) --- 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, 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, con 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; --- 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)