lkml.org 
[lkml]   [2012]   [May]   [24]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH] x86: clear HPET configuration registers on startup
On Mon, 2 Apr 2012, Jan Beulich wrote:

Sorry for ignoring this for so long.

> + cfg = hpet_readl(HPET_CFG);
> + hpet_boot_cfg = kmalloc((last + 2) * sizeof(*hpet_boot_cfg),
> + GFP_KERNEL);
> + if (hpet_boot_cfg)
> + *hpet_boot_cfg = cfg;
> + else
> + pr_warn("HPET initial state will not be saved\n");
> + cfg &= ~(HPET_CFG_ENABLE | HPET_CFG_LEGACY);
> + hpet_writel(cfg, HPET_Tn_CFG(i));

This wants to be

> + hpet_writel(cfg, HPET_CFG);

Right ?

You would have noticed if that code would have run on an AMD SB700
based machine and i would have been != 0 :)

> + if (cfg)
> + pr_warn("HPET: Unrecognized bits %#x set in global cfg\n",
> + cfg);
> +
> + for (i = 0; i <= last; ++i) {
> + cfg = hpet_readl(HPET_Tn_CFG(i));
> + if (hpet_boot_cfg)
> + hpet_boot_cfg[i + 1] = cfg;
> + cfg &= ~(HPET_TN_ENABLE | HPET_TN_LEVEL | HPET_TN_FSB);
> + hpet_writel(cfg, HPET_Tn_CFG(i));
> + cfg &= ~(HPET_TN_PERIODIC | HPET_TN_PERIODIC_CAP
> + | HPET_TN_64BIT_CAP | HPET_TN_32BIT | HPET_TN_ROUTE
> + | HPET_TN_FSB | HPET_TN_FSB_CAP);
> + if (cfg)
> + pr_warn("HPET: Unrecognized bits %#x set in cfg#%u\n",
> + cfg, i);
> + }
> + hpet_print_config();
> +
> if (hpet_clocksource_register())
> goto out_nohpet;
>
> @@ -923,14 +952,28 @@ fs_initcall(hpet_late_init);
> void hpet_disable(void)
> {
> if (is_hpet_capable() && hpet_virt_address) {
> - unsigned int cfg = hpet_readl(HPET_CFG);
> + unsigned int cfg = hpet_readl(HPET_CFG), id, last;
>
> - if (hpet_legacy_int_enabled) {
> + if (hpet_boot_cfg)
> + cfg = *hpet_boot_cfg;

That restores the setting which you recorded at init time. Why do you
want to do that? There is no point to restore to an eventually borked
state. If we shut down the thing, then we better leave it in a
consistent state rather than something dubious, really.

Thanks,

tglx


\
 
 \ /
  Last update: 2012-05-25 00:41    [W:0.074 / U:0.784 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site