Skip to content

Commit 0560204

Browse files
committed
PM: base: power: don't try to use non-existing RTC for storing data
If there is no legacy RTC device, don't try to use it for storing trace data across suspend/resume. Cc: <stable@vger.kernel.org> Signed-off-by: Juergen Gross <jgross@suse.com> Reviewed-by: Rafael J. Wysocki <rafael@kernel.org> Link: https://lore.kernel.org/r/20210903084937.19392-2-jgross@suse.com Signed-off-by: Juergen Gross <jgross@suse.com>
1 parent 8480ed9 commit 0560204

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

drivers/base/power/trace.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
#include <linux/export.h>
1414
#include <linux/rtc.h>
1515
#include <linux/suspend.h>
16+
#include <linux/init.h>
1617

1718
#include <linux/mc146818rtc.h>
1819

@@ -165,6 +166,9 @@ void generate_pm_trace(const void *tracedata, unsigned int user)
165166
const char *file = *(const char **)(tracedata + 2);
166167
unsigned int user_hash_value, file_hash_value;
167168

169+
if (!x86_platform.legacy.rtc)
170+
return;
171+
168172
user_hash_value = user % USERHASH;
169173
file_hash_value = hash_string(lineno, file, FILEHASH);
170174
set_magic_time(user_hash_value, file_hash_value, dev_hash_value);
@@ -267,6 +271,9 @@ static struct notifier_block pm_trace_nb = {
267271

268272
static int __init early_resume_init(void)
269273
{
274+
if (!x86_platform.legacy.rtc)
275+
return 0;
276+
270277
hash_value_early_read = read_magic_time();
271278
register_pm_notifier(&pm_trace_nb);
272279
return 0;
@@ -277,6 +284,9 @@ static int __init late_resume_init(void)
277284
unsigned int val = hash_value_early_read;
278285
unsigned int user, file, dev;
279286

287+
if (!x86_platform.legacy.rtc)
288+
return 0;
289+
280290
user = val % USERHASH;
281291
val = val / USERHASH;
282292
file = val % FILEHASH;

0 commit comments

Comments
 (0)