Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp623044ybl; Fri, 24 Jan 2020 06:36:56 -0800 (PST) X-Google-Smtp-Source: APXvYqzXBYHdDGwM9O4gs0KYYcNN+MkgRSKLb72+KwFhjT4ucE4eluL8M8syxyC2tlUVD8ssDMMD X-Received: by 2002:a05:6808:2d2:: with SMTP id a18mr2222618oid.120.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=cToQy8G/wriQ3YbOD+d2/XeZg855XHFe4KISWpV096v8K9gxtaWtzj3rOGG36sErkR XbmaDlVdG6knrQE/gbKKcoRXAmM04I8dlpnAzex5fb4PvS3zavzcXcPIBO8DpZmWo+xf 55ZhG3amtNLR1nOwGRPW4P1Rh96FLK/B9qpF7Hf+7DEFHthrxlvgeVyt9WhTlQsNBpqC tG8K4/HeGWDI7CfZxpxODNyRqsS1NxCVAPrgu1wlPU86syXKRhDtSwF5dF+uV1Il5pHr TaqDP0ON8GuRwF3tCxhhK+auaHhlRUDWe5mvkIv9DfiDgY0rnQI/FwhYcA7oP4JBMfxy v16g== 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=DHlC0WLVyuuk0ft/rMGO6ZOozXP8jdVJ20kPwtNRKUQ=; b=G8dt4Nko5t7dqriZvcFcqyNKIzpbLns80BuXq5oH0pzkzF0mYtBrLfz7NrI52AhBdb /wVPMg6xGgMoqhr9kG+B158/ReXlAsMkp+zTBbiDBLLLTKlxEV3mzdTD94Muov8KBtYl IEiQrs6VE7vzfFK/fuUhBW1eZeiDB57h4eNAbfe9bIaWSxA/E78gng7mUcnF6+8sgHmd 1kGq6RSdWiiruxagU3ufK12zyhRsFotN/wU0nxHlx/eXJ31+BKVL1DJvqY992HfxoUu0 kWiY4vUOG6ZA0h6nh8JZzhu6sKkExG4ztEcocYhtW3mZ13YUCM92N6V5D+BLCgRqnRDp SbyA== 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 r10si2822283otn.241.2020.01.24.06.36.37; 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 S2389683AbgAXNaV (ORCPT + 99 others); Fri, 24 Jan 2020 08:30:21 -0500 Received: from michel.telenet-ops.be ([195.130.137.88]:37542 "EHLO michel.telenet-ops.be" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389641AbgAXNaU (ORCPT ); Fri, 24 Jan 2020 08:30:20 -0500 Received: from ramsan ([84.195.182.253]) by michel.telenet-ops.be with bizsmtp id uDW42100L5USYZQ06DW4cs; Fri, 24 Jan 2020 14:30:18 +0100 Received: from rox.of.borg ([192.168.97.57]) by ramsan with esmtp (Exim 4.90_1) (envelope-from ) id 1iuz2C-0007bK-ED; 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-00047E-CN; 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 2/2] crypto: ccree - fix debugfs register access while suspended Date: Fri, 24 Jan 2020 14:29:57 +0100 Message-Id: <20200124132957.15769-3-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 Reading the debugfs files under /sys/kernel/debug/ccree/ can be done by the user at any time. On R-Car SoCs, the CCREE device is power-managed using a moduile clock, and if this clock is not running, bogus register values may be read. Fix this by filling in the debugfs_regset32.dev field, so debugfs will make sure the device is resumed while its registers are being read. This fixes the bogus values (0x00000260) in the register dumps on R-Car H3 ES1.0: -e6601000.crypto/regs:HOST_IRR = 0x00000260 -e6601000.crypto/regs:HOST_POWER_DOWN_EN = 0x00000260 +e6601000.crypto/regs:HOST_IRR = 0x00000038 +e6601000.crypto/regs:HOST_POWER_DOWN_EN = 0x00000038 e6601000.crypto/regs:AXIM_MON_ERR = 0x00000000 e6601000.crypto/regs:DSCRPTR_QUEUE_CONTENT = 0x000002aa -e6601000.crypto/regs:HOST_IMR = 0x00000260 +e6601000.crypto/regs:HOST_IMR = 0x017ffeff e6601000.crypto/regs:AXIM_CFG = 0x001f0007 e6601000.crypto/regs:AXIM_CACHE_PARAMS = 0x00000000 -e6601000.crypto/regs:GPR_HOST = 0x00000260 +e6601000.crypto/regs:GPR_HOST = 0x017ffeff e6601000.crypto/regs:AXIM_MON_COMP = 0x00000000 -e6601000.crypto/version:SIGNATURE = 0x00000260 -e6601000.crypto/version:VERSION = 0x00000260 +e6601000.crypto/version:SIGNATURE = 0xdcc63000 +e6601000.crypto/version:VERSION = 0xaf400001 Note that this behavior is system-dependent, and the issue does not show up on all R-Car Gen3 SoCs and boards. Even when the device is suspended, the module clock may be left enabled, if configured by the firmware for Secure Mode, or when controlled by the Real-Time Core. Signed-off-by: Geert Uytterhoeven --- drivers/crypto/ccree/cc_debugfs.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/crypto/ccree/cc_debugfs.c b/drivers/crypto/ccree/cc_debugfs.c index 5669997386988055..35f3a2137502bd96 100644 --- a/drivers/crypto/ccree/cc_debugfs.c +++ b/drivers/crypto/ccree/cc_debugfs.c @@ -81,6 +81,7 @@ int cc_debugfs_init(struct cc_drvdata *drvdata) regset->regs = debug_regs; regset->nregs = ARRAY_SIZE(debug_regs); regset->base = drvdata->cc_base; + regset->dev = dev; ctx->dir = debugfs_create_dir(drvdata->plat_dev->name, cc_debugfs_dir); @@ -102,6 +103,7 @@ int cc_debugfs_init(struct cc_drvdata *drvdata) verset->nregs = ARRAY_SIZE(pid_cid_regs); } verset->base = drvdata->cc_base; + verset->dev = dev; debugfs_create_regset32("version", 0400, ctx->dir, verset); -- 2.17.1