Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp623043ybl; Fri, 24 Jan 2020 06:36:56 -0800 (PST) X-Google-Smtp-Source: APXvYqxELAZn1aYGXDRtSpEigbs1YPQSTj717ybEwf8nqQEU/+BaSToufBJEImqsGvg3SbHpnd0D X-Received: by 2002:aca:1a05:: with SMTP id a5mr2229743oia.97.1579876616556; Fri, 24 Jan 2020 06:36:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1579876616; cv=none; d=google.com; s=arc-20160816; b=PMREpcHbM7ug+mdHScPjgbL+9I8DB6HU2XCa/K+z7hwzDW+tSeSZ76LSNseDr1wbNJ ebq63WoIGEi4Etk3B7w2qmSVNqcrZafgQYwzYp8gODwuK0uL5DBlMkHwN/2tQQDYJud9 RsCsItOwYD3bpijxvurWAXQ3taDetr/y/atoBEvankj2HKv7AR7moBRY5YXEs+rNUDdF PAlA104WhRX6Sh3wvQ50/pPD2MpkVOw6AgV2Ppktbm6cZ8nhn/ECQ1sCaV3wYQfrtlQW Z0VOYW3nAvljeyQyTz7isNBhZYr6NJlnp8eiXVRsmIumfIuPCjbga7RPogDi68oYE3Ci Yl/g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=qdrJ6tbTX3VoABMYLxkKLPbZh2D2Hi+CnUyhhH0OxxA=; b=0iaf4tq205SzO5Wq+4yfxvsb7/blSFtDaKZybZBfjj1W6lFUN3VDkydEBs5vYbnRk2 GcoKbRXELR2/IvKzoWm6vsFmY3pZIXlGwBTylLHpNVYLyoYFjt8S4Rm/NT6xMeuc+QxG ZTHQoANLxc6TvbsZ9sr0OoiVdkSdyoe+IvpeY1N6hWEJGthXmm3UmJVPVwsMbqIlRGrf qsEkcAvgQIocoR4fbN6hbQ988uwCM4tk8YZAbY7XjgLvS70VR6Vwo3BUcMfLbUXb+knU wnMiV7yM1Zf1KwyOGdE/BcLPR0zvkOn31ZiXTP4RAuSHbO8riulN2XMPgDouKaWNvEpR w1rA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-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 z18si3109376otq.121.2020.01.24.06.36.34; Fri, 24 Jan 2020 06:36:56 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-crypto-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-crypto-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389644AbgAXNaT (ORCPT + 99 others); Fri, 24 Jan 2020 08:30:19 -0500 Received: from albert.telenet-ops.be ([195.130.137.90]:56144 "EHLO albert.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389542AbgAXNaT (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-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@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 --- 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; -- 2.17.1