From patchwork Thu Oct 19 22:55:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Roy Franz X-Patchwork-Id: 10018431 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5A986602C8 for ; Thu, 19 Oct 2017 22:57:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4CB3D28E5E for ; Thu, 19 Oct 2017 22:57:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4016E28E69; Thu, 19 Oct 2017 22:57:22 +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=-3.7 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id CD6B028E5E for ; Thu, 19 Oct 2017 22:57:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:Message-Id:Date: Subject:To:From:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To: References:List-Owner; bh=phyVgUmSQDpJSFEZMAf1Aw7tvBI5Ol+zOGkZLQz8kLI=; b=pX3 nBoOuYnooAFaM2fTuDiJ8GCUFMjJsBi1EwIP4hVdRfak/DeNK/bw+H+xU97xrjY8XCy1hr+zvrn2g TgHjV9qXAS9RbV+r0BemoI4Eo2kXlHRM18lXJ2rieh8dQMup8Dxx0zWJWCuEkOlIg7PfugKvoyZZk nGd1wz3EJM3J1+dnGtwoDMDnTSS4SU9W5ifc7RpeAjX1pNULWfAQqDeKSrc5GaMxerMzHVRSwR0S+ +4rJES7XIqKqJNHP0ACXCpC6OwU9N8H9gA4cTtZPY9CM+8g4TsoD0r7YW31TGyh4xfAlNiIy5B9l7 vD0Jp9DN6M5o/sKr5D9jJ/7jCXWH6aw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1e5Jkf-0002Jf-ED; Thu, 19 Oct 2017 22:57:21 +0000 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]) by bombadil.infradead.org with esmtps (Exim 4.87 #1 (Red Hat Linux)) id 1e5Jkc-00025b-6P for linux-arm-kernel@lists.infradead.org; Thu, 19 Oct 2017 22:57:20 +0000 Received: by mail-pf0-x241.google.com with SMTP id a8so8146132pfc.0 for ; Thu, 19 Oct 2017 15:56:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cavium-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=vkuBzx4aLMKiptLi5to1xumPjrWp7kg+iYIdQ/+5OuI=; b=mYOdOWPGg9/tulTGrSBtsaBGP5duESrkkekUtM9wUWEtED6JjnfqsrioPSzhAhEvvj V/wnmEXG9Z02fvXOCEyOCD1jRnSoCLyjSav/YNsB2wOAfCzGSEHgUFs9v8PybF13s/c6 5I6iu97Q6RHCmf708mpofUAvP3SLzYCAyF9bOcsRKCQIxWcTKPum0YJ0ovSFUmxYuNBg g0/51DFtyqyfnAOtAfKmDAwDm+28k0yvVpUu/TGfW8Bp7iDDFSbrniKJWOafVl9CIp7X E1/RfTrcWRpbqpu3YM3cEkJ/72//Si7WY3wGK3Q4b+4YflaESiVHT9yBFnFWTG4rdiah VGlg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=vkuBzx4aLMKiptLi5to1xumPjrWp7kg+iYIdQ/+5OuI=; b=c/LF1tVtp7cfookdKgLTqakAMoIYfaXqX8P3zMvT8zsEN7ScccYn8WjSNHM8JRXdki i5Otkw+4mcPYKeCG00dcWKHtN+CVpJxMPoqd6yw3sJb4t9k0sBc8goZlgqRjP7HQt5fL zYuQGEnpFGaius/A8JrYAf/4TzTeCZYouIAFTWZYXJPS+fByj8lnxtpsFmMIEuNsdoZW oiobCWSLa1lGINMYc7b5ChVrq1sBj3hTDZeLGeRm+WaVAG/A4HnwbQQkrUyGW3zSZ9WV V9J4QW9JppX63JX2rsdiT4J/+bfFfwDi3NcuV4ppS4WSVfAI1JAZcgLXHyp0HRiiH+Q0 cjqg== X-Gm-Message-State: AMCzsaWk2oQbBDOd5XIkWV/69OSYqWwsblUGUN0rBHHHnap50a3GTnMN l+NzvjvWOKOT7qHs7nVui2r1/Q== X-Google-Smtp-Source: ABhQp+TIbrzvzmA0L0kzwnX2uzcHXkoxYc52jyjell3EYjDnnCGcqYRlMhkqXaHzoN92ytRn3fvk/A== X-Received: by 10.98.32.212 with SMTP id m81mr3008572pfj.227.1508453817302; Thu, 19 Oct 2017 15:56:57 -0700 (PDT) Received: from localhost.localdomain (c-73-41-93-56.hsd1.ca.comcast.net. [73.41.93.56]) by smtp.gmail.com with ESMTPSA id t85sm29732115pfe.138.2017.10.19.15.56.54 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Oct 2017 15:56:55 -0700 (PDT) From: Roy Franz X-Google-Original-From: Roy Franz To: dwmw2@infradead.org, computersforpeace@gmail.com, boris.brezillon@free-electrons.com, marek.vasut@gmail.com, richard@nod.at, cyrille.pitchen@wedev4u.fr Subject: [PATCH v2] mtd: slram: use memremap() instead of ioremap() Date: Thu, 19 Oct 2017 15:55:49 -0700 Message-Id: <20171019225549.11422-1-roy.franz@cavium.com> X-Mailer: git-send-email 2.11.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20171019_155718_464173_BDDD38C8 X-CRM114-Status: GOOD ( 13.01 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, roy.franz@cavium.com, hch@infradead.org, linux-mtd@lists.infradead.org, ddaney@cavium.com, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Convert slram to use memremap() to map the memory it uses to back an MTD device, as this is the proper interface for mapping memory. This change enables normal memory to be used to back an MTD device on arm64, as arm64 prevents ioremap() being used on normal memory. Signed-off-by: Roy Franz Acked-by: Ard Biesheuvel Tested-by: David Daney --- Tested on arm64 simulation, using simulator to preload filesystem image into RAM, and also tested on x86_64 using video card memory. This is useful for speeding up booting on (very slow) emulation environments by avoiding any processing of an initramfs. David Daney tested on MIPS64. v2: Fix typo in subject line, s/mdt/mtd/ added acked-by/tested-by drivers/mtd/devices/slram.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/devices/slram.c b/drivers/mtd/devices/slram.c index 8087c36dc693..0ec85f316d24 100644 --- a/drivers/mtd/devices/slram.c +++ b/drivers/mtd/devices/slram.c @@ -163,8 +163,9 @@ static int register_device(char *name, unsigned long start, unsigned long length } if (!(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start = - ioremap(start, length))) { - E("slram: ioremap failed\n"); + memremap(start, length, + MEMREMAP_WB | MEMREMAP_WT | MEMREMAP_WC))) { + E("slram: memremap failed\n"); return -EIO; } ((slram_priv_t *)(*curmtd)->mtdinfo->priv)->end = @@ -186,7 +187,7 @@ static int register_device(char *name, unsigned long start, unsigned long length if (mtd_device_register((*curmtd)->mtdinfo, NULL, 0)) { E("slram: Failed to register new device\n"); - iounmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start); + memunmap(((slram_priv_t *)(*curmtd)->mtdinfo->priv)->start); kfree((*curmtd)->mtdinfo->priv); kfree((*curmtd)->mtdinfo); return(-EAGAIN); @@ -206,7 +207,7 @@ static void unregister_devices(void) while (slram_mtdlist) { nextitem = slram_mtdlist->next; mtd_device_unregister(slram_mtdlist->mtdinfo); - iounmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start); + memunmap(((slram_priv_t *)slram_mtdlist->mtdinfo->priv)->start); kfree(slram_mtdlist->mtdinfo->priv); kfree(slram_mtdlist->mtdinfo); kfree(slram_mtdlist);