mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jordan Crouse <jordan.crouse@amd.com>
To: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>
Cc: Andres Salomon <dilinger@debian.org>,
	linux-geode@bombadil.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: MFGPT driver inhibits boot on some boards
Date: Fri, 1 Aug 2008 10:00:26 -0600	[thread overview]
Message-ID: <20080801160026.GB19184@cosmic.amd.com> (raw)
In-Reply-To: <48932ACD.3080805@LiPPERTEmbedded.de>

On 01/08/08 17:25 +0200, Jens Rottmann wrote:
> mfgpt: check IRQ before using MFGPT as clocksource
> 
> Adds a simple IRQ autodetection to the AMD Geode MFGPT driver, and more
> importantly, adds some checks, if IRQs can actually be received on the
> chosen line.  This fixes cases where MFGPT is selected as clocksource
> though not producing any ticks, so the kernel simply starves during
> boot.
> 
> Signed-off-by: Jens Rottmann <JRottmann@LiPPERTEmbedded.de>

One comment below - otherwise, I reviewed it and it looks good, but 
I haven't tried it.

Jordan

> ---
> 
> --- linux-2.6.26/include/asm-x86/geode.h
> +++ mfgpt-irq-fix/include/asm-x86/geode.h
> @@ -50,6 +50,7 @@
>  #define MSR_PIC_YSEL_HIGH	0x51400021
>  #define MSR_PIC_ZSEL_LOW	0x51400022
>  #define MSR_PIC_ZSEL_HIGH	0x51400023
> +#define MSR_PIC_IRQM_LPC	0x51400025
>  
>  #define MSR_MFGPT_IRQ		0x51400028
>  #define MSR_MFGPT_NR		0x51400029
> @@ -237,7 +238,7 @@
>  }
>  
>  extern int geode_mfgpt_toggle_event(int timer, int cmp, int event, int enable);
> -extern int geode_mfgpt_set_irq(int timer, int cmp, int irq, int enable);
> +extern int geode_mfgpt_set_irq(int timer, int cmp, int *irq, int enable);
>  extern int geode_mfgpt_alloc_timer(int timer, int domain);
>  
>  #define geode_mfgpt_setup_irq(t, c, i) geode_mfgpt_set_irq((t), (c), (i), 1)
> --- linux-2.6.26/arch/x86/kernel/mfgpt_32.c
> +++ mfgpt-irq-fix/arch/x86/kernel/mfgpt_32.c
> @@ -33,6 +33,8 @@
>  #include <linux/module.h>
>  #include <asm/geode.h>
>  
> +#define MFGPT_DEFAULT_IRQ	7
> +
>  static struct mfgpt_timer_t {
>  	unsigned int avail:1;
>  } mfgpt_timers[MFGPT_MAX_TIMERS];
> @@ -157,29 +159,41 @@
>  }
>  EXPORT_SYMBOL_GPL(geode_mfgpt_toggle_event);
>  
> -int geode_mfgpt_set_irq(int timer, int cmp, int irq, int enable)
> +int geode_mfgpt_set_irq(int timer, int cmp, int *irq, int enable)
>  {
> -	u32 val, dummy;
> -	int offset;
> +	u32 zsel, lpc, dummy;
> +	int shift;
>  
>  	if (timer < 0 || timer >= MFGPT_MAX_TIMERS)
>  		return -EIO;
>  
> -	if (geode_mfgpt_toggle_event(timer, cmp, MFGPT_EVENT_IRQ, enable))
> +	/* IRQ already set to 2 means VSA is using the timer's Siamese twin */

Please make this more descriptive - something like this:
/* If the IRQ is set to 2, then VSA is using the other timer in the pair */ 

Siamese twin might be confusing.

> +	shift = ((cmp == MFGPT_CMP1 ? 0 : 4) + timer % 4) * 4;
> +	rdmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
> +	if (((zsel >> shift) & 0xF) == 2)
>  		return -EIO;

> -	rdmsr(MSR_PIC_ZSEL_LOW, val, dummy);
> -
> -	offset = (timer % 4) * 4;
> +	/* Choose IRQ: if none supplied, keep IRQ already set or use default */
> +	if (!*irq)
> +		*irq = (zsel >> shift) & 0xF;
> +	if (!*irq)
> +		*irq = MFGPT_DEFAULT_IRQ;

> -	val &= ~((0xF << offset) | (0xF << (offset + 16)));
> +	/* Can't use IRQ if it's 0 (=disabled), 2, or routed to LPC */
> +	if (*irq < 1 || *irq == 2 || *irq > 15)
> +		return -EIO;
> +	rdmsr(MSR_PIC_IRQM_LPC, lpc, dummy);
> +	if (lpc & (1 << *irq))
> +		return -EIO;

> +	/* All chosen and checked - go for it */
> +	if (geode_mfgpt_toggle_event(timer, cmp, MFGPT_EVENT_IRQ, enable))
> +		return -EIO;
>  	if (enable) {
> -		val |= (irq & 0x0F) << (offset);
> -		val |= (irq & 0x0F) << (offset + 16);
> +		zsel = (zsel & ~(0xF << shift)) | (*irq << shift);
> +		wrmsr(MSR_PIC_ZSEL_LOW, zsel, dummy);
>  	}
>  
> -	wrmsr(MSR_PIC_ZSEL_LOW, val, dummy);
>  	return 0;
>  }
>  
> @@ -242,7 +256,7 @@
>  static unsigned int mfgpt_tick_mode = CLOCK_EVT_MODE_SHUTDOWN;
>  static u16 mfgpt_event_clock;
>  
> -static int irq = 7;
> +static int irq;
>  static int __init mfgpt_setup(char *str)
>  {
>  	get_option(&str, &irq);
> @@ -346,7 +360,7 @@ int __init mfgpt_timer_setup(void)
>  	mfgpt_event_clock = timer;
>  
>  	/* Set up the IRQ on the MFGPT side */
> -	if (geode_mfgpt_setup_irq(mfgpt_event_clock, MFGPT_CMP2, irq)) {
> +	if (geode_mfgpt_setup_irq(mfgpt_event_clock, MFGPT_CMP2, &irq)) {
>  		printk(KERN_ERR "mfgpt-timer:  Could not set up IRQ %d\n", irq);
>  		return -EIO;
>  	}
> @@ -374,13 +388,14 @@ int __init mfgpt_timer_setup(void)
>  			&mfgpt_clockevent);
>  
>  	printk(KERN_INFO
> -	       "mfgpt-timer:  registering the MFGPT timer as a clock event.\n");
> +	       "mfgpt-timer:  Registering MFGPT timer %d as a clock event, using IRQ %d\n",
> +	       timer, irq);
>  	clockevents_register_device(&mfgpt_clockevent);
>  
>  	return 0;
>  
>  err:
> -	geode_mfgpt_release_irq(mfgpt_event_clock, MFGPT_CMP2, irq);
> +	geode_mfgpt_release_irq(mfgpt_event_clock, MFGPT_CMP2, &irq);
>  	printk(KERN_ERR
>  	       "mfgpt-timer:  Unable to set up the MFGPT clock source\n");
>  	return -EIO;
> _
> 
> 


  reply	other threads:[~2008-08-01 16:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-31  7:23 Jens Rottmann
2008-07-31 14:36 ` Jordan Crouse
2008-07-31 20:53   ` Andres Salomon
2008-07-31 20:57   ` pci resource conflicts Andres Salomon
2008-08-01 15:25   ` MFGPT driver inhibits boot on some boards Jens Rottmann
2008-08-01 16:00     ` Jordan Crouse [this message]
2008-08-04 12:40       ` [PATCH] geode-mfgpt: check IRQ before using MFGPT as clocksource Jens Rottmann
2008-08-15 15:11         ` Ingo Molnar
2008-08-15 15:29           ` Jordan Crouse
2008-08-15 15:53             ` Ingo Molnar

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20080801160026.GB19184@cosmic.amd.com \
    --to=jordan.crouse@amd.com \
    --cc=JRottmann@LiPPERTEmbedded.de \
    --cc=dilinger@debian.org \
    --cc=linux-geode@bombadil.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

Powered by JetHome