From owner-svn-src-all@FreeBSD.ORG Fri Nov 15 23:48:52 2013 Return-Path: Delivered-To: svn-src-all@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 ESMTPS id 4DF8EB4F; Fri, 15 Nov 2013 23:48:52 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 246402CFF; Fri, 15 Nov 2013 23:48:52 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.7/8.14.7) with ESMTP id rAFNmqO2035386; Fri, 15 Nov 2013 23:48:52 GMT (envelope-from ian@svn.freebsd.org) Received: (from ian@localhost) by svn.freebsd.org (8.14.7/8.14.5/Submit) id rAFNmpMR035385; Fri, 15 Nov 2013 23:48:51 GMT (envelope-from ian@svn.freebsd.org) Message-Id: <201311152348.rAFNmpMR035385@svn.freebsd.org> From: Ian Lepore Date: Fri, 15 Nov 2013 23:48:51 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r258202 - head/sys/dev/nand X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.16 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 15 Nov 2013 23:48:52 -0000 Author: ian Date: Fri Nov 15 23:48:51 2013 New Revision: 258202 URL: http://svnweb.freebsd.org/changeset/base/258202 Log: Rework the routine that returns a pointer to the table of software ECC byte positions within the OOB area to support chips with unusual OOB sizes such as 218 or 224 bytes. The table for 128 byte OOB works for these but it assumes 3 bytes of ECC per 256 byte block, and in the case of an ONFI chip the params page may ask for something different. In other words, this is better but not yet perfect. Modified: head/sys/dev/nand/nand.c Modified: head/sys/dev/nand/nand.c ============================================================================== --- head/sys/dev/nand/nand.c Fri Nov 15 23:45:13 2013 (r258201) +++ head/sys/dev/nand/nand.c Fri Nov 15 23:48:51 2013 (r258202) @@ -309,23 +309,22 @@ nand_get_chip_param(struct nand_chip *ch static uint16_t * default_software_ecc_positions(struct nand_chip *chip) { - struct nand_ecc_data *eccd; - - eccd = &chip->nand->ecc; - - if (eccd->eccpositions) - return (eccd->eccpositions); - - switch (chip->chip_geom.oob_size) { - case 16: - return ((uint16_t *)&default_software_ecc_positions_16); - case 64: - return ((uint16_t *)&default_software_ecc_positions_64); - case 128: - return ((uint16_t *)&default_software_ecc_positions_128); - default: - return (NULL); /* No ecc bytes positions defs available */ - } + /* If positions have been set already, use them. */ + if (chip->nand->ecc.eccpositions) + return (chip->nand->ecc.eccpositions); + + /* + * XXX Note that the following logic isn't really sufficient, especially + * in the ONFI case where the number of ECC bytes can be dictated by + * values in the parameters page, and that could lead to needing more + * byte positions than exist within the tables of software-ecc defaults. + */ + if (chip->chip_geom.oob_size >= 128) + return (default_software_ecc_positions_128); + if (chip->chip_geom.oob_size >= 64) + return (default_software_ecc_positions_64); + else if (chip->chip_geom.oob_size >= 16) + return (default_software_ecc_positions_16); return (NULL); }