From patchwork Fri Feb 1 08:47:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792301 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7E27E14E1 for ; Fri, 1 Feb 2019 08:51:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7188F31E7B for ; Fri, 1 Feb 2019 08:51:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5FD5E31E9D; Fri, 1 Feb 2019 08:51:13 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 175DB31E82 for ; Fri, 1 Feb 2019 08:51:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725876AbfBAIvM (ORCPT ); Fri, 1 Feb 2019 03:51:12 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48266 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729225AbfBAIsI (ORCPT ); Fri, 1 Feb 2019 03:48:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=l3DOgCmu34NqZKnulcp3vGWxIiN/v8w0KyW6Do+gkok=; b=FtSVRlxtfJotCCF5iySwft2MRE EmQtssDlmFitwgtxHgjDJuhNlKlu1/n86S5ZrJJIF3Zqo7THN83AHxEdL9Hy2IoIrn8GGYUio7mQv ZrGv1lT+lUpm91/4cPzbJ4FFJozlzjPW3Z9zNt3qSV9GkCmu6E8ze4FpEAJfikfG7DA2elWRNXyc3 UIXvaZcevaWhL3dNM8I0NO5WAPU75X+ihtow5zV97kbXy0Dg7XIU57FfwFToqZwKTPKl02PqLUoAH WWMc8EOvcbo+7O280I2w+zzYRKHoYCPZmUWKYXDBBhNyqJAr4GX2sOQ0Ay71zssw74oijWlRijI9G AzYUo5Bw==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUX-0001Mb-R2; Fri, 01 Feb 2019 08:48:06 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 01/18] MIPS: lantiq: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:44 +0100 Message-Id: <20190201084801.10983-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Also use GFP_KERNEL instead of GFP_ATOMIC as the gfp_t for the memory allocation, as we aren't in interrupt context or under a lock. Note that this whole function looks somewhat bogus given that we never even look at the returned dma address, and the CPHYSADDR magic on a returned noncached mapping looks "interesting". But I'll leave that to people more familiar with the code to sort out. Signed-off-by: Christoph Hellwig --- arch/mips/lantiq/xway/vmmc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/arch/mips/lantiq/xway/vmmc.c b/arch/mips/lantiq/xway/vmmc.c index 577ec81b557d..3deab9a77718 100644 --- a/arch/mips/lantiq/xway/vmmc.c +++ b/arch/mips/lantiq/xway/vmmc.c @@ -31,8 +31,8 @@ static int vmmc_probe(struct platform_device *pdev) dma_addr_t dma; cp1_base = - (void *) CPHYSADDR(dma_alloc_coherent(NULL, CP1_SIZE, - &dma, GFP_ATOMIC)); + (void *) CPHYSADDR(dma_alloc_coherent(&pdev->dev, CP1_SIZE, + &dma, GFP_KERNEL)); gpio_count = of_gpio_count(pdev->dev.of_node); while (gpio_count > 0) { From patchwork Fri Feb 1 08:47:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792297 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 38770746 for ; Fri, 1 Feb 2019 08:51:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2B76331E7B for ; Fri, 1 Feb 2019 08:51:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1EFA631E82; Fri, 1 Feb 2019 08:51:08 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 C3CE031E95 for ; Fri, 1 Feb 2019 08:51:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729293AbfBAIsM (ORCPT ); Fri, 1 Feb 2019 03:48:12 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48286 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbfBAIsL (ORCPT ); Fri, 1 Feb 2019 03:48:11 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=oeWjW7MYDj5Z0OrwE0athM1WZmC27Mlek0LN98l8BVY=; b=dT07yaI+2qOd4yysC+I6zQ0t/q e8R1Nemh+lcxBmHKoMTsTa3/OWuLAsKg38m87EolK9UaBBxa2W6AaIyQDxBcbDac0JHMYudwVb2nB 0lU8B+6QhrdWt82W8sZnvenvgD8qSyp16Kx9vENl6nj56xJIqhP4WAsJX+qKpYh3mOXwc1YTbQfXJ s3BTznpc98iSpCFLxLfzT4xs6157/3uNVkXh/CjNfjG4/ie25bdqNjmuZTA1qrQKtc32w8Bgnkeg1 I1UtOZuTUAbgdFXeihGQLQSslkZOER2SKbjXlBE55N/w0m46iF7MlwgXUy4gDesKIvu7S1LPfl3TG imhcKaXA==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUa-0001Ml-Bk; Fri, 01 Feb 2019 08:48:08 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 02/18] dmaengine: imx-sdma: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:45 +0100 Message-Id: <20190201084801.10983-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig --- drivers/dma/imx-sdma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c index 86708fb9bda1..0b6bba0b9f38 100644 --- a/drivers/dma/imx-sdma.c +++ b/drivers/dma/imx-sdma.c @@ -677,7 +677,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, int ret; unsigned long flags; - buf_virt = dma_alloc_coherent(NULL, size, &buf_phys, GFP_KERNEL); + buf_virt = dma_alloc_coherent(sdma->dev, size, &buf_phys, GFP_KERNEL); if (!buf_virt) { return -ENOMEM; } @@ -696,7 +696,7 @@ static int sdma_load_script(struct sdma_engine *sdma, void *buf, int size, spin_unlock_irqrestore(&sdma->channel_0_lock, flags); - dma_free_coherent(NULL, size, buf_virt, buf_phys); + dma_free_coherent(sdma->dev, size, buf_virt, buf_phys); return ret; } @@ -1182,8 +1182,8 @@ static int sdma_request_channel0(struct sdma_engine *sdma) { int ret = -EBUSY; - sdma->bd0 = dma_alloc_coherent(NULL, PAGE_SIZE, &sdma->bd0_phys, - GFP_NOWAIT); + sdma->bd0 = dma_alloc_coherent(sdma->dev, PAGE_SIZE, &sdma->bd0_phys, + GFP_NOWAIT); if (!sdma->bd0) { ret = -ENOMEM; goto out; @@ -1842,7 +1842,7 @@ static int sdma_init(struct sdma_engine *sdma) /* Be sure SDMA has not started yet */ writel_relaxed(0, sdma->regs + SDMA_H_C0PTR); - sdma->channel_control = dma_alloc_coherent(NULL, + sdma->channel_control = dma_alloc_coherent(sdma->dev, MAX_DMA_CHANNELS * sizeof (struct sdma_channel_control) + sizeof(struct sdma_context_data), &ccb_phys, GFP_KERNEL); From patchwork Fri Feb 1 08:47:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792281 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B9654184E for ; Fri, 1 Feb 2019 08:51:00 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC9B131E7B for ; Fri, 1 Feb 2019 08:51:00 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A0C1331E87; Fri, 1 Feb 2019 08:51:00 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 458CE31E82 for ; Fri, 1 Feb 2019 08:51:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729365AbfBAIsR (ORCPT ); Fri, 1 Feb 2019 03:48:17 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48306 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729327AbfBAIsN (ORCPT ); Fri, 1 Feb 2019 03:48:13 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=qzppGvL5YTNR4ERolWGzkqCfDHbPo49RlnLgQJkb/B4=; b=KTUmfgmiCcSdnJYygxwmL4jdmE BlEsBjwRJT+EUpK+qf0kiyQeZEMErFPTttfof2L5+dnLU9jRRGY6MCYuTdqQhCTz4cB6w77tVfsZg /2JSSMOrzcqzWCQdlBLEJH9x927VWVWF+u/V1idwRy2d/1tA+fwu6X3KOAhO/JAsMkLtAQ8k9eTGY wvRdmBI/ZVHZm5ugY1tCvmjM/o/WuB4Gjn1L7mfqjy5yEarPDJ/UxWnhF3qiVojFjRHrpgEPa0wkj hLY1AH68bx8Pd1VKnc31cIQgUEehlB9n5UMMIzeXbZVAXUs6c2JJz3/Y9JIPpdKfzFWuAvXiykJuv fO0nUUJA==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUc-0001NC-Se; Fri, 01 Feb 2019 08:48:11 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 03/18] net: caif: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:46 +0100 Message-Id: <20190201084801.10983-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Also use the proper Kconfig symbol to check for DMA API availability. Signed-off-by: Christoph Hellwig --- drivers/net/caif/caif_spi.c | 30 ++++++++++++++++-------------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/drivers/net/caif/caif_spi.c b/drivers/net/caif/caif_spi.c index d28a1398c091..b7f3e263b57c 100644 --- a/drivers/net/caif/caif_spi.c +++ b/drivers/net/caif/caif_spi.c @@ -73,35 +73,37 @@ MODULE_PARM_DESC(spi_down_tail_align, "SPI downlink tail alignment."); #define LOW_WATER_MARK 100 #define HIGH_WATER_MARK (LOW_WATER_MARK*5) -#ifdef CONFIG_UML +#ifdef CONFIG_HAS_DMA /* * We sometimes use UML for debugging, but it cannot handle * dma_alloc_coherent so we have to wrap it. */ -static inline void *dma_alloc(dma_addr_t *daddr) +static inline void *dma_alloc(struct cfspi *cfspi, dma_addr_t *daddr) { return kmalloc(SPI_DMA_BUF_LEN, GFP_KERNEL); } -static inline void dma_free(void *cpu_addr, dma_addr_t handle) +static inline void dma_free(struct cfspi *cfspi, void *cpu_addr, + dma_addr_t handle) { kfree(cpu_addr); } #else -static inline void *dma_alloc(dma_addr_t *daddr) +static inline void *dma_alloc(struct cfspi *cfspi, dma_addr_t *daddr) { - return dma_alloc_coherent(NULL, SPI_DMA_BUF_LEN, daddr, + return dma_alloc_coherent(&cfspi->pdev->dev, SPI_DMA_BUF_LEN, daddr, GFP_KERNEL); } -static inline void dma_free(void *cpu_addr, dma_addr_t handle) +static inline void dma_free(struct cfspi *cfspi, void *cpu_addr, + dma_addr_t handle) { - dma_free_coherent(NULL, SPI_DMA_BUF_LEN, cpu_addr, handle); + dma_free_coherent(&cfspi->pdev->dev, SPI_DMA_BUF_LEN, cpu_addr, handle); } -#endif /* CONFIG_UML */ +#endif /* CONFIG_HAS_DMA */ #ifdef CONFIG_DEBUG_FS @@ -610,13 +612,13 @@ static int cfspi_init(struct net_device *dev) } /* Allocate DMA buffers. */ - cfspi->xfer.va_tx[0] = dma_alloc(&cfspi->xfer.pa_tx[0]); + cfspi->xfer.va_tx[0] = dma_alloc(cfspi, &cfspi->xfer.pa_tx[0]); if (!cfspi->xfer.va_tx[0]) { res = -ENODEV; goto err_dma_alloc_tx_0; } - cfspi->xfer.va_rx = dma_alloc(&cfspi->xfer.pa_rx); + cfspi->xfer.va_rx = dma_alloc(cfspi, &cfspi->xfer.pa_rx); if (!cfspi->xfer.va_rx) { res = -ENODEV; @@ -665,9 +667,9 @@ static int cfspi_init(struct net_device *dev) return 0; err_create_wq: - dma_free(cfspi->xfer.va_rx, cfspi->xfer.pa_rx); + dma_free(cfspi, cfspi->xfer.va_rx, cfspi->xfer.pa_rx); err_dma_alloc_rx: - dma_free(cfspi->xfer.va_tx[0], cfspi->xfer.pa_tx[0]); + dma_free(cfspi, cfspi->xfer.va_tx[0], cfspi->xfer.pa_tx[0]); err_dma_alloc_tx_0: return res; } @@ -683,8 +685,8 @@ static void cfspi_uninit(struct net_device *dev) cfspi->ndev = NULL; /* Free DMA buffers. */ - dma_free(cfspi->xfer.va_rx, cfspi->xfer.pa_rx); - dma_free(cfspi->xfer.va_tx[0], cfspi->xfer.pa_tx[0]); + dma_free(cfspi, cfspi->xfer.va_rx, cfspi->xfer.pa_rx); + dma_free(cfspi, cfspi->xfer.va_tx[0], cfspi->xfer.pa_tx[0]); set_bit(SPI_TERMINATE, &cfspi->state); wake_up_interruptible(&cfspi->wait); destroy_workqueue(cfspi->wq); From patchwork Fri Feb 1 08:47:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792287 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 5DE84184E for ; Fri, 1 Feb 2019 08:51:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4C62B31E82 for ; Fri, 1 Feb 2019 08:51:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4098531E87; Fri, 1 Feb 2019 08:51:02 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 E9B4B31E98 for ; Fri, 1 Feb 2019 08:51:01 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729361AbfBAIsR (ORCPT ); Fri, 1 Feb 2019 03:48:17 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48326 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726172AbfBAIsQ (ORCPT ); Fri, 1 Feb 2019 03:48:16 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CxZHu4dBypMzIJdePoRBvzcE17U6xI+P3h/hNk9DnbQ=; b=l6xSAXciTrUv6yu7E1BVv+daIt uOF379nXHlyFMEjN6Uksd9kr5QqWZw98NoWx/kI/WP7qyET/ouo7kvwzRT2jgJCR+bxu04lQIXWYf Qk/ZBuRvotjK8PvlB2nKx9UFxIqtPbQJEEbcKR8rhC0vwlpxOVz55tx4RCYiyJfTgjoNtFMCpbPk4 Zv9tNKPN+ce7J67R5aM60FCEc/F+tW24m1Ms5iZ6JTUU/1vXhcGx7H5jov+9jJ3szbPQjnImvpHjz TsayKVrYyeSRgKOj/dsZ8QgdI4Ye1CYQVIhOvGpnsV9dNbFHrF4s8SkAFh8r3pDu4TSjUkPdUypQS 5UXJsZvQ==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUf-0001Np-Ie; Fri, 01 Feb 2019 08:48:13 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 04/18] au1000_eth: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:47 +0100 Message-Id: <20190201084801.10983-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/amd/au1000_eth.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/net/ethernet/amd/au1000_eth.c b/drivers/net/ethernet/amd/au1000_eth.c index e833d1b3fe18..e5073aeea06a 100644 --- a/drivers/net/ethernet/amd/au1000_eth.c +++ b/drivers/net/ethernet/amd/au1000_eth.c @@ -1167,7 +1167,7 @@ static int au1000_probe(struct platform_device *pdev) /* Allocate the data buffers * Snooping works fine with eth on all au1xxx */ - aup->vaddr = (u32)dma_alloc_attrs(NULL, MAX_BUF_SIZE * + aup->vaddr = (u32)dma_alloc_attrs(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS), &aup->dma_addr, 0, DMA_ATTR_NON_CONSISTENT); @@ -1349,7 +1349,7 @@ static int au1000_probe(struct platform_device *pdev) err_remap2: iounmap(aup->mac); err_remap1: - dma_free_attrs(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS), + dma_free_attrs(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS), (void *)aup->vaddr, aup->dma_addr, DMA_ATTR_NON_CONSISTENT); err_vaddr: @@ -1383,7 +1383,7 @@ static int au1000_remove(struct platform_device *pdev) if (aup->tx_db_inuse[i]) au1000_ReleaseDB(aup, aup->tx_db_inuse[i]); - dma_free_attrs(NULL, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS), + dma_free_attrs(&pdev->dev, MAX_BUF_SIZE * (NUM_TX_BUFFS + NUM_RX_BUFFS), (void *)aup->vaddr, aup->dma_addr, DMA_ATTR_NON_CONSISTENT); From patchwork Fri Feb 1 08:47:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792269 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 33DA5188D for ; Fri, 1 Feb 2019 08:50:40 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2464831E79 for ; Fri, 1 Feb 2019 08:50:40 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1828A31E87; Fri, 1 Feb 2019 08:50:40 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 C270B31E7B for ; Fri, 1 Feb 2019 08:50:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729441AbfBAIsU (ORCPT ); Fri, 1 Feb 2019 03:48:20 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48354 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729327AbfBAIsT (ORCPT ); Fri, 1 Feb 2019 03:48:19 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=YxHcnjYJIyN9dSw5XNTjzAkmGK4z/ENOgPTYk1FGBZI=; b=axF0SJy/rQePO2MdOwLhL4wPZm kUGopL49AOrSRzl7zCnocUs7dIHDJws07LpYoYsPTEyFk14KXaLkViehcpaVs2szWBv5z+Hj/AbNO P5fJbWvTN15cCZwf5Cv2GtV37plJ7YSdmW1UYy/S4PYgS04+9pbR+hiAfMCkVimPtvL9a+/xoBo65 Ydnho+Kwb4CoNb/R+G7dECObMxocnY/6bQDDlwgPwEO4D0z+HZR6FK7CDPBfdRD/ww0KFQfYv2WTx XLnnEYImVHE298dffp2Q9L2pnQeB+3NhqHvTFs64TCXXrr3S6xQyZNcX9F+Y5bJqePrQd6frh+fcP ttlTkpsA==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUi-0001OX-3c; Fri, 01 Feb 2019 08:48:16 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 05/18] macb_main: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:48 +0100 Message-Id: <20190201084801.10983-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig Acked-by: Nicolas Ferre --- drivers/net/ethernet/cadence/macb_main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c index 2b2882615e8b..61a27963f1d1 100644 --- a/drivers/net/ethernet/cadence/macb_main.c +++ b/drivers/net/ethernet/cadence/macb_main.c @@ -3673,9 +3673,9 @@ static netdev_tx_t at91ether_start_xmit(struct sk_buff *skb, /* Store packet information (to free when Tx completed) */ lp->skb = skb; lp->skb_length = skb->len; - lp->skb_physaddr = dma_map_single(NULL, skb->data, skb->len, - DMA_TO_DEVICE); - if (dma_mapping_error(NULL, lp->skb_physaddr)) { + lp->skb_physaddr = dma_map_single(&lp->pdev->dev, skb->data, + skb->len, DMA_TO_DEVICE); + if (dma_mapping_error(&lp->pdev->dev, lp->skb_physaddr)) { dev_kfree_skb_any(skb); dev->stats.tx_dropped++; netdev_err(dev, "%s: DMA mapping error\n", __func__); @@ -3765,7 +3765,7 @@ static irqreturn_t at91ether_interrupt(int irq, void *dev_id) if (lp->skb) { dev_kfree_skb_irq(lp->skb); lp->skb = NULL; - dma_unmap_single(NULL, lp->skb_physaddr, + dma_unmap_single(&lp->pdev->dev, lp->skb_physaddr, lp->skb_length, DMA_TO_DEVICE); dev->stats.tx_packets++; dev->stats.tx_bytes += lp->skb_length; From patchwork Fri Feb 1 08:47:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792241 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 85ACA159A for ; Fri, 1 Feb 2019 08:50:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 791A231E78 for ; Fri, 1 Feb 2019 08:50:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6CD2331E7B; Fri, 1 Feb 2019 08:50:23 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 1FA3131E79 for ; Fri, 1 Feb 2019 08:50:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729504AbfBAIs1 (ORCPT ); Fri, 1 Feb 2019 03:48:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48366 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729475AbfBAIsW (ORCPT ); Fri, 1 Feb 2019 03:48:22 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=JrHN5I49NV0qZtB9rpJexCxtdUcm7mEw+htvncP4Mps=; b=KN5jdBesGBbJzuiSAKnjYbrS45 jODfuCNRFto1xnUgIKRdZiGl4x/76/4HKEhHe+2xeySDEe7hc+Sn6NwVl7L9Uz8yXNjYp2Uz+1Cyl Bqp8C1969QjzJ4W/YVeMp4gCwp2yw5g8YZY2uc7s14UmlaKk3H71QpO6+N/r76jTc65/IlaRlLMWv 4QIUGeb1mSRZUEy+N5ridjhswONjwrG/FeMPTD/haxpa9+Lf2mHTkjTQUEA2lUTO1XaygyHNublia MXcYmuatFdhwP/tojkXqXgN68ynEMHrXTNjlZvAlOCexrtAYHCVlSbwPcDdUWc/vo1kTlMS4kwtXW cHrdkCiw==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUk-0001P5-Pk; Fri, 01 Feb 2019 08:48:19 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 06/18] lantiq_etop: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:49 +0100 Message-Id: <20190201084801.10983-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Note this driver seems to lack dma_unmap_* calls entirely, but fixing that is left for another time. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/lantiq_etop.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/lantiq_etop.c b/drivers/net/ethernet/lantiq_etop.c index 32ac9045cdae..f9bb890733b5 100644 --- a/drivers/net/ethernet/lantiq_etop.c +++ b/drivers/net/ethernet/lantiq_etop.c @@ -112,10 +112,12 @@ struct ltq_etop_priv { static int ltq_etop_alloc_skb(struct ltq_etop_chan *ch) { + struct ltq_etop_priv *priv = netdev_priv(ch->netdev); + ch->skb[ch->dma.desc] = netdev_alloc_skb(ch->netdev, MAX_DMA_DATA_LEN); if (!ch->skb[ch->dma.desc]) return -ENOMEM; - ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(NULL, + ch->dma.desc_base[ch->dma.desc].addr = dma_map_single(&priv->pdev->dev, ch->skb[ch->dma.desc]->data, MAX_DMA_DATA_LEN, DMA_FROM_DEVICE); ch->dma.desc_base[ch->dma.desc].addr = @@ -487,7 +489,7 @@ ltq_etop_tx(struct sk_buff *skb, struct net_device *dev) netif_trans_update(dev); spin_lock_irqsave(&priv->lock, flags); - desc->addr = ((unsigned int) dma_map_single(NULL, skb->data, len, + desc->addr = ((unsigned int) dma_map_single(&priv->pdev->dev, skb->data, len, DMA_TO_DEVICE)) - byte_offset; wmb(); desc->ctl = LTQ_DMA_OWN | LTQ_DMA_SOP | LTQ_DMA_EOP | From patchwork Fri Feb 1 08:47:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792261 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6825717E9 for ; Fri, 1 Feb 2019 08:50:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5A8E131E7B for ; Fri, 1 Feb 2019 08:50:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4EAFC31E79; Fri, 1 Feb 2019 08:50:37 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 EB83431E7B for ; Fri, 1 Feb 2019 08:50:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729480AbfBAIs1 (ORCPT ); Fri, 1 Feb 2019 03:48:27 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48384 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729477AbfBAIsY (ORCPT ); Fri, 1 Feb 2019 03:48:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=O5KJ8GRlbczaBVxGOYcgqpq+hGPfEepfpWMZvixHPpI=; b=o92IzzYCttBzDcN4JdyXfmJaDz 28GVjj4SAVJS3enTaCLsnn4HRN3Z+9HaU4ZDJRiq5Ci7NWwJUhvd1ywHZKJFiVmjgtlgwS9n4em4O Nybc3rcenwrkLadXp8GvB1bVLUsgbo3lS6hH/laqCd9FZhri+rR6Hl/ITNDkprYcyBW7zr4PfB0Kw 2HwLCxbAFIkVSD+ZZ/Gf6INEjGPIo623cYKsqPQioYFMglk2kQIvNB4jCgKr5vYRXSnNeaOb0M5X/ 8Y2QqSkEh001eyP8LEh2Ngr3/hinZVxWireKYT0yt5Xo75dXCCdo/3sYutCok7E41thvSXRl/q0vc 0gQqWRzA==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUn-0001Pj-B8; Fri, 01 Feb 2019 08:48:21 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 07/18] pxa168_eth: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:50 +0100 Message-Id: <20190201084801.10983-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Note that this driver seems to entirely lack dma_map_single error handling, but that is left for another time. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/marvell/pxa168_eth.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/marvell/pxa168_eth.c b/drivers/net/ethernet/marvell/pxa168_eth.c index f8a6d6e3cb7a..35f2142aac5e 100644 --- a/drivers/net/ethernet/marvell/pxa168_eth.c +++ b/drivers/net/ethernet/marvell/pxa168_eth.c @@ -201,6 +201,7 @@ struct tx_desc { }; struct pxa168_eth_private { + struct platform_device *pdev; int port_num; /* User Ethernet port number */ int phy_addr; int phy_speed; @@ -331,7 +332,7 @@ static void rxq_refill(struct net_device *dev) used_rx_desc = pep->rx_used_desc_q; p_used_rx_desc = &pep->p_rx_desc_area[used_rx_desc]; size = skb_end_pointer(skb) - skb->data; - p_used_rx_desc->buf_ptr = dma_map_single(NULL, + p_used_rx_desc->buf_ptr = dma_map_single(&pep->pdev->dev, skb->data, size, DMA_FROM_DEVICE); @@ -743,7 +744,7 @@ static int txq_reclaim(struct net_device *dev, int force) netdev_err(dev, "Error in TX\n"); dev->stats.tx_errors++; } - dma_unmap_single(NULL, addr, count, DMA_TO_DEVICE); + dma_unmap_single(&pep->pdev->dev, addr, count, DMA_TO_DEVICE); if (skb) dev_kfree_skb_irq(skb); released++; @@ -805,7 +806,7 @@ static int rxq_process(struct net_device *dev, int budget) if (rx_next_curr_desc == rx_used_desc) pep->rx_resource_err = 1; pep->rx_desc_count--; - dma_unmap_single(NULL, rx_desc->buf_ptr, + dma_unmap_single(&pep->pdev->dev, rx_desc->buf_ptr, rx_desc->buf_size, DMA_FROM_DEVICE); received_packets++; @@ -1274,7 +1275,8 @@ pxa168_eth_start_xmit(struct sk_buff *skb, struct net_device *dev) length = skb->len; pep->tx_skb[tx_index] = skb; desc->byte_cnt = length; - desc->buf_ptr = dma_map_single(NULL, skb->data, length, DMA_TO_DEVICE); + desc->buf_ptr = dma_map_single(&pep->pdev->dev, skb->data, length, + DMA_TO_DEVICE); skb_tx_timestamp(skb); @@ -1528,6 +1530,7 @@ static int pxa168_eth_probe(struct platform_device *pdev) if (err) goto err_free_mdio; + pep->pdev = pdev; SET_NETDEV_DEV(dev, &pdev->dev); pxa168_init_hw(pep); err = register_netdev(dev); From patchwork Fri Feb 1 08:47:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792257 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C159F17E9 for ; Fri, 1 Feb 2019 08:50:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B331631E79 for ; Fri, 1 Feb 2019 08:50:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A764131E82; Fri, 1 Feb 2019 08:50:35 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 530FD31E79 for ; Fri, 1 Feb 2019 08:50:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726428AbfBAIuY (ORCPT ); Fri, 1 Feb 2019 03:50:24 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48410 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729478AbfBAIs1 (ORCPT ); Fri, 1 Feb 2019 03:48:27 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=N5mJ1AAxytGZodzOo16w91XOhAp4pN9n448U5bQziBY=; b=ZE65J7ItNJ+ZOfZ3Mr3Mm1fl3E aY0PbCMBGbW64XSQz8iS0+QcEkpdhJbcJhK9H/nz2diSRxQVmcl+5HaGciP8ZSAmkkKQU++Uzrr+H JbahhXq0KXzG5UtC41unOoeoISl/Tl6jf32Yqs7NMz/+yO6U7NQBeBH2zPJ+5OiM8uOkdFUAcNr4w GkFPPcCO/HrT0czxI8kRwlHzVeppwAhkAx+F16ykf7kAGBoIOZWYKzsL/MlYCJyxvMQBUrKK4Z5Xu nkNHuOjh/kRyXc7sMTLWyGtTr37Fk0tG4SP5C4w8qtZxVhHbuRNM9mK688lBqmI4YGoSFm+a274xk l316XBYw==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUq-0001QE-2W; Fri, 01 Feb 2019 08:48:24 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 08/18] moxart_ether: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:51 +0100 Message-Id: <20190201084801.10983-9-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/moxa/moxart_ether.c | 11 +++++++---- drivers/net/ethernet/moxa/moxart_ether.h | 1 + 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index b34055ac476f..00dec0ffb11b 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c @@ -81,11 +81,13 @@ static void moxart_mac_free_memory(struct net_device *ndev) priv->rx_buf_size, DMA_FROM_DEVICE); if (priv->tx_desc_base) - dma_free_coherent(NULL, TX_REG_DESC_SIZE * TX_DESC_NUM, + dma_free_coherent(&priv->pdev->dev, + TX_REG_DESC_SIZE * TX_DESC_NUM, priv->tx_desc_base, priv->tx_base); if (priv->rx_desc_base) - dma_free_coherent(NULL, RX_REG_DESC_SIZE * RX_DESC_NUM, + dma_free_coherent(&priv->pdev->dev, + RX_REG_DESC_SIZE * RX_DESC_NUM, priv->rx_desc_base, priv->rx_base); kfree(priv->tx_buf_base); @@ -476,6 +478,7 @@ static int moxart_mac_probe(struct platform_device *pdev) priv = netdev_priv(ndev); priv->ndev = ndev; + priv->pdev = pdev; res = platform_get_resource(pdev, IORESOURCE_MEM, 0); ndev->base_addr = res->start; @@ -491,7 +494,7 @@ static int moxart_mac_probe(struct platform_device *pdev) priv->tx_buf_size = TX_BUF_SIZE; priv->rx_buf_size = RX_BUF_SIZE; - priv->tx_desc_base = dma_alloc_coherent(NULL, TX_REG_DESC_SIZE * + priv->tx_desc_base = dma_alloc_coherent(&pdev->dev, TX_REG_DESC_SIZE * TX_DESC_NUM, &priv->tx_base, GFP_DMA | GFP_KERNEL); if (!priv->tx_desc_base) { @@ -499,7 +502,7 @@ static int moxart_mac_probe(struct platform_device *pdev) goto init_fail; } - priv->rx_desc_base = dma_alloc_coherent(NULL, RX_REG_DESC_SIZE * + priv->rx_desc_base = dma_alloc_coherent(&pdev->dev, RX_REG_DESC_SIZE * RX_DESC_NUM, &priv->rx_base, GFP_DMA | GFP_KERNEL); if (!priv->rx_desc_base) { diff --git a/drivers/net/ethernet/moxa/moxart_ether.h b/drivers/net/ethernet/moxa/moxart_ether.h index bee608b547d1..bf4c3029cd0c 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.h +++ b/drivers/net/ethernet/moxa/moxart_ether.h @@ -292,6 +292,7 @@ #define LINK_STATUS 0x4 struct moxart_mac_priv_t { + struct platform_device *pdev; void __iomem *base; unsigned int reg_maccr; unsigned int reg_imr; From patchwork Fri Feb 1 08:47:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792231 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61E6E1874 for ; Fri, 1 Feb 2019 08:50:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 55A0331250 for ; Fri, 1 Feb 2019 08:50:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4951C31B50; Fri, 1 Feb 2019 08:50:12 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 D349531B8F for ; Fri, 1 Feb 2019 08:50:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729475AbfBAIsa (ORCPT ); Fri, 1 Feb 2019 03:48:30 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48430 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729556AbfBAIsa (ORCPT ); Fri, 1 Feb 2019 03:48:30 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=zMOwIVCHl/3RSZU/IZr6L//+E7MYj6EUe0TSRYGQl6Y=; b=LiBiSbGo5IPnaiejGCGng1QljA HXZ0WUc3L7YVimZ6z5jlGBboZ6YKdo0uuqUXkSy7TTJ7B0WtVhWzHy/wNo67WNS05CNQG6NvCFjDa EoqpHqEGFt0HlWOBcOYyH0UwiXtXoP94ercGnU5TanudT4wNnJTQM1/JXUhkTXal3OkAf6SAGNwjR oxd++UEQZvm6Ydtaw90HkQjqPX0E+MySMhsSV3zrkG/xjg0EW4T+syCVvv6Do8R8pfquQsukrPTqa L1XHHiLiigjJJlehTCiDF51ptjTXYtPEaMlwEv1//KHKdrLmaGTBvZE0kCeS1H0XZ8dGNmlXPs8eJ GA1QbSKA==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUs-0001Qm-OP; Fri, 01 Feb 2019 08:48:27 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 09/18] meth: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:52 +0100 Message-Id: <20190201084801.10983-10-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Also use GFP_KERNEL instead of GFP_ATOMIC as the gfp_t for the memory allocation, as we aren't in interrupt context or under a lock. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/sgi/meth.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/drivers/net/ethernet/sgi/meth.c b/drivers/net/ethernet/sgi/meth.c index 0e1b7e960b98..67954a9e3675 100644 --- a/drivers/net/ethernet/sgi/meth.c +++ b/drivers/net/ethernet/sgi/meth.c @@ -68,6 +68,8 @@ module_param(timeout, int, 0); * packets in and out, so there is place for a packet */ struct meth_private { + struct platform_device *pdev; + /* in-memory copy of MAC Control register */ u64 mac_ctrl; @@ -211,8 +213,8 @@ static void meth_check_link(struct net_device *dev) static int meth_init_tx_ring(struct meth_private *priv) { /* Init TX ring */ - priv->tx_ring = dma_alloc_coherent(NULL, TX_RING_BUFFER_SIZE, - &priv->tx_ring_dma, GFP_ATOMIC); + priv->tx_ring = dma_alloc_coherent(&priv->pdev->dev, + TX_RING_BUFFER_SIZE, &priv->tx_ring_dma, GFP_KERNEL); if (!priv->tx_ring) return -ENOMEM; @@ -236,7 +238,7 @@ static int meth_init_rx_ring(struct meth_private *priv) priv->rx_ring[i]=(rx_packet*)(priv->rx_skbs[i]->head); /* I'll need to re-sync it after each RX */ priv->rx_ring_dmas[i] = - dma_map_single(NULL, priv->rx_ring[i], + dma_map_single(&priv->pdev->dev, priv->rx_ring[i], METH_RX_BUFF_SIZE, DMA_FROM_DEVICE); mace->eth.rx_fifo = priv->rx_ring_dmas[i]; } @@ -253,7 +255,7 @@ static void meth_free_tx_ring(struct meth_private *priv) dev_kfree_skb(priv->tx_skbs[i]); priv->tx_skbs[i] = NULL; } - dma_free_coherent(NULL, TX_RING_BUFFER_SIZE, priv->tx_ring, + dma_free_coherent(&priv->pdev->dev, TX_RING_BUFFER_SIZE, priv->tx_ring, priv->tx_ring_dma); } @@ -263,7 +265,7 @@ static void meth_free_rx_ring(struct meth_private *priv) int i; for (i = 0; i < RX_RING_ENTRIES; i++) { - dma_unmap_single(NULL, priv->rx_ring_dmas[i], + dma_unmap_single(&priv->pdev->dev, priv->rx_ring_dmas[i], METH_RX_BUFF_SIZE, DMA_FROM_DEVICE); priv->rx_ring[i] = 0; priv->rx_ring_dmas[i] = 0; @@ -393,7 +395,8 @@ static void meth_rx(struct net_device* dev, unsigned long int_status) fifo_rptr = (fifo_rptr - 1) & 0x0f; } while (priv->rx_write != fifo_rptr) { - dma_unmap_single(NULL, priv->rx_ring_dmas[priv->rx_write], + dma_unmap_single(&priv->pdev->dev, + priv->rx_ring_dmas[priv->rx_write], METH_RX_BUFF_SIZE, DMA_FROM_DEVICE); status = priv->rx_ring[priv->rx_write]->status.raw; #if MFE_DEBUG @@ -454,7 +457,8 @@ static void meth_rx(struct net_device* dev, unsigned long int_status) priv->rx_ring[priv->rx_write] = (rx_packet*)skb->head; priv->rx_ring[priv->rx_write]->status.raw = 0; priv->rx_ring_dmas[priv->rx_write] = - dma_map_single(NULL, priv->rx_ring[priv->rx_write], + dma_map_single(&priv->pdev->dev, + priv->rx_ring[priv->rx_write], METH_RX_BUFF_SIZE, DMA_FROM_DEVICE); mace->eth.rx_fifo = priv->rx_ring_dmas[priv->rx_write]; ADVANCE_RX_PTR(priv->rx_write); @@ -637,7 +641,7 @@ static void meth_tx_1page_prepare(struct meth_private *priv, } /* first page */ - catbuf = dma_map_single(NULL, buffer_data, buffer_len, + catbuf = dma_map_single(&priv->pdev->dev, buffer_data, buffer_len, DMA_TO_DEVICE); desc->data.cat_buf[0].form.start_addr = catbuf >> 3; desc->data.cat_buf[0].form.len = buffer_len - 1; @@ -663,12 +667,12 @@ static void meth_tx_2page_prepare(struct meth_private *priv, } /* first page */ - catbuf1 = dma_map_single(NULL, buffer1_data, buffer1_len, + catbuf1 = dma_map_single(&priv->pdev->dev, buffer1_data, buffer1_len, DMA_TO_DEVICE); desc->data.cat_buf[0].form.start_addr = catbuf1 >> 3; desc->data.cat_buf[0].form.len = buffer1_len - 1; /* second page */ - catbuf2 = dma_map_single(NULL, buffer2_data, buffer2_len, + catbuf2 = dma_map_single(&priv->pdev->dev, buffer2_data, buffer2_len, DMA_TO_DEVICE); desc->data.cat_buf[1].form.start_addr = catbuf2 >> 3; desc->data.cat_buf[1].form.len = buffer2_len - 1; @@ -840,6 +844,7 @@ static int meth_probe(struct platform_device *pdev) memcpy(dev->dev_addr, o2meth_eaddr, ETH_ALEN); priv = netdev_priv(dev); + priv->pdev = pdev; spin_lock_init(&priv->meth_lock); SET_NETDEV_DEV(dev, &pdev->dev); From patchwork Fri Feb 1 08:47:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9CA9E17E9 for ; Fri, 1 Feb 2019 08:50:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9010A31B87 for ; Fri, 1 Feb 2019 08:50:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8385E31C75; Fri, 1 Feb 2019 08:50:05 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 B0AFC31B8B for ; Fri, 1 Feb 2019 08:50:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729606AbfBAIsd (ORCPT ); Fri, 1 Feb 2019 03:48:33 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48446 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729597AbfBAIsd (ORCPT ); Fri, 1 Feb 2019 03:48:33 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=jvXh2nGWWDi+i97GyziQAoz/cRdsHOCxPPGJzQv4Lzs=; b=kPHcfP0xs6RjXXDCs6UAZv01hT fs4kz/psbq6xjiMLPEmNEiprZdYKLWI19K1N/XLD5pkb6yD5mp7kjpZkr1KNj+lpZ+ZghM8kfVc3V kGg77BqmYfbSgMYzMAIcNy991S+Z/Lq0VVMRfqP8z7WwPXYZlcZk6Mn8Qj+MTsjRHx0IGoQ8zLGCP 9nl189pv9ng2b5oSxj7i2ldJZLTXzyrm9qSnheSDWWjUHxOjbsdWVMn/AdN8S7u0g8WOTdA0AE1/q 34R5JbVilnFazJiI/iRgSOzmQlnPS38gz1Ehbivx4pxPkuqMtSwO1Q0RpTnYMZ7ky4vwgwozRP1ez Az2+f4nA==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUv-0001Rh-AG; Fri, 01 Feb 2019 08:48:29 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 10/18] smc911x: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:53 +0100 Message-Id: <20190201084801.10983-11-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig --- drivers/net/ethernet/smsc/smc911x.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/smsc/smc911x.c b/drivers/net/ethernet/smsc/smc911x.c index 8355dfbb8ec3..b550e624500d 100644 --- a/drivers/net/ethernet/smsc/smc911x.c +++ b/drivers/net/ethernet/smsc/smc911x.c @@ -1188,7 +1188,7 @@ smc911x_tx_dma_irq(void *data) DBG(SMC_DEBUG_TX | SMC_DEBUG_DMA, dev, "TX DMA irq handler\n"); BUG_ON(skb == NULL); - dma_unmap_single(NULL, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE); + dma_unmap_single(lp->dev, tx_dmabuf, tx_dmalen, DMA_TO_DEVICE); netif_trans_update(dev); dev_kfree_skb_irq(skb); lp->current_tx_skb = NULL; @@ -1219,7 +1219,7 @@ smc911x_rx_dma_irq(void *data) DBG(SMC_DEBUG_FUNC, dev, "--> %s\n", __func__); DBG(SMC_DEBUG_RX | SMC_DEBUG_DMA, dev, "RX DMA irq handler\n"); - dma_unmap_single(NULL, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE); + dma_unmap_single(lp->dev, rx_dmabuf, rx_dmalen, DMA_FROM_DEVICE); BUG_ON(skb == NULL); lp->current_rx_skb = NULL; PRINT_PKT(skb->data, skb->len); From patchwork Fri Feb 1 08:47:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792121 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F1416186E for ; Fri, 1 Feb 2019 08:48:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E2A6431AD6 for ; Fri, 1 Feb 2019 08:48:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D62D931B8B; Fri, 1 Feb 2019 08:48:39 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 6FF2E31B87 for ; Fri, 1 Feb 2019 08:48:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729666AbfBAIsi (ORCPT ); Fri, 1 Feb 2019 03:48:38 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48470 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729634AbfBAIsf (ORCPT ); Fri, 1 Feb 2019 03:48:35 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=pU0HGVd2mqMY96Sg+NjMcR2p0eV/+Kyy5J3jOlZeRfA=; b=DVnztnYQZKzoT+JeFlNalarZXc DKYysDp7mfma5POpYC66khqOTC3hwKqlH0UkhiF052GFkvIRXiHNM2wrhaUNP2F5l6juTEr+T7hrT hS//HLgdatiRar2k9vIXFDmlysobYx0LAk9qyxYNxKtZ1sg7/XYWyGUivFAgfk3GVts5fHyHwqwnf O82txf8uvAHAjz8jDyJDxiMjAMx0wL6clUmFBUlkWAJambBIMlVC1RSI2KD3j0nD05W3N1/FnPBWy G40VoJ1mRzh0wM5Ggb6UKzr6k+9LoXDeN8xpkDLqMry8GFJAilOiwyXJKCe6e0NFX8iNe8zcmafo/ 6ZOcrW1w==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUUx-0001S8-UW; Fri, 01 Feb 2019 08:48:32 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 11/18] parport_ip32: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:54 +0100 Message-Id: <20190201084801.10983-12-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig --- drivers/parport/parport_ip32.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/drivers/parport/parport_ip32.c b/drivers/parport/parport_ip32.c index 62873070f988..b7a892791c3e 100644 --- a/drivers/parport/parport_ip32.c +++ b/drivers/parport/parport_ip32.c @@ -568,6 +568,7 @@ static irqreturn_t parport_ip32_merr_interrupt(int irq, void *dev_id) /** * parport_ip32_dma_start - begins a DMA transfer + * @p: partport to work on * @dir: DMA direction: DMA_TO_DEVICE or DMA_FROM_DEVICE * @addr: pointer to data buffer * @count: buffer size @@ -575,8 +576,8 @@ static irqreturn_t parport_ip32_merr_interrupt(int irq, void *dev_id) * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be * correctly balanced. */ -static int parport_ip32_dma_start(enum dma_data_direction dir, - void *addr, size_t count) +static int parport_ip32_dma_start(struct parport *p, + enum dma_data_direction dir, void *addr, size_t count) { unsigned int limit; u64 ctrl; @@ -601,7 +602,7 @@ static int parport_ip32_dma_start(enum dma_data_direction dir, /* Prepare DMA pointers */ parport_ip32_dma.dir = dir; - parport_ip32_dma.buf = dma_map_single(NULL, addr, count, dir); + parport_ip32_dma.buf = dma_map_single(&p->bus_dev, addr, count, dir); parport_ip32_dma.len = count; parport_ip32_dma.next = parport_ip32_dma.buf; parport_ip32_dma.left = parport_ip32_dma.len; @@ -625,11 +626,12 @@ static int parport_ip32_dma_start(enum dma_data_direction dir, /** * parport_ip32_dma_stop - ends a running DMA transfer + * @p: partport to work on * * Calls to parport_ip32_dma_start() and parport_ip32_dma_stop() must be * correctly balanced. */ -static void parport_ip32_dma_stop(void) +static void parport_ip32_dma_stop(struct parport *p) { u64 ctx_a; u64 ctx_b; @@ -685,8 +687,8 @@ static void parport_ip32_dma_stop(void) enable_irq(MACEISA_PAR_CTXB_IRQ); parport_ip32_dma.irq_on = 1; - dma_unmap_single(NULL, parport_ip32_dma.buf, parport_ip32_dma.len, - parport_ip32_dma.dir); + dma_unmap_single(&p->bus_dev, parport_ip32_dma.buf, + parport_ip32_dma.len, parport_ip32_dma.dir); } /** @@ -1445,7 +1447,7 @@ static size_t parport_ip32_fifo_write_block_dma(struct parport *p, priv->irq_mode = PARPORT_IP32_IRQ_HERE; - parport_ip32_dma_start(DMA_TO_DEVICE, (void *)buf, len); + parport_ip32_dma_start(p, DMA_TO_DEVICE, (void *)buf, len); reinit_completion(&priv->irq_complete); parport_ip32_frob_econtrol(p, ECR_DMAEN | ECR_SERVINTR, ECR_DMAEN); @@ -1461,7 +1463,7 @@ static size_t parport_ip32_fifo_write_block_dma(struct parport *p, if (ecr & ECR_SERVINTR) break; /* DMA transfer just finished */ } - parport_ip32_dma_stop(); + parport_ip32_dma_stop(p); written = len - parport_ip32_dma_get_residue(); priv->irq_mode = PARPORT_IP32_IRQ_FWD; From patchwork Fri Feb 1 08:47:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792203 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7BFFA1874 for ; Fri, 1 Feb 2019 08:49:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6C71931B50 for ; Fri, 1 Feb 2019 08:49:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6108231B8B; Fri, 1 Feb 2019 08:49:59 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 129B031B87 for ; Fri, 1 Feb 2019 08:49:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729653AbfBAIsi (ORCPT ); Fri, 1 Feb 2019 03:48:38 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48488 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729597AbfBAIsi (ORCPT ); Fri, 1 Feb 2019 03:48:38 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ryF7wEYM+8TnYcdpcL53ItqAkETjJcf7kzT/imJeFkI=; b=pKNpt8ch3VuAp/lHtycoPyxJtu Z76Am5nGRDzsghgCY8qRnw/8FlWusijSVpRzgz8SsWfG4t0HNxftHi5jmIUfoYWaYgKhvGvGvgta5 CfTaDW/UGcdVqryCW2k81UZzHdNt/t6owf5kCDBe7ov2Ud6QSQ3imBRY/r8iPNw5bGkzW7lxLXiyN 2B/C70ZeNkV2GmApvZG2TgWl5kLFadNKz84zxy90MQ186LnxdLEl65DzXJkZu3U2gaezeoV1Vr5hr aYZyMeWg0We0NLbTPje+6wFhleGUPKxWi5Fb2qt7xYdyT0hw0LgObmmH9Cxd/MgjdmFMQMaWU9ZMS 3+5treHw==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUV0-0001Sc-GO; Fri, 01 Feb 2019 08:48:34 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 12/18] fotg210-udc: remove a bogus dma_sync_single_for_device call Date: Fri, 1 Feb 2019 09:47:55 +0100 Message-Id: <20190201084801.10983-13-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP dma_map_single already transfers ownership to the device. Signed-off-by: Christoph Hellwig Acked-by: Felipe Balbi --- drivers/usb/gadget/udc/fotg210-udc.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index bc6abaea907d..fe9cf415f2f1 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -356,10 +356,6 @@ static void fotg210_start_dma(struct fotg210_ep *ep, return; } - dma_sync_single_for_device(NULL, d, length, - ep->dir_in ? DMA_TO_DEVICE : - DMA_FROM_DEVICE); - fotg210_enable_dma(ep, d, length); /* check if dma is done */ From patchwork Fri Feb 1 08:47:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792187 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A969B17E9 for ; Fri, 1 Feb 2019 08:49:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 981CE31223 for ; Fri, 1 Feb 2019 08:49:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8C43431B87; Fri, 1 Feb 2019 08:49:42 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 3F30331B50 for ; Fri, 1 Feb 2019 08:49:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726339AbfBAItc (ORCPT ); Fri, 1 Feb 2019 03:49:32 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48512 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729682AbfBAIsk (ORCPT ); Fri, 1 Feb 2019 03:48:40 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EDCotptuNgPwBtYaw+R0wEyOKfRmfUUw71HtLikhNLA=; b=Dv3neyaRGIu+SiwE9QyF7BMirl TtVPfoQaeoohV30jRW4quZEBxwq41HRwagK8Rlw36NvKcsk8ickC5rAj8X1k2C8ZWbk6nxIRRLSen nzN74fwBrPKdtHLfeLR3sVJmaanh9E/SlWAewWQf7/ozNF+Rla6nKQTt4zOcf9zuIHCeOsSxJLh+6 OSxA7h53T37EaJEfCDBtfnC2pkWtLC/FaYJ+ywUIgsNBCt3f2CovwppI0WzO+h8ejL8LIZBpKuj1k RnumHHkGa6qc0bLGZVMFTy0NaO0rQRTbv+IO0c3Tykd9DlCJ01GJJuqJVe2GUp6oj1wARcKrKoW1E VqfY6XhQ==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUV3-0001TO-0W; Fri, 01 Feb 2019 08:48:37 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 13/18] fotg210-udc: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:56 +0100 Message-Id: <20190201084801.10983-14-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig Acked-by: Felipe Balbi --- drivers/usb/gadget/udc/fotg210-udc.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index fe9cf415f2f1..cec49294bac6 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -326,6 +326,7 @@ static void fotg210_wait_dma_done(struct fotg210_ep *ep) static void fotg210_start_dma(struct fotg210_ep *ep, struct fotg210_request *req) { + struct device *dev = &ep->fotg210->gadget.dev; dma_addr_t d; u8 *buffer; u32 length; @@ -348,10 +349,10 @@ static void fotg210_start_dma(struct fotg210_ep *ep, length = req->req.length; } - d = dma_map_single(NULL, buffer, length, + d = dma_map_single(dev, buffer, length, ep->dir_in ? DMA_TO_DEVICE : DMA_FROM_DEVICE); - if (dma_mapping_error(NULL, d)) { + if (dma_mapping_error(dev, d)) { pr_err("dma_mapping_error\n"); return; } @@ -366,7 +367,7 @@ static void fotg210_start_dma(struct fotg210_ep *ep, /* update actual transfer length */ req->req.actual += length; - dma_unmap_single(NULL, d, length, DMA_TO_DEVICE); + dma_unmap_single(dev, d, length, DMA_TO_DEVICE); } static void fotg210_ep0_queue(struct fotg210_ep *ep, From patchwork Fri Feb 1 08:47:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792173 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id BCB1A188D for ; Fri, 1 Feb 2019 08:49:29 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AD59031B87 for ; Fri, 1 Feb 2019 08:49:29 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A167931B8B; Fri, 1 Feb 2019 08:49:29 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 41E8531B87 for ; Fri, 1 Feb 2019 08:49:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729714AbfBAIsn (ORCPT ); Fri, 1 Feb 2019 03:48:43 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48530 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729634AbfBAIsn (ORCPT ); Fri, 1 Feb 2019 03:48:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=s9q5FJ99lWpVCtL740s0cfRjj+9qxL33pzPFuAa0dhI=; b=TVx7AHJnZp4D4jDgaeH2wts1lf hWXJLVSGVMRIBFNF8T5bpx5xFkhVyaOona7K1kE99gv0ONochH/zxmiV92aFNp3SCXGGW/zNZTiUV g3RHlxoxURDuNPDY9GoSQISMtJz4RVw5Yz8PadhkAL4T4aK85MlCpmRbWpRgkovB9UfNVhRe63r9w 8Vd3bKWGyGRBk3T5WOnoZrvpeHgfMBF1XVeEerthTM/iSRhSwZg/d4z2sFKmTz9WNwfd4Y8/XjsiT qw3XPx0S7rBs4aozfzt6BsKH5BrPbVNi7Siw5ostFr6GkQWx0a8TbgipNtgGouliqFXH+NAANmAP1 26xQ25vg==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUV5-0001Ts-I0; Fri, 01 Feb 2019 08:48:39 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 14/18] da8xx-fb: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:47:57 +0100 Message-Id: <20190201084801.10983-15-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig --- drivers/video/fbdev/da8xx-fb.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/drivers/video/fbdev/da8xx-fb.c b/drivers/video/fbdev/da8xx-fb.c index 43f2a4816860..ec62274b914b 100644 --- a/drivers/video/fbdev/da8xx-fb.c +++ b/drivers/video/fbdev/da8xx-fb.c @@ -1097,9 +1097,9 @@ static int fb_remove(struct platform_device *dev) unregister_framebuffer(info); fb_dealloc_cmap(&info->cmap); - dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base, + dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base, par->p_palette_base); - dma_free_coherent(NULL, par->vram_size, par->vram_virt, + dma_free_coherent(par->dev, par->vram_size, par->vram_virt, par->vram_phys); pm_runtime_put_sync(&dev->dev); pm_runtime_disable(&dev->dev); @@ -1425,7 +1425,7 @@ static int fb_probe(struct platform_device *device) par->vram_size = roundup(par->vram_size/8, ulcm); par->vram_size = par->vram_size * LCD_NUM_BUFFERS; - par->vram_virt = dma_alloc_coherent(NULL, + par->vram_virt = dma_alloc_coherent(par->dev, par->vram_size, &par->vram_phys, GFP_KERNEL | GFP_DMA); @@ -1446,7 +1446,7 @@ static int fb_probe(struct platform_device *device) da8xx_fb_fix.line_length - 1; /* allocate palette buffer */ - par->v_palette_base = dma_alloc_coherent(NULL, PALETTE_SIZE, + par->v_palette_base = dma_alloc_coherent(par->dev, PALETTE_SIZE, &par->p_palette_base, GFP_KERNEL | GFP_DMA); if (!par->v_palette_base) { @@ -1532,11 +1532,12 @@ static int fb_probe(struct platform_device *device) fb_dealloc_cmap(&da8xx_fb_info->cmap); err_release_pl_mem: - dma_free_coherent(NULL, PALETTE_SIZE, par->v_palette_base, + dma_free_coherent(par->dev, PALETTE_SIZE, par->v_palette_base, par->p_palette_base); err_release_fb_mem: - dma_free_coherent(NULL, par->vram_size, par->vram_virt, par->vram_phys); + dma_free_coherent(par->dev, par->vram_size, par->vram_virt, + par->vram_phys); err_release_fb: framebuffer_release(da8xx_fb_info); From patchwork Fri Feb 1 08:47:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792159 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C10D61874 for ; Fri, 1 Feb 2019 08:49:23 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B42B631B87 for ; Fri, 1 Feb 2019 08:49:23 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A879231B8B; Fri, 1 Feb 2019 08:49:23 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=unavailable 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 3299D31B87 for ; Fri, 1 Feb 2019 08:49:23 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729744AbfBAIsq (ORCPT ); Fri, 1 Feb 2019 03:48:46 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48578 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729740AbfBAIsq (ORCPT ); Fri, 1 Feb 2019 03:48:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=A5xmKzo+3eYNNUc1oQhJ9CTFYQ7IubCceXEDOPqtJa8=; b=SCVAPK/70GWKGvXGUzNSO0RGpL nqVNNf2noGf73vN7wvGgXVzKHyfAkfnFXjwzwWvTyDcf7cW8pBG/nyUfyC/zRy6GHRhsIYzZ+Ozw2 tHR0WEAPwOg8XuazPbfiQutJavXblb/M9PeqDJn01C5rmXfRvX5hDnHNzXXoIPhskpxsW54ThP0WQ 1QYXoUFCMhc4wB2WNtK+eRpkP8jIhSE2WIL+IMnhIdsCUe83wbGPWyL3UokRzd4SWXQC3BjQJEfFY xELDTHfdJO2zAqMIkXPUmmMowEF0/YGyQNuoRWNICZcTfaW1giAtmJTW+Ey67eODAUkyRgzNu+s4V yV6fnH5A==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUV8-0001UX-2p; Fri, 01 Feb 2019 08:48:42 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 15/18] gbefb: switch to managed version of the DMA allocator Date: Fri, 1 Feb 2019 09:47:58 +0100 Message-Id: <20190201084801.10983-16-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP gbefb uses managed resources, so it should do the same for DMA allocations. Signed-off-by: Christoph Hellwig --- drivers/video/fbdev/gbefb.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/drivers/video/fbdev/gbefb.c b/drivers/video/fbdev/gbefb.c index 1a242b1338e9..3fcb33232ba3 100644 --- a/drivers/video/fbdev/gbefb.c +++ b/drivers/video/fbdev/gbefb.c @@ -1162,9 +1162,9 @@ static int gbefb_probe(struct platform_device *p_dev) } gbe_revision = gbe->ctrlstat & 15; - gbe_tiles.cpu = - dma_alloc_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t), - &gbe_tiles.dma, GFP_KERNEL); + gbe_tiles.cpu = dmam_alloc_coherent(&p_dev->dev, + GBE_TLB_SIZE * sizeof(uint16_t), + &gbe_tiles.dma, GFP_KERNEL); if (!gbe_tiles.cpu) { printk(KERN_ERR "gbefb: couldn't allocate tiles table\n"); ret = -ENOMEM; @@ -1178,19 +1178,20 @@ static int gbefb_probe(struct platform_device *p_dev) if (!gbe_mem) { printk(KERN_ERR "gbefb: couldn't map framebuffer\n"); ret = -ENOMEM; - goto out_tiles_free; + goto out_release_mem_region; } gbe_dma_addr = 0; } else { /* try to allocate memory with the classical allocator * this has high chance to fail on low memory machines */ - gbe_mem = dma_alloc_wc(NULL, gbe_mem_size, &gbe_dma_addr, - GFP_KERNEL); + gbe_mem = dmam_alloc_attrs(&p_dev->dev, gbe_mem_size, + &gbe_dma_addr, GFP_KERNEL, + DMA_ATTR_WRITE_COMBINE); if (!gbe_mem) { printk(KERN_ERR "gbefb: couldn't allocate framebuffer memory\n"); ret = -ENOMEM; - goto out_tiles_free; + goto out_release_mem_region; } gbe_mem_phys = (unsigned long) gbe_dma_addr; @@ -1237,11 +1238,6 @@ static int gbefb_probe(struct platform_device *p_dev) out_gbe_unmap: arch_phys_wc_del(par->wc_cookie); - if (gbe_dma_addr) - dma_free_wc(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys); -out_tiles_free: - dma_free_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t), - (void *)gbe_tiles.cpu, gbe_tiles.dma); out_release_mem_region: release_mem_region(GBE_BASE, sizeof(struct sgi_gbe)); out_release_framebuffer: @@ -1258,10 +1254,6 @@ static int gbefb_remove(struct platform_device* p_dev) unregister_framebuffer(info); gbe_turn_off(); arch_phys_wc_del(par->wc_cookie); - if (gbe_dma_addr) - dma_free_wc(NULL, gbe_mem_size, gbe_mem, gbe_mem_phys); - dma_free_coherent(NULL, GBE_TLB_SIZE * sizeof(uint16_t), - (void *)gbe_tiles.cpu, gbe_tiles.dma); release_mem_region(GBE_BASE, sizeof(struct sgi_gbe)); gbefb_remove_sysfs(&p_dev->dev); framebuffer_release(info); From patchwork Fri Feb 1 08:47:59 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792149 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19CC2746 for ; Fri, 1 Feb 2019 08:49:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0B7DF31223 for ; Fri, 1 Feb 2019 08:49:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F1D4C315B8; Fri, 1 Feb 2019 08:49:15 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 9D98A31223 for ; Fri, 1 Feb 2019 08:49:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729782AbfBAIss (ORCPT ); Fri, 1 Feb 2019 03:48:48 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48596 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729773AbfBAIsr (ORCPT ); Fri, 1 Feb 2019 03:48:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=it7hgDmLzWc1k/Yz2n7HKXPwU9eNC/NoGZJD3EXx09o=; b=I/04jqniu/vhIQMDD+8JWURNDw QlxyZD+viw/vFPhVRvjZ379SnTKnbe9vSFvvQp04872xAVvrLXXQMX4FWVNM2xo6c0HQn8LfLTeNF xZayuaNfqA5CgPy9RW/wmCo8scUvrucocBrt1DrwQD0rcLFRK7a3JWw2SIrExF1uhBGfuhTWwZM93 K3XMWpe7iTBeRaIvz4PZCEBRNTUDQRMPaEqEKkVZA9W0PTgWgwxo/jzQ0AxGcQFlbUtL5QslqyAG2 bpa8SW4zP6Jf3BbzUsR/EqZf4eoxS8HI6sBudOEX8lRWpAs6pM7BscZCnO5sHRfDv/0mL+lsUCLMm gjsxH36A==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUVA-0001Vl-SH; Fri, 01 Feb 2019 08:48:45 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 16/18] pxa3xx-gcu: pass struct device to dma_mmap_coherent Date: Fri, 1 Feb 2019 09:47:59 +0100 Message-Id: <20190201084801.10983-17-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Just like we do for all other DMA operations. Signed-off-by: Christoph Hellwig --- drivers/video/fbdev/pxa3xx-gcu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/video/fbdev/pxa3xx-gcu.c b/drivers/video/fbdev/pxa3xx-gcu.c index 69cfb337c857..047a2fa4b87e 100644 --- a/drivers/video/fbdev/pxa3xx-gcu.c +++ b/drivers/video/fbdev/pxa3xx-gcu.c @@ -96,6 +96,7 @@ struct pxa3xx_gcu_batch { }; struct pxa3xx_gcu_priv { + struct device *dev; void __iomem *mmio_base; struct clk *clk; struct pxa3xx_gcu_shared *shared; @@ -493,7 +494,7 @@ pxa3xx_gcu_mmap(struct file *file, struct vm_area_struct *vma) if (size != SHARED_SIZE) return -EINVAL; - return dma_mmap_coherent(NULL, vma, + return dma_mmap_coherent(priv->dev, vma, priv->shared, priv->shared_phys, size); case SHARED_SIZE >> PAGE_SHIFT: @@ -670,6 +671,7 @@ static int pxa3xx_gcu_probe(struct platform_device *pdev) platform_set_drvdata(pdev, priv); priv->resource_mem = r; + priv->dev = dev; pxa3xx_gcu_reset(priv); pxa3xx_gcu_init_debug_timer(priv); From patchwork Fri Feb 1 08:48:00 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792141 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B1DBD13BF for ; Fri, 1 Feb 2019 08:49:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FF2831223 for ; Fri, 1 Feb 2019 08:49:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 938B8315B8; Fri, 1 Feb 2019 08:49:13 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 1582D31223 for ; Fri, 1 Feb 2019 08:49:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729284AbfBAItE (ORCPT ); Fri, 1 Feb 2019 03:49:04 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48620 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727450AbfBAIsu (ORCPT ); Fri, 1 Feb 2019 03:48:50 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=sDvNmJs8bLWN8SRNm+1jJVi3Azpnxg3FQ88vYOYjmqM=; b=rYp9fq00R2A5NFcaGo1WysE2b5 z1oTMVXVCSJAWD1vXGa/IpeZ0g8OYNw/huozJPW+ERT1fx12038hUUyrUkVWuap733AD8BHQuq54k 4odzkyshU4mcUJApZ/gFx85PvcmgLlAgG/vUCkqrh7EXL2c/vLcJ8f06QEXQpiiH93iRqPcgLu1qZ ERD/AAgqxENUCwVckMEKB1dWETayLfEgcEWtobHTN9MzcYO1hMt362gJgdJqmI1Gv6MgchY6rq31p oT56KGKMg+4XeY0gJdWaJmXFbjZUahXES5QdUL7s0PYcQa0ey7S2UliwVREZWs/1vjuV0TFMEkmnN E/WuDwaw==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUVD-0001Wd-DA; Fri, 01 Feb 2019 08:48:47 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 17/18] ALSA: hal2: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:48:00 +0100 Message-Id: <20190201084801.10983-18-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Signed-off-by: Christoph Hellwig --- sound/mips/hal2.c | 31 +++++++++++++++++-------------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/sound/mips/hal2.c b/sound/mips/hal2.c index a4ed54aeaf1d..d63e1565b62b 100644 --- a/sound/mips/hal2.c +++ b/sound/mips/hal2.c @@ -454,21 +454,22 @@ static inline void hal2_stop_adc(struct snd_hal2 *hal2) hal2->adc.pbus.pbus->pbdma_ctrl = HPC3_PDMACTRL_LD; } -static int hal2_alloc_dmabuf(struct hal2_codec *codec) +static int hal2_alloc_dmabuf(struct snd_hal2 *hal2, struct hal2_codec *codec) { + struct device *dev = hal2->card->dev; struct hal2_desc *desc; dma_addr_t desc_dma, buffer_dma; int count = H2_BUF_SIZE / H2_BLOCK_SIZE; int i; - codec->buffer = dma_alloc_attrs(NULL, H2_BUF_SIZE, &buffer_dma, + codec->buffer = dma_alloc_attrs(dev, H2_BUF_SIZE, &buffer_dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT); if (!codec->buffer) return -ENOMEM; - desc = dma_alloc_attrs(NULL, count * sizeof(struct hal2_desc), + desc = dma_alloc_attrs(dev, count * sizeof(struct hal2_desc), &desc_dma, GFP_KERNEL, DMA_ATTR_NON_CONSISTENT); if (!desc) { - dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, buffer_dma, + dma_free_attrs(dev, H2_BUF_SIZE, codec->buffer, buffer_dma, DMA_ATTR_NON_CONSISTENT); return -ENOMEM; } @@ -482,17 +483,19 @@ static int hal2_alloc_dmabuf(struct hal2_codec *codec) desc_dma : desc_dma + (i + 1) * sizeof(struct hal2_desc); desc++; } - dma_cache_sync(NULL, codec->desc, count * sizeof(struct hal2_desc), + dma_cache_sync(dev, codec->desc, count * sizeof(struct hal2_desc), DMA_TO_DEVICE); codec->desc_count = count; return 0; } -static void hal2_free_dmabuf(struct hal2_codec *codec) +static void hal2_free_dmabuf(struct snd_hal2 *hal2, struct hal2_codec *codec) { - dma_free_attrs(NULL, codec->desc_count * sizeof(struct hal2_desc), + struct device *dev = hal2->card->dev; + + dma_free_attrs(dev, codec->desc_count * sizeof(struct hal2_desc), codec->desc, codec->desc_dma, DMA_ATTR_NON_CONSISTENT); - dma_free_attrs(NULL, H2_BUF_SIZE, codec->buffer, codec->buffer_dma, + dma_free_attrs(dev, H2_BUF_SIZE, codec->buffer, codec->buffer_dma, DMA_ATTR_NON_CONSISTENT); } @@ -540,7 +543,7 @@ static int hal2_playback_open(struct snd_pcm_substream *substream) runtime->hw = hal2_pcm_hw; - err = hal2_alloc_dmabuf(&hal2->dac); + err = hal2_alloc_dmabuf(hal2, &hal2->dac); if (err) return err; return 0; @@ -550,7 +553,7 @@ static int hal2_playback_close(struct snd_pcm_substream *substream) { struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); - hal2_free_dmabuf(&hal2->dac); + hal2_free_dmabuf(hal2, &hal2->dac); return 0; } @@ -606,7 +609,7 @@ static void hal2_playback_transfer(struct snd_pcm_substream *substream, unsigned char *buf = hal2->dac.buffer + rec->hw_data; memcpy(buf, substream->runtime->dma_area + rec->sw_data, bytes); - dma_cache_sync(NULL, buf, bytes, DMA_TO_DEVICE); + dma_cache_sync(hal2->card->dev, buf, bytes, DMA_TO_DEVICE); } @@ -629,7 +632,7 @@ static int hal2_capture_open(struct snd_pcm_substream *substream) runtime->hw = hal2_pcm_hw; - err = hal2_alloc_dmabuf(adc); + err = hal2_alloc_dmabuf(hal2, adc); if (err) return err; return 0; @@ -639,7 +642,7 @@ static int hal2_capture_close(struct snd_pcm_substream *substream) { struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); - hal2_free_dmabuf(&hal2->adc); + hal2_free_dmabuf(hal2, &hal2->adc); return 0; } @@ -694,7 +697,7 @@ static void hal2_capture_transfer(struct snd_pcm_substream *substream, struct snd_hal2 *hal2 = snd_pcm_substream_chip(substream); unsigned char *buf = hal2->adc.buffer + rec->hw_data; - dma_cache_sync(NULL, buf, bytes, DMA_FROM_DEVICE); + dma_cache_sync(hal2->card->dev, buf, bytes, DMA_FROM_DEVICE); memcpy(substream->runtime->dma_area + rec->sw_data, buf, bytes); } From patchwork Fri Feb 1 08:48:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10792129 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B736746 for ; Fri, 1 Feb 2019 08:48:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 17D96311C9 for ; Fri, 1 Feb 2019 08:48:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02E6D2BCC7; Fri, 1 Feb 2019 08:48:55 +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.7 required=2.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,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 742D43154F for ; Fri, 1 Feb 2019 08:48:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729773AbfBAIsx (ORCPT ); Fri, 1 Feb 2019 03:48:53 -0500 Received: from bombadil.infradead.org ([198.137.202.133]:48640 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729284AbfBAIsx (ORCPT ); Fri, 1 Feb 2019 03:48:53 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-Id:Date:Subject:Cc:To:From:Sender :Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From :Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id:List-Help: List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ofvy4DRKRwc1p2ccQlAyvHR+GYcYUgIMlkL4GALDEIQ=; b=K5Dp0HKkDpQQOoGsgqpd9hQw+W 1cI2Wt5fC71ayCrmx6kBB8zKXuHn0jZ/85yb6b6Czia33X7bUa0Nx+vAP6k6Z6hAzSB16fxeLh0mg i49iM5GoqYTTmqR3pSJbLLsDofyY18N9erRCzVWpU/4rT/jgwrUgbu++7P1XSGpw6UcEBqJyqURSi y0CmJ7H4ZGiiXyRLLZtK79VInnWw6BTlKPO2z5kCrPQkFnJ2qiX2SutshUBubwY7rHYhowTMRtI33 HXQ50m3pId7P4/vnJzMH9FkjyjjmfolqglbxmlY3MbWKUkHKWZhMOU1NXmafmOyoMSKsn11BKNmOf oscjPN3A==; Received: from 089144212163.atnat0021.highway.a1.net ([89.144.212.163] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1gpUVG-0001XC-4S; Fri, 01 Feb 2019 08:48:50 +0000 From: Christoph Hellwig To: John Crispin , Vinod Koul , Dmitry Tarnyagin , Nicolas Ferre , Sudip Mukherjee , Felipe Balbi , linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org, netdev@vger.kernel.org, linux-usb@vger.kernel.org, linux-fbdev@vger.kernel.org, alsa-devel@alsa-project.org Cc: iommu@lists.linux-foundation.org Subject: [PATCH 18/18] ALSA: pass struct device to DMA API functions Date: Fri, 1 Feb 2019 09:48:01 +0100 Message-Id: <20190201084801.10983-19-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190201084801.10983-1-hch@lst.de> References: <20190201084801.10983-1-hch@lst.de> MIME-Version: 1.0 X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-mips-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mips@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The DMA API generally relies on a struct device to work properly, and only barely works without one for legacy reasons. Pass the easily available struct device from the platform_device to remedy this. Also use GFP_KERNEL instead of GFP_USER as the gfp_t for the memory allocation, as we should treat this allocation as a normal kernel one. Signed-off-by: Christoph Hellwig Reviewed-by: Takashi Iwai --- sound/mips/sgio2audio.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/sound/mips/sgio2audio.c b/sound/mips/sgio2audio.c index 3ec9391a4736..53a4ee01c522 100644 --- a/sound/mips/sgio2audio.c +++ b/sound/mips/sgio2audio.c @@ -805,7 +805,7 @@ static int snd_sgio2audio_free(struct snd_sgio2audio *chip) free_irq(snd_sgio2_isr_table[i].irq, &chip->channel[snd_sgio2_isr_table[i].idx]); - dma_free_coherent(NULL, MACEISA_RINGBUFFERS_SIZE, + dma_free_coherent(chip->card->dev, MACEISA_RINGBUFFERS_SIZE, chip->ring_base, chip->ring_base_dma); /* release card data */ @@ -843,8 +843,9 @@ static int snd_sgio2audio_create(struct snd_card *card, chip->card = card; - chip->ring_base = dma_alloc_coherent(NULL, MACEISA_RINGBUFFERS_SIZE, - &chip->ring_base_dma, GFP_USER); + chip->ring_base = dma_alloc_coherent(card->dev, + MACEISA_RINGBUFFERS_SIZE, + &chip->ring_base_dma, GFP_KERNEL); if (chip->ring_base == NULL) { printk(KERN_ERR "sgio2audio: could not allocate ring buffers\n");