Skip to contentSkip to conversation

Bug in omap_gpmc.c:omap_nand_read_prefetch

U-Boot Reitinger 1 participant 1 message Jun 24, 2019

lore
Share & tools
lore

Reitinger

#0 lore raw

Hello,

sorry I am completely new to these kind of mailing lists, and quite probably I violate most of the rules for using this mailing list, but I have a serious bug to report and actually no time at all...

/u-boot_2019/drivers/mtd/nand/raw/omap_gpmc.c - function omap_nand_read_prefetch():

Whenever buf % 4 is neither 0 or 2 (i.e. 1 or 3), too few or too many bytes, respectively, are read before the calls to __read_prefetch_align.

Suggested fix:

original:

    /*
     * If the destination buffer is unaligned, start with reading
     * the overlap byte-wise.
     */
    head = ((uint32_t) buf) % 4;
    if (head) {
        omap_nand_read(mtd, buf, head);
        buf += head;
        len -= head;
    }

fixed:

    /*
     * If the destination buffer is unaligned, start with reading
     * the overlap byte-wise.
     */
    head = ((uint32_t) buf) % 4;
    if (head) {

        head = 4 - head; // randomly equal to head if head == 2 ;-)
        omap_nand_read(mtd, buf, head);
        buf += head;
        len -= head;
    }

Best regards

Peter Reitinger