The Linux Kernel Mailing List
 help / color / mirror / Atom feed
From: Richard Weinberger <richard@nod.at>
To: x86@kernel.org
Cc: tglx@linutronix.de, mingo@redhat.com, hpa@zytor.com,
	seiji.aguchi@hds.com, rientjes@google.com,
	konrad.wilk@oracle.com, linux-kernel@vger.kernel.org,
	bp@alien8.de
Subject: Re: [PATCH] APIC: Read Error Status Register correctly
Date: Wed, 08 Jan 2014 11:20:40 +0100	[thread overview]
Message-ID: <2193321.5PpjVl4PAc@sandpuppy> (raw)
In-Reply-To: <1387823250-27218-1-git-send-email-richard@nod.at>

Am Montag, 23. Dezember 2013, 19:27:30 schrieb Richard Weinberger:
> Currently we do a read, a dummy write and a final read to fetch the error
> code. The value from the final read is taken.
> This is not the recommended way and leads to corrupted/lost ESR values.
> 
> Intel(c) 64 and IA-32 Architectures Software Developer's Manual,
> 
> Combined Volumes 1, 2ABC, 3ABC, Section 10.5.3 states:
> >>Before attempt to read from the ESR, software should first write to it.
> 
> (The value written does not affect the values read subsequently;
> only zero may be written in x2APIC mode.) This write clears
> any previously logged errors and updates the ESR with any errors
> detected since the last write to the ESR.
> This write also rearms the APIC error interrupt triggering mechanism.<<
> 
> This patch removes the first read such that we are conform with the manual.
> 
> On my (very old) Pentium MMX SMP system this patch fixes the issue that
> APIC errors a) are not always reported and b) are reported with false
> error numbers.
> 
> Signed-off-by: Richard Weinberger <richard@nod.at>
> ---
>  arch/x86/kernel/apic/apic.c | 17 ++++++++---------
>  1 file changed, 8 insertions(+), 9 deletions(-)
> 
> diff --git a/arch/x86/kernel/apic/apic.c b/arch/x86/kernel/apic/apic.c
> index d278736..4ec1dd6 100644
> --- a/arch/x86/kernel/apic/apic.c
> +++ b/arch/x86/kernel/apic/apic.c
> @@ -1968,7 +1968,7 @@ __visible void smp_trace_spurious_interrupt(struct
> pt_regs *regs) */
>  static inline void __smp_error_interrupt(struct pt_regs *regs)
>  {
> -	u32 v0, v1;
> +	u32 v;
>  	u32 i = 0;
>  	static const char * const error_interrupt_reason[] = {
>  		"Send CS error",		/* APIC Error Bit 0 */
> @@ -1982,21 +1982,20 @@ static inline void __smp_error_interrupt(struct
> pt_regs *regs) };
> 
>  	/* First tickle the hardware, only then report what went on. -- REW */
> -	v0 = apic_read(APIC_ESR);
>  	apic_write(APIC_ESR, 0);
> -	v1 = apic_read(APIC_ESR);
> +	v = apic_read(APIC_ESR);
>  	ack_APIC_irq();
>  	atomic_inc(&irq_err_count);
> 
> -	apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x(%02x)",
> -		    smp_processor_id(), v0 , v1);
> +	apic_printk(APIC_DEBUG, KERN_DEBUG "APIC error on CPU%d: %02x",
> +		    smp_processor_id(), v);
> 
> -	v1 = v1 & 0xff;
> -	while (v1) {
> -		if (v1 & 0x1)
> +	v &= 0xff;
> +	while (v) {
> +		if (v & 0x1)
>  			apic_printk(APIC_DEBUG, KERN_CONT " : %s", 
error_interrupt_reason[i]);
>  		i++;
> -		v1 >>= 1;
> +		v >>= 1;
>  	}
> 
>  	apic_printk(APIC_DEBUG, KERN_CONT "\n");

Any comments on this?

Thanks,
//richard


      reply	other threads:[~2014-01-08 10:20 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-12-23 18:27 [PATCH] APIC: Read Error Status Register correctly Richard Weinberger
2014-01-08 10:20 ` Richard Weinberger [this message]

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=2193321.5PpjVl4PAc@sandpuppy \
    --to=richard@nod.at \
    --cc=bp@alien8.de \
    --cc=hpa@zytor.com \
    --cc=konrad.wilk@oracle.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=rientjes@google.com \
    --cc=seiji.aguchi@hds.com \
    --cc=tglx@linutronix.de \
    --cc=x86@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