Date: Sun, 18 Jan 2015 13:52:26 -0700 From: Ian Lepore <ian@freebsd.org> To: Daisuke Aoyama <aoyama@peach.ne.jp> Cc: freebsd-arm@freebsd.org Subject: Re: HS mode in RPi Message-ID: <1421614346.14601.338.camel@freebsd.org> In-Reply-To: <9C4B3BEE66EA4C1582F149682BBF729E@ad.peach.ne.jp> References: <AF35369EC7D84B59A5BBAADD77DC1687@ad.peach.ne.jp> <9C4B3BEE66EA4C1582F149682BBF729E@ad.peach.ne.jp>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sun, 2015-01-18 at 17:31 +0900, Daisuke Aoyama wrote: > I forget mention. r276985 is complete wrong. > > SDHCI_COMMAND_FLAGS is never stored in local variable. > So accessing it means "return uninitialized value". > > > if (off == SDHCI_TRANSFER_MODE) { > > return (sc->cmd_and_mode >> 16); > > } else if (off == SDHCI_COMMAND_FLAGS) { > > return (sc->cmd_and_mode & 0x0000ffff); > > } > Fixed in r277346, but nothing will actually change because nothing right now does a 16-bit read of SDHCI_COMMAND_FLAGS. But if that ever changes, now the code will work right. > Also I fixed, the code may return unexpected value. > 16bit width access should use even address. > >return ((val >> (off & 3)*8) & 0xffff); sdhci will never do a bus_space_read_2() on an odd address, so (off & 3) has the same effect as (off & 2). In general it is expected that the bus_space accessor functions will be used with offsets that are aligned to the size of the operation. The documentation doesn't absolutely forbid unaligned access, but it strongly encourages natural alignment and notes that unaligned operations may fail. -- Ian
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?1421614346.14601.338.camel>