From owner-freebsd-mips@freebsd.org Thu Nov 16 00:15:12 2017 Return-Path: Delivered-To: freebsd-mips@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 667DFDEFA20 for ; Thu, 16 Nov 2017 00:15:12 +0000 (UTC) (envelope-from yamori813@yahoo.co.jp) Received: from nh501-vm11.bullet.mail.kks.yahoo.co.jp (nh501-vm11.bullet.mail.kks.yahoo.co.jp [183.79.56.141]) by mx1.freebsd.org (Postfix) with SMTP id E30C46422F for ; Thu, 16 Nov 2017 00:15:11 +0000 (UTC) (envelope-from yamori813@yahoo.co.jp) Received: from [183.79.100.141] by nh501.bullet.mail.kks.yahoo.co.jp with NNFMP; 16 Nov 2017 00:15:04 -0000 Received: from [183.79.100.132] by t504.bullet.mail.kks.yahoo.co.jp with NNFMP; 16 Nov 2017 00:15:04 -0000 Received: from [127.0.0.1] by omp501.mail.kks.yahoo.co.jp with NNFMP; 16 Nov 2017 00:15:04 -0000 X-Yahoo-Newman-Property: ymail-3 X-Yahoo-Newman-Id: 864325.12638.bm@omp501.mail.kks.yahoo.co.jp Received: (qmail 14523 invoked by uid 60001); 16 Nov 2017 00:15:04 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.co.jp; s=yj20110701; t=1510791304; bh=qi7cUs7L0bmEXpLslw52GipAJE2qk2sQYCsThpweVNY=; h=Message-ID:X-YMail-OSG:Received:X-Mailer:X-YMail-JAS:References:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=NhEvMfs8u1MWMPKeOIfn+zyYXK4TmCwcXs+kZmofTXk+oEhRa1+8U+k/5aEKNm7g/HTmgQrYK8QXJzY1YG92c/di8abLPr+kSAnyz7/OgciexfCh7AByplo7VJWahEJXIV8NA1EuNMCxTYwikAW24ujjhsQz12nKhqjLpD3CNFI= DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=yj20110701; d=yahoo.co.jp; h=Message-ID:X-YMail-OSG:Received:X-Mailer:X-YMail-JAS:References:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=l3VUVjGOqyQOYT4mvRKYWkeStNqYOE54PhwdcRFEIl/g0cDvTs3KjF0GAdX0kHAnOW8mGPaQSakSw4gTc1cOYuDKHKpTIAavdvarAbOR4+ahytoNoNLds6nQZF1KPi85R46KzVp9G060dGmzpebnzxzGAoTnOOiVBjrZpcPrXG4=; Message-ID: <506753.3523.qm@web101712.mail.ssk.yahoo.co.jp> X-YMail-OSG: wBd4Se0VM1llQnL2c_Qq6byxgQmCUXFiTA5y6qO8BAv1UEqA10uH1S2nDHImT6c06V_9a9jE3OIaSukQUrw7gti9tXmKfV2XaqaI.wipUqTifeHiidYKsaFNY5d5MBhTtIFr6qNmycCuvFx62GPPeUa7hf62ZqTHh4JSBOXB_quLw1st89i86igjq0rA.D.wmJ1yipuC.WqyrTM2b9BBIAseeQoP7PWlWljgwUfW_lQhP6lqLgnsaCdg9ERuaDiLa4AWStiLQpnhamWt1FVMqtDGxQXmQ8.ZOAPWOZU1kt9Ya20GhL51sICfEV2Mr0CupaPHlJ3YgGXZhWLVSsG.Vd_hpwx9DG.a34Q_xe3AmrRIAq6JKNl.4up_YQMALQ_wqDbpMzF7LZi_9wc.M8UcrqjXPmSlc1U5CoUE3M64sluG_YNcB0M7WGmlyJ8u894ggQDbnLxyGCdmyjAo6NZ0OGXgFxyszSzuQQztbiE_nDbOdjUGNCQRtf25DyqZ8DNCfj2iij1W9SuwcAV3RlZESA0n_Q3RXV.17QYkYRk_NR3JjyIb3fud4R7vGK2otVqZawU7K1TpB6JAzSf.p303qeD6QXd6lepN0C7WPZshsM4XZg-- Received: from [203.165.91.75] by web101712.mail.ssk.yahoo.co.jp via HTTP; Thu, 16 Nov 2017 09:15:03 JST X-Mailer: YahooMailWebService/0.8.111_74 X-YMail-JAS: yW.sfQAVM1mSm6tUEgA2FEqamxu.2TQmWkclqlYBf6M8WHDQd6b0LtLRgOabp_7UrpDMKUZ8Zb_dvBnbVUo_s9R59MXAr_t0FsDQWINV1ym_bUSv5iHdP51dR4E1MwWdUuzW References: <1510699808.25350.3@smtp.office.plausible.coop> <742722.83866.qm@web101707.mail.ssk.yahoo.co.jp> Date: Thu, 16 Nov 2017 09:15:03 +0900 (JST) From: Mori Hiroki Reply-To: Mori Hiroki Subject: Re: MIPS INTRNG changes To: Landon J Fuller , "freebsd-mips@freebsd.org" In-Reply-To: <742722.83866.qm@web101707.mail.ssk.yahoo.co.jp> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable X-BeenThere: freebsd-mips@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: Porting FreeBSD to MIPS List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 16 Nov 2017 00:15:12 -0000 Hi=0A=0AWork fine this patch.=0A=0AI checked this.=0A=0ACorega CG-WLCVR54AG= =A0AR5312=A0=0ANec WR1200=A0AR5315=0A=0AThanks=0A=0AHiroki Mori=0A=0A=0A---= -- Original Message -----=0A> From: Mori Hiroki =0A>= To: Landon J Fuller ; "freebsd-mips@freebsd.org" =0A> Cc: =0A> Date: 2017/11/15, Wed 23:23=0A> Subject= : Re: MIPS INTRNG changes=0A> =0A> Hi=0A> =0A> sys/mips/atheros/ar531x/ is = non-FDT and INTERNG.=0A> =0A> I will check this patch on real cpu tomorrow.= =0A> =0A> Hiroki Mori=A0=0A> =0A> =0A> ----- Original Message -----=0A>>=A0= =A0From: Landon J Fuller =0A>>=A0=A0To: freebsd-mips@f= reebsd.org=0A>>=A0=A0Cc: =0A>>=A0=A0Date: 2017/11/15, Wed 07:50=0A>>=A0=A0S= ubject: MIPS INTRNG changes=0A>> =0A>>=A0=A0Howdy -=0A>> =0A>>=A0=A0To supp= ort nested INTRNG interrupt controllers on non-FDT MIPS targets, =0A> I've= =0A>>=A0=A0implemented a replacement for the cpu_establish_[hard|soft]intr(= ) =0A> workaround=0A>>=A0=A0introduced in r305527 (D7692); I'll be commitin= g this in three days =0A> unless=0A>>=A0=A0anyone objects:=0A>> =0A>>=A0=A0= https://reviews.freebsd.org/D12385=0A>> =0A>>=A0=A0Background:=0A>> =0A>>= =A0=A0Since non-FDT INTRNG targets do not have an equivalent to =0A> OFW_BU= S_MAP_INTR(),=0A>>=A0=A0it is necessary for the MIPS nexus driver to implic= itly establish INTRNG=0A>>=A0=A0interrupt mappings on behalf of child devic= es.=0A>> =0A>>=A0=A0The workaround introduced in r305527 implements this as= follows, on non-FDT=0A>>=A0=A0INTRNG MIPS targets:=0A>> =0A>>=A0=A0- mips/= nexus.c assumes that all bus interrupt requests are for a MIPS=0A>>=A0=A0= =A0 interrupt managed by mips/mips_pic.c=0A>>=A0=A0- Call mips_pic's cpu_cr= eate_intr_map() from nexus_activate_resource() =0A> to=0A>>=A0=A0=A0 alloca= te a new interrupt mapping on-demand.=0A>>=A0=A0- Call mips_pic's cpu_get_i= rq_resource() from nexus_setup_intr() to =0A> fetch a=0A>>=A0=A0=A0 shared = IRQ struct resource for the MIPS interrupt.=0A>> =0A>>=A0=A0In addition to = assuming that all IRQs are owned by mips_pic, on-demand IRQ=0A>>=A0=A0mappi= ng in the BUS_ACTIVATE_RESOURCE() path produces some unexpected =0A> behavi= or:=0A>> =0A>>=A0=A0- Any child bus that uses bus_generic_rl_alloc_resource= () or =0A>>=A0=A0resource_list_alloc()=0A>>=A0=A0to implement BUS_ALLOC_RES= OURCE() will update the child device's =0A> resource=0A>>=A0=A0list entry t= o reference the newly mapped IRQ -- but only if the resource is=0A>>=A0=A0a= llocated with the RF_ACTIVE flag, resulting in BUS_ACTIVATE_RESOURCE() =0A>= being=0A>>=A0=A0called from BUS_ALLOC_RESOURCE() before the resource_list_= entry update is=0A>>=A0=A0performed.=0A>>=A0=A0- BUS_ACTIVATE_RESOURCE() is= itself not resource_list-aware; if RF_ACTIVE =0A> is=0A>>=A0=A0not set dur= ing allocation, and bus_activate_resource() is instead called=0A>>=A0=A0dir= ectly, the child's resource list entry will _not_ updated to the =0A> newly= =0A>>=A0=A0mapped IRQ.=0A>> =0A>>=A0=A0Since the resource_list_entry _may_ = be updated to reference the IRQ =0A> mapping, =0A>>=A0=A0IRQs=0A>>=A0=A0map= pings implicitly created in nexus_activate_resource() cannot be =0A> implic= itly=0A>>=A0=A0unmapped in nexus_deactivate_resource() and must be leaked, = as references =0A> to=0A>>=A0=A0the mapping may remain in a child's resourc= e_list_entry.=0A>> =0A>>=A0=A0Rather than performing on-demand mapping duri= ng resource activation, my =0A> changes=0A>>=A0=A0preemptively produce (on = non-FDT targets) a set of IRQ mappings for all =0A> MIPS=0A>>=A0=A0IRQs in = nexus_attach(), using a fixed range of INTRNG IRQ assignments (0-7) =0A> th= at=0A>>=A0=A0may be statically referenced by child devices.=0A>> =0A>>=A0= =A0With D12385, the mips nexus behavior will now be:=0A>> =0A>>=A0=A0- On n= on-FDT MIPS INTRNG targets, produce a set of fixed MIPS IRQ mappings=0A>>= =A0=A0=A0 in nexus_attach() for the MIPS IRQ range.=0A>>=A0=A0- On all MIPS= INTRNG targets, call mips_pic_activate_intr() from=0A>>=A0=A0=A0 nexus_act= ivate_resource() to perform activation; this will either perform=0A>>=A0=A0= =A0 mips_pic-specific activation if the IRQ is found in mips_pic' table =0A= > of=0A>>=A0=A0=A0 MIPS IRQ mappings, or will call intr_activate_irq() for = IRQs not managed =0A> by=0A>>=A0=A0=A0 mips_pic (e.g. IRQs mapped by a chil= d PIC).=0A>>=A0=A0- On all MIPS INTRNG targets, call mips_pic_deactivate_in= tr() from=0A>>=A0=A0=A0 nexus_deactivate_resource(); this will either perfo= rm mips_pic-specific=0A>>=A0=A0=A0 deactivation, or call intr_deactivate_ir= q() for IRQs not managed by=0A>>=A0=A0=A0 mips_pic.=0A>> =0A>>=A0=A0Cheers,= =0A>>=A0=A0Landon=0A>> =0A>>=A0=A0_________________________________________= ______=0A>>=A0=A0freebsd-mips@freebsd.org mailing list=0A>>=A0=A0https://li= sts.freebsd.org/mailman/listinfo/freebsd-mips=0A>>=A0=A0To unsubscribe, sen= d any mail to =0A>>=A0=A0"freebsd-mips-unsubscribe@freebsd.org"=0A>> =0A> _= ______________________________________________=0A> freebsd-mips@freebsd.org= mailing list=0A> https://lists.freebsd.org/mailman/listinfo/freebsd-mips= =0A> To unsubscribe, send any mail to =0A> "freebsd-mips-unsubscribe@freebs= d.org"=0A>