Date: Sun, 9 Mar 2014 08:39:19 +0100 From: Milan Obuch <freebsd-mips@dino.sk> To: Adrian Chadd <adrian@freebsd.org> Cc: freebsd-mips@freebsd.org Subject: Re: I (think) the AR8327 switch support now works Message-ID: <20140309083919.2810fa97@zeta.dino.sk> In-Reply-To: <CAJ-Vmok6gEG0rMSdAccQZkD-McTY8y7LktE1xQsXy7MNODxP2g@mail.gmail.com> References: <CAJ-Vmok0cVLnH9DQh%2Bz6XF-NQmPKy_Ez37kLtuCSRThwjQHTJQ@mail.gmail.com> <20140301143607.13a96bd6@zeta.dino.sk> <CAJ-Vmom2coTLFn0zcTa=BzxAOopMjCDUBOtQwOVOyQmCeB19wA@mail.gmail.com> <20140301200546.7ff373d1@zeta.dino.sk> <20140301231239.023b8733@zeta.dino.sk> <CAJ-VmoknT-SWVmcDX-Cx8StUVuZNX%2BqNPzLcMBdLxN7qwssNoA@mail.gmail.com> <20140307140432.0a460da1@zeta.dino.sk> <CAJ-Vmok-nF4QdVmUMGJxt4tX=X%2Bvc4_-G100ZPRnQ-2aWyNCog@mail.gmail.com> <20140307204230.3c86b9b1@zeta.dino.sk> <CAJ-Vmo=B0CG1FSCKYeaCmORJuWbJ24g=%2BQkHV7WC8DTV9m1zKA@mail.gmail.com> <20140308140901.19782009@zeta.dino.sk> <CAJ-VmokM5mPxMbbVyaSpyDcn-Fs32g4heWMPZF7n2OpnFK31oA@mail.gmail.com> <20140308173642.0a48d2c2@zeta.dino.sk> <CAJ-VmomnycSYbhf4aKaiK%2BUL%2B-aWXy_tXioRUjMVO62r%2BDpEUA@mail.gmail.com> <20140308234129.76800b5c@zeta.dino.sk> <CAJ-Vmok6gEG0rMSdAccQZkD-McTY8y7LktE1xQsXy7MNODxP2g@mail.gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
This is a MIME-formatted message. If you see this text it means that your E-mail software does not support MIME-formatted messages. --=_mailhost.netlab.sk-22601-1394350765-0001-2 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Content-Disposition: inline On Sat, 8 Mar 2014 14:50:14 -0800 Adrian Chadd <adrian@freebsd.org> wrote: > Ok, well now let's figure out if the reset is working or not. > > look at arswitch_attach(): > > * It sets up the default methods; > * it calls ar8327_attach(); > * it resets the switch via arswitch_reset(); > * it calls the HAL methods to set things up; > * it attaches the PHYs; > * it attaches said PHYs; > * it starts the periodic checks via arswitch_tick(). > > So, I'd add some printf()s in arswitch_attach() to see where it's > getting to before it calls return (ENXIO) or return (err). > > > -a > OK, so I patched said function with some printf's (in attachment), built new kernel and got following result: mdio0: <MDIO> on argemdio0 mdioproxy0: <MII/MDIO proxy, MDIO side> on mdio0 arswitch0: readreg 0x00000000: 0x12041204 arswitch0: readreg 0x00000000: 0x00000000 arswitch0: <Atheros AR8327 Ethernet Switch> on mdio0 arswitch0: arswitch_attach 1 device_attach: arswitch0 attach returned 6 Now I put there some more printf's (in arswitch_probe) and things go a bit stranger. I've got: mdio0: <MDIO> on argemdio0 mdioproxy0: <MII/MDIO proxy, MDIO side> on mdio0 unknown: arswitch_probe 1 arswitch0: readreg 0x00000000: 0x00000000 unknown: arswitch_probe 2 0 and for the second time, just doing one more reboot: mdio0: <MDIO> on argemdio0 mdioproxy0: <MII/MDIO proxy, MDIO side> on mdio0 unknown: arswitch_probe 1 arswitch0: readreg 0x00000000: 0x12041204 unknown: arswitch_probe 2 6 unknown: arswitch_probe 1 arswitch0: readreg 0x00000000: 0x00000000 unknown: arswitch_probe 2 0 arswitch0: <Atheros AR8327 Ethernet Switch> on mdio0 arswitch0: arswitch_attach 1 0 device_attach: arswitch0 attach returned 6 Next reboot brings again the first result, next one the second, again the second, again the first one etc. It looks like two two possibilities are alternating with some level of randomness. To me this tells that mdio does not work reliably in this case - am I right thinking that reading register 0 should always return the same value, 0x12041204, at least when no other register is touched in between? Well, this was with soft reset - I got every time mountroot promp, so just pressing enter gives me panic and then I typed reboot. when doing power-cycle, things are a bit deterministic - three time in a row I got the first result. Next question - why is arswitch_probe function called second time? It is called twice for both switches, so it is probably by design, and as the second switch is only 'hint probed', it does not matter. But for 8327, register is read, unfortunatelly not the same result is given both times. Also, I played with if_arge.c - arge_fetch_mdiobus_clock_rate() function a bit, but no matter the clock divider I used, the results are still the same. I see in next function, arge_reset_miibus a comment about resetting the mdio block(s), so I suspect it is something to be done, maybe, but is not yet. I have no idea how to try it, however. I can just wait for next hint, now. Regards, Milan --=_mailhost.netlab.sk-22601-1394350765-0001-2 Content-Type: application/octet-stream; name="arswitch.c-diff" Content-Transfer-Encoding: base64 Content-Disposition: attachment; filename=arswitch.c-diff SW5kZXg6IC9kYXRhL3NyYy8xMS9zeXMvZGV2L2V0aGVyc3dpdGNoL2Fyc3dpdGNoL2Fyc3dpdGNo LmMKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PQotLS0gL2RhdGEvc3JjLzExL3N5cy9kZXYvZXRoZXJzd2l0Y2gvYXJzd2l0 Y2gvYXJzd2l0Y2guYwkocmV2aXNpb24gMjYyOTI5KQorKysgL2RhdGEvc3JjLzExL3N5cy9kZXYv ZXRoZXJzd2l0Y2gvYXJzd2l0Y2gvYXJzd2l0Y2guYwkod29ya2luZyBjb3B5KQpAQCAtMTM1LDYg KzEzNSw3IEBACiAJCXNjLT5zY19zd2l0Y2h0eXBlID0gQVI4WDE2X1NXSVRDSF9BUjgzMTY7CiAJ CWJyZWFrOwogCWNhc2UgMHgxMjAyOgorCWNhc2UgMHgxMjA0OgogCQljaGlwbmFtZSA9ICJBUjgz MjciOwogCQlzYy0+c2Nfc3dpdGNodHlwZSA9IEFSOFgxNl9TV0lUQ0hfQVI4MzI3OwogCQlzYy0+ bWlpX2xvX2ZpcnN0ID0gMTsKQEAgLTMwNCw2ICszMDUsOCBAQAogCXNjLT5oYWwuYXJzd2l0Y2hf dmxhbl9zZXRfcHZpZCA9IGFyOHh4eF9zZXRfcHZpZDsKIAlzYy0+aGFsLmFyc3dpdGNoX2F0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mV0dXJuIChlcnIpOwogfQogCg== --=_mailhost.netlab.sk-22601-1394350765-0001-2--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20140309083919.2810fa97>