David Brownell wrote: > On Wednesday 29 August 2007, Pierre Ossman wrote: >>> I need the following patch on my (little endian) System to >>> successfully read the csd/cid structure. >> The resp field should already be in host order, so there must be a bug >> in the mmc/spi host controller driver. > > I wouldn't think it could be in host order ... what would have > changed it from wire-order, if not for a patch like Sascha sent? > > This sounds like exactly the failure I'd expect from bugs caused > by omitted byteswapping, since I did all my recent work on a > big-endian machine. > I can confirm, that the byte-swapping patch from Sascha is needed on my little endian mips testbed too. I can also see, that in earlier versions of mmc-spi, the byte swapping was present in there together with routine to read csd/cid. Now it is handled in mmc core, without byte swapping, so it does not work on little endian systems... I've tested mmc-spi from linux-2.6.23-rc8-mm2, plus: - added byte-swapping patch from Sascha - added buffer length patch from Sascha as improved by David This resulted in nearly working mmc-spi, except the problem with the last sector(s). Tried to apply the fix to force single block read for last sector as suggested by Sascha, but it fails not with the last sector, but several of them at the end, with following error: mmcblk0: error -22 sending stop command Changing the patch to use single block reads for any of 8 sectors at the end of sd card, it works perfectly. In addition to that, it seems, that retries are not enabled for sector access in mmc core, so I needed to add set of brq.cmd.retries into mmc_blk_issue_rq() and also checking of mrq->data->error and mrq->stop->error with call to host->ops->request() into mmc_request_done(). Otherwise, block transfers are never retried. And there are cases, that errors are caused by too long wires and high frequencies in my environment, so retries are sometimes very useful. Finally I have tested also the suspend/resume callbacks of mmc core. As I am using sd card in embedded environment (assuming that sd card will never be removed), so MMC_UNSAFE_RESUME is good to me. However, it seems to me, that the - if (!blk_queue_plugged(q)) req = elv_next_request(q); in mmc_queue_thread() is too kind to accept new requests, even when the queue is stopped. This seems to be much better for faster suspending: + if (!blk_queue_plugged(q) && !blk_queue_stopped(q)) req = elv_next_request(q); so that new requests are not accepted if queue is stopped or plugged. See the complete patches bellow, please. Thanks and best regards, Jan