From owner-freebsd-embedded@FreeBSD.ORG Sun Dec 25 13:43:42 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id C15AF106566C for ; Sun, 25 Dec 2011 13:43:42 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 842DB8FC0A for ; Sun, 25 Dec 2011 13:43:42 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 4C18E10FDA4; Sun, 25 Dec 2011 14:43:41 +0100 (CET) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: Stefan Bethke In-Reply-To: Date: Sun, 25 Dec 2011 14:43:40 +0100 Content-Transfer-Encoding: 7bit Message-Id: <97BBBF06-E10F-40D1-A682-73B7BFF27290@lassitu.de> References: To: Eitan Adler X-Mailer: Apple Mail (2.1251.1) Cc: freebsd-embedded@freebsd.org Subject: Re: New port: firmware-utils X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 25 Dec 2011 13:43:42 -0000 Am 24.12.2011 um 03:34 schrieb Eitan Adler: > On Thu, Dec 22, 2011 at 10:06 AM, Stefan Bethke wrote: >> Maybe one of the committers could take a look at this PR: >> http://www.freebsd.org/cgi/query-pr.cgi?pr=163537 > > I'll take a look into adding it to the ports tree. Other people here > may want to take a look into it on a more functional level ;) Thanks! -- Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Mon Dec 26 11:07:04 2011 Return-Path: Delivered-To: freebsd-embedded@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9B12E106566B for ; Mon, 26 Dec 2011 11:07:04 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id 87F048FC21 for ; Mon, 26 Dec 2011 11:07:04 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.5/8.14.5) with ESMTP id pBQB74OX022450 for ; Mon, 26 Dec 2011 11:07:04 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.5/8.14.5/Submit) id pBQB73Va022448 for freebsd-embedded@FreeBSD.org; Mon, 26 Dec 2011 11:07:03 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 26 Dec 2011 11:07:03 GMT Message-Id: <201112261107.pBQB73Va022448@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-embedded@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-embedded@FreeBSD.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2011 11:07:04 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o misc/52256 embedded [picobsd] picobsd build script does not read in user/s o kern/42728 embedded [picobsd] many problems in src/usr.sbin/ppp/* after c 2 problems total. From owner-freebsd-embedded@FreeBSD.ORG Mon Dec 26 20:46:54 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 1115C106564A; Mon, 26 Dec 2011 20:46:54 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 8FCF28FC12; Mon, 26 Dec 2011 20:46:53 +0000 (UTC) Received: by vbbfr13 with SMTP id fr13so15342716vbb.13 for ; Mon, 26 Dec 2011 12:46:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=No/uQ0JdNU30Q4YEBH2dsHhClndSmqdDG50S1qHoflE=; b=HOdB0PpgG01j66cLTtkKH++HUwdBEVZFuhZKxOgoJ51q0X1QreaSZ0UoNfsSfeDXr2 msqnGldizry//S06EAV2JxYqsciOsfOTamzM7Eww1Xqvdh7Ix3ZsSkbNogy0lPe9vJ+S QtNWIkKRAdUIqL7fl/U2yyOX+6ryMcYLgibnM= MIME-Version: 1.0 Received: by 10.52.29.16 with SMTP id f16mr12564729vdh.45.1324932412895; Mon, 26 Dec 2011 12:46:52 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Mon, 26 Dec 2011 12:46:52 -0800 (PST) In-Reply-To: <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <09670C34-0D30-46BC-BA7E-4AAA22193B61@lassitu.de> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> Date: Mon, 26 Dec 2011 12:46:52 -0800 X-Google-Sender-Auth: yz4igUdcBN1pO7xydFJiS-0NoMQ Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2011 20:46:54 -0000 Hi, I've tested the two patches. * the iicbb patch is fine at first glance, but I haven't yet sat down to figure out whether it's fine for older (and non-rtl8366rb) devices. I'll commit it to my repo, so you can just pull it into yours. We should likely change it to default to 10uS to preserve behaviour and then override it in hints (hint.iicbb.0.udelay=3) for this particular board. * the rtl8366rb change however applied and compiled, but it has completely broken things. I don't get any port status updates and etherswitchcfg doesn't actually return any configuration. Would you mind retesting all of that? Adrian From owner-freebsd-embedded@FreeBSD.ORG Mon Dec 26 20:49:27 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2742106566B; Mon, 26 Dec 2011 20:49:27 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 5DBFA8FC0A; Mon, 26 Dec 2011 20:49:26 +0000 (UTC) Received: by vcbfk1 with SMTP id fk1so15244944vcb.13 for ; Mon, 26 Dec 2011 12:49:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=+BE8bKAKuGQZTYDXPXoBBAYHhlM6S4mJk5HUq5boBdw=; b=CsFGUqRkqKiujyyaTET9ql1+qJOwcvXWec/HpyHv9D1TDLM8Au+jxFMux1la/0UrW1 ueA0s8uAku5c8opjuD7E2FW9OHHO4cokEsNS8CwdN6gvedsQJWCDmZeuXzg5meuKnFwL unuedv48TdMN4zs1PB8uvcRCzwmQFaCjQlshY= MIME-Version: 1.0 Received: by 10.52.33.99 with SMTP id q3mr12441260vdi.100.1324932566491; Mon, 26 Dec 2011 12:49:26 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Mon, 26 Dec 2011 12:49:26 -0800 (PST) In-Reply-To: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <09670C34-0D30-46BC-BA7E-4AAA22193B61@lassitu.de> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> Date: Mon, 26 Dec 2011 12:49:26 -0800 X-Google-Sender-Auth: yuQD8n60elMDzVGsQBlPxXLhAkg Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2011 20:49:28 -0000 I think I was a bit too quick. It turns out that after a few minutes of uptime, I get the same behaviour from your iicbb changes. # etherswitchcfg port0: vlangroup: 1 media: Ethernet autoselect (none) status: no carrier port1: vlangroup: 0 media: Ethernet autoselect (1000baseT ) status: active port2: vlangroup: 0 media: Ethernet autoselect (none) status: no carrier port3: vlangroup: 0 media: Ethernet autoselect (none) status: no carrier port4: vlangroup: 0 media: Ethernet autoselect (none) status: no carrier port5: vlangroup: 0 media: Ethernet 1000baseT status: active vlangroup0: vlan: 1 members 1,2,3,4,5 vlangroup1: vlan: 2 members 0,5t .. then after a few minutes: # rtl8366rb0port1: link state changed to DOWN # # # etherswitchcfg port0: vlangroup: 0 media: Ethernet autoselect status: no carrier port1: vlangroup: 0 media: Ethernet autoselect status: no carrier port2: vlangroup: 0 media: Ethernet autoselect status: no carrier port3: vlangroup: 0 media: Ethernet autoselect status: no carrier port4: vlangroup: 0 media: Ethernet autoselect status: no carrier port5: vlangroup: 0 media: Ethernet 10baseT/UTP status: active .. I wonder what's going on there. Adrian From owner-freebsd-embedded@FreeBSD.ORG Mon Dec 26 22:13:33 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 14FD71065677; Mon, 26 Dec 2011 22:13:33 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id B78988FC22; Mon, 26 Dec 2011 22:13:32 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 858AF112D52; Mon, 26 Dec 2011 22:13:31 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Mon, 26 Dec 2011 23:13:30 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <2DC67148-029F-4DD8-BDB8-07897D343E77@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <09670C 34-0D30-46BC-BA7E-4AAA22193B61@lassitu.de> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2011 22:13:33 -0000 Am 26.12.2011 um 21:49 schrieb Adrian Chadd: > I think I was a bit too quick. It turns out that after a few minutes > of uptime, I get the same behaviour from your iicbb changes. Give me a few moments. I think I've painted myself into a corner with = git, so I'm cloning your repo and re-applying my changes against that. = Shouldn't take more than an hour, I hope. Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Mon Dec 26 22:17:02 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A472D106566C; Mon, 26 Dec 2011 22:17:02 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 2B4798FC12; Mon, 26 Dec 2011 22:17:01 +0000 (UTC) Received: by vbbfr13 with SMTP id fr13so15385563vbb.13 for ; Mon, 26 Dec 2011 14:17:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=CWj1GbAqcm+t6Sk2Nu3DyJLkpxmyzqqZ4C29NTt9Rts=; b=nJ2Zp1eX0NFOAMlbXq7BiZqR6TeCaXGDLGEQKCBn9XqoJrXr2TvXBxYJBmCa+2ax4t v+rj2ofoRGi2UVPhP4n4iqfxxYSYHZWn7bma3o2nBD9wtKZZM2pgDffkV1CrxwY6taqT G9FSKWQzAAMD4MSOCyfHboHzYtAaUor9OF8Z4= MIME-Version: 1.0 Received: by 10.52.29.16 with SMTP id f16mr12652884vdh.45.1324937821220; Mon, 26 Dec 2011 14:17:01 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Mon, 26 Dec 2011 14:17:01 -0800 (PST) In-Reply-To: <2DC67148-029F-4DD8-BDB8-07897D343E77@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <2DC67148-029F-4DD8-BDB8-07897D343E77@lassitu.de> Date: Mon, 26 Dec 2011 14:17:01 -0800 X-Google-Sender-Auth: JUQmE--yEpvyP9YqcbBINZzn23E Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2011 22:17:02 -0000 On 26 December 2011 14:13, Stefan Bethke wrote: > Am 26.12.2011 um 21:49 schrieb Adrian Chadd: > >> I think I was a bit too quick. It turns out that after a few minutes >> of uptime, I get the same behaviour from your iicbb changes. > > Give me a few moments. =A0I think I've painted myself into a corner with = git, so I'm cloning your repo and re-applying my changes against that. Shou= ldn't take more than an hour, I hope. I messed up something w/ my git tree earlier today. Sorry :( Adrian From owner-freebsd-embedded@FreeBSD.ORG Mon Dec 26 22:18:32 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 12BA5106564A; Mon, 26 Dec 2011 22:18:32 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id B19378FC0A; Mon, 26 Dec 2011 22:18:31 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id EFDD4112D87; Mon, 26 Dec 2011 22:18:30 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Mon, 26 Dec 2011 23:18:30 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <77F29647-89B0-4538-B638-72F0AFEFA971@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <2DC67148-029F-4DD8-BDB8-07897D343E77@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2011 22:18:32 -0000 Am 26.12.2011 um 23:17 schrieb Adrian Chadd: > On 26 December 2011 14:13, Stefan Bethke wrote: >> Am 26.12.2011 um 21:49 schrieb Adrian Chadd: >>=20 >>> I think I was a bit too quick. It turns out that after a few minutes >>> of uptime, I get the same behaviour from your iicbb changes. >>=20 >> Give me a few moments. I think I've painted myself into a corner = with git, so I'm cloning your repo and re-applying my changes against = that. Shouldn't take more than an hour, I hope. >=20 > I messed up something w/ my git tree earlier today. Sorry :( Should I work from = git://gitorious.org/~adrianchadd/freebsd/adrianchadd-freebsd-work.git, = or from the plain FreeBSD clone? Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Mon Dec 26 23:12:12 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 73882106566B; Mon, 26 Dec 2011 23:12:12 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 163638FC08; Mon, 26 Dec 2011 23:12:12 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 43302112E3B; Mon, 26 Dec 2011 23:12:11 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Tue, 27 Dec 2011 00:12:10 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <49DC2FF3-0513-4CD1-89F2-93A394600D3C@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <2DC67148-029F-4DD8-BDB8-07897D343E77@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Dec 2011 23:12:12 -0000 Am 26.12.2011 um 23:17 schrieb Adrian Chadd: > On 26 December 2011 14:13, Stefan Bethke wrote: >> Am 26.12.2011 um 21:49 schrieb Adrian Chadd: >>=20 >>> I think I was a bit too quick. It turns out that after a few minutes >>> of uptime, I get the same behaviour from your iicbb changes. >>=20 >> Give me a few moments. I think I've painted myself into a corner = with git, so I'm cloning your repo and re-applying my changes against = that. Shouldn't take more than an hour, I hope. >=20 > I messed up something w/ my git tree earlier today. Sorry :( I see that your TP-WN1043ND.hints has 1 usec delay. Technically that = would be too fast; the datasheet says minimum time for SCLK being high = and low respectively is 4 microseconds. With the current code, that = would be hint.iicbb.0.udelay=3D2. I'm building now to test. Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Tue Dec 27 00:01:01 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id DEC3E106564A; Tue, 27 Dec 2011 00:01:01 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 8B3D58FC08; Tue, 27 Dec 2011 00:01:01 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id AA83A112FFE; Tue, 27 Dec 2011 00:01:00 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: <49DC2FF3-0513-4CD1-89F2-93A394600D3C@lassitu.de> Date: Tue, 27 Dec 2011 01:00:59 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <2DC67148-029F-4DD8-BDB8-07897D343E77@lassitu.de> <49DC2FF3-0513-4CD1-89F2-93A394600D3C@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 00:01:02 -0000 Am 27.12.2011 um 00:12 schrieb Stefan Bethke: >=20 > Am 26.12.2011 um 23:17 schrieb Adrian Chadd: >=20 >> On 26 December 2011 14:13, Stefan Bethke wrote: >>> Am 26.12.2011 um 21:49 schrieb Adrian Chadd: >>>=20 >>>> I think I was a bit too quick. It turns out that after a few = minutes >>>> of uptime, I get the same behaviour from your iicbb changes. >>>=20 >>> Give me a few moments. I think I've painted myself into a corner = with git, so I'm cloning your repo and re-applying my changes against = that. Shouldn't take more than an hour, I hope. >>=20 >> I messed up something w/ my git tree earlier today. Sorry :( >=20 > I see that your TP-WN1043ND.hints has 1 usec delay. Technically that = would be too fast; the datasheet says minimum time for SCLK being high = and low respectively is 4 microseconds. With the current code, that = would be hint.iicbb.0.udelay=3D2. >=20 > I'm building now to test. With hint.iicbb.0.udelay=3D2 it's working fine, with the delay down to 1 = the switch chip stops being selected as a slave. Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Tue Dec 27 00:06:24 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6D882106566B; Tue, 27 Dec 2011 00:06:24 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 1C4E68FC12; Tue, 27 Dec 2011 00:06:24 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 49EADA0021; Tue, 27 Dec 2011 00:06:23 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Tue, 27 Dec 2011 01:06:22 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <41C0AA45-1DD9-4895-913D-832E85A1A0E7@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <09670C 34-0D30-46BC-BA7E-4AAA22193B61@lassitu.de> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 00:06:24 -0000 Am 26.12.2011 um 21:46 schrieb Adrian Chadd: > Hi, >=20 > I've tested the two patches. >=20 > * the iicbb patch is fine at first glance, but I haven't yet sat down > to figure out whether it's fine for older (and non-rtl8366rb) devices. > I'll commit it to my repo, so you can just pull it into yours. > We should likely change it to default to 10uS to preserve behaviour > and then override it in hints (hint.iicbb.0.udelay=3D3) for this > particular board. >=20 > * the rtl8366rb change however applied and compiled, but it has > completely broken things. I don't get any port status updates and > etherswitchcfg doesn't actually return any configuration. Would you > mind retesting all of that? Here's a slightly updated patch (pushed to = https://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work/commits/wo= rk/ath): Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Tue Dec 27 00:07:01 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E6C9F106564A; Tue, 27 Dec 2011 00:07:01 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 475E28FC15; Tue, 27 Dec 2011 00:07:01 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 6D7D6A0031; Tue, 27 Dec 2011 00:07:00 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: multipart/mixed; boundary="Apple-Mail=_67BAA412-B86D-4ADF-850D-FC1A49EADEB9" From: Stefan Bethke In-Reply-To: Date: Tue, 27 Dec 2011 01:07:00 +0100 Message-Id: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <09670C 34-0D30-46BC-BA7E-4AAA22193B61@lassitu.de> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 00:07:02 -0000 --Apple-Mail=_67BAA412-B86D-4ADF-850D-FC1A49EADEB9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Am 26.12.2011 um 21:46 schrieb Adrian Chadd: > Hi, >=20 > I've tested the two patches. >=20 > * the iicbb patch is fine at first glance, but I haven't yet sat down > to figure out whether it's fine for older (and non-rtl8366rb) devices. > I'll commit it to my repo, so you can just pull it into yours. > We should likely change it to default to 10uS to preserve behaviour > and then override it in hints (hint.iicbb.0.udelay=3D3) for this > particular board. >=20 > * the rtl8366rb change however applied and compiled, but it has > completely broken things. I don't get any port status updates and > etherswitchcfg doesn't actually return any configuration. Would you > mind retesting all of that? Here's a slightly updated patch (pushed to = https://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work/commits/wo= rk/ath): --Apple-Mail=_67BAA412-B86D-4ADF-850D-FC1A49EADEB9 Content-Disposition: attachment; filename=rtl8366rb.patch Content-Type: application/octet-stream; x-unix-mode=0644; name="rtl8366rb.patch" Content-Transfer-Encoding: 7bit diff --git a/sys/dev/etherswitch/rtl8366rb.c b/sys/dev/etherswitch/rtl8366rb.c index f41a425..a2566b4 100644 --- a/sys/dev/etherswitch/rtl8366rb.c +++ b/sys/dev/etherswitch/rtl8366rb.c @@ -139,7 +139,7 @@ rtl8366rb_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; - mtx_init(&sc->sc_mtx, device_get_nameunit(dev), MTX_NETWORK_LOCK, + mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "rtl8366rb", MTX_DEF); rtl8366rb_init(dev); smi_read(dev, RTL8366RB_CVCR, &rev); @@ -200,17 +200,69 @@ rtl8366rb_detach(device_t dev) return (0); } +static int +rtl8366rb_media_from_portstatus(int portstatus) +{ + int media; + + if ((portstatus & RTL8366RB_PLSR_LINK) == 0) + return IFM_ETHER | IFM_NONE; + media = IFM_ETHER; + switch (portstatus & RTL8366RB_PLSR_SPEED_MASK) { + case RTL8366RB_PLSR_SPEED_10: + media |= IFM_10_T; + break; + case RTL8366RB_PLSR_SPEED_100: + media |= IFM_100_TX; + break; + case RTL8366RB_PLSR_SPEED_1000: + media |= IFM_1000_T; + break; + } + if ((portstatus & RTL8366RB_PLSR_FULLDUPLEX) != 0) + media |= IFM_FDX; + else + media |= IFM_HDX; + if ((portstatus & RTL8366RB_PLSR_TXPAUSE) != 0) + media |= IFM_ETH_TXPAUSE; + if ((portstatus & RTL8366RB_PLSR_RXPAUSE) != 0) + media |= IFM_ETH_RXPAUSE; + return media; +} + +static void +rtl833rb_miipollstat(struct rtl8366rb_softc *sc) +{ + int i; + struct mii_data *mii; + struct mii_softc *child; + uint16_t value; + int portstatus; + + for (i = 0; i < RTL8366RB_NUM_PORTS-1; i++) { + mii = device_get_softc(sc->miibus[i]); + if ((i % 2) == 0) { + smi_read(sc->dev, RTL8366RB_PLSR_BASE + i/2, &value); + portstatus = value & 0xff; + } else { + portstatus = (value >> 8) & 0xff; + } + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = rtl8366rb_media_from_portstatus(portstatus); + LIST_FOREACH(child, &mii->mii_phys, mii_list) { + if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) != child->mii_inst) + continue; + (void)PHY_SERVICE(child, mii, MII_POLLSTAT); + } + } +} + static void rtl8366rb_tick(void *arg) { struct rtl8366rb_softc *sc = arg; - int i; - for (i=0; i < RTL8366RB_NUM_PORTS-1; i++) { - if (sc->miibus[i] != NULL) - mii_tick(device_get_softc(sc->miibus[i])); - mii_pollstat(device_get_softc(sc->miibus[i])); - } + rtl833rb_miipollstat(sc); callout_reset(&sc->callout_tick, hz, rtl8366rb_tick, sc); } @@ -333,20 +385,7 @@ rtl_getport(device_t dev, etherswitch_port_t *p) ifmr->ifm_count = 0; smi_read(dev, RTL8366RB_PLSR_BASE + (RTL8366RB_NUM_PORTS-1)/2, &v); v = v >> (8 * ((RTL8366RB_NUM_PORTS-1) % 2)); - switch (v & RTL8366RB_PLSR_SPEED_MASK) { - case RTL8366RB_PLSR_SPEED_10: - ifmr->ifm_current = IFM_ETHER | IFM_10_T; - break; - case RTL8366RB_PLSR_SPEED_100: - ifmr->ifm_current = IFM_ETHER | IFM_100_TX; - break; - case RTL8366RB_PLSR_SPEED_1000: - ifmr->ifm_current = IFM_ETHER | IFM_1000_T; - break; - } - if ((v & RTL8366RB_PLSR_FULLDUPLEX) != 0) - ifmr->ifm_current |= IFM_FDX; - ifmr->ifm_active = ifmr->ifm_current; + ifmr->ifm_active = ifmr->ifm_current = rtl8366rb_media_from_portstatus(v); ifmr->ifm_mask = 0; ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID; } @@ -435,10 +474,7 @@ rtl8366rb_ifmedia_upd(struct ifnet *ifp) { struct rtl8366rb_softc *sc = ifp->if_softc; struct mii_data *mii = device_get_softc(sc->miibus[ifp->if_dunit]); - struct mii_softc *miisc; - LIST_FOREACH(miisc, &mii->mii_phys, mii_list) - PHY_RESET(miisc); mii_mediachg(mii); return (0); } diff --git a/sys/dev/etherswitch/rtl8366rbvar.h b/sys/dev/etherswitch/rtl8366rbvar.h index f14373a..3c6067b 100644 --- a/sys/dev/etherswitch/rtl8366rbvar.h +++ b/sys/dev/etherswitch/rtl8366rbvar.h @@ -43,8 +43,9 @@ #define RTL8366RB_SGCR_MAX_LENGTH_1536 0x0010 #define RTL8366RB_SGCR_MAX_LENGTH_1552 0x0020 #define RTL8366RB_SGCR_MAX_LENGTH_9216 0x0030 -#define RTL8366RB_SGCR_EN_VLAN 0x2000 -#define RTL8366RB_SGCR_EN_VLAN_4KTB 0x4000 +#define RTL8366RB_SGCR_EN_VLAN 0x2000 +#define RTL8366RB_SGCR_EN_VLAN_4KTB 0x4000 +#define RTL8366RB_SGCR_EN_QOS 0x8000 /* Port Enable Control: DISABLE_PORT[5:0] */ #define RTL8366RB_PECR 0x0001 @@ -65,27 +66,28 @@ #define RTL8366RB_PLSR_SPEED_10 0x00 #define RTL8366RB_PLSR_SPEED_100 0x01 #define RTL8366RB_PLSR_SPEED_1000 0x02 -#define RTL8366RB_PLSR_FULLDUPLEX 0x10 +#define RTL8366RB_PLSR_FULLDUPLEX 0x08 +#define RTL8366RB_PLSR_LINK 0x10 #define RTL8366RB_PLSR_TXPAUSE 0x20 #define RTL8366RB_PLSR_RXPAUSE 0x40 #define RTL8366RB_PLSR_NO_AUTO 0x80 /* VLAN Member Configuration, 3 registers per VLAN */ #define RTL8366RB_VMCR_BASE 0x0020 -#define RTL8366RB_VMCR_MULT 3 -#define RTL8366RB_VMCR_DOT1Q_REG 0 +#define RTL8366RB_VMCR_MULT 3 +#define RTL8366RB_VMCR_DOT1Q_REG 0 #define RTL8366RB_VMCR_DOT1Q_VID_SHIFT 0 #define RTL8366RB_VMCR_DOT1Q_VID_MASK 0x0fff #define RTL8366RB_VMCR_DOT1Q_PCP_SHIFT 12 #define RTL8366RB_VMCR_DOT1Q_PCP_MASK 0x7000 -#define RTL8366RB_VMCR_MU_REG 1 +#define RTL8366RB_VMCR_MU_REG 1 #define RTL8366RB_VMCR_MU_MEMBER_SHIFT 0 #define RTL8366RB_VMCR_MU_MEMBER_MASK 0x00ff #define RTL8366RB_VMCR_MU_UNTAG_SHIFT 8 #define RTL8366RB_VMCR_MU_UNTAG_MASK 0xff00 -#define RTL8366RB_VMCR_FID_REG 2 +#define RTL8366RB_VMCR_FID_REG 2 #define RTL8366RB_VMCR_FID_FID_SHIFT 0 -#define RTL8366RB_VMCR_FID_FID_MASK 0x0007 +#define RTL8366RB_VMCR_FID_FID_MASK 0x0007 #define RTL8366RB_VMCR(_reg, _vlan) \ (RTL8366RB_VMCR_BASE + _reg + _vlan * RTL8366RB_VMCR_MULT) /* VLAN Identifier */ @@ -93,13 +95,15 @@ (_r[RTL8366RB_VMCR_DOT1Q_REG] & RTL8366RB_VMCR_DOT1Q_VID_MASK) /* Priority Code Point */ #define RTL8366RB_VMCR_PCP(_r) \ - ((_r[RTL8366RB_VMCR_DOT1Q_REG] & RTL8366RB_VMCR_DOT1Q_PCP_MASK) >> RTL8366RB_VMCR_DOT1Q_PCP_SHIFT) + ((_r[RTL8366RB_VMCR_DOT1Q_REG] & RTL8366RB_VMCR_DOT1Q_PCP_MASK) \ + >> RTL8366RB_VMCR_DOT1Q_PCP_SHIFT) /* Member ports */ #define RTL8366RB_VMCR_MEMBER(_r) \ (_r[RTL8366RB_VMCR_MU_REG] & RTL8366RB_VMCR_MU_MEMBER_MASK) /* Untagged ports */ #define RTL8366RB_VMCR_UNTAG(_r) \ - ((_r[RTL8366RB_VMCR_MU_REG] & RTL8366RB_VMCR_MU_UNTAG_MASK) >> RTL8366RB_VMCR_MU_UNTAG_SHIFT) + ((_r[RTL8366RB_VMCR_MU_REG] & RTL8366RB_VMCR_MU_UNTAG_MASK) \ + >> RTL8366RB_VMCR_MU_UNTAG_SHIFT) /* Forwarding ID */ #define RTL8366RB_VMCR_FID(_r) \ (_r[RTL8366RB_VMCR_FID_REG] & RTL8366RB_VMCR_FID_FID_MASK) @@ -135,6 +139,19 @@ /* VLAN Ingress Control 2: [5:0] */ #define RTL8366RB_VIC2R 0x037f +/* MIB registers */ +#define RTL8366RB_MCNT_BASE 0x1000 +#define RTL8366RB_MCTLR 0x13f0 +#define RTL8366RB_MCTLR_BUSY 0x0001 +#define RTL8366RB_MCTLR_RESET 0x0002 +#define RTL8366RB_MCTLR_RESET_PORT_MASK 0x00fc +#define RTL8366RB_MCTLR_RESET_ALL 0x0800 + +#define RTL8366RB_MCNT(_port, _r) \ + (RTL8366RB_MCNT_BASE + 0x50 * (_port) + (_r)) +#define RTL8366RB_MCTLR_RESET_PORT(_p) \ + (1 << ((_p) + 2)) + /* PHY Access Control */ #define RTL8366RB_PACR 0x8000 #define RTL8366RB_PACR_WRITE 0x0000 diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c index 7c03ab4..cdb65e5 100644 --- a/sys/dev/iicbus/iicbb.c +++ b/sys/dev/iicbus/iicbb.c @@ -437,7 +437,6 @@ iicbb_start(device_t dev, u_char slave, int timeout) static int iicbb_stop(device_t dev) { - i2c_stop(dev); I2C_LOG(">\n"); return (0); --Apple-Mail=_67BAA412-B86D-4ADF-850D-FC1A49EADEB9 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Stefan -- Stefan Bethke Fon +49 151 14070811 --Apple-Mail=_67BAA412-B86D-4ADF-850D-FC1A49EADEB9-- From owner-freebsd-embedded@FreeBSD.ORG Tue Dec 27 07:02:57 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 77171106564A for ; Tue, 27 Dec 2011 07:02:57 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id 25C1A8FC14 for ; Tue, 27 Dec 2011 07:02:56 +0000 (UTC) Received: by vbbfr13 with SMTP id fr13so15683623vbb.13 for ; Mon, 26 Dec 2011 23:02:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=oCVlAWeHrYSROMjGQDbi2xCXW0n7VqgOJiViWnYbqSw=; b=xjmHftovVQU8LJs/JzCl19s959XC6hijJj8qb+aaWMGXkSuJHF7v/ttmufXYK+7EHt 2TBTW605QLDHCexqcG4RtKvrauCir9/G5ypvbsDfH8IkCNFaALcv3LfKDR20sEOdaLHc R8whBNeUNUEEasiXoKNnoPhXT6NhXyiCFpyCs= MIME-Version: 1.0 Received: by 10.52.33.99 with SMTP id q3mr13006664vdi.100.1324969376433; Mon, 26 Dec 2011 23:02:56 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Mon, 26 Dec 2011 23:02:56 -0800 (PST) In-Reply-To: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> Date: Mon, 26 Dec 2011 23:02:56 -0800 X-Google-Sender-Auth: KMVZpcJL2vMvpiAhO9dIyX9picQ Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 07:02:57 -0000 Hi, I've tested this code out: * The rtl8366 updates have dropped CPU use, thanks! * The iicbb code makes things unstable, as we discovered on irc * Using what's in -HEAD, the minimum stable delay is "5" * .. but when I use your iicbb changes, "5" is also unstable. So is something perhaps just plain wrong with the iicbb code? Adrian From owner-freebsd-embedded@FreeBSD.ORG Tue Dec 27 14:42:16 2011 Return-Path: Delivered-To: freebsd-embedded@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E71991065675 for ; Tue, 27 Dec 2011 14:42:16 +0000 (UTC) (envelope-from krassi@bulinfo.net) Received: from mx.bulinfo.net (mx.bulinfo.net [193.194.156.1]) by mx1.freebsd.org (Postfix) with ESMTP id 9E7038FC0C for ; Tue, 27 Dec 2011 14:42:16 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.bulinfo.net (Postfix) with ESMTP id 099225CA27 for ; Tue, 27 Dec 2011 16:25:32 +0200 (EET) X-Virus-Scanned: amavisd-new at bulinfo.net Received: from mx.bulinfo.net ([127.0.0.1]) by localhost (mx.bulinfo.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id suQ3O6-CJzAG for ; Tue, 27 Dec 2011 16:25:31 +0200 (EET) Received: from [192.168.2.187] (pythia.bulinfo.net [212.72.195.5]) by mx.bulinfo.net (Postfix) with ESMTP id CDF1C5C963 for ; Tue, 27 Dec 2011 16:25:31 +0200 (EET) Message-ID: <4EF9D58A.9030608@bulinfo.net> Date: Tue, 27 Dec 2011 16:26:18 +0200 From: Krassimir Slavchev User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.23) Gecko/20110929 Thunderbird/3.1.15 MIME-Version: 1.0 To: freebsd-embedded@FreeBSD.org X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Subject: Interrupting boot process X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 14:42:17 -0000 Hello list, I use nanobsd (FreeBSD 8) and would like to prevent interrupting of the boot process by hitting CTRL+C. All consoles are marked as insecure in /etc/ttys. The problem is that the /etc/rc.initdiskless can be interrupted at the moment when /etc is empty and the result is dropping into a shell without asking for a password. I have tried to trap the interrupt signal from rc.initdiskless but no luck. What is the appropriate solution of this problem? Best Regards From owner-freebsd-embedded@FreeBSD.ORG Tue Dec 27 17:18:55 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0051F106566B; Tue, 27 Dec 2011 17:18:54 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 34C488FC17; Tue, 27 Dec 2011 17:18:53 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id D4E3741A91; Tue, 27 Dec 2011 17:18:51 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: multipart/mixed; boundary="Apple-Mail=_8BCC333A-BF48-41F3-90E3-140840423ED9" From: Stefan Bethke In-Reply-To: Date: Tue, 27 Dec 2011 18:18:51 +0100 Message-Id: <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <09670C 34-0D30-46BC-BA7E-4AAA22193B61@lassitu.de> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 17:18:55 -0000 --Apple-Mail=_8BCC333A-BF48-41F3-90E3-140840423ED9 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=us-ascii Am 27.12.2011 um 01:07 schrieb Stefan Bethke: > Am 26.12.2011 um 21:46 schrieb Adrian Chadd: >=20 >> Hi, >>=20 >> I've tested the two patches. >>=20 >> * the iicbb patch is fine at first glance, but I haven't yet sat down >> to figure out whether it's fine for older (and non-rtl8366rb) = devices. >> I'll commit it to my repo, so you can just pull it into yours. >> We should likely change it to default to 10uS to preserve behaviour >> and then override it in hints (hint.iicbb.0.udelay=3D3) for this >> particular board. >>=20 >> * the rtl8366rb change however applied and compiled, but it has >> completely broken things. I don't get any port status updates and >> etherswitchcfg doesn't actually return any configuration. Would you >> mind retesting all of that? >=20 > Here's a slightly updated patch (pushed to = https://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work/commits/wo= rk/ath): Another update: --Apple-Mail=_8BCC333A-BF48-41F3-90E3-140840423ED9 Content-Disposition: attachment; filename=rtl8366rb.patch Content-Type: application/octet-stream; name="rtl8366rb.patch" Content-Transfer-Encoding: 7bit diff --git a/sbin/etherswitchcfg/etherswitchcfg.8 b/sbin/etherswitchcfg/etherswitchcfg.8 index de43a26..538950c 100644 --- a/sbin/etherswitchcfg/etherswitchcfg.8 +++ b/sbin/etherswitchcfg/etherswitchcfg.8 @@ -11,10 +11,18 @@ .Ar info .Nm .Op Fl "f control file" +.Ar phy +.Ar phy.register[=value] +.Nm +.Op Fl "f control file" .Ar port%d .Ar command parameter .Nm .Op Fl "f control file" +.Ar reg +.Ar register[=value] +.Nm +.Op Fl "f control file" .Ar vlangroup%d .Ar command parameter .Sh DESCRIPTION @@ -23,27 +31,55 @@ The utility is used to configure an Ethernet switch built into the system. .Nm accepts a number of options: -.Bl -tag -width Fl "f control file" -compact +.Bl -tag -width ".Fl f" -compact .It Fl "f control file" Specifies the .Xr etherswitch 4 control file that represents the switch to be configured. +It defaults to +.Li /dev/etherswitch0 . +.It Fl m +When reporting port information, also list available media options for +that port. .It Fl v Produce more verbose output. Without this flag, lines that represent inactive or empty configuration options are omitted. .El +.Ss phy +The phy command provides access to the registers of the PHYs attached +to or integrated into the switch controller. +PHY registers are specified as phy.register, +where +.Ar phy +is usually the port number, and +.Ar register +is the register number. +Both can be provided as decimal, octal or hexadecimal numbers in any of the formats +understood by +.Xr strtol 4 . +To set the register value, use the form instance.register=value. .Ss port The port command selects one of the ports of the switch. It supports the following commands: -.Bl -tag -width Ar vlangroup number -compact +.Bl -tag -width ".Ar vlangroup number" -compact .It Ar vlangroup number Sets the VLAN group number that is used to process incoming frames that are not tagged. +.It Ar media mediaspec +Specifies the physical media configuration to be configured for a port. +.It Ar mediaopt mediaoption +Specifies a list of media options for a port. See +.Xr ifconfig 8 +for details on +.Ar media and +.Ar mediaopt . .El +.Ss reg +The reg command provides access to the registers of the switch controller. .Ss vlangroup The vlangroup command selects one of the VLAN groups for configuration. It supports the following commands: -.Bl -tag -width Ar vlangroup -compact +.Bl -tag -width ".Ar vlangroup" -compact .It Ar vlan VID Sets the VLAN ID (802.1q VID) for this VLAN group. Frames transmitted on tagged member ports of this group will be tagged diff --git a/sbin/etherswitchcfg/etherswitchcfg.c b/sbin/etherswitchcfg/etherswitchcfg.c index 9994a3d..e6129f3 100644 --- a/sbin/etherswitchcfg/etherswitchcfg.c +++ b/sbin/etherswitchcfg/etherswitchcfg.c @@ -59,7 +59,8 @@ enum cmdmode { MODE_NONE = 0, MODE_PORT, MODE_VLANGROUP, - MODE_REGISTER + MODE_REGISTER, + MODE_PHYREG }; struct cfg { @@ -105,6 +106,30 @@ write_register(struct cfg *cfg, int r, int v) err(EX_OSERR, "ioctl(IOETHERSWITCHSETREG)"); } +static int +read_phyregister(struct cfg *cfg, int phy, int reg) +{ + struct etherswitch_phyreg er; + + er.phy = phy; + er.reg = reg; + if (ioctl(cfg->fd, IOETHERSWITCHGETPHYREG, &er) != 0) + err(EX_OSERR, "ioctl(IOETHERSWITCHGETPHYREG)"); + return (er.val); +} + +static void +write_phyregister(struct cfg *cfg, int phy, int reg, int val) +{ + struct etherswitch_phyreg er; + + er.phy = phy; + er.reg = reg; + er.val = val; + if (ioctl(cfg->fd, IOETHERSWITCHSETPHYREG, &er) != 0) + err(EX_OSERR, "ioctl(IOETHERSWITCHSETPHYREG)"); +} + static void set_port_vlangroup(struct cfg *cfg, char *argv[]) { @@ -239,6 +264,29 @@ set_register(struct cfg *cfg, char *arg) return (0); } +static int +set_phyregister(struct cfg *cfg, char *arg) +{ + int phy, reg, val; + char *c, *d; + + phy = strtol(arg, &c, 0); + if (c==arg) + return (1); + if (*c != '.') + return (1); + d = c+1; + reg = strtol(d, &c, 0); + if (d == c) + return (1); + if (*c == '=') { + val = strtol(c+1, NULL, 0); + write_phyregister(cfg, phy, reg, val); + } + printf("\treg %d.0x%02x=0x%04x\n", phy, reg, read_phyregister(cfg, phy, reg)); + return (0); +} + static void print_port(struct cfg *cfg, int port) { @@ -351,6 +399,7 @@ newmode(struct cfg *cfg, enum cmdmode mode) print_vlangroup(cfg, cfg->unit); break; case MODE_REGISTER: + case MODE_PHYREG: break; } cfg->mode = mode; @@ -406,6 +455,8 @@ main(int argc, char *argv[]) if (cfg.unit < 0 || cfg.unit >= cfg.info.es_nvlangroups) errx(EX_USAGE, "port unit must be between 0 and %d", cfg.info.es_nvlangroups); newmode(&cfg, MODE_VLANGROUP); + } else if (strcmp(argv[0], "phy") == 0) { + newmode(&cfg, MODE_PHYREG); } else if (strcmp(argv[0], "reg") == 0) { newmode(&cfg, MODE_REGISTER); } else { @@ -434,6 +485,12 @@ main(int argc, char *argv[]) continue; } break; + case MODE_PHYREG: + if (set_phyregister(&cfg, argv[0]) != 0) { + newmode(&cfg, MODE_NONE); + continue; + } + break; } argc--; argv++; diff --git a/sys/dev/etherswitch/etherswitch.c b/sys/dev/etherswitch/etherswitch.c index 19b4630..9d1a865 100644 --- a/sys/dev/etherswitch/etherswitch.c +++ b/sys/dev/etherswitch/etherswitch.c @@ -202,6 +202,7 @@ etherswitchioctl(struct cdev *cdev, u_long cmd, caddr_t data, int flags, struct device_t etherswitch = device_get_parent(dev); etherswitch_info_t *info; etherswitch_reg_t *reg; + etherswitch_phyreg_t *phyreg; int error = 0; switch (cmd) { @@ -210,16 +211,16 @@ etherswitchioctl(struct cdev *cdev, u_long cmd, caddr_t data, int flags, struct bcopy(info, data, sizeof(etherswitch_info_t)); break; - case IOETHERSWITCHSETREG: - reg = (etherswitch_reg_t *)data; - error = ETHERSWITCH_WRITEREG(etherswitch, reg->reg, reg->val); - break; - case IOETHERSWITCHGETREG: reg = (etherswitch_reg_t *)data; reg->val = ETHERSWITCH_READREG(etherswitch, reg->reg); break; + case IOETHERSWITCHSETREG: + reg = (etherswitch_reg_t *)data; + error = ETHERSWITCH_WRITEREG(etherswitch, reg->reg, reg->val); + break; + case IOETHERSWITCHGETPORT: error = ETHERSWITCH_GETPORT(etherswitch, (etherswitch_port_t *)data); break; @@ -236,6 +237,16 @@ etherswitchioctl(struct cdev *cdev, u_long cmd, caddr_t data, int flags, struct error = ETHERSWITCH_SETVGROUP(etherswitch, (etherswitch_vlangroup_t *)data); break; + case IOETHERSWITCHGETPHYREG: + phyreg = (etherswitch_phyreg_t *)data; + phyreg->val = ETHERSWITCH_READPHYREG(etherswitch, phyreg->phy, phyreg->reg); + break; + + case IOETHERSWITCHSETPHYREG: + phyreg = (etherswitch_phyreg_t *)data; + error = ETHERSWITCH_WRITEPHYREG(etherswitch, phyreg->phy, phyreg->reg, phyreg->val); + break; + default: error = ENOTTY; } diff --git a/sys/dev/etherswitch/etherswitch.h b/sys/dev/etherswitch/etherswitch.h index df59c12..90ecb48 100644 --- a/sys/dev/etherswitch/etherswitch.h +++ b/sys/dev/etherswitch/etherswitch.h @@ -18,6 +18,13 @@ struct etherswitch_reg { }; typedef struct etherswitch_reg etherswitch_reg_t; +struct etherswitch_phyreg { + uint16_t phy; + uint16_t reg; + uint16_t val; +}; +typedef struct etherswitch_phyreg etherswitch_phyreg_t; + #define ETHERSWITCH_NAMEMAX 64 struct etherswitch_info { @@ -56,5 +63,7 @@ typedef struct etherswitch_vlangroup etherswitch_vlangroup_t; #define IOETHERSWITCHSETPORT _IOW('i', 5, etherswitch_port_t) #define IOETHERSWITCHGETVLANGROUP _IOWR('i', 6, etherswitch_vlangroup_t) #define IOETHERSWITCHSETVLANGROUP _IOW('i', 7, etherswitch_vlangroup_t) +#define IOETHERSWITCHGETPHYREG _IOWR('i', 8, etherswitch_phyreg_t) +#define IOETHERSWITCHSETPHYREG _IOW('i', 9, etherswitch_phyreg_t) #endif diff --git a/sys/dev/etherswitch/etherswitch_if.m b/sys/dev/etherswitch/etherswitch_if.m index d704ee3..7429c04 100644 --- a/sys/dev/etherswitch/etherswitch_if.m +++ b/sys/dev/etherswitch/etherswitch_if.m @@ -35,6 +35,25 @@ METHOD int writereg { }; # +# Read PHY register +# +METHOD int readphyreg { + device_t dev; + int phy; + int reg; +}; + +# +# Write PHY register +# +METHOD int writephyreg { + device_t dev; + int phy; + int reg; + int value; +}; + +# # Get port configuration # METHOD int getport { diff --git a/sys/dev/etherswitch/rtl8366rb.c b/sys/dev/etherswitch/rtl8366rb.c index 6f3e378..b9ca71e 100644 --- a/sys/dev/etherswitch/rtl8366rb.c +++ b/sys/dev/etherswitch/rtl8366rb.c @@ -33,6 +33,7 @@ #include #include #include +#include #include #include @@ -43,6 +44,7 @@ #include #include +#include #include #include #include @@ -51,16 +53,17 @@ #include #include +#include "iicbus_if.h" #include "miibus_if.h" #include "etherswitch_if.h" struct rtl8366rb_softc { - struct mtx sc_mtx; + struct mtx smi_mtx; device_t dev; - char *ifname[RTL8366RB_NUM_PORTS-1]; - device_t miibus[RTL8366RB_NUM_PORTS-1]; - struct ifnet *ifp[RTL8366RB_NUM_PORTS-1]; + char *ifname[RTL8366RB_NUM_PHYS]; + device_t miibus[RTL8366RB_NUM_PHYS]; + struct ifnet *ifp[RTL8366RB_NUM_PHYS]; device_t etherswitch; struct callout callout_tick; }; @@ -71,10 +74,29 @@ static etherswitch_info_t etherswitch_info = { .es_name = "Realtek RTL8366RB" }; +#if 1 || defined(DEBUG) +#define DPRINTF(dev, args...) device_printf(dev, args) +#define DEVERR(dev, err, fmt, args...) do { \ + if (err != 0) device_printf(dev, fmt, err, args); \ + } while (0) +#else +#define DPRINTF(dev, args...) +#define DEVERR(dev, err, fmt, args...) +#endif + +static int reset_count = 0; +static int delayed_select = 0; +static SYSCTL_NODE(_debug, OID_AUTO, rtl8366rb, CTLFLAG_RD, 0, "rtl8366rb"); +SYSCTL_INT(_debug_rtl8366rb, OID_AUTO, reset_count, CTLFLAG_RW, &reset_count, 0, + "number of times the bus had to be reset due to an error"); +SYSCTL_INT(_debug_rtl8366rb, OID_AUTO, delayed_select, CTLFLAG_RW, &delayed_select, 0, + "number of times we had to wait for the chip to become selectable"); static int smi_read(device_t dev, uint16_t addr, uint16_t *data); +static int smi_read_lockheld(device_t dev, uint16_t addr, uint16_t *data); static int smi_write(device_t dev, uint16_t addr, uint16_t data); static int smi_rmw(device_t dev, uint16_t addr, uint16_t mask, uint16_t data); +static void smi_reset(device_t dev); static void rtl8366rb_tick(void *arg); static int rtl8366rb_ifmedia_upd(struct ifnet *); static void rtl8366rb_ifmedia_sts(struct ifnet *, struct ifmediareq *); @@ -97,7 +119,8 @@ rtl8366rb_probe(device_t dev) { uint16_t chipid; - if (smi_read(dev, RTL8366RB_CIR, &chipid)) + smi_reset(dev); + if (smi_read_lockheld(dev, RTL8366RB_CIR, &chipid)) return (ENXIO); if (chipid != RTL8366RB_CIR_ID8366RB) return (ENXIO); @@ -109,6 +132,10 @@ static void rtl8366rb_init(device_t dev) { /* Initialisation for TL-WR1043ND */ + smi_rmw(dev, RTL8366RB_RCR, + RTL8366RB_RCR_HARD_RESET, + RTL8366RB_RCR_HARD_RESET); + DELAY(100000); /* Enable 16 VLAN mode */ smi_rmw(dev, RTL8366RB_SGCR, RTL8366RB_SGCR_EN_VLAN | RTL8366RB_SGCR_EN_VLAN_4KTB, @@ -139,8 +166,7 @@ rtl8366rb_attach(device_t dev) sc = device_get_softc(dev); sc->dev = dev; - mtx_init(&sc->sc_mtx, device_get_nameunit(dev), "rtl8366rb", - MTX_DEF); + mtx_init(&sc->smi_mtx, "smi", NULL, MTX_DEF); rtl8366rb_init(dev); smi_read(dev, RTL8366RB_CVCR, &rev); device_printf(dev, "rev. %d\n", rev & 0x000f); @@ -148,7 +174,7 @@ rtl8366rb_attach(device_t dev) /* attach miibus and phys */ /* PHYs need an interface, so we generate a dummy one */ /* The sixth port doesn't have a PHY */ - for (i = 0; i < RTL8366RB_NUM_PORTS-1; i++) { + for (i = 0; i < RTL8366RB_NUM_PHYS; i++) { sc->ifp[i] = if_alloc(IFT_ETHER); sc->ifp[i]->if_softc = sc; sc->ifp[i]->if_flags |= IFF_UP | IFF_BROADCAST | IFF_DRV_RUNNING @@ -165,13 +191,14 @@ rtl8366rb_attach(device_t dev) return (err); } } + device_printf(dev, "done attaching phys\n"); sc->etherswitch = device_add_child(dev, "etherswitch", -1); err = device_probe_and_attach(sc->etherswitch); if (err != 0) return (err); - callout_init_mtx(&sc->callout_tick, &sc->sc_mtx, 0); + callout_init(&sc->callout_tick, 1); rtl8366rb_tick(sc); return (err); @@ -186,7 +213,7 @@ rtl8366rb_detach(device_t dev) sc = device_get_softc(dev); if (sc->etherswitch) device_delete_child(dev, sc->etherswitch); - for (i=0; i < RTL8366RB_NUM_PORTS-1; i++) { + for (i=0; i < RTL8366RB_NUM_PHYS; i++) { if (sc->miibus[i]) device_delete_child(dev, sc->miibus[i]); if (sc->ifp[i] != NULL) @@ -195,11 +222,68 @@ rtl8366rb_detach(device_t dev) } bus_generic_detach(dev); callout_drain(&sc->callout_tick); - mtx_destroy(&sc->sc_mtx); + mtx_destroy(&sc->smi_mtx); return (0); } +static int +rtl8366rb_media_from_portstatus(int portstatus) +{ + int media; + + if ((portstatus & RTL8366RB_PLSR_LINK) == 0) + return IFM_ETHER | IFM_NONE; + media = IFM_ETHER; + switch (portstatus & RTL8366RB_PLSR_SPEED_MASK) { + case RTL8366RB_PLSR_SPEED_10: + media |= IFM_10_T; + break; + case RTL8366RB_PLSR_SPEED_100: + media |= IFM_100_TX; + break; + case RTL8366RB_PLSR_SPEED_1000: + media |= IFM_1000_T; + break; + } + if ((portstatus & RTL8366RB_PLSR_FULLDUPLEX) != 0) + media |= IFM_FDX; + else + media |= IFM_HDX; + if ((portstatus & RTL8366RB_PLSR_TXPAUSE) != 0) + media |= IFM_ETH_TXPAUSE; + if ((portstatus & RTL8366RB_PLSR_RXPAUSE) != 0) + media |= IFM_ETH_RXPAUSE; + return media; +} + +static void +rtl833rb_miipollstat(struct rtl8366rb_softc *sc) +{ + int i; + struct mii_data *mii; + struct mii_softc *child; + uint16_t value; + int portstatus; + + for (i = 0; i < RTL8366RB_NUM_PHYS; i++) { + mii = device_get_softc(sc->miibus[i]); + if ((i % 2) == 0) { + smi_read(sc->dev, RTL8366RB_PLSR_BASE + i/2, &value); + portstatus = value & 0xff; + } else { + portstatus = (value >> 8) & 0xff; + } + mii->mii_media_status = IFM_AVALID; + mii->mii_media_active = rtl8366rb_media_from_portstatus(portstatus); + LIST_FOREACH(child, &mii->mii_phys, mii_list) { + if (IFM_INST(mii->mii_media.ifm_cur->ifm_media) != child->mii_inst) + continue; + mii_phy_update(child, MII_POLLSTAT); + } + } +} + static void rtl833rb_miipollstat(struct rtl8366rb_softc *sc) { @@ -253,80 +337,161 @@ static void rtl8366rb_tick(void *arg) { struct rtl8366rb_softc *sc = arg; - + rtl833rb_miipollstat(sc); callout_reset(&sc->callout_tick, hz, rtl8366rb_tick, sc); } +static void +smi_reset(device_t dev) +{ + device_t iicbus, iicbb; + int i; + + DPRINTF(dev, "resetting bus\n"); + iicbus = device_get_parent(dev); + iicbb = device_get_parent(iicbus); + iicbus_reset(iicbus, IIC_FASTEST, RTL8366RB_IIC_ADDR, NULL); + for (i=3; i--; ) { + IICBUS_STOP(iicbb); + } + reset_count++; +} + static int -smi_read(device_t dev, uint16_t addr, uint16_t *data) +smi_read_lockheld(device_t dev, uint16_t addr, uint16_t *data) { int err; - device_t parent = device_get_parent(dev); + device_t iicbus = device_get_parent(dev); struct iicbus_ivar *devi = IICBUS_IVAR(dev); int slave = devi->addr; char bytes[2]; - int xferd; + int xferd, i; bytes[0] = addr & 0xff; bytes[1] = (addr >> 8) & 0xff; - err = iicbus_start(parent, slave | IICBUS_READ, IICBUS_TIMEOUT); + /* + * The chip does not use clock stretching when it is busy, + * instead ignoring the command. Retry a few times. + */ + for (i = RTL_IICBUS_RETRIES; i--; ) { + err = iicbus_start(iicbus, slave | RTL_IICBUS_READ, RTL_IICBUS_TIMEOUT); + if (err != IIC_ENOACK) + break; + DELAY(RTL_IICBUS_TIMEOUT); + delayed_select++; + } if (err != 0) goto out; - err = iicbus_write(parent, bytes, 2, &xferd, IICBUS_TIMEOUT); + err = iicbus_write(iicbus, bytes, 2, &xferd, RTL_IICBUS_TIMEOUT); if (err != 0) goto out; - err = iicbus_read(parent, bytes, 2, &xferd, IIC_LAST_READ, 0); + err = iicbus_read(iicbus, bytes, 2, &xferd, IIC_LAST_READ, 0); if (err != 0) goto out; *data = ((bytes[1] & 0xff) << 8) | (bytes[0] & 0xff); out: - iicbus_stop(parent); + iicbus_stop(iicbus); return err; } static int -smi_write(device_t dev, uint16_t addr, uint16_t data) +smi_write_lockheld(device_t dev, uint16_t addr, uint16_t data) { int err; - device_t parent = device_get_parent(dev); + device_t iicbus = device_get_parent(dev); struct iicbus_ivar *devi = IICBUS_IVAR(dev); int slave = devi->addr; char bytes[4]; - int xferd; + int xferd, i; bytes[0] = addr & 0xff; bytes[1] = (addr >> 8) & 0xff; bytes[2] = data & 0xff; bytes[3] = (data >> 8) & 0xff; - err = iicbus_request_bus(parent, dev, IIC_WAIT); - if (err == 0) { - err = iicbus_start(parent, slave | IICBUS_WRITE, IICBUS_TIMEOUT); - if (err == 0) - err = iicbus_write(parent, bytes, 4, &xferd, IICBUS_TIMEOUT); - iicbus_stop(parent); + /* + * The chip does not use clock stretching when it is busy, + * instead ignoring the command. Retry a few times. + */ + for (i = RTL_IICBUS_RETRIES; i--; ) { + err = iicbus_start(iicbus, slave | RTL_IICBUS_WRITE, RTL_IICBUS_TIMEOUT); + if (err != IIC_ENOACK) + break; + DELAY(RTL_IICBUS_TIMEOUT); + delayed_select++; } - iicbus_release_bus(parent, dev); + if (err == 0) + err = iicbus_write(iicbus, bytes, 4, &xferd, RTL_IICBUS_TIMEOUT); + iicbus_stop(iicbus); return err; } static int +smi_read(device_t dev, uint16_t addr, uint16_t *data) +{ + struct rtl8366rb_softc *sc = device_get_softc(dev); + device_t iicbus = device_get_parent(dev); + int err; + + mtx_lock(&sc->smi_mtx); + err = iicbus_request_bus(iicbus, dev, IIC_WAIT); + if (err == 0) + err = smi_read_lockheld(dev, addr, data); + iicbus_release_bus(iicbus, dev); + if (err != 0) + smi_reset(dev); + mtx_unlock(&sc->smi_mtx); + DEVERR(dev, err, "smi_read()=%d: addr=%04x\n", addr); + return (err == 0 ? 0 : EIO); +} + +static int +smi_write(device_t dev, uint16_t addr, uint16_t data) +{ + struct rtl8366rb_softc *sc = device_get_softc(dev); + device_t iicbus = device_get_parent(dev); + int err; + + mtx_lock(&sc->smi_mtx); + err = iicbus_request_bus(iicbus, dev, IIC_WAIT); + if (err == 0) + err = smi_write_lockheld(dev, addr, data); + iicbus_release_bus(iicbus, dev); + if (err != 0) + smi_reset(dev); + mtx_unlock(&sc->smi_mtx); + DEVERR(dev, err, "smi_write()=%d: addr=%04x\n", addr); + return (err == 0 ? 0 : EIO); +} + +static int smi_rmw(device_t dev, uint16_t addr, uint16_t mask, uint16_t data) { + struct rtl8366rb_softc *sc = device_get_softc(dev); + device_t iicbus = device_get_parent(dev); int err; uint16_t oldv, newv; - err = smi_read(dev, addr, &oldv); + mtx_lock(&sc->smi_mtx); + err = iicbus_request_bus(iicbus, dev, IIC_WAIT); if (err == 0) { - newv = oldv & ~mask; - newv |= data & mask; - if (newv != oldv) - err = smi_write(dev, addr, newv); + err = smi_read_lockheld(dev, addr, &oldv); + if (err == 0) { + newv = oldv & ~mask; + newv |= data & mask; + if (newv != oldv) + err = smi_write_lockheld(dev, addr, newv); + } } - return err; + iicbus_release_bus(iicbus, dev); + if (err != 0) + smi_reset(dev); + mtx_unlock(&sc->smi_mtx); + DEVERR(dev, err, "smi_rmw()=%d: addr=%04x\n", addr); + return (err == 0 ? 0 : EIO); } static etherswitch_info_t * @@ -365,7 +530,7 @@ rtl_getport(device_t dev, etherswitch_port_t *p) p->es_vlangroup = RTL8366RB_PVCR_GET(p->es_port, rtl_readreg(dev, RTL8366RB_PVCR_REG(p->es_port))); - if (p->es_port < RTL8366RB_NUM_PORTS-1) { + if (p->es_port < RTL8366RB_NUM_PHYS) { sc = device_get_softc(dev); mii = device_get_softc(sc->miibus[p->es_port]); ifm = &mii->mii_media; @@ -375,22 +540,9 @@ rtl_getport(device_t dev, etherswitch_port_t *p) } else { /* fill in fixed values for CPU port */ ifmr->ifm_count = 0; - smi_read(dev, RTL8366RB_PLSR_BASE + (RTL8366RB_NUM_PORTS-1)/2, &v); - v = v >> (8 * ((RTL8366RB_NUM_PORTS-1) % 2)); - switch (v & RTL8366RB_PLSR_SPEED_MASK) { - case RTL8366RB_PLSR_SPEED_10: - ifmr->ifm_current = IFM_ETHER | IFM_10_T; - break; - case RTL8366RB_PLSR_SPEED_100: - ifmr->ifm_current = IFM_ETHER | IFM_100_TX; - break; - case RTL8366RB_PLSR_SPEED_1000: - ifmr->ifm_current = IFM_ETHER | IFM_1000_T; - break; - } - if ((v & RTL8366RB_PLSR_FULLDUPLEX) != 0) - ifmr->ifm_current |= IFM_FDX; - ifmr->ifm_active = ifmr->ifm_current; + smi_read(dev, RTL8366RB_PLSR_BASE + (RTL8366RB_NUM_PHYS)/2, &v); + v = v >> (8 * ((RTL8366RB_NUM_PHYS) % 2)); + ifmr->ifm_active = ifmr->ifm_current = rtl8366rb_media_from_portstatus(v); ifmr->ifm_mask = 0; ifmr->ifm_status = IFM_ACTIVE | IFM_AVALID; } @@ -412,7 +564,7 @@ rtl_setport(device_t dev, etherswitch_port_t *p) RTL8366RB_PVCR_VAL(p->es_port, p->es_vlangroup)); if (err) return (err); - if (p->es_port >= RTL8366RB_NUM_PORTS-1) + if (p->es_port >= RTL8366RB_NUM_PHYS) return (0); sc = device_get_softc(dev); mii = device_get_softc(sc->miibus[p->es_port]); @@ -455,23 +607,58 @@ rtl_setvgroup(device_t dev, etherswitch_vlangroup_t *vg) static int rtl_readphy(device_t dev, int phy, int reg) { + struct rtl8366rb_softc *sc = device_get_softc(dev); + device_t iicbus = device_get_parent(dev); uint16_t data = 0; - - smi_write(dev, RTL8366RB_PACR, RTL8366RB_PACR_READ); - smi_write(dev, RTL8366RB_PHYREG(phy, 0, reg), 0); - smi_read(dev, RTL8366RB_PADR, &data); + int err; + + if (phy < 0 || phy >= RTL8366RB_NUM_PHYS) + return (ENXIO); + if (reg < 0 || reg >= RTL8366RB_NUM_PHY_REG) + return (ENXIO); + mtx_lock(&sc->smi_mtx); + err = iicbus_request_bus(iicbus, dev, IIC_WAIT); + if (err == 0) + err = smi_write_lockheld(dev, RTL8366RB_PACR, RTL8366RB_PACR_READ); + if (err == 0) + err = smi_write_lockheld(dev, RTL8366RB_PHYREG(phy, 0, reg), 0); + if (err == 0) { + DELAY(RTL_IICBUS_PHYDELAY); /* chip needs time to talk to PHY */ + err = smi_read_lockheld(dev, RTL8366RB_PADR, &data); + } + iicbus_release_bus(iicbus, dev); + if (err != 0) + smi_reset(dev); + mtx_unlock(&sc->smi_mtx); + DEVERR(dev, err, "rtl_readphy()=%d: phy=%d.%02x\n", phy, reg); return (data); } static int rtl_writephy(device_t dev, int phy, int reg, int data) { + struct rtl8366rb_softc *sc = device_get_softc(dev); + device_t iicbus = device_get_parent(dev); int err; - err = smi_write(dev, RTL8366RB_PACR, RTL8366RB_PACR_WRITE); - if (err) - return (err); - return smi_write(dev, RTL8366RB_PHYREG(phy, 0, reg), data); + if (phy < 0 || phy >= RTL8366RB_NUM_PHYS) + return (ENXIO); + if (reg < 0 || reg >= RTL8366RB_NUM_PHY_REG) + return (ENXIO); + mtx_lock(&sc->smi_mtx); + err = iicbus_request_bus(iicbus, dev, IIC_WAIT); + if (err == 0) + err = smi_write_lockheld(dev, RTL8366RB_PACR, RTL8366RB_PACR_WRITE); + if (err == 0) + err = smi_write_lockheld(dev, RTL8366RB_PHYREG(phy, 0, reg), data); + if (err == 0) + DELAY(RTL_IICBUS_PHYDELAY); /* chip needs time to talk to PHY */ + iicbus_release_bus(iicbus, dev); + if (err != 0) + smi_reset(dev); + mtx_unlock(&sc->smi_mtx); + DEVERR(dev, err, "rtl_writephy()=%d: phy=%d.%02x\n", phy, reg); + return (err == 0 ? 0 : EIO); } static int @@ -511,6 +698,8 @@ static device_method_t rtl8366rb_methods[] = { DEVMETHOD(etherswitch_getinfo, rtl_getinfo), DEVMETHOD(etherswitch_readreg, rtl_readreg), DEVMETHOD(etherswitch_writereg, rtl_writereg), + DEVMETHOD(etherswitch_readphyreg, rtl_readphy), + DEVMETHOD(etherswitch_writephyreg, rtl_writephy), DEVMETHOD(etherswitch_getport, rtl_getport), DEVMETHOD(etherswitch_setport, rtl_setport), DEVMETHOD(etherswitch_getvgroup, rtl_getvgroup), diff --git a/sys/dev/etherswitch/rtl8366rbvar.h b/sys/dev/etherswitch/rtl8366rbvar.h index df17cb6..354ca95 100644 --- a/sys/dev/etherswitch/rtl8366rbvar.h +++ b/sys/dev/etherswitch/rtl8366rbvar.h @@ -28,9 +28,12 @@ #define RTL8366RB_IIC_ADDR 0xa8 -#define IICBUS_TIMEOUT 100 /* us */ -#define IICBUS_READ 1 -#define IICBUS_WRITE 0 +#define RTL_IICBUS_TIMEOUT 100 /* us */ +#define RTL_IICBUS_READ 1 +#define RTL_IICBUS_WRITE 0 +/* number of times to try and select the chip on the I2C bus */ +#define RTL_IICBUS_RETRIES 3 +#define RTL_IICBUS_PHYDELAY 500 /* us */ /* Register definitions */ @@ -43,8 +46,9 @@ #define RTL8366RB_SGCR_MAX_LENGTH_1536 0x0010 #define RTL8366RB_SGCR_MAX_LENGTH_1552 0x0020 #define RTL8366RB_SGCR_MAX_LENGTH_9216 0x0030 -#define RTL8366RB_SGCR_EN_VLAN 0x2000 -#define RTL8366RB_SGCR_EN_VLAN_4KTB 0x4000 +#define RTL8366RB_SGCR_EN_VLAN 0x2000 +#define RTL8366RB_SGCR_EN_VLAN_4KTB 0x4000 +#define RTL8366RB_SGCR_EN_QOS 0x8000 /* Port Enable Control: DISABLE_PORT[5:0] */ #define RTL8366RB_PECR 0x0001 @@ -73,20 +77,20 @@ /* VLAN Member Configuration, 3 registers per VLAN */ #define RTL8366RB_VMCR_BASE 0x0020 -#define RTL8366RB_VMCR_MULT 3 -#define RTL8366RB_VMCR_DOT1Q_REG 0 +#define RTL8366RB_VMCR_MULT 3 +#define RTL8366RB_VMCR_DOT1Q_REG 0 #define RTL8366RB_VMCR_DOT1Q_VID_SHIFT 0 #define RTL8366RB_VMCR_DOT1Q_VID_MASK 0x0fff #define RTL8366RB_VMCR_DOT1Q_PCP_SHIFT 12 #define RTL8366RB_VMCR_DOT1Q_PCP_MASK 0x7000 -#define RTL8366RB_VMCR_MU_REG 1 +#define RTL8366RB_VMCR_MU_REG 1 #define RTL8366RB_VMCR_MU_MEMBER_SHIFT 0 #define RTL8366RB_VMCR_MU_MEMBER_MASK 0x00ff #define RTL8366RB_VMCR_MU_UNTAG_SHIFT 8 #define RTL8366RB_VMCR_MU_UNTAG_MASK 0xff00 -#define RTL8366RB_VMCR_FID_REG 2 +#define RTL8366RB_VMCR_FID_REG 2 #define RTL8366RB_VMCR_FID_FID_SHIFT 0 -#define RTL8366RB_VMCR_FID_FID_MASK 0x0007 +#define RTL8366RB_VMCR_FID_FID_MASK 0x0007 #define RTL8366RB_VMCR(_reg, _vlan) \ (RTL8366RB_VMCR_BASE + _reg + _vlan * RTL8366RB_VMCR_MULT) /* VLAN Identifier */ @@ -94,13 +98,15 @@ (_r[RTL8366RB_VMCR_DOT1Q_REG] & RTL8366RB_VMCR_DOT1Q_VID_MASK) /* Priority Code Point */ #define RTL8366RB_VMCR_PCP(_r) \ - ((_r[RTL8366RB_VMCR_DOT1Q_REG] & RTL8366RB_VMCR_DOT1Q_PCP_MASK) >> RTL8366RB_VMCR_DOT1Q_PCP_SHIFT) + ((_r[RTL8366RB_VMCR_DOT1Q_REG] & RTL8366RB_VMCR_DOT1Q_PCP_MASK) \ + >> RTL8366RB_VMCR_DOT1Q_PCP_SHIFT) /* Member ports */ #define RTL8366RB_VMCR_MEMBER(_r) \ (_r[RTL8366RB_VMCR_MU_REG] & RTL8366RB_VMCR_MU_MEMBER_MASK) /* Untagged ports */ #define RTL8366RB_VMCR_UNTAG(_r) \ - ((_r[RTL8366RB_VMCR_MU_REG] & RTL8366RB_VMCR_MU_UNTAG_MASK) >> RTL8366RB_VMCR_MU_UNTAG_SHIFT) + ((_r[RTL8366RB_VMCR_MU_REG] & RTL8366RB_VMCR_MU_UNTAG_MASK) \ + >> RTL8366RB_VMCR_MU_UNTAG_SHIFT) /* Forwarding ID */ #define RTL8366RB_VMCR_FID(_r) \ (_r[RTL8366RB_VMCR_FID_REG] & RTL8366RB_VMCR_FID_FID_MASK) @@ -136,6 +142,19 @@ /* VLAN Ingress Control 2: [5:0] */ #define RTL8366RB_VIC2R 0x037f +/* MIB registers */ +#define RTL8366RB_MCNT_BASE 0x1000 +#define RTL8366RB_MCTLR 0x13f0 +#define RTL8366RB_MCTLR_BUSY 0x0001 +#define RTL8366RB_MCTLR_RESET 0x0002 +#define RTL8366RB_MCTLR_RESET_PORT_MASK 0x00fc +#define RTL8366RB_MCTLR_RESET_ALL 0x0800 + +#define RTL8366RB_MCNT(_port, _r) \ + (RTL8366RB_MCNT_BASE + 0x50 * (_port) + (_r)) +#define RTL8366RB_MCTLR_RESET_PORT(_p) \ + (1 << ((_p) + 2)) + /* PHY Access Control */ #define RTL8366RB_PACR 0x8000 #define RTL8366RB_PACR_WRITE 0x0000 @@ -149,5 +168,6 @@ /* general characteristics of the chip */ #define RTL8366RB_NUM_PORTS 6 +#define RTL8366RB_NUM_PHYS (RTL8366RB_NUM_PORTS-1) #define RTL8366RB_NUM_VLANS 16 - +#define RTL8366RB_NUM_PHY_REG 32 diff --git a/sys/dev/flash/mx25l.c b/sys/dev/flash/mx25l.c index d5c2270..3ac1d02 100644 --- a/sys/dev/flash/mx25l.c +++ b/sys/dev/flash/mx25l.c @@ -102,6 +102,7 @@ struct mx25l_flash_ident flash_devices[] = { { "mx25ll128", 0xc2, 0x2018, 64 * 1024, 256, FL_ERASE_4K | FL_ERASE_32K }, { "s25fl128", 0x01, 0x2018, 64 * 1024, 256, FL_NONE }, { "s25sl064a", 0x01, 0x0216, 64 * 1024, 128, FL_NONE }, + { "w25q64bv", 0xef, 0x4017, 64 * 1024, 128, FL_ERASE_4K }, }; static uint8_t diff --git a/sys/dev/gpio/gpiobus.c b/sys/dev/gpio/gpiobus.c index 09ebe4e..c6fbaae 100644 --- a/sys/dev/gpio/gpiobus.c +++ b/sys/dev/gpio/gpiobus.c @@ -349,7 +349,9 @@ gpiobus_acquire_bus(device_t busdev, device_t child) GPIOBUS_ASSERT_LOCKED(sc); if (sc->sc_owner) - panic("rb_cpldbus: cannot serialize the access to device."); + panic("%s: acquire_bus(%s): already acquired by %s", + device_get_nameunit(busdev), device_get_nameunit(busdev), + device_get_nameunit(child)); sc->sc_owner = child; } @@ -362,9 +364,12 @@ gpiobus_release_bus(device_t busdev, device_t child) GPIOBUS_ASSERT_LOCKED(sc); if (!sc->sc_owner) - panic("rb_cpldbus: releasing unowned bus."); + panic("%s: release_bus(%s): not owned", + device_get_nameunit(busdev), device_get_nameunit(busdev)); if (sc->sc_owner != child) - panic("rb_cpldbus: you don't own the bus. game over."); + panic("%s: release_bus(%s): acquired by %s", + device_get_nameunit(busdev), device_get_nameunit(busdev), + device_get_nameunit(child)); sc->sc_owner = NULL; } diff --git a/sys/dev/iicbus/iicbb.c b/sys/dev/iicbus/iicbb.c index fed203c..a0e6255 100644 --- a/sys/dev/iicbus/iicbb.c +++ b/sys/dev/iicbus/iicbb.c @@ -276,24 +276,31 @@ iicbb_zero(device_t dev, int timeout) static int iicbb_ack(device_t dev, int timeout) { - struct iicbb_softc *sc = device_get_softc(dev); - int noack; - int k = 0; - - I2C_SET(sc,dev,0,1); - I2C_SET(sc,dev,1,1); - do { - noack = I2C_GETSDA(dev); - if (!noack) + struct iicbb_softc *sc = (struct iicbb_softc *)device_get_softc(dev); + int timeout = sc->iictimeout; + int value; + + /* 0 */ + IICBB_SETSDA(device_get_parent(dev), 1); + DELAY(sc->iicdelay); + /* 1 */ + IICBB_SETSCL(device_get_parent(dev), 1); + while (1) { + DELAY(sc->iicdelay); + /* allow clock stretching */ + if (IICBB_GETSCL(device_get_parent(dev)) != 0) break; - DELAY(1); - k++; - } while (k < timeout); - - I2C_SET(sc,dev,0,1); - I2C_DEBUG(printf("%c ",noack?'-':'+')); - - return (noack); + if (timeout <= 0) + return (-1); + timeout -= sc->iicdelay; + } + /* 2 */ + value = IICBB_GETSDA(device_get_parent(dev)); + DELAY(sc->iicdelay); + /* 3 */ + IICBB_SETSCL(device_get_parent(dev), 0); + DELAY(sc->iicdelay); + return (value != 0 ? 1 : 0); } static void @@ -346,6 +353,7 @@ static int iicbb_reset(device_t dev, u_char speed, u_char addr, u_char *oldaddr) { return (IICBB_RESET(device_get_parent(dev), speed, addr, oldaddr)); + i2c_stop(dev); } static int @@ -354,38 +362,31 @@ iicbb_start(device_t dev, u_char slave, int timeout) struct iicbb_softc *sc = device_get_softc(dev); int error; - I2C_DEBUG(printf("<")); - - I2C_SET(sc,dev,1,1); - I2C_SET(sc,dev,1,0); - I2C_SET(sc,dev,0,0); - - /* send address */ - iicbb_sendbyte(dev, slave, timeout); - - /* check for ack */ - if (iicbb_ack(dev, timeout)) { - error = IIC_ENOACK; - goto error; + I2C_LOG("<"); + + sc->iictimeout = timeout; + if (i2c_start(dev) < 0) + return (IIC_ENOACK); + error = i2c_xmitbyte(dev, slave); + if (error < 0) + return (IIC_EBUSERR); /* lost arbitration */ + I2C_LOG("%02x", slave); + error = i2c_recvbit(dev); + if (error < 0) + return (IIC_EBUSERR); /* lost arbitration */ + I2C_LOG("%c", error != 0 ? '-' : '+'); + if (error != 0) { + iicbb_stop(dev); + return (IIC_ENOACK); } - - return(0); - -error: - iicbb_stop(dev); - return (error); + return (0); } static int iicbb_stop(device_t dev) { - struct iicbb_softc *sc = device_get_softc(dev); - - I2C_SET(sc,dev,0,0); - I2C_SET(sc,dev,1,0); - I2C_SET(sc,dev,1,1); - I2C_DEBUG(printf(">")); - I2C_DEBUG(printf("\n")); + i2c_stop(dev); + I2C_LOG(">\n"); return (0); } diff --git a/sys/modules/rtl8366rb/Makefile b/sys/modules/rtl8366rb/Makefile index 41cacd3..8d9800f 100644 --- a/sys/modules/rtl8366rb/Makefile +++ b/sys/modules/rtl8366rb/Makefile @@ -5,6 +5,6 @@ CFLAGS+= -DDEBUG .PATH: ${.CURDIR}/../../dev/etherswitch KMOD= rtl8366rb SRCS= rtl8366rb.c rtl8366rbvar.h -SRCS+= device_if.h bus_if.h miibus_if.h etherswitch_if.h opt_cputype.h +SRCS+= device_if.h bus_if.h iicbus_if.h miibus_if.h etherswitch_if.h opt_cputype.h .include --Apple-Mail=_8BCC333A-BF48-41F3-90E3-140840423ED9 Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset=us-ascii Make code more robust. o Add ioctls to read and write PHY registers. o properly stop I2C transaction when selection fails, or the transaction fails halfway through. With debugging enabled, debug.rtl8366rb.reset_count counts the number of times the bus has been reset after an error. o Add a DELAY() to reading and writing PHY registers to give the chip time to talk to the PHY. Without this DELAY, the chip may be unresponsive. o Add debugging code to print info on failed I2C transactions. o When selecting the chip fails, retry a number of times. With debugging enabled, debug.rtl8366rb.delayed_select counts the number of times this has happened. o Don't call PHY_SERVICE() (because that runs the phy service code that queries the PHY for the currently selected media); call mii_phy_update() -- Stefan Bethke Fon +49 151 14070811 --Apple-Mail=_8BCC333A-BF48-41F3-90E3-140840423ED9-- From owner-freebsd-embedded@FreeBSD.ORG Tue Dec 27 21:48:34 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 509551065672; Tue, 27 Dec 2011 21:48:34 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id EF38F8FC14; Tue, 27 Dec 2011 21:48:33 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 9BB6D780B7; Tue, 27 Dec 2011 21:48:32 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=us-ascii From: Stefan Bethke In-Reply-To: <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> Date: Tue, 27 Dec 2011 22:48:31 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <09670C 34-0D30-46BC-BA7E-4AAA22193B61@lassitu.de> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: Oleksandr Tymoshenko , "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Dec 2011 21:48:34 -0000 More code, now actually working. (Had problems with git merging.) Please use this patch for my changes to iicbb. Also gpiobus.c = improvement for better panic messages. rtl8366.c now will retry a failed PHY register access; it seems that = sometimes, it just doesn't work on the first attempt (roughly 1 in = 1000). With this change, the API consumer never sees an error (about 30 = minutes of max speed PHY register accesses in a tight loop, with WITNESS = disabled for max. speed.) Also, link status is now queried from the chip instead of from the PHY = for the callout. When running the ioctl, the PHY code gets executed. = The result of both is identical, so there should be no spurious link = status changes. The newest iteration can be gotten from: https://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work (branch = work/ath) http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) http://www.lassitu.de/freebsd/etherswitch.tbz (all files) The tbz includes all new and modified files, except for = sys/conf/files/*, Makefiles, etc. If you need the patch for that, = please let me know. Have a look at my or Adrians repo, they're in there = as well. Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 06:17:33 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9890D106566B for ; Wed, 28 Dec 2011 06:17:33 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 4DC108FC0C for ; Wed, 28 Dec 2011 06:17:33 +0000 (UTC) Received: by vcbfk1 with SMTP id fk1so16691525vcb.13 for ; Tue, 27 Dec 2011 22:17:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=WMf1fymugrDOe6YeiIvy+xt/caIHKBCynOvQFJejbVE=; b=Xx7yPP1difATaSKAX9iMbCuUulLWqxBoij+wVhFIw+NkU50HiAQ4/0uleTlOR+a+TX f2ZelK+Xa0BD85IQTSNgLxUJgmlTRjDdIPZXUec9fb8Le7fCXP8lxkE/apMFbI8UgOXt SVd3yh/eSyiXR0S+/wF3KG73AZASgTqFGONNk= MIME-Version: 1.0 Received: by 10.220.213.137 with SMTP id gw9mr17891920vcb.3.1325053052690; Tue, 27 Dec 2011 22:17:32 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Tue, 27 Dec 2011 22:17:32 -0800 (PST) In-Reply-To: <4EF9D58A.9030608@bulinfo.net> References: <4EF9D58A.9030608@bulinfo.net> Date: Tue, 27 Dec 2011 22:17:32 -0800 X-Google-Sender-Auth: e1pRxaYqaVQmzjCBwDKmTIrfSxk Message-ID: From: Adrian Chadd To: Krassimir Slavchev Content-Type: text/plain; charset=ISO-8859-1 Cc: freebsd-embedded@freebsd.org Subject: Re: Interrupting boot process X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 06:17:33 -0000 On 27 December 2011 06:26, Krassimir Slavchev wrote: > Hello list, > > I use nanobsd (FreeBSD 8) and would like to prevent interrupting of the > boot process by hitting CTRL+C. All consoles are marked as insecure in > /etc/ttys. Why not disable interrupts in /etc/rc too? Adrian From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 06:25:24 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B66D1065670 for ; Wed, 28 Dec 2011 06:25:24 +0000 (UTC) (envelope-from krassi@bulinfo.net) Received: from mx.bulinfo.net (mx.bulinfo.net [193.194.156.1]) by mx1.freebsd.org (Postfix) with ESMTP id F02B48FC12 for ; Wed, 28 Dec 2011 06:25:23 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by mx.bulinfo.net (Postfix) with ESMTP id 827455C9C2; Wed, 28 Dec 2011 08:25:22 +0200 (EET) X-Virus-Scanned: amavisd-new at bulinfo.net Received: from mx.bulinfo.net ([127.0.0.1]) by localhost (mx.bulinfo.net [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id mWD8WP7I5iES; Wed, 28 Dec 2011 08:25:22 +0200 (EET) Received: from [192.168.2.187] (pythia.bulinfo.net [212.72.195.5]) by mx.bulinfo.net (Postfix) with ESMTP id 408285C9BE; Wed, 28 Dec 2011 08:25:22 +0200 (EET) Message-ID: <4EFAB652.5090307@bulinfo.net> Date: Wed, 28 Dec 2011 08:25:22 +0200 From: Krassimir Slavchev User-Agent: Mozilla/5.0 (X11; U; FreeBSD amd64; en-US; rv:1.9.2.23) Gecko/20110929 Thunderbird/3.1.15 MIME-Version: 1.0 To: Adrian Chadd References: <4EF9D58A.9030608@bulinfo.net> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: freebsd-embedded@freebsd.org Subject: Re: Interrupting boot process X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 06:25:24 -0000 On 12/28/11 08:17, Adrian Chadd wrote: > On 27 December 2011 06:26, Krassimir Slavchev wrote: >> Hello list, >> >> I use nanobsd (FreeBSD 8) and would like to prevent interrupting of the >> boot process by hitting CTRL+C. All consoles are marked as insecure in >> /etc/ttys. > > Why not disable interrupts in /etc/rc too? I already have: trap : 2 trap : 3 both in /etc/rc and /etc/rc.initdiskless May be I miss something else? > > > Adrian > From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 06:54:35 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 28CE0106566C for ; Wed, 28 Dec 2011 06:54:35 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id BE4C68FC12 for ; Wed, 28 Dec 2011 06:54:34 +0000 (UTC) Received: by vcbfk1 with SMTP id fk1so16722603vcb.13 for ; Tue, 27 Dec 2011 22:54:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=HMoyTMg5skoE1yR01HXbrdVebsMS+noxPGDajT/48sA=; b=OodDQ1qvkkCW0tq4JX1Uus6KIIIdAs6W1/5OCK4h97o7YjLY9/HflpqQfEiEy6wDcY 7HE9apjrV0TtElXeIvF0H8kVTbcFPWaScnlcQr+6QMrvbaI6K+SEorTwFokqMJLNIwg3 SR0i/35W+0w77GLdHcpmd+/DQoP35GEy9ikuA= MIME-Version: 1.0 Received: by 10.220.213.200 with SMTP id gx8mr18065124vcb.13.1325055274028; Tue, 27 Dec 2011 22:54:34 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Tue, 27 Dec 2011 22:54:33 -0800 (PST) In-Reply-To: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> Date: Tue, 27 Dec 2011 22:54:33 -0800 X-Google-Sender-Auth: qaTAV-xJ06CQKfzwbe0ne18ZXl8 Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 06:54:35 -0000 Hi, I have a few questions: * are you testing this all out with the -HEAD debugging enabled? ie, witness, invariants, etc? * Why'd you rename the mutex in the rtl8366rb driver from sc->sc_mtx to sc->smi_mtx ? * Why are you creating the callout w/out the lock now, rather than with a lock? non-locked callouts make it more difficult to cancel cleanly/atomically. * Are this smi_*_lockheld() functions designed to be called with sc_smi_mtx held? If so, add a lock assertion macro there. * You call DELAY() with the lock held: + DELAY(RTL_IICBUS_PHYDELAY); /* chip needs time to talk to PHY */ .. why not use pause() instead? I don't like how it could result in that particular mutex being held for far, far too long (and I'm starting to be weary of mutexes being used as a way of serialising slow device access, but I digress).. * You've implemented retries here, which make sense. How then does the Linux driver work? Or is it doing retries and I just don't remember. * The older iicbb code with the original timeout doesn't result in any timeouts at all, just FYI. I'm happy with the idea of a faster, more efficient iicbb where the driver also handles timeouts correctly.. I just wonder whether we're making it more complicated. How is it OpenWRT/Linux doesn't end up suffering from these high CPU spikes when doing bitbanged GPIO? Or are they seeing them but preemption is just masking it? Adrian From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 06:55:18 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BC34E1065673 for ; Wed, 28 Dec 2011 06:55:18 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 630148FC17 for ; Wed, 28 Dec 2011 06:55:18 +0000 (UTC) Received: by vcbfk1 with SMTP id fk1so16723192vcb.13 for ; Tue, 27 Dec 2011 22:55:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=RqKCL0f0o0f+S2ekc5CLfrx56SdSFpNzQ81x0yTBkws=; b=L19xMLmGKRnPN4w5Se/PkxV7EdHpzbnWaYcUnYI1SeqLm4gJPEFXteE4tyTKr5ufy9 5HexQPEVm8ZFRa781/Y0+qVARBx2pQ3d1uNSspXDkuv+8DLMe123dBoRZiQcnvXqApYM k8g9xK89rLBSuQZ3Lp2ZqMhELHzYhVOf0mia4= MIME-Version: 1.0 Received: by 10.220.153.134 with SMTP id k6mr17977189vcw.23.1325055317936; Tue, 27 Dec 2011 22:55:17 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Tue, 27 Dec 2011 22:55:17 -0800 (PST) In-Reply-To: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> Date: Tue, 27 Dec 2011 22:55:17 -0800 X-Google-Sender-Auth: YTG1xZKoTG0VhMC1Tli7_ChhPs4 Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 06:55:18 -0000 .. fyi, I'm just about to commit this to my git repository and push it. We can do some further tidying up after that. Adrian From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 11:15:26 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0F945106564A; Wed, 28 Dec 2011 11:15:26 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id AF09B8FC12; Wed, 28 Dec 2011 11:15:25 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 87D6B11287A; Wed, 28 Dec 2011 11:15:24 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Wed, 28 Dec 2011 12:15:23 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 11:15:26 -0000 Am 28.12.2011 um 07:54 schrieb Adrian Chadd: > Hi, >=20 > I have a few questions: >=20 > * are you testing this all out with the -HEAD debugging enabled? ie, > witness, invariants, etc? Yes, just for my last test I disabled witness to run the test with max. = speed. > * Why'd you rename the mutex in the rtl8366rb driver from sc->sc_mtx > to sc->smi_mtx ? That's a spurious change; in an interim version, I had two mutexes (one = for the callout, one for the bus access). > * Why are you creating the callout w/out the lock now, rather than > with a lock? non-locked callouts make it more difficult to cancel > cleanly/atomically. With the mutex, I had trouble. I can't recall right now what exactly it = was. > * Are this smi_*_lockheld() functions designed to be called with > sc_smi_mtx held? If so, add a lock assertion macro there. Will do. > * You call DELAY() with the lock held: >=20 > + DELAY(RTL_IICBUS_PHYDELAY); /* chip > needs time to talk to PHY */ >=20 > .. why not use pause() instead? I don't like how it could result in > that particular mutex being held for far, far too long (and I'm > starting to be weary of mutexes being used as a way of serialising > slow device access, but I digress).. I'll give it a shot. > * You've implemented retries here, which make sense. How then does the > Linux driver work? Or is it doing retries and I just don't remember. The linux driver, as far as I can tell, never actually talks to the = PHYs, unless you compile it with debugging. > * The older iicbb code with the original timeout doesn't result in any > timeouts at all, just FYI. I'm happy with the idea of a faster, more > efficient iicbb where the driver also handles timeouts correctly.. I > just wonder whether we're making it more complicated. I'm fairly confident that the HEAD iicbb.c is slow and partially broken = (the waitack function in particular). I believe the reason you're = seeing no timeouts with that code is due to it being slow, plus not = reporting errors properly. > How is it OpenWRT/Linux doesn't end up suffering from these high CPU > spikes when doing bitbanged GPIO? Or are they seeing them but > preemption is just masking it? They do not talk to the PHYs. BTW, with the newest iteration of rtl8366rb.c, the callout reads three = registers, instead of five PHYs times three registers, which turns into = 5*3*3=3D30 rtl8366rb register accesses. In my testing, I couln't "feel" the slowdown anymore, even with WITNESS = enabled. Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 12:50:01 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 0B8F61065670 for ; Wed, 28 Dec 2011 12:50:01 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vw0-f54.google.com (mail-vw0-f54.google.com [209.85.212.54]) by mx1.freebsd.org (Postfix) with ESMTP id A5C6D8FC15 for ; Wed, 28 Dec 2011 12:50:00 +0000 (UTC) Received: by vbbfr13 with SMTP id fr13so17140042vbb.13 for ; Wed, 28 Dec 2011 04:50:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=G2WS4YPMbRONKnW8gM+9ZokDrl+lq5OpCJzFY60N1lk=; b=Acikh0fnax6NbVvbOrJO1bktobHOEU+wdDclHvrYNw+VHYOAo3diOzKJrVIG9oa62I WGFUgH7frSXjIfTayy/bQT/iY2ziulQMwQ9IQD8QrB8ADJDY9v1xQFN9CaFzxJf52HJP fLAWjZun1eeaxzLJI89W4bMKRNKRg+cOcv9y4= MIME-Version: 1.0 Received: by 10.52.33.99 with SMTP id q3mr15138130vdi.100.1325076600136; Wed, 28 Dec 2011 04:50:00 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Wed, 28 Dec 2011 04:50:00 -0800 (PST) In-Reply-To: <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529EC2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> Date: Wed, 28 Dec 2011 04:50:00 -0800 X-Google-Sender-Auth: z-ulXVTTaKdDfEyxqXeATASmUrs Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 12:50:01 -0000 Hi, Ok, can you then please send me an updated diff which: * renames *_lockheld() to *_locked(), just for consistency with the kernel; * rename smi_mtx back to sc_mtx, just for consistency; * add _LOCK, _UNLOCK, _LOCK_ASSERT, _UNLOCK_ASSERT macros; * use those to enforce correct locking. :) Let's do that. We'll then worry about the callout mutex use afterwards. Adrian From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 12:53:04 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 38163106566B; Wed, 28 Dec 2011 12:53:04 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id DDD9F8FC0A; Wed, 28 Dec 2011 12:53:03 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 20674112D32; Wed, 28 Dec 2011 12:53:03 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Wed, 28 Dec 2011 13:53:02 +0100 Content-Transfer-Encoding: 7bit Message-Id: <15B22D65-22A7-403F-AFF7-A70FE0F9F6B5@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529E C2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 12:53:04 -0000 Am 28.12.2011 um 13:50 schrieb Adrian Chadd: > Hi, > > Ok, can you then please send me an updated diff which: > > * renames *_lockheld() to *_locked(), just for consistency with the kernel; > * rename smi_mtx back to sc_mtx, just for consistency; > * add _LOCK, _UNLOCK, _LOCK_ASSERT, _UNLOCK_ASSERT macros; > * use those to enforce correct locking. :) > > Let's do that. We'll then worry about the callout mutex use afterwards. Give me a moment, I'm looking into the PHY access code. Stefan -- Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 12:56:06 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BCCDA1065670 for ; Wed, 28 Dec 2011 12:56:06 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 662FD8FC12 for ; Wed, 28 Dec 2011 12:56:06 +0000 (UTC) Received: by vcbfk1 with SMTP id fk1so17052542vcb.13 for ; Wed, 28 Dec 2011 04:56:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=oAjRuSd523J94ZivOkJywUCMOEKSlxf6HvLhvQ+mpHk=; b=atdXEiGtbytrsz21wbE0/6ogDY/UYbI7INkiMLOfYs2g4equv5eLCElkVxftkoSpoR Y+fdi6CxssW2fOfl0xLB0b8wZ0eGxwy5JGHDnTlkq7q+k8gh4Ty/lVafXbmnUKcRrbBM aX3qvxO0GC3NUfOt4X1TwEfQizygFBLFn6Yy0= MIME-Version: 1.0 Received: by 10.220.153.134 with SMTP id k6mr18484956vcw.23.1325076965714; Wed, 28 Dec 2011 04:56:05 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Wed, 28 Dec 2011 04:56:05 -0800 (PST) In-Reply-To: <15B22D65-22A7-403F-AFF7-A70FE0F9F6B5@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <15B22D65-22A7-403F-AFF7-A70FE0F9F6B5@lassitu.de> Date: Wed, 28 Dec 2011 04:56:05 -0800 X-Google-Sender-Auth: hCWnK5yPG3a1a53BaQXPbIFmMWg Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 12:56:06 -0000 On 28 December 2011 04:53, Stefan Bethke wrote: > Give me a moment, I'm looking into the PHY access code. No worries. I need to go to work :) Meanwhile, I really should implement these if_arge PLL set routines as well as setting up the MII clock.. Adrian From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 13:52:31 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 96E4A106566C; Wed, 28 Dec 2011 13:52:31 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 482518FC0C; Wed, 28 Dec 2011 13:52:31 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 783F9112F11; Wed, 28 Dec 2011 13:52:30 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Wed, 28 Dec 2011 14:52:29 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <45529E C2-73BE-4F69-A9BE-E22D9FEAADD7@lassitu.de> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 13:52:31 -0000 Am 28.12.2011 um 13:50 schrieb Adrian Chadd: > Hi, >=20 > Ok, can you then please send me an updated diff which: >=20 > * renames *_lockheld() to *_locked(), just for consistency with the = kernel; > * rename smi_mtx back to sc_mtx, just for consistency; > * add _LOCK, _UNLOCK, _LOCK_ASSERT, _UNLOCK_ASSERT macros; > * use those to enforce correct locking. :) >=20 > Let's do that. We'll then worry about the callout mutex use = afterwards. Implement a number of suggestions by Adrian: * add mutex to callout * add locking macros * rename _lockheld to _locked * bring debugging under DEBUG, incl. sysctls * move i2c select retry to its own function * mtx_sleep when retrying the select * only reset bus on probe * do not DELAY on phy access retries * count phy access retries (under DEBUG) http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work (branch = work/ath) http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) http://www.lassitu.de/freebsd/etherswitch.tbz (all files) --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 18:13:05 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id CFC101065680 for ; Wed, 28 Dec 2011 18:13:05 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 749A38FC14 for ; Wed, 28 Dec 2011 18:13:05 +0000 (UTC) Received: by vcbfk1 with SMTP id fk1so17384901vcb.13 for ; Wed, 28 Dec 2011 10:13:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=1wFvdIr2YmfqQ847SHzOOmJaCLSAT8J+Egar+sz+crA=; b=t3XgDWQenP+hOBcpQxz/eugHcXlQMsdzVn/lpfRkiYAfn1d3nwSPgCr/sM2xCGtJNM cj0WwPWv6wgOiwTtf2VKlyow5NiqQ5KEiBgNbrZySSq7TPhAiKalZNNi76Y37kKf5P7j iyKUbKRRAZqaJHNzkAHcqcdHXr7IHRdn7kXYg= MIME-Version: 1.0 Received: by 10.52.33.99 with SMTP id q3mr15663203vdi.100.1325095984860; Wed, 28 Dec 2011 10:13:04 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Wed, 28 Dec 2011 10:13:04 -0800 (PST) In-Reply-To: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <15B22D65-22A7-403F-AFF7-A70FE0F9F6B5@lassitu.de> Date: Wed, 28 Dec 2011 10:13:04 -0800 X-Google-Sender-Auth: RmhM_tM6Ao9rwpI3sabXVxueBSg Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 18:13:05 -0000 So far: rtl8366rb0: resetting bus rtl8366rb0: smi_read()=2: addr=0014 rtl8366rb0port1: link state changed to UP rtl8366rb0port1: link state changed to DOWN rtl8366rb0: resetting bus rtl8366rb0: smi_read()=2: addr=0014 .. so seeing these resets should be fine? Or? Adrian From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 18:35:09 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 9ED24106566B for ; Wed, 28 Dec 2011 18:35:09 +0000 (UTC) (envelope-from adrian.chadd@gmail.com) Received: from mail-vx0-f182.google.com (mail-vx0-f182.google.com [209.85.220.182]) by mx1.freebsd.org (Postfix) with ESMTP id 28ACD8FC14 for ; Wed, 28 Dec 2011 18:34:59 +0000 (UTC) Received: by vcbfk1 with SMTP id fk1so17406581vcb.13 for ; Wed, 28 Dec 2011 10:34:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=avxeCja71ZgFIZPjg1/wEZRv3s7zyuq/LUqzGW+vD0E=; b=GjUG/9jPd5M1Hx2DAwEfpm4uPvR1DmW+GsHF2yIswB0oLtPpSgNqOq329fwRt/HsN+ YiDaxn0D/1n1EQ9TDqw717V6WMZpfTxi6DT0ToVzqu7mW2lAXVILI1iLOdM65B7C7imC dHi69YpZ6hv9R8C0yRLH1nxIKYiOfHGpkDHOQ= MIME-Version: 1.0 Received: by 10.220.213.200 with SMTP id gx8mr19219467vcb.13.1325097298538; Wed, 28 Dec 2011 10:34:58 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.52.36.5 with HTTP; Wed, 28 Dec 2011 10:34:58 -0800 (PST) In-Reply-To: <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> Date: Wed, 28 Dec 2011 10:34:58 -0800 X-Google-Sender-Auth: gIiZNQcKJb8Ec6diAAsRyUr_KT8 Message-ID: From: Adrian Chadd To: Stefan Bethke Content-Type: text/plain; charset=ISO-8859-1 Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 18:35:09 -0000 On 28 December 2011 05:52, Stefan Bethke wrote: > Implement a number of suggestions by Adrian: > * add mutex to callout > * add locking macros > * rename _lockheld to _locked > * bring debugging under DEBUG, incl. sysctls > * move i2c select retry to its own function > * mtx_sleep when retrying the select > * only reset bus on probe > * do not DELAY on phy access retries > * count phy access retries (under DEBUG) > > http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work (branch work/ath) > http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against Adrians gitorious repo as of now) > http://www.lassitu.de/freebsd/etherswitch.tbz (all files) The patch didn't compile - you were missing softc *sc pointers in smi_read_locked and smi_write_locked. Then when I added it: iicbb0: on gpioiic0 iicbb0: udelay=5 microseconds iicbus0: on iicbb0 master-only iic0: on iicbus0 panic: mutex (null) not owned at /home/adrian/work/freebsd/git/adrianchadd-freebsd-work/adrianchadd-freebsd-work/sys/dev/etherswitch/rtl8366rb.c:365 KDB: enter: panic .. and I bet it's because the path through rtl8366rb_probe() calls smi_read_locked() without things being locked. Which it can't be, there's no softc yet. :) So perhaps you need an smi_read() which doesn't have a lock, and use that just for the probe path. Also, remember to use braces ( ) around fields in a macro. :) Adrian From owner-freebsd-embedded@FreeBSD.ORG Wed Dec 28 23:21:47 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B2C63106564A; Wed, 28 Dec 2011 23:21:47 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 629388FC1C; Wed, 28 Dec 2011 23:21:47 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 3197A1139B9; Wed, 28 Dec 2011 23:21:46 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Thu, 29 Dec 2011 00:21:45 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <3F9F9391-C8A7-49C2-90BE-29AB9E9DE145@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 28 Dec 2011 23:21:47 -0000 Am 28.12.2011 um 19:34 schrieb Adrian Chadd: > On 28 December 2011 05:52, Stefan Bethke wrote: >=20 >> Implement a number of suggestions by Adrian: >> * add mutex to callout >> * add locking macros >> * rename _lockheld to _locked >> * bring debugging under DEBUG, incl. sysctls >> * move i2c select retry to its own function >> * mtx_sleep when retrying the select >> * only reset bus on probe >> * do not DELAY on phy access retries >> * count phy access retries (under DEBUG) >>=20 >> http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work = (branch work/ath) >> http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) >> http://www.lassitu.de/freebsd/etherswitch.tbz (all files) >=20 > The patch didn't compile - you were missing softc *sc pointers in > smi_read_locked and smi_write_locked. I profusely apologise for this sloppyness. After 20 years, I should = know better than making changes between testing and committing. I'll fix this up right away. Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Thu Dec 29 00:29:24 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B1247106564A; Thu, 29 Dec 2011 00:29:24 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 612958FC08; Thu, 29 Dec 2011 00:29:24 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 8E3B3113D8E; Thu, 29 Dec 2011 00:29:23 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Thu, 29 Dec 2011 01:29:22 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <2BB71545-7DE9-493D-92FE-AD4CEDCBF2D1@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2011 00:29:24 -0000 Am 28.12.2011 um 19:34 schrieb Adrian Chadd: > On 28 December 2011 05:52, Stefan Bethke wrote: >=20 >> Implement a number of suggestions by Adrian: >> * add mutex to callout >> * add locking macros >> * rename _lockheld to _locked >> * bring debugging under DEBUG, incl. sysctls >> * move i2c select retry to its own function >> * mtx_sleep when retrying the select >> * only reset bus on probe >> * do not DELAY on phy access retries >> * count phy access retries (under DEBUG) >>=20 >> http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work = (branch work/ath) >> http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) >> http://www.lassitu.de/freebsd/etherswitch.tbz (all files) >=20 > The patch didn't compile - you were missing softc *sc pointers in > smi_read_locked and smi_write_locked. I've updated the above with code that compiles as a module and = compiled-in, and is working as I expect it to. > Also, remember to use braces ( ) around fields in a macro. :) Where specifically did I miss them? Thanks, Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Thu Dec 29 10:18:32 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 66F28106566B; Thu, 29 Dec 2011 10:18:32 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 130E48FC0A; Thu, 29 Dec 2011 10:18:32 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id E0C836D1C6; Thu, 29 Dec 2011 10:18:30 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: <2BB71545-7DE9-493D-92FE-AD4CEDCBF2D1@lassitu.de> Date: Thu, 29 Dec 2011 11:18:30 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> <2BB71545-7DE9-493D-92FE-AD4CEDCBF2D1@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2011 10:18:32 -0000 > http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work (branch = work/ath) > http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) > http://www.lassitu.de/freebsd/etherswitch.tbz (all files) I've now gotten the panic again with the callout: Sleeping on "rtl8366rbstart" with the following non-sleepable locks = held: exclusive sleep mutex rtl8366rbcallout (rtl8366rbcallout) r =3D 0 = (0x80769114) locked @ = /home/stb/working/fe/stb-adrianchadd-freebsd-work/sys/kern/kern_mutex.c:14= 8 callout_init_mtx() says > The usable lock classes are currently limited to mutexes and rwlocks, = because callout handlers run in softclock swi, so they cannot sleep nor = acquire sleepable locks like sx or lockmgr. The way I read that, any callout will be run in a way that does not = allow sleeping. I'm not sure how to handle this. Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Thu Dec 29 10:50:10 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D6FFE1065678; Thu, 29 Dec 2011 10:50:10 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id 50FD58FC29; Thu, 29 Dec 2011 10:50:10 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 93EE36D83F; Thu, 29 Dec 2011 10:50:09 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Thu, 29 Dec 2011 11:50:09 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <9A1E9A46-BE00-4EBA-AC8A-2D61C3CCABE8@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> <2BB71545-7DE9-493D-92FE-AD4CEDCBF2D1@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2011 10:50:11 -0000 Am 29.12.2011 um 11:18 schrieb Stefan Bethke: >> http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work = (branch work/ath) >> http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) >> http://www.lassitu.de/freebsd/etherswitch.tbz (all files) >=20 > I've now gotten the panic again with the callout: > Sleeping on "rtl8366rbstart" with the following non-sleepable locks = held: > exclusive sleep mutex rtl8366rbcallout (rtl8366rbcallout) r =3D 0 = (0x80769114) locked @ = /home/stb/working/fe/stb-adrianchadd-freebsd-work/sys/kern/kern_mutex.c:14= 8 >=20 > callout_init_mtx() says >> The usable lock classes are currently limited to mutexes and rwlocks, = because callout handlers run in softclock swi, so they cannot sleep nor = acquire sleepable locks like sx or lockmgr. >=20 > The way I read that, any callout will be run in a way that does not = allow sleeping. I'm not sure how to handle this. Here's one way, replacing the callout with a thread: diff --git a/sys/dev/etherswitch/rtl8366rb.c = b/sys/dev/etherswitch/rtl8366rb.c index 599f5f0..2acb206 100644 --- a/sys/dev/etherswitch/rtl8366rb.c +++ b/sys/dev/etherswitch/rtl8366rb.c @@ -30,6 +30,7 @@ #include #include #include +#include #include #include #include @@ -60,13 +61,13 @@ =20 struct rtl8366rb_softc { struct mtx smi_mtx; /* serialize access to SMI/I2C = bus */ - struct mtx callout_mtx; /* serialize callout */ device_t dev; char *ifname[RTL8366RB_NUM_PHYS]; device_t miibus[RTL8366RB_NUM_PHYS]; struct ifnet *ifp[RTL8366RB_NUM_PHYS]; device_t etherswitch; - struct callout callout_tick; + struct thread *tickthread; + int ticking; }; =20 static etherswitch_info_t etherswitch_info =3D { @@ -171,7 +172,6 @@ rtl8366rb_attach(device_t dev) sc =3D device_get_softc(dev); sc->dev =3D dev; mtx_init(&sc->smi_mtx, "rtl8366rbsmi", NULL, MTX_DEF); - mtx_init(&sc->callout_mtx, "rtl8366rbcallout", NULL, MTX_DEF); =20 rtl8366rb_init(dev); smi_read(dev, RTL8366RB_CVCR, &rev); @@ -202,8 +202,9 @@ rtl8366rb_attach(device_t dev) if (err !=3D 0) return (err); =20 - callout_init_mtx(&sc->callout_tick, &sc->callout_mtx, 0); - rtl8366rb_tick(sc); + sc->ticking =3D 1; + kthread_add(rtl8366rb_tick, sc, NULL, &sc->tickthread, 0, 0, \ + "%s tick", device_get_nameunit(dev)); =20 return (err); } @@ -217,6 +218,11 @@ rtl8366rb_detach(device_t dev) sc =3D device_get_softc(dev); if (sc->etherswitch) device_delete_child(dev, sc->etherswitch); + if (sc->ticking) { + sc->ticking =3D 0; + wakeup_one(sc->tickthread); + tsleep(sc, 0, "tickexit", 0); + } for (i=3D0; i < RTL8366RB_NUM_PHYS; i++) { if (sc->miibus[i]) device_delete_child(dev, sc->miibus[i]); @@ -225,8 +231,6 @@ rtl8366rb_detach(device_t dev) free(sc->ifname[i], M_DEVBUF); } bus_generic_detach(dev); - callout_drain(&sc->callout_tick); - mtx_destroy(&sc->callout_mtx); mtx_destroy(&sc->smi_mtx); =20 return (0); @@ -295,8 +299,12 @@ rtl8366rb_tick(void *arg) { struct rtl8366rb_softc *sc =3D arg; =20 - rtl833rb_miipollstat(sc); - callout_reset(&sc->callout_tick, hz, rtl8366rb_tick, sc); + while (sc->ticking) { + rtl833rb_miipollstat(sc); + tsleep(sc->tickthread, 0, "tick", hz); + }; + wakeup_one(sc); + kthread_exit(); } =20 static int --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Thu Dec 29 16:56:33 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 281FE1065670; Thu, 29 Dec 2011 16:56:33 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id CA60D8FC13; Thu, 29 Dec 2011 16:56:32 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id A77531113BD; Thu, 29 Dec 2011 16:56:31 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: Date: Thu, 29 Dec 2011 17:56:31 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <7A8E7854-4696-44B9-B0BE-3D6640BA0A49@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> <2BB71545-7DE9-493D-92FE-AD4CEDCBF2D1@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 29 Dec 2011 16:56:33 -0000 Am 29.12.2011 um 11:18 schrieb Stefan Bethke: > http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work (branch = work/ath) > http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) > http://www.lassitu.de/freebsd/etherswitch.tbz (all files) I've updated the patch: Improve locking. There is now one lock for the softc. SMI bus access is serialized = through a softc field protected by sc_mtx. All bus access functions can be called with RTL_NOWAIT, making them punt immediately if the bus was already acquired. This allows the callout to try and read all three port status registers, or just abort and wait for the next round. For bus access through the control device, the functions are called with RTL_WAITOK, which will make them sleep until the bus becomes available (through the standard mtx_lock()). With this version, I get no WITNESS warnings, nor panics from the = callout. The retries for I2C select and PHY register access always succeed (100k+ test accesses in a tight loop). Stefan --=20 Stefan Bethke Fon +49 151 14070811 From owner-freebsd-embedded@FreeBSD.ORG Fri Dec 30 00:23:19 2011 Return-Path: Delivered-To: freebsd-embedded@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 2BB631065672; Fri, 30 Dec 2011 00:23:19 +0000 (UTC) (envelope-from stb@lassitu.de) Received: from gilb.zs64.net (gilb.zs64.net [IPv6:2001:470:1f0b:105e::1ea]) by mx1.freebsd.org (Postfix) with ESMTP id CD83C8FC12; Fri, 30 Dec 2011 00:23:18 +0000 (UTC) Received: by gilb.zs64.net (Postfix, from stb@lassitu.de) id 0E16511215B; Fri, 30 Dec 2011 00:23:18 +0000 (UTC) Mime-Version: 1.0 (Apple Message framework v1251.1) Content-Type: text/plain; charset=iso-8859-1 From: Stefan Bethke In-Reply-To: <7A8E7854-4696-44B9-B0BE-3D6640BA0A49@lassitu.de> Date: Fri, 30 Dec 2011 01:23:17 +0100 Content-Transfer-Encoding: quoted-printable Message-Id: <7EAD98F7-FDB6-404B-82FE-8D5BC081BD9B@lassitu.de> References: <0F6CC18F-6973-42A2-AC03-F01BF59458AE@lassitu.de> <1100F70E-9DA9-4163-AC9A-423ECE5AA9A3@lassitu.de> <18CABB46-9B9A-41CB-8742-6723C5FF4D67@lassitu.de> <2CBD8651-E132-49DC-A082-37A8F5C626EA@bsdimp.com> <267FB3D6-830E-4A2F-8C1C-A96873EDCD31@lassitu.de> <12538AED-175C-4B1E-BF05-6FD05D14CE70@lassitu.de> <2135AD2B-76D4-4B3D-A009-8F3BEC836051@lassitu.de> <2BB71545-7DE9-493D-92FE-AD4CEDCBF2D1@lassitu.de> <7A8E7854-4696-44B9-B0BE-3D6640BA0A49@lassitu.de> To: Adrian Chadd X-Mailer: Apple Mail (2.1251.1) Cc: "freebsd-embedded@freebsd.org" Subject: Re: Updated switch/glue patch? X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Dec 2011 00:23:19 -0000 Am 29.12.2011 um 17:56 schrieb Stefan Bethke: > Am 29.12.2011 um 11:18 schrieb Stefan Bethke: >=20 >> http://gitorious.org/~stb/freebsd/stb-adrianchadd-freebsd-work = (branch work/ath) >> http://www.lassitu.de/freebsd/etherswitch-adrian.patch (patch against = Adrians gitorious repo as of now) >> http://www.lassitu.de/freebsd/etherswitch.tbz (all files) >=20 > With this version, I get no WITNESS warnings, nor panics from the = callout. > The retries for I2C select and PHY register access always succeed = (100k+ > test accesses in a tight loop). All the retries are probably bogus. I've switched back to the original = version of iicbb.c, and I'm not getting a single retry on either select = or PHY register access. I'll look into why my improved code is working worse than the original, = but for the time being, we should stick to the original code. The = recovery options in rtl8366rb.c don't really hurt and can stay for the = moment. Stefan --=20 Stefan Bethke Fon +49 151 14070811