From owner-freebsd-mips@FreeBSD.ORG Sat Oct 1 12:08:32 2011 Return-Path: Delivered-To: freebsd-mips@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38AD31065670; Sat, 1 Oct 2011 12:08:32 +0000 (UTC) (envelope-from c.jayachandran@gmail.com) Received: from mail-wy0-f182.google.com (mail-wy0-f182.google.com [74.125.82.182]) by mx1.freebsd.org (Postfix) with ESMTP id 662108FC0C; Sat, 1 Oct 2011 12:08:31 +0000 (UTC) Received: by wyj26 with SMTP id 26so2523841wyj.13 for ; Sat, 01 Oct 2011 05:08:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=ePXSWMQDHmwYlc7/MH1AxYwtW3smAIiaxFWnRyQKO58=; b=bDSbkyzRB6Gp7C7Uxy2FBGZiCAUtPUz3iqAh7pyChjRJBPJzZTlz0TqM68VU5+JSI+ U7dVAV42S18tOB+zbILSb07sDg35nB693V7v6sD6C2RhzIdQ2Ahyxm2YH0GLyfC/YGTT +nRoJk5ZRSUP6xf3iW5Tgmdn81HPqMyRWSIwc= MIME-Version: 1.0 Received: by 10.216.220.131 with SMTP id o3mr13174859wep.11.1317470910417; Sat, 01 Oct 2011 05:08:30 -0700 (PDT) Sender: c.jayachandran@gmail.com Received: by 10.216.154.5 with HTTP; Sat, 1 Oct 2011 05:08:30 -0700 (PDT) In-Reply-To: References: <201110010556.p915uQH6003016@svn.freebsd.org> Date: Sat, 1 Oct 2011 17:38:30 +0530 X-Google-Sender-Auth: AlAnHcdzo8XFAY5_JpctiPghLws Message-ID: From: "Jayachandran C." To: Adrian Chadd Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable Cc: Alexander Motin , freebsd-mips@freebsd.org Subject: Re: svn commit: r225892 - head/sys/mips/mips X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 01 Oct 2011 12:08:32 -0000 Hi Adrain, On Sat, Oct 1, 2011 at 4:01 PM, Adrian Chadd wrote: > Just FYI, the MIPS24K software users manual, section 9.2.1: > > > 9.2.1 Wait IE Ignore > A feature is included in the core that simplifies the task of using > the WAIT instruction in the idle loop of an OS. The WAIT instruction > is typically in block of code where the OS first checks to see if > there is any pending work and if there is not, it will execute the > WAIT as shown below. > ... > > There is a tricky race condition present in this code. If an interrupt > arrives between the pending check and the WAIT instruction, the > service routine will return and execute the WAIT and go to sleep. > However, the interrupt may have been enabling some pending work to be > done in the =91bottom-half=92 processing. If the core goes back to sleep, > this pending work will not be done until the next interrupt arrives. > > The OS can check to see if the interrupt was signalled in this window > and adjust the EPC value to before the pending check, but this > involves a fair amount of work. Linux code seems to have this solution, i.e in the interrupt handler, compare the EPC with the r4_wait function's address before the 'wait' and then fixup EPC if needed. > The Wait IE Ignore feature enables a > simpler solution for the race con- dition. With this feature, a WAIT > condition will be terminated by an active interrupt signal, even if > that signal is pre- vented from causing an interrupt by StatusIE being > clear or TCStatusIXMT being set. This allows interrupts to be disabled > in this section of code while still allowing the WAIT to complete. Thanks for finding this. > That's likely a good solution for my platform, if it actually is > implemented for my core. Would you mind seeing if XLR has something > similar? I'll code this up tonight/tomorrow and see if I can coax my > mips24k cores to work correctly. Looks like I will have to implement the EPC fixup solution for XLR. But in the end I think probably we will have two implementations, one for the processors which can safely wait with interrupts off without the scheduling latency, and the other for platforms that need the EPC fixup. JC.