Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp5327599ybv; Tue, 11 Feb 2020 13:35:35 -0800 (PST) X-Google-Smtp-Source: APXvYqzci9bIqfVnzkZqzM2F3bjDOf6G1DJI+HIGjRTeO8iFPULda9aJfgyuJXT0LsdodJHIiEPu X-Received: by 2002:a9d:774e:: with SMTP id t14mr6714988otl.358.1581456935782; Tue, 11 Feb 2020 13:35:35 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581456935; cv=none; d=google.com; s=arc-20160816; b=VN8yY3CbMlMElCqSzSaJi9fbIa5gqF3ErL6ADZJtOxPmf68ioqtLxiIvuamYz2tkzh NhMXBoeqCrRw06smuA+iz6gWy6xa7cTGOJ8UGh8WAtbx2RLKvR/4dX5gzfYDu009aqAZ b5aSTGsddgbwr0z9G6tGibcb740i2zU1vKWdWH9XE4ECQkLHTOWGNjGZ0sQoznIiUaJ0 yHz3v5O/puLinkhVprGDcoHic7jkQ1F51rZei7J4ELbo7PCOFA2WBEBAu095zsMXVjI8 qjd0BNM25X2sgAFPwrXjVTWbVcwCB/E+l2iQtfo025JOQ9ZGC/EHlJlyp0PwB9KECw0s cvHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=yEIoqOjcMx8sukXeqJRSXXftILHtzIu3Oy/GTvCJHW0=; b=uYoW8tAR1o89W0hplo/dz4Q1yPjzUEMBpMQXUvdVili8MYDgsB+NENCdHNudJI5kyD wUm5VNrgw5CrFtYW94kzAKatLOzgdxTHJ2G1Z/Nmt1BbUFE1lUgcG1xK5XPnkQNHLrKR OFufqp99WN88AhJdagnAjJhvXv6qavj85Lrx2GBS24GIvy9VimzSSepQgc2qd0CBGjb2 IVcpk7+MUs4YftUrIHJCa9secAr5uM8mOxLe1G91PUs7K+LEJu8bT8dVrnZmWC4CguNN vXZBcsyMhkImiA8+zJqCRoGyeLQRgfZ2zLZnTPJ6QsyKl7fmYghUik2zUzbdwl0okTBd gNhw== 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 w4si2648862otl.214.2020.02.11.13.35.24; Tue, 11 Feb 2020 13:35:35 -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 S1731377AbgBKSV3 (ORCPT + 99 others); Tue, 11 Feb 2020 13:21:29 -0500 Received: from laurent.telenet-ops.be ([195.130.137.89]:44994 "EHLO laurent.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730122AbgBKSTc (ORCPT ); Tue, 11 Feb 2020 13:19:32 -0500 Received: from ramsan ([84.195.182.253]) by laurent.telenet-ops.be with bizsmtp id 1WKV2200K5USYZQ01WKV3C; Tue, 11 Feb 2020 19:19:30 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1j1a89-0002nb-Ar; Tue, 11 Feb 2020 19:19:29 +0100 Received: from geert by rox.of.borg with local (Exim 4.90_1) (envelope-from ) id 1j1a89-0003y7-9j; Tue, 11 Feb 2020 19:19:29 +0100 From: Geert Uytterhoeven To: Gilad Ben-Yossef , Herbert Xu , "David S . Miller" Cc: Greg Kroah-Hartman , "Rafael J . Wysocki" , linux-crypto@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org, Geert Uytterhoeven Subject: [PATCH v2 01/34] debugfs: regset32: Add Runtime PM support Date: Tue, 11 Feb 2020 19:18:55 +0100 Message-Id: <20200211181928.15178-2-geert+renesas@glider.be> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200211181928.15178-1-geert+renesas@glider.be> References: <20200211181928.15178-1-geert+renesas@glider.be> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 lock-ups. 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 Reviewed-by: Niklas Söderlund Reviewed-by: Greg Kroah-Hartman Acked-by: Rafael J. Wysocki --- Affected drivers: - drivers/crypto/ccree (fixed) - drivers/gpu/drm/msm/disp/dpu1 - drivers/usb/dwc3 - drivers/usb/host/ehci-omap.c - drivers/usb/host/ehci-tegra.c - drivers/usb/host/ohci-platform.c - drivers/usb/host/xhci-dbgcap.c - drivers/usb/host/xhci-histb.c - drivers/usb/host/xhci-hub.c - drivers/usb/host/xhci-mtk.c - drivers/usb/host/xhci-pci.c - drivers/usb/host/xhci-tegra.c - drivers/usb/host/xhci.c - drivers/usb/mtu3 - drivers/usb/musb drivers/usb/host/xhci-plat.c Some drivers call pm_runtime_forbid(), but given the comment "users should enable runtime pm using power/control in sysfs", this can be overridden from userspace? v2: - Add Reviewed-by, Acked-by, - s/locks/lock-ups/. --- 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 634b09d18b77f46f..204734f8d1c6d648 100644 --- a/fs/debugfs/file.c +++ b/fs/debugfs/file.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include @@ -1060,7 +1061,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 3d013de64f70ec42..ad416853e722fca7 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