提交 a85a00a6 编写于 作者: U unsik Kim 提交者: Jens Axboe

mg_disk: Add missing ready status check on mg_write()

When last sector is written, ready bit of status register should be
checked.
Signed-off-by: Nunsik Kim <donari75@gmail.com>
Acked-by: NBartlomiej Zolnierkiewicz <bzolnier@gmail.com>
Signed-off-by: NJens Axboe <jens.axboe@oracle.com>
上级 394c6cc6
...@@ -524,16 +524,16 @@ static void mg_write_one(struct mg_host *host, struct request *req) ...@@ -524,16 +524,16 @@ static void mg_write_one(struct mg_host *host, struct request *req)
static void mg_write(struct request *req) static void mg_write(struct request *req)
{ {
struct mg_host *host = req->rq_disk->private_data; struct mg_host *host = req->rq_disk->private_data;
bool rem; unsigned int rem = blk_rq_sectors(req);
if (mg_out(host, blk_rq_pos(req), blk_rq_sectors(req), if (mg_out(host, blk_rq_pos(req), rem,
MG_CMD_WR, NULL) != MG_ERR_NONE) { MG_CMD_WR, NULL) != MG_ERR_NONE) {
mg_bad_rw_intr(host); mg_bad_rw_intr(host);
return; return;
} }
MG_DBG("requested %d sects (from %ld), buffer=0x%p\n", MG_DBG("requested %d sects (from %ld), buffer=0x%p\n",
blk_rq_sectors(req), blk_rq_pos(req), req->buffer); rem, blk_rq_pos(req), req->buffer);
if (mg_wait(host, ATA_DRQ, if (mg_wait(host, ATA_DRQ,
MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
...@@ -541,25 +541,23 @@ static void mg_write(struct request *req) ...@@ -541,25 +541,23 @@ static void mg_write(struct request *req)
return; return;
} }
mg_write_one(host, req); do {
mg_write_one(host, req);
outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base + MG_REG_COMMAND); outb(MG_CMD_WR_CONF, (unsigned long)host->dev_base +
MG_REG_COMMAND);
do { rem--;
if (blk_rq_sectors(req) > 1 && if (rem > 1 && mg_wait(host, ATA_DRQ,
mg_wait(host, ATA_DRQ, MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) { mg_bad_rw_intr(host);
return;
} else if (mg_wait(host, MG_STAT_READY,
MG_TMAX_WAIT_WR_DRQ) != MG_ERR_NONE) {
mg_bad_rw_intr(host); mg_bad_rw_intr(host);
return; return;
} }
} while (mg_end_request(host, 0, MG_SECTOR_SIZE));
rem = mg_end_request(host, 0, MG_SECTOR_SIZE);
if (rem)
mg_write_one(host, req);
outb(MG_CMD_WR_CONF,
(unsigned long)host->dev_base + MG_REG_COMMAND);
} while (rem);
} }
static void mg_read_intr(struct mg_host *host) static void mg_read_intr(struct mg_host *host)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册