From patchwork Fri Jan 24 13:29:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Geert Uytterhoeven X-Patchwork-Id: 11350315 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 19F39924 for ; Fri, 24 Jan 2020 13:30:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 025882075D for ; Fri, 24 Jan 2020 13:30:34 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389856AbgAXNaa (ORCPT ); Fri, 24 Jan 2020 08:30:30 -0500 Received: from albert.telenet-ops.be ([195.130.137.90]:56142 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389540AbgAXNaT (ORCPT ); Fri, 24 Jan 2020 08:30:19 -0500 Received: from ramsan ([84.195.182.253]) by albert.telenet-ops.be with bizsmtp id uDW42100T5USYZQ06DW4VA; Fri, 24 Jan 2020 14:30:17 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1iuz2C-0007bH-D3; Fri, 24 Jan 2020 14:30:04 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1iuz2C-00047C-Ba; Fri, 24 Jan 2020 14:30:04 +0100 From: Geert Uytterhoeven To: Greg Kroah-Hartman , Gilad Ben-Yossef , Herbert Xu , "David S . Miller" , "Rafael J . Wysocki" Cc: Rob Clark , Sean Paul , Felipe Balbi , Alan Stern , Thierry Reding , Jonathan Hunter , Mathias Nyman , Matthias Brugger , Chunfeng Yun , Bin Liu , linux-crypto@vger.kernel.org, linux-pm@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH 1/2] debugfs: regset32: Add Runtime PM support Date: Fri, 24 Jan 2020 14:29:56 +0100 Message-Id: <20200124132957.15769-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200124132957.15769-1-geert+renesas@glider.be> References: <20200124132957.15769-1-geert+renesas@glider.be> Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org Hardware registers of devices under control of power management cannot be accessed at all times. If such a device is suspended, register accesses may lead to undefined behavior, like reading bogus values, or causing exceptions or system locks. Extend struct debugfs_regset32 with an optional field to let device drivers specify the device the registers in the set belong to. This allows debugfs_show_regset32() to make sure the device is resumed while its registers are being read. Signed-off-by: Geert Uytterhoeven Acked-by: Rafael J. Wysocki Reviewed-by: Greg Kroah-Hartman --- fs/debugfs/file.c | 8 ++++++++ include/linux/debugfs.h | 1 + 2 files changed, 9 insertions(+) diff --git a/fs/debugfs/file.c b/fs/debugfs/file.c index dede25247b81f72a..5e52d68421c678f2 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -1057,7 +1058,14 @@ static int debugfs_show_regset32(struct seq_file *s, void *data) { struct debugfs_regset32 *regset = s->private; + if (regset->dev) + pm_runtime_get_sync(regset->dev); + debugfs_print_regs32(s, regset->regs, regset->nregs, regset->base, ""); + + if (regset->dev) + pm_runtime_put(regset->dev); + return 0; } diff --git a/include/linux/debugfs.h b/include/linux/debugfs.h index bf9b6cafa4c26a68..5d0783ae09f365ac 100644 --- a/include/linux/debugfs.h +++ b/include/linux/debugfs.h @@ -35,6 +35,7 @@ struct debugfs_regset32 { const struct debugfs_reg32 *regs; int nregs; void __iomem *base; + struct device *dev; /* Optional device for Runtime PM */ }; extern struct dentry *arch_debugfs_dir;