From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4CCA3C33CB2 for ; Wed, 15 Jan 2020 15:42:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 23F09214AF for ; Wed, 15 Jan 2020 15:42:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ragnatech-se.20150623.gappssmtp.com header.i=@ragnatech-se.20150623.gappssmtp.com header.b="FdYmDlvQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729047AbgAOPmQ (ORCPT ); Wed, 15 Jan 2020 10:42:16 -0500 Received: from mail-lf1-f68.google.com ([209.85.167.68]:43898 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728885AbgAOPmP (ORCPT ); Wed, 15 Jan 2020 10:42:15 -0500 Received: by mail-lf1-f68.google.com with SMTP id 9so13060940lfq.10 for ; Wed, 15 Jan 2020 07:42:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ragnatech-se.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:content-transfer-encoding:in-reply-to; bh=N8b+H5+4AZUL8IrGlHZ9KVMloMXldascwYgfWlKN9rE=; b=FdYmDlvQrDy1LEQoaENUdqQc5r3i7VCErTzZ5eHAyDXArk/GW99jkbp7T/Mxjk+CG5 SBO4KnwzdCUIyGt6JV6AdRoxJFp1eVMUJMitA7oIj0LPDMFAhG6SktRL6shLejMecolJ RNf+yvdk+EcEmv89u84BAdIxqY6qt/udZVFDgOdC4nHiuekLe/06CWxUyaKL+AFPoM8w GqHLhnocT6dX9ydIprR4NVtLzNqnbWO7GY1L+fzMKUl0LPNlQ1Ga+enLfzmcwAk7YC4j GfKHXJAQBo9oZP4QqL1b03SoNylfIePIRZZLMJQmcOsmbTR8HAOcM5imRIIFSdmEOZAW 3trA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:content-transfer-encoding :in-reply-to; bh=N8b+H5+4AZUL8IrGlHZ9KVMloMXldascwYgfWlKN9rE=; b=GwZN1gSTM7oJSXIPE+ZJ3172RDVRB5IkTS3tJQS0P5TWWyjtTTkyws42YjrelNVvuj pQMFqe4ZebhW9dNss9NzeLQHhqcB/BPOPC3Q6QfBdHzuHIP6rz/7GVjQW0R/TLCWPQjO D0G71tvUGx5nnP75U7JLp6FygBpdd7oJi+RmC912YVb5oKifbkfzGw+WWyRV3VmZEGPg hZpW0emYUnEDsaqi98C0dbdzJxHhWZIN1Pu9Qnv0hcdds0QpVg1I1pXunnMNGFrXBvqr w81RFkeQQbTgLT1n/OFA2L7VDDIABCb9T1oWi3pvmAQg12OHDm8l3S2HN0+7yarG6mr2 xSdA== X-Gm-Message-State: APjAAAVeYJk3+lK89heJeM+IfKF964qWC6zNE+6n6k7FX5jsh42Pc8f5 AqDtRDyYXeCl5Q82A4kAEY1T1g== X-Google-Smtp-Source: APXvYqzYfC/bkCYczOz0Rbf8DDPIo53usGVtIxNysW7JZRLyBZmcO/JlAzaVVBNPrSuP94EewnXcPA== X-Received: by 2002:ac2:5503:: with SMTP id j3mr5100238lfk.104.1579102932939; Wed, 15 Jan 2020 07:42:12 -0800 (PST) Received: from localhost (h-93-159.A463.priv.bahnhof.se. [46.59.93.159]) by smtp.gmail.com with ESMTPSA id g85sm9118361lfd.66.2020.01.15.07.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 15 Jan 2020 07:42:12 -0800 (PST) Date: Wed, 15 Jan 2020 16:42:12 +0100 From: Niklas =?iso-8859-1?Q?S=F6derlund?= To: Geert Uytterhoeven Cc: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , "Rafael J . Wysocki" , Kevin Hilman , Ulf Hansson , Chris Brandt , linux-mtd@lists.infradead.org, linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH resend] mtd: maps: physmap: Add minimal Runtime PM support Message-ID: <20200115154212.GA977577@oden.dyn.berto.se> References: <20200115131323.6883-1-geert+renesas@glider.be> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20200115131323.6883-1-geert+renesas@glider.be> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, Thanks for your work. On 2020-01-15 14:13:23 +0100, Geert Uytterhoeven wrote: > Add minimal runtime PM support (enable on probe, disable on remove), to > ensure proper operation with a parent device that uses runtime PM. > > This is needed on systems where the FLASH is connected to a bus > controller that is contained in a PM domain and/or has a gateable > functional clock. In such cases, before accessing any device connected > to the external bus, the PM domain must be powered up, and/or the > functional clock must be enabled, which is typically handled through > runtime PM by the bus controller driver. > > An example of this is the Renesas APE6-EVM development board, which has > an Ethernet controller and a CFI FLASH connected to the Bus State > Controller (BSC) of an R-Mobile APE6 SoC. > As long as the Ethernet driver, which had Runtime PM support since > commit 3a611e26e958b037 ("net/smsc911x: Add minimal runtime PM > support"), keeps the BSC powered, accessing the FLASH works. > When the ethernet node in r8a73a4-ape6evm.dts is disabled, the BSC is > never powered up, and the kernel crashes when trying to access the > FLASH: > > Unhandled fault: imprecise external abort (0x1406) at 0x00000000 > pgd = (ptrval) > [00000000] *pgd=7fef2835 > Internal error: : 1406 [#1] SMP ARM > CPU: 0 PID: 122 Comm: hd Tainted: G W 5.5.0-rc1-ape6evm-00814-g38ca966db25b9dbd-dirty #136 > Hardware name: Generic R8A73A4 (Flattened Device Tree) > PC is at chip_ready+0x12c/0x380 > LR is at chip_ready+0x10c/0x380 > > Signed-off-by: Geert Uytterhoeven Reviewed-by: Niklas Söderlund > --- > Probably the device should be powered down after probing, and powered > up/down on-demand in the various {get,put}_chip() functions. However, > that is an optimization which touches more intimidate details of the > internal MTD API, and can be done later. > --- > drivers/mtd/maps/physmap-core.c | 20 +++++++++++++++----- > 1 file changed, 15 insertions(+), 5 deletions(-) > > diff --git a/drivers/mtd/maps/physmap-core.c b/drivers/mtd/maps/physmap-core.c > index a9f7964e2edb6668..8f7f966fa9a7ee8a 100644 > --- a/drivers/mtd/maps/physmap-core.c > +++ b/drivers/mtd/maps/physmap-core.c > @@ -38,6 +38,7 @@ > #include > #include > #include > +#include > #include > > #include "physmap-gemini.h" > @@ -64,16 +65,16 @@ static int physmap_flash_remove(struct platform_device *dev) > { > struct physmap_flash_info *info; > struct physmap_flash_data *physmap_data; > - int i, err; > + int i, err = 0; > > info = platform_get_drvdata(dev); > if (!info) > - return 0; > + goto out; > > if (info->cmtd) { > err = mtd_device_unregister(info->cmtd); > if (err) > - return err; > + goto out; > > if (info->cmtd != info->mtds[0]) > mtd_concat_destroy(info->cmtd); > @@ -88,7 +89,10 @@ static int physmap_flash_remove(struct platform_device *dev) > if (physmap_data && physmap_data->exit) > physmap_data->exit(dev); > > - return 0; > +out: > + pm_runtime_put(&dev->dev); > + pm_runtime_disable(&dev->dev); > + return err; > } > > static void physmap_set_vpp(struct map_info *map, int state) > @@ -484,13 +488,19 @@ static int physmap_flash_probe(struct platform_device *dev) > return -EINVAL; > } > > + pm_runtime_enable(&dev->dev); > + pm_runtime_get_sync(&dev->dev); > + > if (dev->dev.of_node) > err = physmap_flash_of_init(dev); > else > err = physmap_flash_pdata_init(dev); > > - if (err) > + if (err) { > + pm_runtime_put(&dev->dev); > + pm_runtime_disable(&dev->dev); > return err; > + } > > for (i = 0; i < info->nmaps; i++) { > struct resource *res; > -- > 2.17.1 > -- Regards, Niklas Söderlund