Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp7153365ybl; Wed, 15 Jan 2020 16:39:43 -0800 (PST) X-Google-Smtp-Source: APXvYqwlwpt+PWnY61HR4FNJhLnUI5gp1i9eKEXGj+oSVGlHnQx+usuh1dq8+Xs1MTnJnnlrzmqy X-Received: by 2002:aca:503:: with SMTP id 3mr2218799oif.106.1579135183284; Wed, 15 Jan 2020 16:39:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579135183; cv=none; d=google.com; s=arc-20160816; b=x4ghIpFio5kS0LlkApsLCdvY5nT2idEd2d5suV5BYsV7E8wkO/BrnrClZGGq+9M/cx PyiGrZ5yQsTsnsVhOr4Zl1K24nc/bSMldza4DoM4uRMpXFGfCgbOTLaxvghswL/h23jH lMZRp0Gf8HZL7h37m8MGlUFPFsbeu835NpkHF4YZAcNs13dUmU4gvmy5TME5N0LVdotG OpRWMm1Twx5uVqs0AU6uIoIfWTH0Hno9vSjY50MylbUJLAmIoZC23S/axvogG2d1CL0K enPBiTkzTLBP3nTtgWi7ssYKJeK1xe4XSkBbMuXTnursN6JsjrCCrH80nZj4UkE+TQ7d sDUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:references :in-reply-to:subject:cc:to:from:dkim-signature; bh=L7QJ/f4bNLbu+zgtCVRouMzQLIb9HBj4OTPjr+5W3DQ=; b=L9a0ICXr11jhtWLqw6WyhNhXhDrbHRUBqRh7nSLjguN6xDEdPXBA49jrJVj7lDtZK6 HhI5SM8uyBRw5I2KE3AHFuLnDfjWg0cF2O/KwIf0iUqXgtTrwcu4u5TifB2UPESz3dFP oqUy1tbLEU0WwNHFNLJhBu03DnA0yjYjC6p4/jeTusFPntJE/PqfrSSSAxDFVvdmHZzn aooOAT5Y4WjtN0dM7SAZfkfKLKH2Wmbjzne6wm06yFKDOsNdnIZV7CE0DuQX9q8OI1HA jF+xAc5dPQC3FWZ8wFkPTkiAbPk8yeaGJxfZqs7yRZcdTH0V6arydiP7m7SZrYhl8hD2 iNfQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=BTau1aLS; 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 30si11615791otr.75.2020.01.15.16.39.30; Wed, 15 Jan 2020 16:39:43 -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; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=BTau1aLS; 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 S1731187AbgAOXs6 (ORCPT + 99 others); Wed, 15 Jan 2020 18:48:58 -0500 Received: from mail-pf1-f194.google.com ([209.85.210.194]:39304 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730395AbgAOXs5 (ORCPT ); Wed, 15 Jan 2020 18:48:57 -0500 Received: by mail-pf1-f194.google.com with SMTP id q10so9273983pfs.6 for ; Wed, 15 Jan 2020 15:48:57 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:in-reply-to:references:date:message-id :mime-version; bh=L7QJ/f4bNLbu+zgtCVRouMzQLIb9HBj4OTPjr+5W3DQ=; b=BTau1aLSM6XrFVbAH+llCS5d4H+w35zbbek1SIBSul6t2IoGnURs9KRucAaII9sIAA vzmCi3yFZcXsVxej1C/1WF4hUzQ0+OBzSVqoRcT9RfWZPUDIvh8ymfzXODzSzFAagVn4 NFVg/I20YGMksvLl8JG/RCdxGgq4bvo05sqEPbBqkkAVzLqoQ6IiwZjKbOebTDdczIm6 OX9M0LTO+0F47835owNuEjvvkSwrEmsa42vn/rkPqrtrT1GuneEFjPEjknBte3l1lPK7 TEkMxBfV2v0/G45kv0htZmEEdRhbt8oIAQYJEv8gPLfkH3vIGV3KmO40OXcBO/E/nkHz 0fNQ== 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:in-reply-to:references:date :message-id:mime-version; bh=L7QJ/f4bNLbu+zgtCVRouMzQLIb9HBj4OTPjr+5W3DQ=; b=VrRNr9hJY7PpOIrvWxT2G7fvUDNFCQR0zzQiaQ8UqwHwbl6/u6jM0oDPmsBZNuBfD4 p5dzTRj3SrVZUZKrD2Ihkp4rtQwR0ceoF99MLuAby6YB427aHEccp8+e660R5Y1hiVkV kxoJBf71DGQtOAiYw3NmC+ud5GdkjAxSFPfWz48aOCg8q4QsxuLVIvl/N1pQk/1B92vp OikqI9NzSUqxwYNYCxbF3+2aMuoyIOb4d/E8tPLoBT5rgZpY0Bz3t7kRdk4lloQT6G9+ youjO3igFAOY9xoA7hrrpF1kTUKoXiXaWxfxe/NKzGX4ci4IDI15XC2c6tWuOsWB1Rv+ 5JyA== X-Gm-Message-State: APjAAAUrkH3OXdqNDnmuyjOd+M1FDI7YPlLtqGQYeLnU6kXPoBSpp2rn TlNj7sV2JO9c5HD9tahltP4n9n2EP4cVPg== X-Received: by 2002:a63:214e:: with SMTP id s14mr35566633pgm.428.1579132136730; Wed, 15 Jan 2020 15:48:56 -0800 (PST) Received: from localhost ([2601:602:9200:a1a5:2952:4c53:16b9:8f97]) by smtp.gmail.com with ESMTPSA id j14sm21588497pgs.57.2020.01.15.15.48.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 15 Jan 2020 15:48:56 -0800 (PST) From: Kevin Hilman To: Geert Uytterhoeven , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: "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, Geert Uytterhoeven Subject: Re: [PATCH resend] mtd: maps: physmap: Add minimal Runtime PM support In-Reply-To: <20200115131323.6883-1-geert+renesas@glider.be> References: <20200115131323.6883-1-geert+renesas@glider.be> Date: Wed, 15 Jan 2020 15:48:53 -0800 Message-ID: <7hk15s9t7e.fsf@baylibre.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Geert Uytterhoeven writes: > 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: Kevin Hilman > --- > 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. Agreed. Without that, the BSC (in your example) will never get powered off as long as there's a flash device pobed. Kevin > --- > 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