From owner-freebsd-arm@FreeBSD.ORG Wed Jul 31 08:29:06 2013 Return-Path: Delivered-To: freebsd-arm@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 907956B for ; Wed, 31 Jul 2013 08:29:06 +0000 (UTC) (envelope-from ghw@7axu.com) Received: from mail-we0-f171.google.com (mail-we0-f171.google.com [74.125.82.171]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 239DC214D for ; Wed, 31 Jul 2013 08:29:05 +0000 (UTC) Received: by mail-we0-f171.google.com with SMTP id q55so331403wes.2 for ; Wed, 31 Jul 2013 01:28:57 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=mime-version:x-originating-ip:in-reply-to:references:from:date :message-id:subject:to:cc:content-type:content-transfer-encoding :x-gm-message-state; bh=CvzjtvkqZyAc5cgn6ZqHgcdiB3Bi2xhpAPPvhJBbz7I=; b=HCRaXGPJ84VtDB9qeUbmTdwwcZgpC3Vhmb/XHZF6g1zawXWGfAi92eGiKcPgtJhdY1 HLV7phmBv8U5neg6E283Wt+WzRruuMlGQwyZGciiiJwZf9fPVVzUjggSOA0gxMe1Gyy5 C/PFVNvre+E5tx/2p16Qo/qx93F0huzM5IFkVvWpvA4iEB5ZH+YWsraSG/kenRzSPLkt UZnWuP08LdLz/ml8BRp0rVwFGFME0mJ9J+BS0qJ/3YCrTFWvCgZpB67BGrKDn89KM1v2 JugwG1yaApvyxEsvZHEOwxNADG27s7tA64xWq0M1uevbpqmHR83Pw9mDxPsmTTDUd6FH s09A== X-Received: by 10.194.20.163 with SMTP id o3mr7951350wje.53.1375259337809; Wed, 31 Jul 2013 01:28:57 -0700 (PDT) MIME-Version: 1.0 Received: by 10.194.93.34 with HTTP; Wed, 31 Jul 2013 01:28:17 -0700 (PDT) X-Originating-IP: [54.249.112.206] In-Reply-To: <1375151095.45247.54.camel@revolution.hippie.lan> References: <20130729211540.GZ26412@funkthat.com> <1375151095.45247.54.camel@revolution.hippie.lan> From: XiaoQI Ge Date: Wed, 31 Jul 2013 16:28:17 +0800 Message-ID: Subject: Re: My WLI-UC-GNM up crash To: Ian Lepore Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-Gm-Message-State: ALoCoQkJduq6xDLkLzqlMYX0N6SHbdbRKUmfIV+oOMSvTd4mkdJCBTEz6obOgN+zkTa3BaHM78JT Cc: "freebsd-wireless@freebsd.org" , freebsd-arm , Hans Petter Selasky X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Porting FreeBSD to the StrongARM Processor List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jul 2013 08:29:06 -0000 Last night, I use the latest FreeBSD source (r253827) and crochet-freebsd compile img My WLI-UC-GNM will be disconnected after a period of operation run0: device timeout run0: at uhub0, port 1, addr 2 (disconnected) Another log prompted ti_mmchs0: Error: current cmd NULL, already done? My BB-Black broken? -- Regards. By: XiaoQI Ge; PGP:8B09D5F7 WWW: https://www.7axu.com/ 2013/7/30 Ian Lepore : > On Mon, 2013-07-29 at 14:15 -0700, John-Mark Gurney wrote: >> Hans Petter Selasky wrote this message on Mon, Jul 29, 2013 at 19:58 +02= 00: >> > The aligned will make sure that the structure gets padded properly to = the size specified. Only on ARM/MIPS etc, structures get automatically alig= ned according to the element in the structure requiring the greatest alignm= ent. I've test-compiled the USB WLAN drivers, and the aligned makes a diffe= rence. The problem is that the radiotap header skews some following element= s, so that they are no longer aligned. The radiotap header itself is packed= , and this is not a problem. >> >> Ouch, has anyone looked at the code that caused this? >> >> in ieee80211_radiotap.c, it looks like the original fault was in either >> set_channel, or set_xchannel, and both do (the equivalent of): >> struct { >> uint16_t freq; >> uint16_t flags; >> } *rc =3D p; >> >> rc->freq =3D htole16(c->ic_freq); >> rc->flags =3D htole16(c->ic_flags); >> > > If there's any chance the pointer isn't aligned in code like this, then > htole16() is the wrong function, it should be using le16enc() such as > > le16enc(&rc->freq, c->ic_freq); > le16enc(&rc->flags, c->ic_flags); > > With any luck, an x86 compiler can optimize the inline code for the > endian enc/dec functions to take advantage of the platform's ability to > do unaligned accesses. But that's a side issue to code correctness -- > portable code has to get these things right even when it's inefficient. > > -- Ian > >> And then there is complicated code that calculates offsets, etc, in >> radiotap_offset.. What we probably really need is to mark the above >> as __packed or equiv so that we don't assume that the passed in pointer >> is aligned... >> >> The whole management of this radiochan and radiotap_offset is pretty >> nasty... If marking the structures __packed works, it's probably >> because two bugs are offsetting, and magicly making things align >> again... >> >> > -----Original message----- >> > > From:Warner Losh > >> > > Sent: Monday 29th July 2013 17:04 >> > > To: Adrian Chadd > >> > > Cc: Hans Petter Selasky >; freebsd-arm >; freebsd-wireless@freebsd.org >> > > Subject: Re: My WLI-UC-GNM up crash >> > > >> > > Aren't structures already aligned to 4 bytes when placed inside othe= r structures (unless marked __packed)? >> > > >> > > Warner >> > > >> > > On Jul 28, 2013, at 11:50 AM, Adrian Chadd wrote: >> > > >> > > > As long as that results in the radiotap structures being 4 or 8 by= te >> > > > padded when it's embedded in the softc - then yes, indeed. >> > > > >> > > > Xiao, can you try? >> > > > >> > > > >> > > > -adrian >> > > > >> > > > On 28 July 2013 03:35, Hans Petter Selasky > wrote: >> > > >> Hi, >> > > >> >> > > >> Can you try the attached patch? >> > > >> >> > > >> --HPS >> > > > _______________________________________________ >> > > > freebsd-arm@freebsd.org mailing = list >> > > > http://lists.freebsd.org/mailman/listinfo/freebsd-arm >> > > > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.= org " >> > > >> > > >> > >> > _______________________________________________ >> > freebsd-arm@freebsd.org mailing list >> > http://lists.freebsd.org/mailman/listinfo/freebsd-arm >> > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org" >> > > > _______________________________________________ > freebsd-arm@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arm > To unsubscribe, send any mail to "freebsd-arm-unsubscribe@freebsd.org"