Received: by 10.223.185.116 with SMTP id b49csp1128793wrg; Fri, 23 Feb 2018 12:26:15 -0800 (PST) X-Google-Smtp-Source: AH8x22464NO1GmUAf5Z64GBsSXLMfFIDTzhhHJ62dqgO4E+hkgiOxBHI56XOH2dBmtASM4oNxOED X-Received: by 10.101.92.196 with SMTP id b4mr2290692pgt.27.1519417574935; Fri, 23 Feb 2018 12:26:14 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1519417574; cv=none; d=google.com; s=arc-20160816; b=VQSW3PQfHlremrVYYv2uGM+t86PlUta8R8pgoFTTMumA0i1ATx91XIbQsPd46q4dTx mPp07Zv72NXOFsSIKyrAfiboKO0zRssMDwsNdZk2sWuI7kT1WvAE8WjUqXiB+uApIau4 XbQG4Be9OZGAD9XYNRet6kgiP+1pNYTFXTw1O+mnJ2kNRuSh7NcMbso95U9PDLVEsf0G gOqMKlF685ZqPkHNOmlgrzUO6QEPMk1uQ7WkH/BKuVLB3Uh1Wb2dVu/ojveUolGodyyx rB/xuaADvCxqSeMZp3Fko6nTalGZyOOWw40wLFdX9cBK5QylXYoWFpMlBBYv9nucFOhC pdaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from :arc-authentication-results; bh=Svl4nIX365SZkIVEMS9wByfw1zYkebv5g17nAJj4KI8=; b=fzTZYGdbLKQBXdnAm+1BEUfquniP/mPQyzE6fMVzqVgpf+1RLqcZhfh1zqoNfhypYx LBOA5tNinR3D2Ym9jGBd82hrPv+7hPXGMioxAaC038bELqU875os3rNjtSlFuPk47KTM KGV9g3z4OQ8Mf3AgLa0I/5kOqOphn91t45XSwrA7mnFyeSv0BQ50aONvTQizdYlrmU6L YCtpKzTS6EhUhabOK3vXHYeB95D1GJA/oT9yo/826a7fz//GANzYMbbkmI2JQmPYI8LA 5KIIh0dB6aKqUcI/D4UDRIJRotn8EpbVJ49X+08cQePCqNWKy/BUsFLRXPAhMv/4RrUu N16g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id y40-v6si2235334pla.753.2018.02.23.12.25.58; Fri, 23 Feb 2018 12:26:14 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754262AbeBWShl (ORCPT + 99 others); Fri, 23 Feb 2018 13:37:41 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:38748 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932188AbeBWShj (ORCPT ); Fri, 23 Feb 2018 13:37:39 -0500 Received: from localhost (LFbn-1-12258-90.w90-92.abo.wanadoo.fr [90.92.71.90]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 634DBBBF; Fri, 23 Feb 2018 18:37:38 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Arnd Bergmann , Brian Norris Subject: [PATCH 4.4 106/193] mtd: sh_flctl: pass FIFO as physical address Date: Fri, 23 Feb 2018 19:25:39 +0100 Message-Id: <20180223170342.521240156@linuxfoundation.org> X-Mailer: git-send-email 2.16.2 In-Reply-To: <20180223170325.997716448@linuxfoundation.org> References: <20180223170325.997716448@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.4-stable review patch. If anyone has any objections, please let me know. ------------------ From: Arnd Bergmann commit 1873315fb156cbc8e46f28e8b128f17ff6c31728 upstream. By convention, the FIFO address we pass using dmaengine_slave_config is a physical address in the form that is understood by the DMA engine, as a dma_addr_t, phys_addr_t or resource_size_t. The sh_flctl driver however passes a virtual __iomem address that gets cast to dma_addr_t in the slave driver. This happens to work on shmobile because that platform sets up an identity mapping for its MMIO regions, but such code is not portable to other platforms, and prevents us from ever changing the platform mapping or reusing the driver on other architectures like ARM64 that might not have the mapping. We also get a warning about a type mismatch for the case that dma_addr_t is wider than a pointer, i.e. when CONFIG_LPAE is set: drivers/mtd/nand/sh_flctl.c: In function 'flctl_setup_dma': drivers/mtd/nand/sh_flctl.c:163:17: warning: cast from pointer to integer of different size [-Wpointer-to-int-cast] cfg.dst_addr = (dma_addr_t)FLDTFIFO(flctl); This changes the driver to instead pass the physical address of the FIFO that is extracted from the MMIO resource, making the code more portable and avoiding the warning. Signed-off-by: Arnd Bergmann Signed-off-by: Brian Norris Signed-off-by: Greg Kroah-Hartman --- drivers/mtd/nand/sh_flctl.c | 5 +++-- include/linux/mtd/sh_flctl.h | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) --- a/drivers/mtd/nand/sh_flctl.c +++ b/drivers/mtd/nand/sh_flctl.c @@ -160,7 +160,7 @@ static void flctl_setup_dma(struct sh_fl memset(&cfg, 0, sizeof(cfg)); cfg.direction = DMA_MEM_TO_DEV; - cfg.dst_addr = (dma_addr_t)FLDTFIFO(flctl); + cfg.dst_addr = flctl->fifo; cfg.src_addr = 0; ret = dmaengine_slave_config(flctl->chan_fifo0_tx, &cfg); if (ret < 0) @@ -176,7 +176,7 @@ static void flctl_setup_dma(struct sh_fl cfg.direction = DMA_DEV_TO_MEM; cfg.dst_addr = 0; - cfg.src_addr = (dma_addr_t)FLDTFIFO(flctl); + cfg.src_addr = flctl->fifo; ret = dmaengine_slave_config(flctl->chan_fifo0_rx, &cfg); if (ret < 0) goto err; @@ -1096,6 +1096,7 @@ static int flctl_probe(struct platform_d flctl->reg = devm_ioremap_resource(&pdev->dev, res); if (IS_ERR(flctl->reg)) return PTR_ERR(flctl->reg); + flctl->fifo = res->start + 0x24; /* FLDTFIFO */ irq = platform_get_irq(pdev, 0); if (irq < 0) { --- a/include/linux/mtd/sh_flctl.h +++ b/include/linux/mtd/sh_flctl.h @@ -148,6 +148,7 @@ struct sh_flctl { struct platform_device *pdev; struct dev_pm_qos_request pm_qos; void __iomem *reg; + resource_size_t fifo; uint8_t done_buff[2048 + 64]; /* max size 2048 + 64 */ int read_bytes;