* [PATCH 4.19 240/321] mmc: core: align max segment size with logical block size [not found] <20191203223427.103571230@linuxfoundation.org> @ 2019-12-03 22:35 ` Greg Kroah-Hartman 2019-12-05 22:22 ` Pavel Machek 0 siblings, 1 reply; 3+ messages in thread From: Greg Kroah-Hartman @ 2019-12-03 22:35 UTC (permalink / raw) To: linux-kernel Cc: Greg Kroah-Hartman, stable, Naresh Kamboju, Christoph Hellwig, Faiz Abbas, linux-block, Ming Lei, Ulf Hansson, Sasha Levin From: Ming Lei <ming.lei@redhat.com> [ Upstream commit c53336c8f5f29043fded57912cc06c24e12613d7 ] Logical block size is the lowest possible block size that the storage device can address. Max segment size is often related with controller's DMA capability. And it is reasonable to align max segment size with logical block size. SDHCI sets un-aligned max segment size, and causes ADMA error, so fix it by aligning max segment size with logical block size. Reported-by: Naresh Kamboju <naresh.kamboju@linaro.org> Cc: Christoph Hellwig <hch@lst.de> Cc: Naresh Kamboju <naresh.kamboju@linaro.org> Cc: Faiz Abbas <faiz_abbas@ti.com> Cc: linux-block@vger.kernel.org Signed-off-by: Ming Lei <ming.lei@redhat.com> Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org> Signed-off-by: Sasha Levin <sashal@kernel.org> --- drivers/mmc/core/block.c | 6 ------ drivers/mmc/core/queue.c | 9 ++++++++- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/drivers/mmc/core/block.c b/drivers/mmc/core/block.c index eee004fb3c3e3..527ab15c421f9 100644 --- a/drivers/mmc/core/block.c +++ b/drivers/mmc/core/block.c @@ -2384,12 +2384,6 @@ static struct mmc_blk_data *mmc_blk_alloc_req(struct mmc_card *card, snprintf(md->disk->disk_name, sizeof(md->disk->disk_name), "mmcblk%u%s", card->host->index, subname ? subname : ""); - if (mmc_card_mmc(card)) - blk_queue_logical_block_size(md->queue.queue, - card->ext_csd.data_sector_size); - else - blk_queue_logical_block_size(md->queue.queue, 512); - set_capacity(md->disk, size); if (mmc_host_cmd23(card->host)) { diff --git a/drivers/mmc/core/queue.c b/drivers/mmc/core/queue.c index 18aae28845ec9..becc6594a8a47 100644 --- a/drivers/mmc/core/queue.c +++ b/drivers/mmc/core/queue.c @@ -355,6 +355,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card) { struct mmc_host *host = card->host; u64 limit = BLK_BOUNCE_HIGH; + unsigned block_size = 512; if (mmc_dev(host)->dma_mask && *mmc_dev(host)->dma_mask) limit = (u64)dma_max_pfn(mmc_dev(host)) << PAGE_SHIFT; @@ -368,7 +369,13 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card) blk_queue_max_hw_sectors(mq->queue, min(host->max_blk_count, host->max_req_size / 512)); blk_queue_max_segments(mq->queue, host->max_segs); - blk_queue_max_segment_size(mq->queue, host->max_seg_size); + + if (mmc_card_mmc(card)) + block_size = card->ext_csd.data_sector_size; + + blk_queue_logical_block_size(mq->queue, block_size); + blk_queue_max_segment_size(mq->queue, + round_down(host->max_seg_size, block_size)); INIT_WORK(&mq->recovery_work, mmc_mq_recovery_handler); INIT_WORK(&mq->complete_work, mmc_blk_mq_complete_work); -- 2.20.1 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH 4.19 240/321] mmc: core: align max segment size with logical block size 2019-12-03 22:35 ` [PATCH 4.19 240/321] mmc: core: align max segment size with logical block size Greg Kroah-Hartman @ 2019-12-05 22:22 ` Pavel Machek 2019-12-06 0:54 ` Ming Lei 0 siblings, 1 reply; 3+ messages in thread From: Pavel Machek @ 2019-12-05 22:22 UTC (permalink / raw) To: Greg Kroah-Hartman Cc: linux-kernel, stable, Naresh Kamboju, Christoph Hellwig, Faiz Abbas, linux-block, Ming Lei, Ulf Hansson, Sasha Levin [-- Attachment #1: Type: text/plain, Size: 1028 bytes --] Hi! > From: Ming Lei <ming.lei@redhat.com> > > [ Upstream commit c53336c8f5f29043fded57912cc06c24e12613d7 ] > > Logical block size is the lowest possible block size that the storage > device can address. Max segment size is often related with controller's > DMA capability. And it is reasonable to align max segment size with > logical block size. > SDHCI sets un-aligned max segment size, and causes ADMA error, so > fix it by aligning max segment size with logical block size. If un-aligned max segment sizes are problem, should we add checks to prevent setting them? At least these set unaligned problems; is that a problem? drivers/block/nbd.c: blk_queue_max_segment_size(disk->queue, UINT_MAX); drivers/block/virtio_blk.c: blk_queue_max_segment_size(q, -1U); drivers/block/rbd.c: blk_queue_max_segment_size(q, UINT_MAX); Best regards, Pavel -- (english) http://www.livejournal.com/~pavelmachek (cesky, pictures) http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html [-- Attachment #2: signature.asc --] [-- Type: application/pgp-signature, Size: 195 bytes --] ^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 4.19 240/321] mmc: core: align max segment size with logical block size 2019-12-05 22:22 ` Pavel Machek @ 2019-12-06 0:54 ` Ming Lei 0 siblings, 0 replies; 3+ messages in thread From: Ming Lei @ 2019-12-06 0:54 UTC (permalink / raw) To: Pavel Machek Cc: Greg Kroah-Hartman, linux-kernel, stable, Naresh Kamboju, Christoph Hellwig, Faiz Abbas, linux-block, Ulf Hansson, Sasha Levin On Thu, Dec 05, 2019 at 11:22:47PM +0100, Pavel Machek wrote: > Hi! > > > From: Ming Lei <ming.lei@redhat.com> > > > > [ Upstream commit c53336c8f5f29043fded57912cc06c24e12613d7 ] > > > > Logical block size is the lowest possible block size that the storage > > device can address. Max segment size is often related with controller's > > DMA capability. And it is reasonable to align max segment size with > > logical block size. > > > SDHCI sets un-aligned max segment size, and causes ADMA error, so > > fix it by aligning max segment size with logical block size. > > If un-aligned max segment sizes are problem, should we add checks to > prevent setting them? > > At least these set unaligned problems; is that a problem? > > drivers/block/nbd.c: blk_queue_max_segment_size(disk->queue, UINT_MAX); > drivers/block/virtio_blk.c: blk_queue_max_segment_size(q, -1U); > drivers/block/rbd.c: blk_queue_max_segment_size(q, UINT_MAX); In theory, all segment size should be aligned, however the above MAX value just means the queue hasn't max segment size limit, so it won't be applied actually. Thanks, Ming ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2019-12-06 0:54 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <20191203223427.103571230@linuxfoundation.org>
2019-12-03 22:35 ` [PATCH 4.19 240/321] mmc: core: align max segment size with logical block size Greg Kroah-Hartman
2019-12-05 22:22 ` Pavel Machek
2019-12-06 0:54 ` Ming Lei
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox