From owner-freebsd-ppc@freebsd.org Fri Apr 12 19:19:38 2019 Return-Path: Delivered-To: freebsd-ppc@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 80AD8158405C for ; Fri, 12 Apr 2019 19:19:38 +0000 (UTC) (envelope-from marklmi@yahoo.com) Received: from sonic306-21.consmr.mail.ne1.yahoo.com (sonic306-21.consmr.mail.ne1.yahoo.com [66.163.189.83]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 9D99B89140 for ; Fri, 12 Apr 2019 19:19:37 +0000 (UTC) (envelope-from marklmi@yahoo.com) X-YMail-OSG: 7UyuzpUVM1nzK26GadMw.PtXKIZdC0DLdjfBxD_.VBxrHXHZ6yqdAGNioMKLL5I 123OXwgoKFrCzFIOHYPh6EiE3EgPHMzuji3AlaHZu6hFBLCoQA6X6EebIp_kNmVzUzLhap04YAo6 XfD_xqhvMJ4ajAnzY5d8Nrj6PJRsdnfF9ox5evQMX6RKt8NTIdZoS2QsQdrpoOkHBN1hom7rfsEP R432VmRdCRW_UrhSmoP9ms.QPDpQAtfWxWr.XXI87A2DQFjkcc21o6EOfsttAPXSUDzDjsmDh.7h gbGm2qmIVOwB86P5orPDmc9veQCHSPjrPFswdKWF4eO1LYazfDGM6WETrhxAnXFeq3Alfyiwz9PO yy9OZ0BMREuHSdcJy6Q97iYfgN4TkLVyzFOBuyIn_MGtNaIXyKb8hTTpsK9PT3E8DZQdX0uGm0ZB YEpK47ZxqV4liz5QZ4OuMV6Gcj5QgbxeLfQYNEUD0Kn0K5.Pe.0EfWiliCzscw6WzJElfb.PJx.9 X5Txuy1AnfhQaNn1a8WAZcHzecuP_Xd6X_pmSSPcZW1aoRPMyiaCF5Az5LXGLlaGHarsi_.tpF9f YhhR6ENgNQ5TabGuQQfwIUfSc2B3D4AF8NULGfvj342TBHgUCy7rC_7W669TCQ80V7LPI9GHXCw4 Dp12Nwxf9ZxxLOQfDSPNiR8E35wU1D.jYkeQpQ3zxQRs9Zs.fL3Zr44X3ME1lpzF4lLeK_vxo0_9 fBJmeCewVPgEQKHaqAb3d3Bk1LIF3Dve0.7r1c2mpKBit6rfV952y9e09e3ZE1BmDDlhBHgvTjfe OvvYBeV8HAZEpRJC0ZkO0TND_UEAiTPnJoXrhSbwfK469odYXpQbpy.K5LfOhq4Q0ZH.qcWT1Km8 P_oMK7QMGP_PMu71KMiKr7hZxIJ1xXMqhNe8WSh..0u0WmBtN7e5gzb8Xd5FN6Ka89sWCBKpQKND jgCMEVUXufoAHtcfr5nuWMY.qi0WJ3nKcwWL5h5hcOtBYuw32dBK_35JmbVlR4FmpNuAPs9vgh7u OV2RtKLOnPoZ70daQz.zMgNiNZArFiL4AC3pvJXQXFwFj1ubBJhKczvygcnqkzdCr3YPKK2y_y13 pdwXx3kY1tknQFn3LMI.KBEjl Received: from sonic.gate.mail.ne1.yahoo.com by sonic306.consmr.mail.ne1.yahoo.com with HTTP; Fri, 12 Apr 2019 19:19:35 +0000 Received: from c-76-115-7-162.hsd1.or.comcast.net (EHLO [192.168.1.103]) ([76.115.7.162]) by smtp432.mail.ne1.yahoo.com (Oath Hermes SMTP Server) with ESMTPA ID 191feb0de2778945bcb58097b49e1c07; Fri, 12 Apr 2019 19:19:34 +0000 (UTC) From: Mark Millard Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: quoted-printable Mime-Version: 1.0 (Mac OS X Mail 12.4 \(3445.104.8\)) Subject: Patches to allow usefdt mode that works on a 2 socket PowerMac3,6 example too --and makes more work on 2-socket/1-core-each PowerMac11,2 Message-Id: <988F644F-D5E7-4FB4-AAB3-A72E9DA88CE6@yahoo.com> Date: Fri, 12 Apr 2019 12:19:33 -0700 To: FreeBSD PowerPC ML , Justin Hibbits X-Mailer: Apple Mail (2.3445.104.8) X-Rspamd-Queue-Id: 9D99B89140 X-Spamd-Bar: / X-Spamd-Result: default: False [0.00 / 15.00]; RCVD_VIA_SMTP_AUTH(0.00)[]; R_SPF_ALLOW(-0.20)[+ptr:yahoo.com]; MV_CASE(0.50)[]; FREEMAIL_FROM(0.00)[yahoo.com]; RCVD_COUNT_THREE(0.00)[3]; TO_DN_ALL(0.00)[]; DKIM_TRACE(0.00)[yahoo.com:+]; MX_GOOD(-0.01)[cached: mta6.am0.yahoodns.net]; DMARC_POLICY_ALLOW(-0.50)[yahoo.com,reject]; FROM_EQ_ENVFROM(0.00)[]; RCVD_TLS_LAST(0.00)[]; MIME_TRACE(0.00)[0:+]; FREEMAIL_ENVFROM(0.00)[yahoo.com]; ASN(0.00)[asn:36646, ipnet:66.163.184.0/21, country:US]; MID_RHS_MATCH_FROM(0.00)[]; DWL_DNSWL_NONE(0.00)[yahoo.com.dwl.dnswl.org : 127.0.5.0]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.95)[-0.948,0]; R_DKIM_ALLOW(-0.20)[yahoo.com:s=s2048]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_THREE(0.00)[3]; NEURAL_SPAM_SHORT(0.54)[0.535,0]; NEURAL_HAM_LONG(-0.16)[-0.160,0]; MIME_GOOD(-0.10)[text/plain]; IP_SCORE(1.08)[ip: (2.89), ipnet: 66.163.184.0/21(1.44), asn: 36646(1.15), country: US(-0.06)]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_IN_DNSWL_NONE(0.00)[83.189.163.66.list.dnswl.org : 127.0.5.0] X-BeenThere: freebsd-ppc@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Porting FreeBSD to the PowerPC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 12 Apr 2019 19:19:38 -0000 With the following 2 patches for converting openfirmware to fdt content. . . PowerMac11,2 example for usefdt mode: A) bge0 and bge1 are back in their historical places. B) powerd on the PowerMac11,2 works again. C) sysctl -a | grep cpufreq lists items for all the cpus D) probably more. PowerMac3,6 example for usefdt mode: E) gem0 is present again and even works. F) Both CPUs are used again. F) probably more. (powerpd and cpufreq's are not operable/present even in non-usefdt mode.) This message does not deal with other investigatory patches for other issues than converting openfirmware to fdt. But my test environment has all my investigatory patches in order to avoid other things getting in the way of my investigations. The code comments are fairly explicit about what and why for the changes. I treat the patches as investigatory, not ready in form for being official FreeBSD material. There are likely questions of if the change go in the right long-term direction --or even if old PowerMacs will continue to be viewed as worth supporting (because they compete with time spent on modern support). I'll note that I've never had the 2-socket/1-core-each PowerMac7,2 get any visible behavior after the Kernel entry point message with any variation of usefdt mode. Failing so early, I've not figured out any way to investigate it hanging up. It does boot in non-usefdt mode with my other investigatory patches in place. The openfirmware to fdt conversion patches are (white space details might not have been preserved in the message): # svnlite diff /usr/src/stand/powerpc/ofw/ | more Index: /usr/src/stand/powerpc/ofw/ofwfdt.c =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D --- /usr/src/stand/powerpc/ofw/ofwfdt.c (revision 345758) +++ /usr/src/stand/powerpc/ofw/ofwfdt.c (working copy) @@ -42,22 +42,54 @@ } =20 static void -add_node_to_fdt(void *buffer, phandle_t node, int fdt_offset) +add_node_to_fdt(void *buffer, phandle_t parent_node, int fdt_offset) { int i, child_offset, error; - char name[255], *lastprop, *subname; + char name[255+1], *lastprop, *subname; // +1 added for always = having a trailing '\0' position. void *propbuf; ssize_t proplen; =20 - lastprop =3D NULL; - while (OF_nextprop(node, lastprop, name) > 0) { - proplen =3D OF_getproplen(node, name); + // WARNING: fdt_setprop adds to the beginning of the property = sequence. So, + // to avoid reversing the sequence, use it last to first for the = originals. =20 + int prop_cnt=3D 0; + lastprop=3D NULL; + while (0 1024) + } + if (proplen > 1024) { + printf("proplen was large: %jd while adding = property %s to " + "parent_node %d\n", (intmax_t)proplen, name, = fdt_offset); +#if 0 +// WARNING: Some Macintoshes end up with video-card driver code as = properties. +// An example PowerMac7,2 configuration had 2 such properties, = each +// being 96306 bytes in size. If these were ever used in a = truncated +// from things would be messed up. So do not force = truncations. There +// are a few other, smaller properties that bigger than 1 = KBytes. I +// checked: fdt_platform_load_dtb's 409600 buflen is more than +// sufficient for the example context. + proplen =3D 1024; +#endif + } =20 propbuf =3D malloc(proplen); if (propbuf =3D=3D NULL) { @@ -64,25 +96,93 @@ printf("Cannot allocate memory for prop %s\n", = name); return; } - OF_getprop(node, name, propbuf, proplen); + OF_getprop(parent_node, name, propbuf, proplen); error =3D fdt_setprop(buffer, fdt_offset, name, propbuf, = proplen); free(propbuf); - lastprop =3D name; if (error) printf("Error %d adding property %s to " - "node %d\n", error, name, fdt_offset); + "parent_node %d\n", error, name, = fdt_offset); } =20 - if (!OF_hasprop(node, "phandle") && !OF_hasprop(node, = "linux,phandle") - && !OF_hasprop(node, "ibm,phandle")) - fdt_setprop(buffer, fdt_offset, "phandle", &node, = sizeof(node)); + if (!OF_hasprop(parent_node, "phandle") && = !OF_hasprop(parent_node, "linux,phandle") + && !OF_hasprop(parent_node, "ibm,phandle")) + fdt_setprop(buffer, fdt_offset, "phandle", &parent_node, = sizeof(parent_node)); =20 - for (node =3D OF_child(node); node > 0; node =3D OF_peer(node)) = { - OF_package_to_path(node, name, sizeof(name)); - subname =3D strrchr(name, '/'); + // WARNING: fdt_add_subnode adds to the beginning of the node = sequence (after + // the properties). So, to avoid reversing the sequence, use it = last to first + // for the originals. + + // WARNING: openfirmware's package-to-path(nd,nm,len) does not = place a trailing '\0' + // character in nm when it returns a full_str_len with = len<=3Dfull_str_len . + // For full_str_len=3D 0) return -FDT_ERR_EXISTS; - else if (offset !=3D -FDT_ERR_NOTFOUND) + else +#endif + if (offset !=3D -FDT_ERR_NOTFOUND) return offset; =20 /* Try to place the new node after the parent's properties */ =3D=3D=3D Mark Millard marklmi at yahoo.com ( dsl-only.net went away in early 2018-Mar)