From owner-svn-src-head@freebsd.org Mon Jan 29 09:27:03 2018 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 19813EDF953; Mon, 29 Jan 2018 09:27:03 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id A936F872F5; Mon, 29 Jan 2018 09:27:02 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 89F62263F2; Mon, 29 Jan 2018 09:27:02 +0000 (UTC) (envelope-from wma@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id w0T9R2CK008703; Mon, 29 Jan 2018 09:27:02 GMT (envelope-from wma@FreeBSD.org) Received: (from wma@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id w0T9R2ot008700; Mon, 29 Jan 2018 09:27:02 GMT (envelope-from wma@FreeBSD.org) Message-Id: <201801290927.w0T9R2ot008700@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: wma set sender to wma@FreeBSD.org using -f From: Wojciech Macek Date: Mon, 29 Jan 2018 09:27:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r328537 - in head/sys/powerpc: aim powernv X-SVN-Group: head X-SVN-Commit-Author: wma X-SVN-Commit-Paths: in head/sys/powerpc: aim powernv X-SVN-Commit-Revision: 328537 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 29 Jan 2018 09:27:03 -0000 Author: wma Date: Mon Jan 29 09:27:02 2018 New Revision: 328537 URL: https://svnweb.freebsd.org/changeset/base/328537 Log: PowerNV: move LPCR and LPID altering to cpudep_ap_early_bootstrap It turns out that under some circumstances we can get DSI or DSE before we set LPCR and LPID so we should set it as early as possible. Authored by: Patryk Duda Submitted by: Wojciech Macek Obtained from: Semihalf Sponsored by: IBM, QCM Technologies Modified: head/sys/powerpc/aim/mp_cpudep.c head/sys/powerpc/powernv/platform_powernv.c Modified: head/sys/powerpc/aim/mp_cpudep.c ============================================================================== --- head/sys/powerpc/aim/mp_cpudep.c Mon Jan 29 09:24:28 2018 (r328536) +++ head/sys/powerpc/aim/mp_cpudep.c Mon Jan 29 09:27:02 2018 (r328537) @@ -64,9 +64,6 @@ cpudep_ap_early_bootstrap(void) register_t reg; #endif - __asm __volatile("mtsprg 0, %0" :: "r"(ap_pcpu)); - powerpc_sync(); - switch (mfpvr() >> 16) { case IBM970: case IBM970FX: @@ -86,7 +83,20 @@ cpudep_ap_early_bootstrap(void) #endif powerpc_sync(); break; + case IBMPOWER8: + case IBMPOWER8E: + isync(); + /* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */ + mtspr(SPR_LPID, 0); + isync(); + + mtspr(SPR_LPCR, LPCR_LPES); + isync(); + break; } + + __asm __volatile("mtsprg 0, %0" :: "r"(ap_pcpu)); + powerpc_sync(); } uintptr_t Modified: head/sys/powerpc/powernv/platform_powernv.c ============================================================================== --- head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29 09:24:28 2018 (r328536) +++ head/sys/powerpc/powernv/platform_powernv.c Mon Jan 29 09:27:02 2018 (r328537) @@ -128,6 +128,7 @@ powernv_attach(platform_t plat) pcell_t prop; phandle_t cpu; int res, len, node, idx; + register_t msr; /* Ping OPAL again just to make sure */ opal_check(); @@ -141,6 +142,19 @@ powernv_attach(platform_t plat) cpu_idle_hook = powernv_cpu_idle; powernv_boot_pir = mfspr(SPR_PIR); + /* LPID must not be altered when PSL_DR or PSL_IR is set */ + msr = mfmsr(); + mtmsr(msr & ~(PSL_DR | PSL_IR)); + + /* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */ + mtspr(SPR_LPID, 0); + isync(); + + mtmsr(msr); + + mtspr(SPR_LPCR, LPCR_LPES); + isync(); + /* Init CPU bits */ powernv_smp_ap_init(plat); @@ -444,21 +458,6 @@ powernv_reset(platform_t platform) static void powernv_smp_ap_init(platform_t platform) { - register_t msr; - - /* LPID must not be altered when PSL_DR or PSL_IR is set */ - msr = mfmsr(); - mtmsr(msr & ~(PSL_DR | PSL_IR)); - - isync(); - /* Direct interrupts to SRR instead of HSRR and reset LPCR otherwise */ - mtspr(SPR_LPID, 0); - isync(); - - mtmsr(msr); - - mtspr(SPR_LPCR, LPCR_LPES); - isync(); } static void