From patchwork Thu Mar 21 22:52:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10864465 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 75F0D922 for ; Thu, 21 Mar 2019 22:53:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5BE7F2A474 for ; Thu, 21 Mar 2019 22:53:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4F2DF2A52E; Thu, 21 Mar 2019 22:53:10 +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 DECE42A474 for ; Thu, 21 Mar 2019 22:53:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727395AbfCUWxF (ORCPT ); Thu, 21 Mar 2019 18:53:05 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40000 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726247AbfCUWxE (ORCPT ); Thu, 21 Mar 2019 18:53:04 -0400 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=m3Qh2DgtKUHbRBqWhI2F/vLKKN FfbGCgg9BYJNHKAxAyhNo/iz/NuMhgkC4PVMCVMW6FFs0KFZoQG4ZsyxbOn5bPE4QU9c2Aac1pESO pgB6zCbebubmEyYQxUNxyUOWB/9zm6owPKeMglPxF6fP+oHe9/svSgEUvfzA6TSEachHLk97KJbgS MdQQth6bJFrFTOzJRN4Cr5ZucDE/Nfu2fZ7tKR6DupZk2y/zkJsV8XgcD1mVznXBb4ZaDsyue2Tyb 4+0GY3+0/4Dr3o2aX8TRL1k0PX4V2Zr5U21MhThs33MgyTcWTWvynjKhKteqx4NgvaklfwFQqXMub OQfirbCg==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h76YV-0007lg-W0; Thu, 21 Mar 2019 22:53:00 +0000 From: Christoph Hellwig To: Russell King , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/7] parport_ip32: pass struct device to DMA API functions Date: Thu, 21 Mar 2019 15:52:29 -0700 Message-Id: <20190321225235.30648-2-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321225235.30648-1-hch@lst.de> References: <20190321225235.30648-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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@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 Thu Mar 21 22:52:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10864469 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 D0F9613B5 for ; Thu, 21 Mar 2019 22:53:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7DC42A474 for ; Thu, 21 Mar 2019 22:53:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id ABF412A52E; Thu, 21 Mar 2019 22:53:14 +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 50F952A474 for ; Thu, 21 Mar 2019 22:53:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727416AbfCUWxJ (ORCPT ); Thu, 21 Mar 2019 18:53:09 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40532 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726896AbfCUWxJ (ORCPT ); Thu, 21 Mar 2019 18:53:09 -0400 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=sBlqznH7rjBOhc2hY1LI2NLLZe bBDUtIJ/WBMA2oWwbUwQT7cDojT2pOfk8BnATBvXq1uSpO4kGgVBpSolguZgMzd8LTa3JaFkyaEcT O4+N1hAEWOgJ4wmrpnrs6r2VUbxxTAbZJP4nybps/xuylrhJIaS00s8/YHOicYFY7uBIWwYsM1woX 5toBZpMxQBPfWj1hSfhWiWOKt+CGKMP5pNLz0D+rhvibcHWyvj19R+tHuhMWb87lK0ocTyv62F93o pb1oQB2cli2sN2nlMlWFyJWdzH1nzplH9wZgQt/r+3y13k+lgLF9x4ZbJPlkH1mExeYlj3Dz2l9gh IELB2C7A==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h76Yb-0007sm-H9; Thu, 21 Mar 2019 22:53:05 +0000 From: Christoph Hellwig To: Russell King , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/7] da8xx-fb: pass struct device to DMA API functions Date: Thu, 21 Mar 2019 15:52:30 -0700 Message-Id: <20190321225235.30648-3-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321225235.30648-1-hch@lst.de> References: <20190321225235.30648-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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@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: Bartlomiej Zolnierkiewicz --- 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 Thu Mar 21 22:52:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10864471 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 4BF3313B5 for ; Thu, 21 Mar 2019 22:53:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 328E22A474 for ; Thu, 21 Mar 2019 22:53:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 26E7C2A52E; Thu, 21 Mar 2019 22:53:18 +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 BBBBC2A474 for ; Thu, 21 Mar 2019 22:53:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726896AbfCUWxR (ORCPT ); Thu, 21 Mar 2019 18:53:17 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:41514 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbfCUWxR (ORCPT ); Thu, 21 Mar 2019 18:53:17 -0400 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=ntvwk3rfU/7cOzHhrbebJIAuOs B75r4Afik/Um3yWXh7dqXvkG6qs45ksusQ9yYM9SahlSGJ/J3ixd7O0ia1Me9xiqK7fJFrzOKJgRF bNQiD+d3hqh+RN7PUqFKg4q4CDFeAlgP+Zxh5+cep0bXThffOZS34ZJiCa6nQ8tiqU/8L25eoikM/ K77kIZ9NFNy1KQg8XTtTqeM5oaXatdRZEIhwuPJQlACGjFpqrNiyqDDNnRf14B4fPUaT2osUWgiOI hkzNX6DzWrsETe5oGNPIeAmQ/ZwVn5qBg+R+GgCsuKPR1auhvVLvkzVvJhPfeOO5WHKrh7nhxThVT +yrDzgwQ==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h76Yg-000801-QL; Thu, 21 Mar 2019 22:53:10 +0000 From: Christoph Hellwig To: Russell King , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 3/7] gbefb: switch to managed version of the DMA allocator Date: Thu, 21 Mar 2019 15:52:31 -0700 Message-Id: <20190321225235.30648-4-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321225235.30648-1-hch@lst.de> References: <20190321225235.30648-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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@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 Acked-by: Bartlomiej Zolnierkiewicz --- 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 Thu Mar 21 22:52:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10864475 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 DB01D13B5 for ; Thu, 21 Mar 2019 22:53:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C29952A474 for ; Thu, 21 Mar 2019 22:53:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6AF72A52E; Thu, 21 Mar 2019 22:53:25 +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 5D8A92A474 for ; Thu, 21 Mar 2019 22:53:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727463AbfCUWxY (ORCPT ); Thu, 21 Mar 2019 18:53:24 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:42354 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727000AbfCUWxY (ORCPT ); Thu, 21 Mar 2019 18:53:24 -0400 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=B2eR77nNGty3Ns/sXLjhkZw9sj dSjGib2AAFYPoDeBJIDC5I9efGThXkaf722fN1UXGsyOLaId//CoBZJtir64aXnEBGbeFgMizv+W8 jRydcAOEaQ+fr72qWJY7OV05Tf6jxCqEJpZ+E1KJLgy2BJ7IRf8DHVR0mRlZs237jlMxvMTRHMxq2 6Gz2WxrBHfakfkNPWoJPvqEig1NRNOvOxqPFaQf2KuHbulolXn7xDwNwT0vg/w7R45s1UCSPjn6j/ D9QbnCLcpJVbMys4lu2qwcoSaCrnssM3PaMnJGtQwxnBt5xxEfMmgBmXt1aFBDWQpSm4tDZMCEpPO QIfy32jA==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h76Ym-00089R-Hw; Thu, 21 Mar 2019 22:53:16 +0000 From: Christoph Hellwig To: Russell King , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 4/7] pxa3xx-gcu: pass struct device to dma_mmap_coherent Date: Thu, 21 Mar 2019 15:52:32 -0700 Message-Id: <20190321225235.30648-5-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321225235.30648-1-hch@lst.de> References: <20190321225235.30648-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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Just like we do for all other DMA operations. Signed-off-by: Christoph Hellwig Acked-by: Bartlomiej Zolnierkiewicz --- 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 Thu Mar 21 22:52:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10864477 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 8977A922 for ; Thu, 21 Mar 2019 22:53:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7207C2A474 for ; Thu, 21 Mar 2019 22:53:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65E532A52E; Thu, 21 Mar 2019 22:53: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=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 087F82A474 for ; Thu, 21 Mar 2019 22:53:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726557AbfCUWx3 (ORCPT ); Thu, 21 Mar 2019 18:53:29 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:42866 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbfCUWx3 (ORCPT ); Thu, 21 Mar 2019 18:53:29 -0400 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=wNIVp/3PbkEedkhIB8pmA67cLys6VfkT7RY7LY2wi3M=; b=Sd8x6YVC79e9T1/vEsh+EUZ5lK kQYtPjS9UCpEhQZ+r7wu4m5eKMRrfFDp/fkdOVcDKrBKctlulMmYpKdkHEygsKhag29a4uuIP9fwS EEszP0t9jtTDbzRZa7ceV8tqbM4TcuDPqeDJJkXviFCAx2SOuUDxgiCxjMptf7POlaJUFWSV5DkqQ 8A4iFtLEtM6NoC1sUbU4TTd1qCSOYoYfxtVZqdOqJ9JZT2MdXEywuZRvzj30A9+o/Ziw4tWqcVKc9 IzoHXuqgYtdfqQkz7tm+LylrarNSDJH2UEdDtmWVif4zcpYolOcY8qgO89mZE7oXQKpcCzQ9CdklR HMdRClcA==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h76Ys-0008Ia-8B; Thu, 21 Mar 2019 22:53:22 +0000 From: Christoph Hellwig To: Russell King , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 5/7] arm: use a dummy struct device for ISA DMA use of the DMA API Date: Thu, 21 Mar 2019 15:52:33 -0700 Message-Id: <20190321225235.30648-6-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321225235.30648-1-hch@lst.de> References: <20190321225235.30648-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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This gets rid of the last NULL dev argument passed to the DMA API. Signed-off-by: Christoph Hellwig --- arch/arm/kernel/dma-isa.c | 8 +++++++- arch/arm/mach-rpc/dma.c | 8 +++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/arch/arm/kernel/dma-isa.c b/arch/arm/kernel/dma-isa.c index 84363fe7bad2..10c45cc6b957 100644 --- a/arch/arm/kernel/dma-isa.c +++ b/arch/arm/kernel/dma-isa.c @@ -55,6 +55,12 @@ static int isa_get_dma_residue(unsigned int chan, dma_t *dma) return chan < 4 ? count : (count << 1); } +static struct device isa_dma_dev = { + .init_name = "fallback device", + .coherent_dma_mask = ~(dma_addr_t)0, + .dma_mask = &isa_dma_dev.coherent_dma_mask, +}; + static void isa_enable_dma(unsigned int chan, dma_t *dma) { if (dma->invalid) { @@ -89,7 +95,7 @@ static void isa_enable_dma(unsigned int chan, dma_t *dma) dma->sg = &dma->buf; dma->sgcount = 1; dma->buf.length = dma->count; - dma->buf.dma_address = dma_map_single(NULL, + dma->buf.dma_address = dma_map_single(&isa_dma_dev, dma->addr, dma->count, direction); } diff --git a/arch/arm/mach-rpc/dma.c b/arch/arm/mach-rpc/dma.c index fb48f3141fb4..f2703ca17954 100644 --- a/arch/arm/mach-rpc/dma.c +++ b/arch/arm/mach-rpc/dma.c @@ -151,6 +151,12 @@ static void iomd_free_dma(unsigned int chan, dma_t *dma) free_irq(idma->irq, idma); } +static struct device isa_dma_dev = { + .init_name = "fallback device", + .coherent_dma_mask = ~(dma_addr_t)0, + .dma_mask = &isa_dma_dev.coherent_dma_mask, +}; + static void iomd_enable_dma(unsigned int chan, dma_t *dma) { struct iomd_dma *idma = container_of(dma, struct iomd_dma, dma); @@ -168,7 +174,7 @@ static void iomd_enable_dma(unsigned int chan, dma_t *dma) idma->dma.sg = &idma->dma.buf; idma->dma.sgcount = 1; idma->dma.buf.length = idma->dma.count; - idma->dma.buf.dma_address = dma_map_single(NULL, + idma->dma.buf.dma_address = dma_map_single(&isa_dma_dev, idma->dma.addr, idma->dma.count, idma->dma.dma_mode == DMA_MODE_READ ? DMA_FROM_DEVICE : DMA_TO_DEVICE); From patchwork Thu Mar 21 22:52:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10864481 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 1E00513B5 for ; Thu, 21 Mar 2019 22:53:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 065ED2A474 for ; Thu, 21 Mar 2019 22:53:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EE2EE2A52E; Thu, 21 Mar 2019 22:53:44 +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 84D002A474 for ; Thu, 21 Mar 2019 22:53:44 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727502AbfCUWxe (ORCPT ); Thu, 21 Mar 2019 18:53:34 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43514 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727500AbfCUWxe (ORCPT ); Thu, 21 Mar 2019 18:53:34 -0400 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=Ez+3EWjdVvcOHsf4UKZtVhBc01z3rs8TGTRNqolA6d8=; b=nyWYIRuc0OdL0079dxLKpM0LW+ 38D8w27a41xu2YwM1h3qiP8uXOOb1B7viyiFZZKEEV52tP0kb0BYXlu4FkDn7wbwsNV6eu4x5z62w 2ydHpj7skFQBYlrwr+r3u6IkWao0fFUFUIJuw7DdUcDj0m3+FOdEdvKqhwH5rrim/sSSn5sYVpJeW C6yhNKWQv2sN54hkl8vghYi9Y+Utvmyrkz3YGD/VIWkAnNzunjC7c8PDBBMnvfgYS8jQi8kNPTWHq R0PcmhNT2WqfLSJRukNqgQrKDejsMFvWMTzjDl6w2AMLSCAM5tqE28HQ+AqjepTxM96xny6dk8be3 gwjueO6w==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h76Yx-0008RO-Nz; Thu, 21 Mar 2019 22:53:27 +0000 From: Christoph Hellwig To: Russell King , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 6/7] dma-mapping: remove leftover NULL device support Date: Thu, 21 Mar 2019 15:52:34 -0700 Message-Id: <20190321225235.30648-7-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321225235.30648-1-hch@lst.de> References: <20190321225235.30648-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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Most dma_map_ops implementations already had some issues with a NULL device, or did simply crash if one was fed to them. Now that we have cleaned up all the obvious offenders we can stop to pretend we support this mode. Signed-off-by: Christoph Hellwig --- Documentation/DMA-API-HOWTO.txt | 13 ++++++------- include/linux/dma-mapping.h | 6 +++--- kernel/dma/direct.c | 2 +- 3 files changed, 10 insertions(+), 11 deletions(-) diff --git a/Documentation/DMA-API-HOWTO.txt b/Documentation/DMA-API-HOWTO.txt index 1a721d0f35c8..0e98cf7466dd 100644 --- a/Documentation/DMA-API-HOWTO.txt +++ b/Documentation/DMA-API-HOWTO.txt @@ -365,13 +365,12 @@ __get_free_pages() (but takes size instead of a page order). If your driver needs regions sized smaller than a page, you may prefer using the dma_pool interface, described below. -The consistent DMA mapping interfaces, for non-NULL dev, will by -default return a DMA address which is 32-bit addressable. Even if the -device indicates (via DMA mask) that it may address the upper 32-bits, -consistent allocation will only return > 32-bit addresses for DMA if -the consistent DMA mask has been explicitly changed via -dma_set_coherent_mask(). This is true of the dma_pool interface as -well. +The consistent DMA mapping interfaces, will by default return a DMA address +which is 32-bit addressable. Even if the device indicates (via the DMA mask) +that it may address the upper 32-bits, consistent allocation will only +return > 32-bit addresses for DMA if the consistent DMA mask has been +explicitly changed via dma_set_coherent_mask(). This is true of the +dma_pool interface as well. dma_alloc_coherent() returns two values: the virtual address which you can use to access it from the CPU and dma_handle which you pass to the diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 75e60be91e5f..6309a721394b 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -267,9 +267,9 @@ size_t dma_direct_max_mapping_size(struct device *dev); static inline const struct dma_map_ops *get_dma_ops(struct device *dev) { - if (dev && dev->dma_ops) + if (dev->dma_ops) return dev->dma_ops; - return get_arch_dma_ops(dev ? dev->bus : NULL); + return get_arch_dma_ops(dev->bus); } static inline void set_dma_ops(struct device *dev, @@ -650,7 +650,7 @@ static inline void dma_free_coherent(struct device *dev, size_t size, static inline u64 dma_get_mask(struct device *dev) { - if (dev && dev->dma_mask && *dev->dma_mask) + if (dev->dma_mask && *dev->dma_mask) return *dev->dma_mask; return DMA_BIT_MASK(32); } diff --git a/kernel/dma/direct.c b/kernel/dma/direct.c index fcdb23e8d2fc..2c2772e9702a 100644 --- a/kernel/dma/direct.c +++ b/kernel/dma/direct.c @@ -311,7 +311,7 @@ static inline bool dma_direct_possible(struct device *dev, dma_addr_t dma_addr, size_t size) { return swiotlb_force != SWIOTLB_FORCE && - (!dev || dma_capable(dev, dma_addr, size)); + dma_capable(dev, dma_addr, size); } dma_addr_t dma_direct_map_page(struct device *dev, struct page *page, From patchwork Thu Mar 21 22:52:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 10864479 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 DDB0C13B5 for ; Thu, 21 Mar 2019 22:53:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C54382A474 for ; Thu, 21 Mar 2019 22:53:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B6A2E2A52E; Thu, 21 Mar 2019 22:53:43 +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 4568C2A474 for ; Thu, 21 Mar 2019 22:53:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726995AbfCUWxi (ORCPT ); Thu, 21 Mar 2019 18:53:38 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:43806 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725953AbfCUWxh (ORCPT ); Thu, 21 Mar 2019 18:53:37 -0400 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=AyCBwPbpM5mZLjGJI2JihnqcjJj7rmgeIxLbnmVYgXQ=; b=dfqJALfCXIwms+p3RVZbiVrpcC kfv81fyh60h9t6nB26O7crLPEG4KoscROX48qPWUJmpnBzalzL3fPC2lcTkRZ5U8HnT8ZQDtmgemP CS7oybZd4qr/1HjwL9opq+wk73NLr1Wob8xrtVzLMU++0osbazVlEyayHqsfZN1osVG6lGG6FvaKa +Hr2bwNLXJNCqouTjLknCJQBC8SUa8qDgk1Ele+v1oHCVAOs2PgMZ4z5po0ntOhF7K7mWCQT2z3aD VQjdnCCsNdaGXVZn1g3LmCioR56m4q5uNgiShXXx3s5XLsrsd+hxAv/LaPLk2gc/EwAoJbcEt0DtL DpkrF/Mw==; Received: from [199.255.44.128] (helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1h76Z3-00008j-1j; Thu, 21 Mar 2019 22:53:33 +0000 From: Christoph Hellwig To: Russell King , x86@kernel.org, Sudip Mukherjee , Bartlomiej Zolnierkiewicz Cc: linux-doc@vger.kernel.org, linux-arm-kernel@lists.infradead.org, dri-devel@lists.freedesktop.org, linux-fbdev@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org Subject: [PATCH 7/7] x86: remove the x86_dma_fallback_dev hack Date: Thu, 21 Mar 2019 15:52:35 -0700 Message-Id: <20190321225235.30648-8-hch@lst.de> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20190321225235.30648-1-hch@lst.de> References: <20190321225235.30648-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-fbdev-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-fbdev@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Now that we removed support for the NULL device argument in the DMA API, there is no need to cater for that in the x86 code. Signed-off-by: Christoph Hellwig Reviewed-by: Thomas Gleixner --- arch/x86/include/asm/dma-mapping.h | 10 ---------- arch/x86/kernel/amd_gart_64.c | 6 ------ arch/x86/kernel/pci-dma.c | 20 -------------------- kernel/dma/mapping.c | 7 ------- 4 files changed, 43 deletions(-) diff --git a/arch/x86/include/asm/dma-mapping.h b/arch/x86/include/asm/dma-mapping.h index ce4d176b3d13..6b15a24930e0 100644 --- a/arch/x86/include/asm/dma-mapping.h +++ b/arch/x86/include/asm/dma-mapping.h @@ -13,14 +13,7 @@ #include #include -#ifdef CONFIG_ISA -# define ISA_DMA_BIT_MASK DMA_BIT_MASK(24) -#else -# define ISA_DMA_BIT_MASK DMA_BIT_MASK(32) -#endif - extern int iommu_merge; -extern struct device x86_dma_fallback_dev; extern int panic_on_overflow; extern const struct dma_map_ops *dma_ops; @@ -30,7 +23,4 @@ static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) return dma_ops; } -bool arch_dma_alloc_attrs(struct device **dev); -#define arch_dma_alloc_attrs arch_dma_alloc_attrs - #endif diff --git a/arch/x86/kernel/amd_gart_64.c b/arch/x86/kernel/amd_gart_64.c index 2c0aa34af69c..bf7f13ea3c64 100644 --- a/arch/x86/kernel/amd_gart_64.c +++ b/arch/x86/kernel/amd_gart_64.c @@ -233,9 +233,6 @@ static dma_addr_t gart_map_page(struct device *dev, struct page *page, unsigned long bus; phys_addr_t paddr = page_to_phys(page) + offset; - if (!dev) - dev = &x86_dma_fallback_dev; - if (!need_iommu(dev, paddr, size)) return paddr; @@ -392,9 +389,6 @@ static int gart_map_sg(struct device *dev, struct scatterlist *sg, int nents, if (nents == 0) return 0; - if (!dev) - dev = &x86_dma_fallback_dev; - out = 0; start = 0; start_sg = sg; diff --git a/arch/x86/kernel/pci-dma.c b/arch/x86/kernel/pci-dma.c index d460998ae828..dcd272dbd0a9 100644 --- a/arch/x86/kernel/pci-dma.c +++ b/arch/x86/kernel/pci-dma.c @@ -51,14 +51,6 @@ int iommu_pass_through __read_mostly; extern struct iommu_table_entry __iommu_table[], __iommu_table_end[]; -/* Dummy device used for NULL arguments (normally ISA). */ -struct device x86_dma_fallback_dev = { - .init_name = "fallback device", - .coherent_dma_mask = ISA_DMA_BIT_MASK, - .dma_mask = &x86_dma_fallback_dev.coherent_dma_mask, -}; -EXPORT_SYMBOL(x86_dma_fallback_dev); - void __init pci_iommu_alloc(void) { struct iommu_table_entry *p; @@ -77,18 +69,6 @@ void __init pci_iommu_alloc(void) } } -bool arch_dma_alloc_attrs(struct device **dev) -{ - if (!*dev) - *dev = &x86_dma_fallback_dev; - - if (!is_device_dma_capable(*dev)) - return false; - return true; - -} -EXPORT_SYMBOL(arch_dma_alloc_attrs); - /* * See for the iommu kernel * parameter documentation. diff --git a/kernel/dma/mapping.c b/kernel/dma/mapping.c index c000906348c9..685a53f2a793 100644 --- a/kernel/dma/mapping.c +++ b/kernel/dma/mapping.c @@ -238,10 +238,6 @@ u64 dma_get_required_mask(struct device *dev) } EXPORT_SYMBOL_GPL(dma_get_required_mask); -#ifndef arch_dma_alloc_attrs -#define arch_dma_alloc_attrs(dev) (true) -#endif - void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle, gfp_t flag, unsigned long attrs) { @@ -256,9 +252,6 @@ void *dma_alloc_attrs(struct device *dev, size_t size, dma_addr_t *dma_handle, /* let the implementation decide on the zone to allocate from: */ flag &= ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM); - if (!arch_dma_alloc_attrs(&dev)) - return NULL; - if (dma_is_direct(ops)) cpu_addr = dma_direct_alloc(dev, size, dma_handle, flag, attrs); else if (ops->alloc)