From owner-freebsd-wireless@FreeBSD.ORG Wed Jul 31 08:36:31 2013 Return-Path: Delivered-To: freebsd-wireless@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTP id 3264B408 for ; Wed, 31 Jul 2013 08:36:31 +0000 (UTC) (envelope-from ghw@7axu.com) Received: from mail-wg0-f44.google.com (mail-wg0-f44.google.com [74.125.82.44]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B876B21B6 for ; Wed, 31 Jul 2013 08:36:30 +0000 (UTC) Received: by mail-wg0-f44.google.com with SMTP id l18so330416wgh.23 for ; Wed, 31 Jul 2013 01:36:23 -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=MjDHRFB/yimg1sNMY6NAQK+1jkakVATlaojKKLOgg63QacRDLBtiJZywqf1YnpQWhm cOf/alkIjb5KZd+NAt749Rk5HyMf3VuzCH4B3JkytIBD5bCUFlWbA3P8A5uaCa1b3+iV u71MtB8WaLFy9VZ2gGTSXDJEbfYzANiiDsspltPnz8LgXmF5R4WU5mr9FmDO6CV8/Zac kiYswr2dn4pRoQpqlwdeqLXPIpJ0cV9C8v6cfs16XBBSGzBs9hvKB7/WZjLfyiy2Rzx1 yVmmdMFdgE9HRkuxJleESy4ySBgWkyteijByVzEzTNkulD+S5QYHZfV3UomUqpkHZoBQ 1+1g== 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: ALoCoQmH7KOWrbJSxGGYAqeIn6W14mEU3Ob/FgJiYZeGB7Mde+krJaZWyWjhEF0IWJDNi2QhHZ9W Cc: John-Mark Gurney , "freebsd-wireless@freebsd.org" , freebsd-arm , Hans Petter Selasky X-BeenThere: freebsd-wireless@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Discussions of 802.11 stack, tools device driver development." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 31 Jul 2013 08:36:31 -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"