Skip to content

Commit d5a1c7e

Browse files
bp3tk0vjohnstultz-work
authored andcommitted
rtc-cmos: Add an alarm disable quirk
41c7f74 ("rtc: Disable the alarm in the hardware (v2)") added the functionality to disable the RTC wake alarm when shutting down the box. However, there are at least two b0rked BIOSes we know about: https://bugzilla.novell.com/show_bug.cgi?id=812592 https://bugzilla.novell.com/show_bug.cgi?id=805740 where, when wakeup alarm is enabled in the BIOS, the machine reboots automatically right after shutdown, regardless of what wakeup time is programmed. Bisecting the issue lead to this patch so disable its functionality with a DMI quirk only for those boxes. Cc: Brecht Machiels <brecht@mos6581.org> Cc: Thomas Gleixner <tglx@linutronix.de> Cc: John Stultz <john.stultz@linaro.org> Cc: Rabin Vincent <rabin.vincent@stericsson.com> Cc: stable <stable@vger.kernel.org> Signed-off-by: Borislav Petkov <bp@suse.de> [jstultz: Changed variable name for clarity, added extra dmi entry] Tested-by: Brecht Machiels <brecht@mos6581.org> Tested-by: Borislav Petkov <bp@suse.de> Signed-off-by: John Stultz <john.stultz@linaro.org>
1 parent d26e4fe commit d5a1c7e

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

drivers/rtc/rtc-cmos.c

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@
3434
#include <linux/interrupt.h>
3535
#include <linux/spinlock.h>
3636
#include <linux/platform_device.h>
37-
#include <linux/mod_devicetable.h>
3837
#include <linux/log2.h>
3938
#include <linux/pm.h>
4039
#include <linux/of.h>
4140
#include <linux/of_platform.h>
41+
#include <linux/dmi.h>
4242

4343
/* this is for "generic access to PC-style RTC" using CMOS_READ/CMOS_WRITE */
4444
#include <asm-generic/rtc.h>
@@ -377,6 +377,51 @@ static int cmos_set_alarm(struct device *dev, struct rtc_wkalrm *t)
377377
return 0;
378378
}
379379

380+
/*
381+
* Do not disable RTC alarm on shutdown - workaround for b0rked BIOSes.
382+
*/
383+
static bool alarm_disable_quirk;
384+
385+
static int __init set_alarm_disable_quirk(const struct dmi_system_id *id)
386+
{
387+
alarm_disable_quirk = true;
388+
pr_info("rtc-cmos: BIOS has alarm-disable quirk. ");
389+
pr_info("RTC alarms disabled\n");
390+
return 0;
391+
}
392+
393+
static const struct dmi_system_id rtc_quirks[] __initconst = {
394+
/* https://bugzilla.novell.com/show_bug.cgi?id=805740 */
395+
{
396+
.callback = set_alarm_disable_quirk,
397+
.ident = "IBM Truman",
398+
.matches = {
399+
DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
400+
DMI_MATCH(DMI_PRODUCT_NAME, "4852570"),
401+
},
402+
},
403+
/* https://bugzilla.novell.com/show_bug.cgi?id=812592 */
404+
{
405+
.callback = set_alarm_disable_quirk,
406+
.ident = "Gigabyte GA-990XA-UD3",
407+
.matches = {
408+
DMI_MATCH(DMI_SYS_VENDOR,
409+
"Gigabyte Technology Co., Ltd."),
410+
DMI_MATCH(DMI_PRODUCT_NAME, "GA-990XA-UD3"),
411+
},
412+
},
413+
/* http://permalink.gmane.org/gmane.linux.kernel/1604474 */
414+
{
415+
.callback = set_alarm_disable_quirk,
416+
.ident = "Toshiba Satellite L300",
417+
.matches = {
418+
DMI_MATCH(DMI_SYS_VENDOR, "TOSHIBA"),
419+
DMI_MATCH(DMI_PRODUCT_NAME, "Satellite L300"),
420+
},
421+
},
422+
{}
423+
};
424+
380425
static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
381426
{
382427
struct cmos_rtc *cmos = dev_get_drvdata(dev);
@@ -385,6 +430,9 @@ static int cmos_alarm_irq_enable(struct device *dev, unsigned int enabled)
385430
if (!is_valid_irq(cmos->irq))
386431
return -EINVAL;
387432

433+
if (alarm_disable_quirk)
434+
return 0;
435+
388436
spin_lock_irqsave(&rtc_lock, flags);
389437

390438
if (enabled)
@@ -1157,6 +1205,8 @@ static int __init cmos_init(void)
11571205
platform_driver_registered = true;
11581206
}
11591207

1208+
dmi_check_system(rtc_quirks);
1209+
11601210
if (retval == 0)
11611211
return 0;
11621212

0 commit comments

Comments
 (0)