From owner-freebsd-embedded@FreeBSD.ORG Fri Nov 15 17:04:42 2013 Return-Path: Delivered-To: freebsd-embedded@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 ESMTPS id 12DD4102; Fri, 15 Nov 2013 17:04:42 +0000 (UTC) Received: from mho-02-ewr.mailhop.org (mho-02-ewr.mailhop.org [204.13.248.72]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id DD0062736; Fri, 15 Nov 2013 17:04:41 +0000 (UTC) Received: from c-24-8-230-52.hsd1.co.comcast.net ([24.8.230.52] helo=damnhippie.dyndns.org) by mho-02-ewr.mailhop.org with esmtpsa (TLSv1:AES256-SHA:256) (Exim 4.72) (envelope-from ) id 1VhMos-0005nO-9r; Fri, 15 Nov 2013 17:04:34 +0000 Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id rAFH4VO4075085; Fri, 15 Nov 2013 10:04:31 -0700 (MST) (envelope-from ian@FreeBSD.org) X-Mail-Handler: Dyn Standard SMTP by Dyn X-Originating-IP: 24.8.230.52 X-Report-Abuse-To: abuse@dyndns.com (see http://www.dyndns.com/services/sendlabs/outbound_abuse.html for abuse reporting information) X-MHO-User: U2FsdGVkX1+zTIfNHyCjxN8Qfd3b6FwY Subject: Re: [PATCH 4/5] Unpack (align) and decode (endian) the values in the onfi_params struct. From: Ian Lepore To: kristof@sigsegv.be In-Reply-To: <1384381960-98851-5-git-send-email-kristof@sigsegv.be> References: <1383782353.31172.183.camel@revolution.hippie.lan> <1384381960-98851-1-git-send-email-kristof@sigsegv.be> <1384381960-98851-5-git-send-email-kristof@sigsegv.be> Content-Type: text/plain; charset="us-ascii" Date: Fri, 15 Nov 2013 10:04:31 -0700 Message-ID: <1384535071.31172.381.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: Grzegorz Bernacki , freebsd-embedded@FreeBSD.org X-BeenThere: freebsd-embedded@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: Dedicated and Embedded Systems List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Nov 2013 17:04:42 -0000 On Wed, 2013-11-13 at 23:32 +0100, kristof@sigsegv.be wrote: > From: Kristof Provost > > ONFI parameters are little-endian, hence we must take care to convert them to > native endianness. We must also pay attention to unalligned accesses. > > Copy the interesting parameters to a new struct so the rest of the code can > forget about these problems. > --- > sys/dev/nand/nand.c | 2 +- > sys/dev/nand/nand.h | 16 +++++++++++++- > sys/dev/nand/nand_generic.c | 51 +++++++++++++++++++++++++++---------------- > 3 files changed, 48 insertions(+), 21 deletions(-) > > diff --git a/sys/dev/nand/nand.c b/sys/dev/nand/nand.c > index f46d0f0..902ff79 100644 > --- a/sys/dev/nand/nand.c > +++ b/sys/dev/nand/nand.c > @@ -115,7 +115,7 @@ nand_init(struct nand_softc *nand, device_t dev, int ecc_mode, > } > > void > -nand_onfi_set_params(struct nand_chip *chip, struct onfi_params *params) > +nand_onfi_set_params(struct nand_chip *chip, struct onfi_chip_params *params) > { > struct chip_geom *cg; > > diff --git a/sys/dev/nand/nand.h b/sys/dev/nand/nand.h > index d9bfad7..4fbe75c 100644 > --- a/sys/dev/nand/nand.h > +++ b/sys/dev/nand/nand.h > @@ -235,6 +235,20 @@ struct onfi_params { > }__attribute__((packed)); > CTASSERT(sizeof(struct onfi_params) == 256); > > +struct onfi_chip_params { > + uint8_t luns; > + uint32_t blocks_per_lun; > + uint32_t pages_per_block; > + uint32_t bytes_per_page; > + uint32_t spare_bytes_per_page; > + uint16_t t_bers; > + uint16_t t_prog; > + uint16_t t_r; > + uint16_t t_ccs; > + uint16_t features; > + uint8_t address_cycles; > +}; Sorry for the delay on this, I finally got around to looking at these today. The only comment I have on the 5 patches is that if the 'luns' field of the new onfi_chip_params struct were moved to the end, the struct would be ideally packed with no unused padding on architectures where alignment counts. -- Ian