From owner-freebsd-ppc@freebsd.org Tue Nov 15 05:53:22 2016 Return-Path: Delivered-To: freebsd-ppc@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 088E4C42387 for ; Tue, 15 Nov 2016 05:53:22 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: from asp.reflexion.net (outbound-mail-210-29.reflexion.net [208.70.210.29]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id A92091EBC for ; Tue, 15 Nov 2016 05:53:21 +0000 (UTC) (envelope-from markmi@dsl-only.net) Received: (qmail 23498 invoked from network); 15 Nov 2016 05:53:08 -0000 Received: from unknown (HELO mail-cs-02.app.dca.reflexion.local) (10.81.19.2) by 0 (rfx-qmail) with SMTP; 15 Nov 2016 05:53:08 -0000 Received: by mail-cs-02.app.dca.reflexion.local (Reflexion email security v8.10.2) with SMTP; Tue, 15 Nov 2016 00:53:25 -0500 (EST) Received: (qmail 6175 invoked from network); 15 Nov 2016 05:53:25 -0000 Received: from unknown (HELO iron2.pdx.net) (69.64.224.71) by 0 (rfx-qmail) with (AES256-SHA encrypted) SMTP; 15 Nov 2016 05:53:25 -0000 Received: from [192.168.1.106] (c-76-115-7-162.hsd1.or.comcast.net [76.115.7.162]) by iron2.pdx.net (Postfix) with ESMTPSA id D21A5EC7B30; Mon, 14 Nov 2016 21:53:18 -0800 (PST) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 10.1 \(3251\)) Subject: Re: svn commit: r306065 - in head/sys vs. PowerMacs: Nathan's trail patch included but inappropriate? [My hack vs. Apple G4's.] From: Mark Millard In-Reply-To: <01cfa4e9-954f-3e86-c8d7-36ec8523dde0@freebsd.org> Date: Mon, 14 Nov 2016 21:53:18 -0800 Cc: "Jukka A. Ukkonen" , Justin Hibbits , FreeBSD PowerPC ML , Peter Grehan Content-Transfer-Encoding: 7bit Message-Id: References: <917EFF5A-D054-4424-9D7D-4E4BEF6072EF@gmail.com> <4bb1046a-225d-66b2-7b00-067f0d6f6c60@gmail.com> <465041D5-C1A2-48F4-9CA7-DD03B094FAE4@dsl-only.net> <01cfa4e9-954f-3e86-c8d7-36ec8523dde0@freebsd.org> To: Nathan Whitehorn X-Mailer: Apple Mail (2.3251) X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 15 Nov 2016 05:53:22 -0000 On 2016-Sep-21, at 3:01 PM, Peter Grehan wrote: >> I've never had my hands on an eMac. I'm not sure if it has the same >> SPRGx requirements as other G4's or not. > > That's the machine that caused the sprg save/restore. > https://svnweb.freebsd.org/base?view=revision&revision=151891 > > later, > > Peter. My patch/hack as I have always had it for booting PowerMac G5's does not change the content for G4's (such as eMac G4's). I made a separate case for __powerpc64__ --and only for AIM-capable as well. My code has been: # svnlite diff /usr/src/sys/powerpc/ofw/ofw_machdep.c Index: /usr/src/sys/powerpc/ofw/ofw_machdep.c =================================================================== --- /usr/src/sys/powerpc/ofw/ofw_machdep.c (revision 308247) +++ /usr/src/sys/powerpc/ofw/ofw_machdep.c (working copy) @@ -111,6 +111,24 @@ * Assume that interrupt are disabled at this point, or * SPRG1-3 could be trashed */ +#if defined(AIM) && defined(__powerpc64__) +/* HACK: PowerMac G5 specific code to avoid demonstrated hangs in + * the early boot time frame: avoid mtsprg0 use. + * This would need a live test for PowerMac vs. not in order + * to remove HACK status --but without calling into + * OpenFirmware or the problem would be recreated. + */ + if (1) + __asm __volatile("mfsprg0 %0\n\t" + "mtsprg1 %1\n\t" + "mtsprg2 %2\n\t" + "mtsprg3 %3\n\t" + : "=&r"(ofw_sprg0_save) + : "r"(ofmsr[2]), + "r"(ofmsr[3]), + "r"(ofmsr[4])); + else +#endif __asm __volatile("mfsprg0 %0\n\t" "mtsprg0 %1\n\t" "mtsprg1 %2\n\t" (The comment does not reflect the modern discussion of why the change works: the code has been around a long time.) I do not know if there are any AIM-capable __powerpc64__ contexts for which the change is inappropriate. It would be nice if it was always appropriate to that kind of context and could be added to head and stable/11 and stable/10 . (I've no experience before stable/10: so untested prior to that.) Jukka did experiments with eliminating more --and not just for AIM-capable __powerpc64__ but some other PowerMac contexts as well. But I kept to the minimal generated-code change which appeared to fix the problematical behavior. === Mark Millard markmi at dsl-only.net