Subject: Re: [PATCH v2] powerpc: Rework lazy-interrupt handling

From: Benjamin Herrenschmidt <[email-masked]>
Date: Fri, 10 Feb 2012 07:47:20 +1100

On Thu, 2012-02-09 at 19:03 +0200, Tudor Laurentiu wrote:

> > +masked_interrupt_book3e_0x900:
> > +	ACK_DEC(r11);
> > +	li	r11,PACA_HAPPENED_DEC
> > +	b	masked_interrupt_book3e_no_mask
> > +masked_interrupt_book3e_0x980:
> > +	ACK_FIT(r11);
> > +	li	r11,PACA_HAPPENED_DEC
> > +	b	masked_interrupt_book3e_no_mask
> > +masked_interrupt_book3e_0x280:
> > +masked_interrupt_book3e_0x2c0:
> > +	li	r11,PACA_HAPPENED_DBELL
> > +	b	masked_interrupt_book3e_no_mask
> > +
> > +masked_interrupt_book3e_no_mask:
> > +	mtcr	r10
> > +	lbz	r10,PACAIRQHAPPENED(r13)
> > +	ori	r10,r10,r11
> 
> Shouldn't this be an 'or'?

Yes, absolutely. This is a typo/thinko I do all the time ... oops.

> > +	stb	r10,PACAIRQHAPPENED(r13)
> > +	b	1f
> > +masked_interrupt_book3e_full_mask:
> >   	mtcr	r10
> > -masked_interrupt_book3e_common:
> > -	stb	r11,PACAHARDIRQEN(r13)
> > +	lbz	r10,PACAIRQHAPPENED(r13)
> > +	ori	r10,r10,r11
> 
> Same comment.

I'll respin and fix.

Cheers,
Ben

> > +	stb	r10,PACAIRQHAPPENED(r13)
> >   	mfspr	r10,SPRN_SRR1
> >   	rldicl	r11,r10,48,1		/* clear MSR_EE */
> >   	rotldi	r10,r11,16
> >   	mtspr	SPRN_SRR1,r10
> > -	ld	r10,PACA_EXGEN+EX_R10(r13);	/* restore registers */
> > +1:	ld	r10,PACA_EXGEN+EX_R10(r13);
> >   	ld	r11,PACA_EXGEN+EX_R11(r13);
> >   	mfspr	r13,SPRN_SPRG_GEN_SCRATCH;
> >   	rfi
> >   	b	.
> >
> >   /*
> > + * Called from arch_local_irq_enable when an interrupt needs
> > + * to be resent. r3 contains either 0x500,0x900,0x260 or 0x280
> > + * to indicate the kind of interrupt. MSR:EE is already off.
> > + * We generate a stackframe like if a real interrupt had happened.
> > + *
> > + * Note: While MSR:EE is off, we need to make sure that _MSR
> > + * in the generated frame has EE set to 1 or the exception
> > + * handler will not properly re-enable them.
> > + */
> > +_GLOBAL(__reemit_interrupt)
> > +	/* We are going to jump to the exception common code which
> > +	 * will retrieve various register values from the PACA which
> > +	 * we don't give a damn about.
> > +	 */
> > +	mflr	r10
> > +	mfmsr	r11
> > +	mfcr	r4;
> > +	mtspr	SPRN_SPRG_GEN_SCRATCH,r13;
> > +	std	r1,PACA_EXGEN+EX_R1(r13);
> > +	stw	r4,PACA_EXGEN+EX_CR(r13);
> > +	ori	r11,r11,MSR_EE
> > +	subi	r1,r1,INT_FRAME_SIZE;
> > +	cmpwi	cr0,r3,0x500
> > +	beq	exc_0x500_common
> > +	cmpwi	cr0,r3,0x900
> > +	beq+	exc_0x900_common
> > +	cmpwi	cr0,r3,0x280
> > +	beq+	exc_0x280_common
> > +	blr
> > +
> > +/*
> >    * This is called from 0x300 and 0x400 handlers after the prologs with
> >    * r14 and r15 containing the fault address and error code, with the
> >    * original values stashed away in the PACA
> > @@ -680,6 +762,8 @@ BAD_STACK_TRAMPOLINE(0x000)
> >   BAD_STACK_TRAMPOLINE(0x100)
> >   BAD_STACK_TRAMPOLINE(0x200)
> >   BAD_STACK_TRAMPOLINE(0x260)
> > +BAD_STACK_TRAMPOLINE(0x280)
> > +BAD_STACK_TRAMPOLINE(0x2a0)
> >   BAD_STACK_TRAMPOLINE(0x2c0)
> >   BAD_STACK_TRAMPOLINE(0x2e0)
> >   BAD_STACK_TRAMPOLINE(0x300)
> 
> ---
> Best Regards, Laurentiu