Received: by 2002:ab2:7903:0:b0:1fb:b500:807b with SMTP id a3csp930114lqj; Mon, 3 Jun 2024 05:32:10 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWdcWC9MRGkUNUoU0P2oaDrbOxb/xLgapzwZ+iL6qdxyfi0FCfL1nIzI1zHMsO75dYgnbk89bJdlceebErQRNYg6vZ5JeVzzUpHAWPXGw== X-Google-Smtp-Source: AGHT+IGJ5bSTO+SH5Ea38bBwx6jDigP6rNF41P26RGIXq5Q3fp0tK0uv+O+EC6Q/SY/eKkgf0wAW X-Received: by 2002:a05:620a:9c6:b0:792:c0b7:8eb8 with SMTP id af79cd13be357-794f5cd45e6mr973782985a.61.1717417930274; Mon, 03 Jun 2024 05:32:10 -0700 (PDT) Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id af79cd13be357-794f2f05911si826316985a.151.2024.06.03.05.32.10 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 03 Jun 2024 05:32:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-199112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@OUTLOOK.COM.AU header.s=selector1 header.b=MWGe5PeM; arc=fail (signature failed); spf=pass (google.com: domain of linux-kernel+bounces-199112-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-199112-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=outlook.com.au Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id E1CDF1C23CC2 for ; Mon, 3 Jun 2024 12:32:09 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8210212C473; Mon, 3 Jun 2024 12:32:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=OUTLOOK.COM.AU header.i=@OUTLOOK.COM.AU header.b="MWGe5PeM" Received: from AUS01-SY4-obe.outbound.protection.outlook.com (mail-sy4aus01olkn2176.outbound.protection.outlook.com [40.92.62.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9CFD8060D; Mon, 3 Jun 2024 12:31:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=40.92.62.176 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717417921; cv=fail; b=taAjcJPqbX/OhQBjI/o5Ylx3/s+urAGqyG5pVX1jKkOWNSTpt7p5hpqNSdhTxdo7Cy4DVhS0u7l/WZs0DzodDWEznbeHruibWMDFobeIlvLbminASnYRAyovEmFcjiNMwZiVjxmjxAbU/PDtOqZZpAzqPGkPEZxqdJCmvL8ogHg= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1717417921; c=relaxed/simple; bh=JbCtl178Sb4OKM7R04qsA6KleFuUPQxilHm1z46IxQM=; h=Message-ID:Date:Subject:To:Cc:References:From:In-Reply-To: Content-Type:MIME-Version; b=XHyAXj5lKgr2d7Y/2veUpw7y4mO7jUOh2tNBTp1lC1N+5lhj0UjJTBrpqXmJeKAOCUpWH7i20GGIJ7ZHa7AYy66u2OmFGozWyKbBLPtmVPy6HH0MByNYgRtr8Y4/iz0f0Q9n63aLLyJmE+KxQHai86hKiUkvnHMHvK1UPhZkE3A= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com.au; spf=pass smtp.mailfrom=outlook.com.au; dkim=pass (2048-bit key) header.d=OUTLOOK.COM.AU header.i=@OUTLOOK.COM.AU header.b=MWGe5PeM; arc=fail smtp.client-ip=40.92.62.176 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=outlook.com.au Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=outlook.com.au ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=emKlwN8ptZ1XadpLr7qrnRAoOqN5ZtjjwVo71SRKh+DHptOJ8Hmcyuy2LzyIktIvdKRsM0Asbo5ZrmEVB056jOr2nZU2Wuj24KfWwpU5D+g3fbet5Ni1frajXvVsOw2PDivQlArjdVjvDw2bGTYti/4tylKg5miFV2z95EEym06wp/d7LsOJHSYvVnadUQgXkrENc1KMohblqmUapJjYjWqRJ0dPA0ZnyURQWw1L8aB2pa+wFnhDdP5lRDQdh/2c1ItpdGyD7zBW4XnyqCPnO9ml1k8Jy8Yu1AB4JTKqm2Z5/VhzTPEVNC4eY6KRFc5CuomVlyGK+C6OWc+dK3+hLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=mPZ9AhXQOPpv11GjrYqc+CLAJ54dgjbr5HJKAD89fRU=; b=cRMWWeQjCekhmB7Jd4JOzPmwwMkbzauM/+drUJDWcF1EEdpmAzMgShZoxGmjUIyNYJXDubcdQAgqhSJDx8IeWZzNXAluAuG/83jlg2zQk0kIsoNlZrGe4lO5aroEiHpoABRK0PWnvKXKsJEM7PNAdMAPCVja1NQyjQRutHguAugEGgJE13tesR6ahV3A7d9mQQHYJujWuTylHejt/fi7IiB4CUL1XrZpE+p2lH7SzYGJ8BBw7cz1n4buhlad9VmOkO7x617TdZJQk6gAVrm1B2gFNxr8svLs/U+v/BIjOEW5MOZWUM3epPUkgnRuXIeeble88VAUjKKoR4PKq1NL4g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=none; dmarc=none; dkim=none; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=OUTLOOK.COM.AU; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=mPZ9AhXQOPpv11GjrYqc+CLAJ54dgjbr5HJKAD89fRU=; b=MWGe5PeMGq4lCTrI6tLxvkLKp32rbLIdKYmeA7GzRV/aZH60srmIx7+tnTCXXsjDIhNlSj2eAoSqQuLzBGytidF7DlDZCFkZBzJ51Olz+e8G+5MmaA9tpws1OfQimuk32vyWhwa1zsxxpT7AEhSfF413SbgqrNnYtZ8KS7GslcaAMCWFeT7PHM8SkDAbsacoE2jWtpDwOydpqtWwvh4tIbweTSaVyfQBPUCpjOszVeaaal65AlPRtqBopEW+xgods+8Mb3t4P0OuFQqz4FwAJPaZHNb8Yg1Ojc6pmIasVIJVo3h/nO26btpYVKybf8T+W/zB3aD5egarKZopGDXDZA== Received: from SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:159::9) by ME0P282MB4880.AUSP282.PROD.OUTLOOK.COM (2603:10c6:220:228::8) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7409.46; Mon, 3 Jun 2024 12:31:53 +0000 Received: from SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM ([fe80::37cc:3733:d1e9:d8e4]) by SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM ([fe80::37cc:3733:d1e9:d8e4%3]) with mapi id 15.20.7633.021; Mon, 3 Jun 2024 12:31:53 +0000 Message-ID: Date: Mon, 3 Jun 2024 22:31:50 +1000 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH RFT v3 3/4] hwmon: (spd5118) Add suspend/resume support To: Guenter Roeck , linux-hwmon@vger.kernel.org Cc: devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , Conor Dooley , linux-kernel@vger.kernel.org, Armin Wolf , =?UTF-8?Q?Thomas_Wei=C3=9Fschuh?= , =?UTF-8?Q?Ren=C3=A9_Rebe?= , Wolfram Sang References: <20240531230556.1409532-1-linux@roeck-us.net> <20240531230556.1409532-4-linux@roeck-us.net> Content-Language: en-AU, en-US, en-GB From: Stephen Horvath In-Reply-To: <20240531230556.1409532-4-linux@roeck-us.net> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-TMN: [vDfmsyOYtmOU0t3nkPUJQQRdNkxsCPsQrcfsYd/EWjdDMnUjEd+fPdFVhdbiklidD4ZXHI+CKB8=] X-ClientProxiedBy: SY5P282CA0192.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:249::18) To SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM (2603:10c6:10:159::9) X-Microsoft-Original-Message-ID: <8884b0f5-17fb-4e40-ba78-375e1637a496@outlook.com.au> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SY4P282MB3063:EE_|ME0P282MB4880:EE_ X-MS-Office365-Filtering-Correlation-Id: 8e3d50cb-8164-4009-9429-08dc83c925f9 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: uSLmJFy5ScjcBU6yxKFLgba9ZrHUACdcABe9Qidd5GXolV67mNEZXr4aPwMD5DeIUpBmvSeX8ex5cS8xu4SdTDNuPxbHMTsTtFUU1SEq1uFcn/FFbuNAhI3bGfRwnezg5RE1ZcxyrEB9UiQvDKsULxqB6zArHX8Z9Pmbm1hsXZu8dO09PeT85Rj/AomPtpg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FWOXdNUGNMQlR1TkFvNGJGRkV2d3pTSFZoREsv?= =?utf-8?B?T281b2dWemRxcEIrQm1VdG5EZ2QrbFR1V0NXT2owTWlYRENYL05WNTllSFcx?= =?utf-8?B?Z0lnRFVJazVIcUh0WVZtSGpNeWJOYXhuQTdYejE3UDJuOXA0cmtLcnJCYXpa?= =?utf-8?B?SGx1bytESHR2ZjFxQktEbE14RGVXbjg2QWZTc3EzNktTVWpyYWNWeVpqVERL?= =?utf-8?B?WXdHMks5N3NiTWNyRDFtUGZwNTFWU2FyejV6Qlk1RjRKSXVWTmwrejN5cEEw?= =?utf-8?B?M2gyWU5NdkRxVHZONXFheXdnZnJaU3U5aWJWdDJTdklXSFJvNkpINGRldGtY?= =?utf-8?Q?dElEu7Ht3ef067mnyLDNuQMIPwhrxHM7w0ugK1u?= X-OriginatorOrg: sct-15-20-4755-11-msonline-outlook-746f3.templateTenant X-MS-Exchange-CrossTenant-Network-Message-Id: 8e3d50cb-8164-4009-9429-08dc83c925f9 X-MS-Exchange-CrossTenant-AuthSource: SY4P282MB3063.AUSP282.PROD.OUTLOOK.COM X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 Jun 2024 12:31:53.1344 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 84df9e7f-e9f6-40af-b435-aaaaaaaaaaaa X-MS-Exchange-CrossTenant-RMS-PersistedConsumerOrg: 00000000-0000-0000-0000-000000000000 X-MS-Exchange-Transport-CrossTenantHeadersStamped: ME0P282MB4880 Hi, On 1/6/24 09:05, Guenter Roeck wrote: > Add suspend/resume support to ensure that limit and configuration > registers are updated and synchronized after a suspend/resume cycle. > > Cc: Armin Wolf > Signed-off-by: Guenter Roeck > --- > v3: No change > > v2: New patch > > RFT: I tested the patch through a suspend/resume cycle, and it seems > to work, but I am not sure if that had any effect because, > after all, the memory is still active during suspend/resume. > I was unable to test a hibernation cycle with my system. > For me, the driver just reports 0°C after suspend/resume, but works fine beforehand, tested on both my desktop and laptop, with kernel 6.9.3 and 6.10.0-rc2 (on the laptop only). Hibernation does seem to work fine though (at least on 6.9.3). > drivers/hwmon/spd5118.c | 29 +++++++++++++++++++++++++++++ > 1 file changed, 29 insertions(+) > > diff --git a/drivers/hwmon/spd5118.c b/drivers/hwmon/spd5118.c > index d3fc0ae17743..baa315172298 100644 > --- a/drivers/hwmon/spd5118.c > +++ b/drivers/hwmon/spd5118.c > @@ -20,6 +20,7 @@ > #include > #include > #include > +#include > #include > #include > > @@ -432,6 +433,8 @@ static int spd5118_probe(struct i2c_client *client) > if (!spd5118_vendor_valid(bank, vendor)) > return -ENODEV; > > + dev_set_drvdata(dev, regmap); > + > hwmon_dev = devm_hwmon_device_register_with_info(dev, "spd5118", > regmap, &spd5118_chip_info, > NULL); > @@ -449,6 +452,31 @@ static int spd5118_probe(struct i2c_client *client) > return 0; > } > > +static int spd5118_suspend(struct device *dev) > +{ > + struct regmap *regmap = dev_get_drvdata(dev); > + > + regcache_cache_bypass(regmap, true); > + regmap_update_bits(regmap, SPD5118_REG_TEMP_CONFIG, SPD5118_TS_DISABLE, > + SPD5118_TS_DISABLE); > + regcache_cache_bypass(regmap, false); > + > + regcache_cache_only(regmap, true); > + regcache_mark_dirty(regmap); > + > + return 0; > +} > + > +static int spd5118_resume(struct device *dev) > +{ > + struct regmap *regmap = dev_get_drvdata(dev); > + > + regcache_cache_only(regmap, false); Adding something like this fixes the readings after resume for me: regmap_update_bits(regmap, SPD5118_REG_TEMP_CONFIG, SPD5118_TS_DISABLE, 0); But that was just the naive solution I thought of. > + return regcache_sync(regmap); > +} > + > +static DEFINE_SIMPLE_DEV_PM_OPS(spd5118_pm_ops, spd5118_suspend, spd5118_resume); > + > static const struct i2c_device_id spd5118_id[] = { > { "spd5118", 0 }, > { } > @@ -466,6 +494,7 @@ static struct i2c_driver spd5118_driver = { > .driver = { > .name = "spd5118", > .of_match_table = spd5118_of_ids, > + .pm = pm_sleep_ptr(&spd5118_pm_ops), > }, > .probe = spd5118_probe, > .id_table = spd5118_id, For reference: I believe both my devices also have Montage Technology M88SPD5118 chips; the desktop has Kingston KF560C36-32 RAM, the laptop has Crucial CT16G56C46S5. Thanks, Steve