linux-mips
[Top] [All Lists]

Re: [PATCH v2] MIPS: Alchemy: fix wait function

To: "Maciej W. Rozycki" <macro@linux-mips.org>
Subject: Re: [PATCH v2] MIPS: Alchemy: fix wait function
From: Manuel Lauss <manuel.lauss@gmail.com>
Date: Sat, 8 Jun 2013 22:15:47 +0200
Cc: Ralf Baechle <ralf@linux-mips.org>, Linux-MIPS <linux-mips@linux-mips.org>
Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc:content-type; bh=giLbHgVXgJhMqVPMQE+7Tdb/gH9iT0SSVs3Itw7fr24=; b=cKM3rmWEEsMI+QrOOLmB+0rrZHPM0WyDCeO5dGy03z/0z+cwoNxKpklrQC4sk9JZGf Dkd5ibUhOnu2X2jsErF1yj+gHYZmSzDOl7MPvX9EYyflIcU7Dgil3ShWlh4mxxrI4FRx 8E5TFPjkgXVCzbJuJbt+OFZdezFA3K2AJKefL9CwrYc/csF0T+jMQ3pCcvCLZ71OVPKs qwd4PBPnI91qTCr6/UqQ1bEe6TMYPWYStavWVy42PGxdOXxsR+CEk/pd/8miwkdvuimb 4umMipxi57F0DF1CsGapZT0TpzPH8ApkPu0B7LuNEdguVsuSfWSiagbTATADEVocMfcP YiuQ==
In-reply-to: <alpine.LFD.2.03.1306081907130.21418@linux-mips.org>
List-archive: <http://www.linux-mips.org/archives/linux-mips/>
List-help: <mailto:ecartis@linux-mips.org?Subject=help>
List-id: linux-mips <linux-mips.eddie.linux-mips.org>
List-owner: <mailto:ralf@linux-mips.org>
List-post: <mailto:linux-mips@linux-mips.org>
List-software: Ecartis version 1.0.0
List-subscribe: <mailto:ecartis@linux-mips.org?subject=subscribe%20linux-mips>
List-unsubscribe: <mailto:ecartis@linux-mips.org?subject=unsubscribe%20linux-mips>
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <1369315716-7408-1-git-send-email-manuel.lauss@gmail.com> <alpine.LFD.2.03.1306081907130.21418@linux-mips.org>
Sender: linux-mips-bounce@linux-mips.org
On Sat, Jun 8, 2013 at 8:18 PM, Maciej W. Rozycki <macro@linux-mips.org> wrote:
> On Thu, 23 May 2013, Manuel Lauss wrote:
>
>> Only an interrupt can wake the core from 'wait', enable interrupts
>> locally before executing 'wait'.
>>
>> Signed-off-by: Manuel Lauss <manuel.lauss@gmail.com>
>> ---
>> Ralf made me aware of the race in between enabling interrupts and
>> entering wait.  While this patch does not eliminate it, it shrinks it
>> to 1 instruction.  It's not perfect, but lets Alchemy boot until a
>> more sophisticated solution (like __r4k_wait) can be implemented
>> without having to duplicate the interrupt exception handler.
>
>  I suggest double-checking with Alchemy documentation, but I doubt there
> is a race here, the write-back pipeline stage of MTC0 should overlap with
> the execution stage of WAIT, so assuming interrupts were previously
> disabled there should be no window between setting CP0.Status.IE and
> executing WAIT that would permit an interrrupt exception to be taken.

That was my thinking as well.  The Alchemy manuals (at least the ones I have)
don't specify the stage where c0 writes complete or 'wait' executes, but the
wording on how and when exceptions are raised makes me believe the
scheme above is race-free.


>  There is a bug in your change however.
[...]
>  You can't just take $8 away under the feet of GCC without telling the
> compiler, it may be storing some data there across the asm.  Rather than
> picking an arbitrary register as a clobber I suggest using an output
> register constraint associated with a scratch variable (depending on
> register usage GCC may possibly be able to reuse the same register both
> for input and for output).

I've fixed that, and sent out a new patch.

Thank you very much!
        Manuel

<Prev in Thread] Current Thread [Next in Thread>