pass queue_limits to blk_mq_alloc_disk for simple drivers
Subsystems (18)
Hi Jens,
this series converts all "simple" blk-mq drivers that don't have complex internal layering or other oddities to pass the queue_limits to blk_mq_alloc_disk. None of these drivers updates the limits at runtime.
Diffstat:
arch/um/drivers/ubd_kern.c | 8 +- drivers/block/aoe/aoeblk.c | 15 ++--- drivers/block/floppy.c | 6 +- drivers/block/mtip32xx/mtip32xx.c | 13 ++-- drivers/block/nbd.c | 13 ++-- drivers/block/ps3disk.c | 17 +++--- drivers/block/rbd.c | 29 +++++----- drivers/block/rnbd/rnbd-clt.c | 64 +++++++++-------------- drivers/block/sunvdc.c | 18 +++--- drivers/block/ublk_drv.c | 90 +++++++++++++++------------------ drivers/cdrom/gdrom.c | 14 ++--- drivers/memstick/core/ms_block.c | 14 ++--- drivers/memstick/core/mspro_block.c | 15 ++--- drivers/mmc/core/queue.c | 97 +++++++++++++++++++----------------- drivers/mtd/mtd_blkdevs.c | 12 ++-- drivers/mtd/ubi/block.c | 6 +- drivers/s390/block/scm_blk.c | 17 +++--- 17 files changed, 222 insertions(+), 226 deletions(-)
PATCH 1/17 ubd: pass queue_limits to blk_mq_alloc_disk
Pass the few limits ubd imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- arch/um/drivers/ubd_kern.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
arch/um/drivers/ubd_kern.c +5 -3
@@ -881,6 +881,10 @@ static const struct blk_mq_ops ubd_mq_ops = {static int ubd_add (int n,char **error_out) {struct ubd *ubd_dev = &ubd_devs[n]; +struct queue_limits lim = { + .max_segments =MAX_SG , + .seg_boundary_mask =PAGE_SIZE -1 , + };struct gendisk *disk;int err =0 ;
@@ -906,7 +910,7 @@ static int ubd_add(int n, char **error_out)if (err) goto out; - disk =blk_mq_alloc_disk (&ubd_dev->tag_set,NULL , ubd_dev); + disk =blk_mq_alloc_disk (&ubd_dev->tag_set, &lim, ubd_dev);if (IS_ERR (disk)) { err =PTR_ERR (disk); goto out_cleanup_tags;
@@ -914,8 +918,6 @@ static int ubd_add(int n, char **error_out) ubd_dev->queue = disk->queue;blk_queue_write_cache (ubd_dev->queue, true, false); -blk_queue_max_segments (ubd_dev->queue,MAX_SG ); -blk_queue_segment_boundary (ubd_dev->queue,PAGE_SIZE -1 ); err =ubd_disk_register (UBD_MAJOR , ubd_dev->size, n, disk);if (err) goto out_cleanup_disk;
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 2/17 aoe: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits aoe imposes directly to blk_mq_alloc_disk instead of setting them one at a time and improve the way the default max_hw_sectors is initialized while we're at it.
--- drivers/block/aoe/aoeblk.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/block/aoe/aoeblk.c +7 -8
@@ -24,8 +24,8 @@ static DEFINE_MUTEX(aoeblk_mutex);static struct kmem_cache *buf_pool_cache;static struct dentry *aoe_debugfs_dir; -/* GPFS needs a larger value than the default. */ -static int aoe_maxsectors; +/* random default picked from the historic block max_sectors cap */ +static int aoe_maxsectors =2560 ;module_param (aoe_maxsectors, int,0644 );MODULE_PARM_DESC (aoe_maxsectors,"When nonzero, set the maximum number of sectors per I/O request" );
@@ -334,6 +334,10 @@ aoeblk_gdalloc(void *vp)mempool_t *mp;struct blk_mq_tag_set *set;sector_t ssize; +struct queue_limits lim = { + .max_hw_sectors = aoe_maxsectors, + .io_opt =SZ_2M , + };ulong flags;int late =0 ;int err;
@@ -371,7 +375,7 @@ aoeblk_gdalloc(void *vp) goto err_mempool; } - gd =blk_mq_alloc_disk (set,NULL , d); + gd =blk_mq_alloc_disk (set, &lim, d);if (IS_ERR (gd)) {pr_err ("aoe: cannot allocate block queue for %ld.%d\n" , d->aoemajor, d->aoeminor);
@@ -384,14 +388,9 @@ aoeblk_gdalloc(void *vp)WARN_ON (d->flags &DEVFL_TKILL );WARN_ON (d->gd);WARN_ON (d->flags &DEVFL_UP ); -/* random number picked from the history block max_sectors cap */ -blk_queue_max_hw_sectors (gd->queue,2560u ); -blk_queue_io_opt (gd->queue,SZ_2M ); d->bufpool = mp; d->blkq = gd->queue; d->gd = gd; -if (aoe_maxsectors) -blk_queue_max_hw_sectors (gd->queue, aoe_maxsectors); gd->major =AOE_MAJOR ; gd->first_minor = d->sysminor; gd->minors =AOE_PARTITIONS ;
Signature · 1 line
2.39.2
PATCH 3/17 floppy: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits floppy imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/block/floppy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/block/floppy.c +4 -2
@@ -4516,13 +4516,15 @@ static bool floppy_available(int drive)static int floppy_alloc_disk (unsigned int drive,unsigned int type) { +struct queue_limits lim = { + .max_hw_sectors =64 , + };struct gendisk *disk; - disk =blk_mq_alloc_disk (&tag_sets[drive],NULL ,NULL ); + disk =blk_mq_alloc_disk (&tag_sets[drive], &lim,NULL );if (IS_ERR (disk))return PTR_ERR (disk); -blk_queue_max_hw_sectors (disk->queue,64 ); disk->major =FLOPPY_MAJOR ; disk->first_minor =TOMINOR (drive) | (type <<2 ); disk->minors =1 ;
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 03/17] floppy: pass queue_limits to blk_mq_alloc_disk
Hello,
Quoted 7 lines · Christoph Hellwig
Pass the few limits floppy imposes directly to
blk_mq_alloc_diskinstead of setting them one at a time.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/floppy.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 23 lines
drivers/block/floppy.c +4
-2@@ -4516,13 +4516,15 @@ static bool floppy_available(int drive)static int floppy_alloc_disk (unsigned int drive,unsigned int type) { +struct queue_limits lim = { + .max_hw_sectors =64 , + };struct gendisk *disk; - disk =blk_mq_alloc_disk (&tag_sets[drive],NULL ,NULL ); + disk =blk_mq_alloc_disk (&tag_sets[drive], &lim,NULL );if (IS_ERR (disk))return PTR_ERR (disk); -blk_queue_max_hw_sectors (disk->queue,64 ); disk->major =FLOPPY_MAJOR ; disk->first_minor =TOMINOR (drive) | (type <<2 ); disk->minors =1 ;
PATCH 4/17 mtip: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits mtip imposes directly to blk_mq_alloc_disk instead of setting them one at a time and drop the pointless setting of a io_min that is equal to the physical block size.
--- drivers/block/mtip32xx/mtip32xx.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/block/mtip32xx/mtip32xx.c +7 -6
@@ -3401,6 +3401,12 @@ static const struct blk_mq_ops mtip_mq_ops = {*/ static int mtip_block_initialize (struct driver_data *dd) { +struct queue_limits lim = { + .physical_block_size =4096 , + .max_hw_sectors =0xffff , + .max_segments =MTIP_MAX_SG , + .max_segment_size =0x400000 , + };int rv =0 , wait_for_rebuild =0 ;sector_t capacity;unsigned int index =0 ;
@@ -3431,7 +3437,7 @@ static int mtip_block_initialize(struct driver_data *dd) goto block_queue_alloc_tag_error; } - dd->disk =blk_mq_alloc_disk (&dd->tags,NULL , dd); + dd->disk =blk_mq_alloc_disk (&dd->tags, &lim, dd);if (IS_ERR (dd->disk)) {dev_err (&dd->pdev->dev,"Unable to allocate request queue\n" );
@@ -3481,12 +3487,7 @@ static int mtip_block_initialize(struct driver_data *dd)/* Set device limits. */ blk_queue_flag_set (QUEUE_FLAG_NONROT , dd->queue);blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , dd->queue); -blk_queue_max_segments (dd->queue,MTIP_MAX_SG ); -blk_queue_physical_block_size (dd->queue,4096 ); -blk_queue_max_hw_sectors (dd->queue,0xffff ); -blk_queue_max_segment_size (dd->queue,0x400000 );dma_set_max_seg_size (&dd->pdev->dev,0x400000 ); -blk_queue_io_min (dd->queue,4096 );/* Set the capacity of the device in 512 byte sectors. */ if (!(mtip_hw_get_capacity (dd, &capacity))) {
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 5/17 nbd: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits nbd imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/block/nbd.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-)
drivers/block/nbd.c +7 -6
@@ -1783,6 +1783,12 @@ static const struct blk_mq_ops nbd_mq_ops = {static struct nbd_device *nbd_dev_add (int index,unsigned int refs) { +struct queue_limits lim = { + .max_hw_sectors =65536 , + .max_user_sectors =256 , + .max_segments =USHRT_MAX , + .max_segment_size =UINT_MAX , + };struct nbd_device *nbd;struct gendisk *disk;int err = -ENOMEM ;
@@ -1823,7 +1829,7 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)if (err <0 ) goto out_free_tags; - disk =blk_mq_alloc_disk (&nbd->tag_set,NULL ,NULL ); + disk =blk_mq_alloc_disk (&nbd->tag_set, &lim,NULL );if (IS_ERR (disk)) { err =PTR_ERR (disk); goto out_free_idr;
@@ -1843,11 +1849,6 @@ static struct nbd_device *nbd_dev_add(int index, unsigned int refs)* Tell the block layer that we are not a rotational device */ blk_queue_flag_set (QUEUE_FLAG_NONROT , disk->queue); -blk_queue_max_discard_sectors (disk->queue,0 ); -blk_queue_max_segment_size (disk->queue,UINT_MAX ); -blk_queue_max_segments (disk->queue,USHRT_MAX ); -blk_queue_max_hw_sectors (disk->queue,65536 ); - disk->queue->limits.max_sectors =256 ;mutex_init (&nbd->config_lock);refcount_set (&nbd->config_refs,0 );
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 6/17 ps3disk: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits ps3disk imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/block/ps3disk.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/block/ps3disk.c +9 -8
@@ -382,6 +382,14 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)struct ps3disk_private *priv;int error;unsigned int devidx; +struct queue_limits lim = { + .logical_block_size = dev->blk_size, + .max_hw_sectors = dev->bounce_size >>9 , + .max_segments =-1 , + .max_segment_size = dev->bounce_size, + .dma_alignment = dev->blk_size -1 , + }; +struct request_queue *queue;struct gendisk *gendisk;
@@ -431,7 +439,7 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev)if (error) goto fail_teardown; - gendisk =blk_mq_alloc_disk (&priv->tag_set,NULL , dev); + gendisk =blk_mq_alloc_disk (&priv->tag_set, &lim, dev);if (IS_ERR (gendisk)) {dev_err (&dev->sbd.core,"%s:%u: blk_mq_alloc_disk failed\n" , __func__, __LINE__);
@@ -441,15 +449,8 @@ static int ps3disk_probe(struct ps3_system_bus_device *_dev) queue = gendisk->queue; -blk_queue_max_hw_sectors (queue, dev->bounce_size >>9 ); -blk_queue_dma_alignment (queue, dev->blk_size-1 ); -blk_queue_logical_block_size (queue, dev->blk_size); -blk_queue_write_cache (queue, true, false); -blk_queue_max_segments (queue,-1 ); -blk_queue_max_segment_size (queue, dev->bounce_size); - priv->gendisk = gendisk; gendisk->major = ps3disk_major; gendisk->first_minor = devidx *PS3DISK_MINORS ;
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 7/17 rbd: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the limits rbd imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/block/rbd.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)
drivers/block/rbd.c +15 -14
@@ -4952,6 +4952,14 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)struct request_queue *q;unsigned int objset_bytes = rbd_dev->layout.object_size * rbd_dev->layout.stripe_count; +struct queue_limits lim = { + .max_hw_sectors = objset_bytes >>SECTOR_SHIFT , + .max_user_sectors = objset_bytes >>SECTOR_SHIFT , + .io_min = rbd_dev->opts->alloc_size, + .io_opt = rbd_dev->opts->alloc_size, + .max_segments =USHRT_MAX , + .max_segment_size =UINT_MAX , + };int err;memset (&rbd_dev->tag_set,0 ,sizeof (rbd_dev->tag_set));
@@ -4966,7 +4974,13 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)if (err)return err; - disk =blk_mq_alloc_disk (&rbd_dev->tag_set,NULL , rbd_dev); +if (rbd_dev->opts->trim) { + lim.discard_granularity = rbd_dev->opts->alloc_size; + lim.max_hw_discard_sectors = objset_bytes >>SECTOR_SHIFT ; + lim.max_write_zeroes_sectors = objset_bytes >>SECTOR_SHIFT ; + } + + disk =blk_mq_alloc_disk (&rbd_dev->tag_set, &lim, rbd_dev);if (IS_ERR (disk)) { err =PTR_ERR (disk); goto out_tag_set;
@@ -4987,19 +5001,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)blk_queue_flag_set (QUEUE_FLAG_NONROT , q);/* QUEUE_FLAG_ADD_RANDOM is off by default for blk-mq */ -blk_queue_max_hw_sectors (q, objset_bytes >>SECTOR_SHIFT ); - q->limits.max_sectors =queue_max_hw_sectors (q); -blk_queue_max_segments (q,USHRT_MAX ); -blk_queue_max_segment_size (q,UINT_MAX ); -blk_queue_io_min (q, rbd_dev->opts->alloc_size); -blk_queue_io_opt (q, rbd_dev->opts->alloc_size); - -if (rbd_dev->opts->trim) { - q->limits.discard_granularity = rbd_dev->opts->alloc_size; -blk_queue_max_discard_sectors (q, objset_bytes >>SECTOR_SHIFT ); -blk_queue_max_write_zeroes_sectors (q, objset_bytes >>SECTOR_SHIFT ); - } -if (!ceph_test_opt (rbd_dev->rbd_client->client,NOCRC ))blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , q);
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 07/17] rbd: pass queue_limits to blk_mq_alloc_disk
Quoted 64 lines · Christoph Hellwig
Pass the limits rbd imposes directly to
blk_mq_alloc_diskinstead of setting them one at a time.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/block/rbd.c | 29 +++++++++++++++-------------- 1 file changed, 15 insertions(+), 14 deletions(-)drivers/block/rbd.c +15
-15@@ -4952,6 +4952,14 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)struct request_queue *q;unsigned int objset_bytes = rbd_dev->layout.object_size * rbd_dev->layout.stripe_count; +struct queue_limits lim = { + .max_hw_sectors = objset_bytes >>SECTOR_SHIFT , + .max_user_sectors = objset_bytes >>SECTOR_SHIFT , + .io_min = rbd_dev->opts->alloc_size, + .io_opt = rbd_dev->opts->alloc_size, + .max_segments =USHRT_MAX , + .max_segment_size =UINT_MAX , + };int err;memset (&rbd_dev->tag_set,0 ,sizeof (rbd_dev->tag_set));@@ -4966,7 +4974,13 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)if (err)return err; - disk =blk_mq_alloc_disk (&rbd_dev->tag_set,NULL , rbd_dev); +if (rbd_dev->opts->trim) { + lim.discard_granularity = rbd_dev->opts->alloc_size; + lim.max_hw_discard_sectors = objset_bytes >>SECTOR_SHIFT ; + lim.max_write_zeroes_sectors = objset_bytes >>SECTOR_SHIFT ; + } + + disk =blk_mq_alloc_disk (&rbd_dev->tag_set, &lim, rbd_dev);if (IS_ERR (disk)) { err =PTR_ERR (disk); goto out_tag_set;@@ -4987,19 +5001,6 @@ static int rbd_init_disk(struct rbd_device *rbd_dev)blk_queue_flag_set (QUEUE_FLAG_NONROT , q);/* QUEUE_FLAG_ADD_RANDOM is off by default for blk-mq */ -blk_queue_max_hw_sectors (q, objset_bytes >>SECTOR_SHIFT ); - q->limits.max_sectors =queue_max_hw_sectors (q); -blk_queue_max_segments (q,USHRT_MAX ); -blk_queue_max_segment_size (q,UINT_MAX ); -blk_queue_io_min (q, rbd_dev->opts->alloc_size); -blk_queue_io_opt (q, rbd_dev->opts->alloc_size); - -if (rbd_dev->opts->trim) { - q->limits.discard_granularity = rbd_dev->opts->alloc_size; -blk_queue_max_discard_sectors (q, objset_bytes >>SECTOR_SHIFT ); -blk_queue_max_write_zeroes_sectors (q, objset_bytes >>SECTOR_SHIFT ); - } -if (!ceph_test_opt (rbd_dev->rbd_client->client,NOCRC ))blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , q); --
Quoted 2 lines
2.39.2
Thanks,
Ilya
PATCH 8/17 rnbd-clt: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the limits rnbd-clt imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
While at it don't set an explicit number of discard segments, as 1 is the default (which most drivers rely on).
--- drivers/block/rnbd/rnbd-clt.c | 64 ++++++++++++++--------------------- 1 file changed, 25 insertions(+), 39 deletions(-)
drivers/block/rnbd/rnbd-clt.c +25 -39
@@ -1329,43 +1329,6 @@ static void rnbd_init_mq_hw_queues(struct rnbd_clt_dev *dev) } } -static void setup_request_queue (struct rnbd_clt_dev *dev, -struct rnbd_msg_open_rsp *rsp) -{ -blk_queue_logical_block_size (dev->queue, -le16_to_cpu (rsp->logical_block_size)); -blk_queue_physical_block_size (dev->queue, -le16_to_cpu (rsp->physical_block_size)); -blk_queue_max_hw_sectors (dev->queue, - dev->sess->max_io_size /SECTOR_SIZE ); - -/* -* we don't support discards to "discontiguous" segments -* in on request -*/ -blk_queue_max_discard_segments (dev->queue,1 ); - -blk_queue_max_discard_sectors (dev->queue, -le32_to_cpu (rsp->max_discard_sectors)); - dev->queue->limits.discard_granularity = -le32_to_cpu (rsp->discard_granularity); - dev->queue->limits.discard_alignment = -le32_to_cpu (rsp->discard_alignment); -if (le16_to_cpu (rsp->secure_discard)) -blk_queue_max_secure_erase_sectors (dev->queue, -le32_to_cpu (rsp->max_discard_sectors)); -blk_queue_flag_set (QUEUE_FLAG_SAME_COMP , dev->queue); -blk_queue_flag_set (QUEUE_FLAG_SAME_FORCE , dev->queue); -blk_queue_max_segments (dev->queue, dev->sess->max_segments); -blk_queue_io_opt (dev->queue, dev->sess->max_io_size); -blk_queue_virt_boundary (dev->queue,SZ_4K -1 ); -blk_queue_write_cache (dev->queue, - !!(rsp->cache_policy &RNBD_WRITEBACK ), - !!(rsp->cache_policy &RNBD_FUA )); -blk_queue_max_write_zeroes_sectors (dev->queue, -le32_to_cpu (rsp->max_write_zeroes_sectors)); -} -static int rnbd_clt_setup_gen_disk (struct rnbd_clt_dev *dev,struct rnbd_msg_open_rsp *rsp,int idx) {
@@ -1403,18 +1366,41 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev,static int rnbd_client_setup_device (struct rnbd_clt_dev *dev,struct rnbd_msg_open_rsp *rsp) { +struct queue_limits lim = { + .logical_block_size =le16_to_cpu (rsp->logical_block_size), + .physical_block_size =le16_to_cpu (rsp->physical_block_size), + .io_opt = dev->sess->max_io_size, + .max_hw_sectors = dev->sess->max_io_size /SECTOR_SIZE , + .max_hw_discard_sectors =le32_to_cpu (rsp->max_discard_sectors), + .discard_granularity =le32_to_cpu (rsp->discard_granularity), + .discard_alignment =le32_to_cpu (rsp->discard_alignment), + .max_segments = dev->sess->max_segments, + .virt_boundary_mask =SZ_4K -1 , + .max_write_zeroes_sectors = +le32_to_cpu (rsp->max_write_zeroes_sectors), + };int idx = dev->clt_device_id; dev->size =le64_to_cpu (rsp->nsectors) *le16_to_cpu (rsp->logical_block_size); - dev->gd =blk_mq_alloc_disk (&dev->sess->tag_set,NULL , dev); +if (rsp->secure_discard) { + lim.max_secure_erase_sectors = +le32_to_cpu (rsp->max_discard_sectors); + } + + dev->gd =blk_mq_alloc_disk (&dev->sess->tag_set, &lim, dev);if (IS_ERR (dev->gd))return PTR_ERR (dev->gd); dev->queue = dev->gd->queue;rnbd_init_mq_hw_queues (dev); -setup_request_queue (dev, rsp); +blk_queue_flag_set (QUEUE_FLAG_SAME_COMP , dev->queue); +blk_queue_flag_set (QUEUE_FLAG_SAME_FORCE , dev->queue); +blk_queue_write_cache (dev->queue, + !!(rsp->cache_policy &RNBD_WRITEBACK ), + !!(rsp->cache_policy &RNBD_FUA )); +return rnbd_clt_setup_gen_disk (dev, rsp, idx); }
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
Re: [PATCH 08/17] rnbd-clt: pass queue_limits to blk_mq_alloc_disk
Quoted 8 lines · Christoph Hellwig
Pass the limits rnbd-clt imposes directly to
blk_mq_alloc_diskinstead of setting them one at a time.While at it don't set an explicit number of discard segments, as 1 is the default (which most drivers rely on).
Signed-off-by Christoph Hellwig <[email protected]>
lgtm, thx!
Quoted 99 lines
--- drivers/block/rnbd/rnbd-clt.c | 64 ++++++++++++++--------------------- 1 file changed, 25 insertions(+), 39 deletions(-)drivers/block/rnbd/rnbd-clt.c +25
-40@@ -1329,43 +1329,6 @@ static void rnbd_init_mq_hw_queues(struct rnbd_clt_dev *dev) } } -static void setup_request_queue (struct rnbd_clt_dev *dev, -struct rnbd_msg_open_rsp *rsp) -{ -blk_queue_logical_block_size (dev->queue, -le16_to_cpu (rsp->logical_block_size)); -blk_queue_physical_block_size (dev->queue, -le16_to_cpu (rsp->physical_block_size)); -blk_queue_max_hw_sectors (dev->queue, - dev->sess->max_io_size /SECTOR_SIZE ); - -/* -* we don't support discards to "discontiguous" segments -* in on request -*/ -blk_queue_max_discard_segments (dev->queue,1 ); - -blk_queue_max_discard_sectors (dev->queue, -le32_to_cpu (rsp->max_discard_sectors)); - dev->queue->limits.discard_granularity = -le32_to_cpu (rsp->discard_granularity); - dev->queue->limits.discard_alignment = -le32_to_cpu (rsp->discard_alignment); -if (le16_to_cpu (rsp->secure_discard)) -blk_queue_max_secure_erase_sectors (dev->queue, -le32_to_cpu (rsp->max_discard_sectors)); -blk_queue_flag_set (QUEUE_FLAG_SAME_COMP , dev->queue); -blk_queue_flag_set (QUEUE_FLAG_SAME_FORCE , dev->queue); -blk_queue_max_segments (dev->queue, dev->sess->max_segments); -blk_queue_io_opt (dev->queue, dev->sess->max_io_size); -blk_queue_virt_boundary (dev->queue,SZ_4K -1 ); -blk_queue_write_cache (dev->queue, - !!(rsp->cache_policy &RNBD_WRITEBACK ), - !!(rsp->cache_policy &RNBD_FUA )); -blk_queue_max_write_zeroes_sectors (dev->queue, -le32_to_cpu (rsp->max_write_zeroes_sectors)); -} -static int rnbd_clt_setup_gen_disk (struct rnbd_clt_dev *dev,struct rnbd_msg_open_rsp *rsp,int idx) {@@ -1403,18 +1366,41 @@ static int rnbd_clt_setup_gen_disk(struct rnbd_clt_dev *dev,static int rnbd_client_setup_device (struct rnbd_clt_dev *dev,struct rnbd_msg_open_rsp *rsp) { +struct queue_limits lim = { + .logical_block_size =le16_to_cpu (rsp->logical_block_size), + .physical_block_size =le16_to_cpu (rsp->physical_block_size), + .io_opt = dev->sess->max_io_size, + .max_hw_sectors = dev->sess->max_io_size /SECTOR_SIZE , + .max_hw_discard_sectors =le32_to_cpu (rsp->max_discard_sectors), + .discard_granularity =le32_to_cpu (rsp->discard_granularity), + .discard_alignment =le32_to_cpu (rsp->discard_alignment), + .max_segments = dev->sess->max_segments, + .virt_boundary_mask =SZ_4K -1 , + .max_write_zeroes_sectors = +le32_to_cpu (rsp->max_write_zeroes_sectors), + };int idx = dev->clt_device_id; dev->size =le64_to_cpu (rsp->nsectors) *le16_to_cpu (rsp->logical_block_size); - dev->gd =blk_mq_alloc_disk (&dev->sess->tag_set,NULL , dev); +if (rsp->secure_discard) { + lim.max_secure_erase_sectors = +le32_to_cpu (rsp->max_discard_sectors); + } + + dev->gd =blk_mq_alloc_disk (&dev->sess->tag_set, &lim, dev);if (IS_ERR (dev->gd))return PTR_ERR (dev->gd); dev->queue = dev->gd->queue;rnbd_init_mq_hw_queues (dev); -setup_request_queue (dev, rsp); +blk_queue_flag_set (QUEUE_FLAG_SAME_COMP , dev->queue); +blk_queue_flag_set (QUEUE_FLAG_SAME_FORCE , dev->queue); +blk_queue_write_cache (dev->queue, + !!(rsp->cache_policy &RNBD_WRITEBACK ), + !!(rsp->cache_policy &RNBD_FUA )); +return rnbd_clt_setup_gen_disk (dev, rsp, idx); } --2.39.2
PATCH 9/17 sunvdc: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits sunvdc imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/block/sunvdc.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-)
drivers/block/sunvdc.c +9 -9
@@ -784,6 +784,14 @@ static const struct blk_mq_ops vdc_mq_ops = {static int probe_disk (struct vdc_port *port) { +struct queue_limits lim = { + .physical_block_size = port->vdisk_phys_blksz, + .max_hw_sectors = port->max_xfer_size, +/* Each segment in a request is up to an aligned page in size. */ + .seg_boundary_mask =PAGE_SIZE -1 , + .max_segment_size =PAGE_SIZE , + .max_segments = port->ring_cookies, + };struct request_queue *q;struct gendisk *g;int err;
@@ -824,7 +832,7 @@ static int probe_disk(struct vdc_port *port)if (err)return err; - g =blk_mq_alloc_disk (&port->tag_set,NULL , port); + g =blk_mq_alloc_disk (&port->tag_set, &lim, port);if (IS_ERR (g)) { printk(KERN_ERR PFX "%s: Could not allocate gendisk.\n", port->vio.name);
@@ -835,12 +843,6 @@ static int probe_disk(struct vdc_port *port) port->disk = g; q = g->queue; -/* Each segment in a request is up to an aligned page in size. */ -blk_queue_segment_boundary (q,PAGE_SIZE -1 ); -blk_queue_max_segment_size (q,PAGE_SIZE ); - -blk_queue_max_segments (q, port->ring_cookies); -blk_queue_max_hw_sectors (q, port->max_xfer_size); g->major = vdc_major; g->first_minor = port->vio.vdev->dev_no <<PARTITION_SHIFT ; g->minors =1 <<PARTITION_SHIFT ;
@@ -872,8 +874,6 @@ static int probe_disk(struct vdc_port *port) } } -blk_queue_physical_block_size (q, port->vdisk_phys_blksz); - pr_info(PFX "%s: %u sectors (%u MB) protocol %d.%d\n", g->disk_name, port->vdisk_size, (port->vdisk_size >> (20 - 9)),
Signature · 6 lines
2.39.2 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/
PATCH 10/17 gdrom: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits gdrom imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/cdrom/gdrom.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-)
drivers/cdrom/gdrom.c +8 -6
@@ -724,11 +724,6 @@ static void probe_gdrom_setupdisk(void)static int probe_gdrom_setupqueue (void ) { -blk_queue_logical_block_size (gd.gdrom_rq,GDROM_HARD_SECTOR ); -/* using DMA so memory will need to be contiguous */ -blk_queue_max_segments (gd.gdrom_rq,1 ); -/* set a large max size to get most from DMA */ -blk_queue_max_segment_size (gd.gdrom_rq,0x40000 ); gd.disk->queue = gd.gdrom_rq;return gdrom_init_dma_mode (); }
@@ -743,6 +738,13 @@ static const struct blk_mq_ops gdrom_mq_ops = {*/ static int probe_gdrom (struct platform_device *devptr) { +struct queue_limits lim = { + .logical_block_size =GDROM_HARD_SECTOR , +/* using DMA so memory will need to be contiguous */ + .max_segments =1 , +/* set a large max size to get most from DMA */ + .max_segment_size =0x40000 , + };int err;/*
@@ -778,7 +780,7 @@ static int probe_gdrom(struct platform_device *devptr)if (err) goto probe_fail_free_cd_info; - gd.disk =blk_mq_alloc_disk (&gd.tag_set,NULL ,NULL ); + gd.disk =blk_mq_alloc_disk (&gd.tag_set, &lim,NULL );if (IS_ERR (gd.disk)) { err =PTR_ERR (gd.disk); goto probe_fail_free_tag_set;
Signature · 1 line
2.39.2
PATCH 11/17 ms_block: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits ms_block imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/memstick/core/ms_block.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
drivers/memstick/core/ms_block.c +7 -7
@@ -2078,6 +2078,12 @@ static const struct blk_mq_ops msb_mq_ops = {static int msb_init_disk (struct memstick_dev *card) {struct msb_data *msb =memstick_get_drvdata (card); +struct queue_limits lim = { + .logical_block_size = msb->page_size, + .max_hw_sectors =MS_BLOCK_MAX_PAGES , + .max_segments =MS_BLOCK_MAX_SEGS , + .max_segment_size =MS_BLOCK_MAX_PAGES * msb->page_size, + };int rc;unsigned long capacity;
@@ -2093,19 +2099,13 @@ static int msb_init_disk(struct memstick_dev *card)if (rc) goto out_release_id; - msb->disk =blk_mq_alloc_disk (&msb->tag_set,NULL , card); + msb->disk =blk_mq_alloc_disk (&msb->tag_set, &lim, card);if (IS_ERR (msb->disk)) { rc =PTR_ERR (msb->disk); goto out_free_tag_set; } msb->queue = msb->disk->queue; -blk_queue_max_hw_sectors (msb->queue,MS_BLOCK_MAX_PAGES ); -blk_queue_max_segments (msb->queue,MS_BLOCK_MAX_SEGS ); -blk_queue_max_segment_size (msb->queue, -MS_BLOCK_MAX_PAGES * msb->page_size); -blk_queue_logical_block_size (msb->queue, msb->page_size); -sprintf (msb->disk->disk_name,"msblk%d" , msb->disk_id); msb->disk->fops = &msb_bdops; msb->disk->private_data = msb;
Signature · 1 line
2.39.2
PATCH 12/17 mspro_block: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits mspro_block imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/memstick/core/mspro_block.c | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-)
drivers/memstick/core/mspro_block.c +7 -8
@@ -1103,6 +1103,12 @@ static const struct blk_mq_ops mspro_mq_ops = {static int mspro_block_init_disk (struct memstick_dev *card) {struct mspro_block_data *msb =memstick_get_drvdata (card); +struct queue_limits lim = { + .logical_block_size = msb->page_size, + .max_hw_sectors =MSPRO_BLOCK_MAX_PAGES , + .max_segments =MSPRO_BLOCK_MAX_SEGS , + .max_segment_size =MSPRO_BLOCK_MAX_PAGES * msb->page_size, + };struct mspro_devinfo *dev_info =NULL ;struct mspro_sys_info *sys_info =NULL ;struct mspro_sys_attr *s_attr =NULL ;
@@ -1138,18 +1144,13 @@ static int mspro_block_init_disk(struct memstick_dev *card)if (rc) goto out_release_id; - msb->disk =blk_mq_alloc_disk (&msb->tag_set,NULL , card); + msb->disk =blk_mq_alloc_disk (&msb->tag_set, &lim, card);if (IS_ERR (msb->disk)) { rc =PTR_ERR (msb->disk); goto out_free_tag_set; } msb->queue = msb->disk->queue; -blk_queue_max_hw_sectors (msb->queue,MSPRO_BLOCK_MAX_PAGES ); -blk_queue_max_segments (msb->queue,MSPRO_BLOCK_MAX_SEGS ); -blk_queue_max_segment_size (msb->queue, -MSPRO_BLOCK_MAX_PAGES * msb->page_size); - msb->disk->major = major; msb->disk->first_minor = disk_id <<MSPRO_BLOCK_PART_SHIFT ; msb->disk->minors =1 <<MSPRO_BLOCK_PART_SHIFT ;
@@ -1158,8 +1159,6 @@ static int mspro_block_init_disk(struct memstick_dev *card)sprintf (msb->disk->disk_name,"mspblk%d" , disk_id); -blk_queue_logical_block_size (msb->queue, msb->page_size); - capacity =be16_to_cpu (sys_info->user_block_count); capacity *=be16_to_cpu (sys_info->block_size); capacity *= msb->page_size >>9 ;
Signature · 1 line
2.39.2
PATCH 13/17 mtd_blkdevs: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits mtd_blkdevs imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/mtd/mtd_blkdevs.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
drivers/mtd/mtd_blkdevs.c +6 -6
@@ -277,6 +277,7 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) {struct mtd_blktrans_ops *tr = new->tr;struct mtd_blktrans_dev *d; +struct queue_limits lim = { };int last_devnum =-1 ;struct gendisk *gd;int ret;
@@ -331,9 +332,13 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new) BLK_MQ_F_SHOULD_MERGE | BLK_MQ_F_BLOCKING);if (ret) goto out_kfree_tag_set; + + lim.logical_block_size = tr->blksize; +if (tr->discard) + lim.max_hw_discard_sectors =UINT_MAX ;/* Create gendisk */ - gd =blk_mq_alloc_disk (new->tag_set,NULL , new); + gd =blk_mq_alloc_disk (new->tag_set, &lim, new);if (IS_ERR (gd)) { ret =PTR_ERR (gd); goto out_free_tag_set;
@@ -371,14 +376,9 @@ int add_mtd_blktrans_dev(struct mtd_blktrans_dev *new)if (tr->flush)blk_queue_write_cache (new->rq, true, false); -blk_queue_logical_block_size (new->rq, tr->blksize); -blk_queue_flag_set (QUEUE_FLAG_NONROT , new->rq);blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , new->rq); -if (tr->discard) -blk_queue_max_discard_sectors (new->rq,UINT_MAX ); - gd->queue = new->rq;if (new->readonly)
Signature · 1 line
2.39.2
PATCH 14/17 ubiblock: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits ubiblock imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/mtd/ubi/block.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
drivers/mtd/ubi/block.c +4 -2
@@ -348,6 +348,9 @@ static int calc_disk_capacity(struct ubi_volume_info *vi, u64 *disk_capacity)int ubiblock_create (struct ubi_volume_info *vi) { +struct queue_limits lim = { + .max_segments =UBI_MAX_SG_COUNT , + };struct ubiblock *dev;struct gendisk *gd;u64 disk_capacity;
@@ -393,7 +396,7 @@ int ubiblock_create(struct ubi_volume_info *vi)/* Initialize the gendisk of this ubiblock device */ - gd =blk_mq_alloc_disk (&dev->tag_set,NULL , dev); + gd =blk_mq_alloc_disk (&dev->tag_set, &lim, dev);if (IS_ERR (gd)) { ret =PTR_ERR (gd); goto out_free_tags;
@@ -416,7 +419,6 @@ int ubiblock_create(struct ubi_volume_info *vi) dev->gd = gd; dev->rq = gd->queue; -blk_queue_max_segments (dev->rq,UBI_MAX_SG_COUNT );list_add_tail (&dev->list, &ubiblock_devices);
Signature · 1 line
2.39.2
Re: [PATCH 14/17] ubiblock: pass queue_limits to blk_mq_alloc_disk
Quoted 7 lines · Christoph Hellwig
Pass the few limits ubiblock imposes directly to
blk_mq_alloc_diskinstead of setting them one at a time.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/mtd/ubi/block.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-)
Quoted 33 lines
drivers/mtd/ubi/block.c +4
-2@@ -348,6 +348,9 @@ static int calc_disk_capacity(struct ubi_volume_info *vi, u64 *disk_capacity)int ubiblock_create (struct ubi_volume_info *vi) { +struct queue_limits lim = { + .max_segments =UBI_MAX_SG_COUNT , + };struct ubiblock *dev;struct gendisk *gd;u64 disk_capacity;@@ -393,7 +396,7 @@ int ubiblock_create(struct ubi_volume_info *vi)/* Initialize the gendisk of this ubiblock device */ - gd =blk_mq_alloc_disk (&dev->tag_set,NULL , dev); + gd =blk_mq_alloc_disk (&dev->tag_set, &lim, dev);if (IS_ERR (gd)) { ret =PTR_ERR (gd); goto out_free_tags;@@ -416,7 +419,6 @@ int ubiblock_create(struct ubi_volume_info *vi) dev->gd = gd; dev->rq = gd->queue; -blk_queue_max_segments (dev->rq,UBI_MAX_SG_COUNT );list_add_tail (&dev->list, &ubiblock_devices);
PATCH 15/17 scm_blk: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the few limits scm_block imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/s390/block/scm_blk.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/s390/block/scm_blk.c +9 -8
@@ -435,10 +435,17 @@ static const struct blk_mq_ops scm_mq_ops = {int scm_blk_dev_setup (struct scm_blk_dev *bdev,struct scm_device *scmdev) { -unsigned int devindex, nr_max_blk; +struct queue_limits lim = { + .logical_block_size =1 <<12 , + }; +unsigned int devindex;struct request_queue *rq;int len, ret; + lim.max_segments =min (scmdev->nr_max_block, + (unsigned int ) (PAGE_SIZE /sizeof (struct aidaw ))); + lim.max_hw_sectors = lim.max_segments <<3 ;/* 8 * 512 = blk_size */ + devindex =atomic_inc_return (&nr_devices) -1 ;/* scma..scmz + scmaa..scmzz */ if (devindex >701 ) {
@@ -462,18 +469,12 @@ int scm_blk_dev_setup(struct scm_blk_dev *bdev, struct scm_device *scmdev)if (ret) goto out; - bdev->gendisk =blk_mq_alloc_disk (&bdev->tag_set,NULL , scmdev); + bdev->gendisk =blk_mq_alloc_disk (&bdev->tag_set, &lim, scmdev);if (IS_ERR (bdev->gendisk)) { ret =PTR_ERR (bdev->gendisk); goto out_tag; } rq = bdev->rq = bdev->gendisk->queue; - nr_max_blk =min (scmdev->nr_max_block, - (unsigned int ) (PAGE_SIZE /sizeof (struct aidaw ))); - -blk_queue_logical_block_size (rq,1 <<12 ); -blk_queue_max_hw_sectors (rq, nr_max_blk <<3 );/* 8 * 512 = blk_size */ -blk_queue_max_segments (rq, nr_max_blk);blk_queue_flag_set (QUEUE_FLAG_NONROT , rq);blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , rq);
Signature · 1 line
2.39.2
PATCH 16/17 ublk: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the limits ublk imposes directly to blk_mq_alloc_disk instead of setting them one at a time.
--- drivers/block/ublk_drv.c | 90 ++++++++++++++++++---------------------- 1 file changed, 41 insertions(+), 49 deletions(-)
drivers/block/ublk_drv.c +41 -49
@@ -246,21 +246,12 @@ static int ublk_dev_param_zoned_validate(const struct ublk_device *ub)return 0 ; } -static int ublk_dev_param_zoned_apply (struct ublk_device *ub) +static void ublk_dev_param_zoned_apply (struct ublk_device *ub) { -const struct ublk_param_zoned *p = &ub->params.zoned; - -disk_set_zoned (ub->ub_disk);blk_queue_flag_set (QUEUE_FLAG_ZONE_RESETALL , ub->ub_disk->queue);blk_queue_required_elevator_features (ub->ub_disk->queue,ELEVATOR_F_ZBD_SEQ_WRITE ); -disk_set_max_active_zones (ub->ub_disk, p->max_active_zones); -disk_set_max_open_zones (ub->ub_disk, p->max_open_zones); -blk_queue_max_zone_append_sectors (ub->ub_disk->queue, p->max_zone_append_sectors); - ub->ub_disk->nr_zones =ublk_get_nr_zones (ub); - -return 0 ; }/* Based on virtblk_alloc_report_buffer */
@@ -432,9 +423,8 @@ static int ublk_dev_param_zoned_validate(const struct ublk_device *ub)return -EOPNOTSUPP ; } -static int ublk_dev_param_zoned_apply (struct ublk_device *ub) +static void ublk_dev_param_zoned_apply (struct ublk_device *ub) { -return -EOPNOTSUPP ; }static int ublk_revalidate_disk_zones (struct ublk_device *ub)
@@ -498,11 +488,6 @@ static void ublk_dev_param_basic_apply(struct ublk_device *ub)struct request_queue *q = ub->ub_disk->queue;const struct ublk_param_basic *p = &ub->params.basic; -blk_queue_logical_block_size (q,1 << p->logical_bs_shift); -blk_queue_physical_block_size (q,1 << p->physical_bs_shift); -blk_queue_io_min (q,1 << p->io_min_shift); -blk_queue_io_opt (q,1 << p->io_opt_shift); -blk_queue_write_cache (q, p->attrs &UBLK_ATTR_VOLATILE_CACHE , p->attrs &UBLK_ATTR_FUA );if (p->attrs &UBLK_ATTR_ROTATIONAL )
@@ -510,29 +495,12 @@ static void ublk_dev_param_basic_apply(struct ublk_device *ub)else blk_queue_flag_set (QUEUE_FLAG_NONROT , q); -blk_queue_max_hw_sectors (q, p->max_sectors); -blk_queue_chunk_sectors (q, p->chunk_sectors); -blk_queue_virt_boundary (q, p->virt_boundary_mask); -if (p->attrs &UBLK_ATTR_READ_ONLY )set_disk_ro (ub->ub_disk, true);set_capacity (ub->ub_disk, p->dev_sectors); } -static void ublk_dev_param_discard_apply (struct ublk_device *ub) -{ -struct request_queue *q = ub->ub_disk->queue; -const struct ublk_param_discard *p = &ub->params.discard; - - q->limits.discard_alignment = p->discard_alignment; - q->limits.discard_granularity = p->discard_granularity; -blk_queue_max_discard_sectors (q, p->max_discard_sectors); -blk_queue_max_write_zeroes_sectors (q, - p->max_write_zeroes_sectors); -blk_queue_max_discard_segments (q, p->max_discard_segments); -} -static int ublk_validate_params (const struct ublk_device *ub) {/* basic param is the only one which must be set */
@@ -576,20 +544,12 @@ static int ublk_validate_params(const struct ublk_device *ub)return 0 ; } -static int ublk_apply_params (struct ublk_device *ub) +static void ublk_apply_params (struct ublk_device *ub) { -if (!(ub->params.types &UBLK_PARAM_TYPE_BASIC )) -return -EINVAL ; -ublk_dev_param_basic_apply (ub); -if (ub->params.types &UBLK_PARAM_TYPE_DISCARD ) -ublk_dev_param_discard_apply (ub); -if (ub->params.types &UBLK_PARAM_TYPE_ZONED ) -return ublk_dev_param_zoned_apply (ub); - -return 0 ; +ublk_dev_param_zoned_apply (ub); }static inline bool ublk_support_user_copy (const struct ublk_queue *ubq)
@@ -2205,12 +2165,47 @@ static struct ublk_device *ublk_get_device_from_id(int idx)static int ublk_ctrl_start_dev (struct ublk_device *ub,struct io_uring_cmd *cmd) {const struct ublksrv_ctrl_cmd *header =io_uring_sqe_cmd (cmd->sqe); +const struct ublk_param_basic *p = &ub->params.basic;int ublksrv_pid = (int )header->data[0 ]; +struct queue_limits lim = { + .logical_block_size =1 << p->logical_bs_shift, + .physical_block_size =1 << p->physical_bs_shift, + .io_min =1 << p->io_min_shift, + .io_opt =1 << p->io_opt_shift, + .max_hw_sectors = p->max_sectors, + .chunk_sectors = p->chunk_sectors, + .virt_boundary_mask = p->virt_boundary_mask, + + };struct gendisk *disk;int ret = -EINVAL ;if (ublksrv_pid <=0 )return -EINVAL ; +if (!(ub->params.types &UBLK_PARAM_TYPE_BASIC )) +return -EINVAL ; + +if (ub->params.types &UBLK_PARAM_TYPE_DISCARD ) { +const struct ublk_param_discard *pd = &ub->params.discard; + + lim.discard_alignment = pd->discard_alignment; + lim.discard_granularity = pd->discard_granularity; + lim.max_hw_discard_sectors = pd->max_discard_sectors; + lim.max_write_zeroes_sectors = pd->max_write_zeroes_sectors; + lim.max_discard_segments = pd->max_discard_segments; + } + +if (ub->params.types &UBLK_PARAM_TYPE_ZONED ) { +const struct ublk_param_zoned *p = &ub->params.zoned; + +if (!IS_ENABLED (CONFIG_BLK_DEV_ZONED )) +return -EOPNOTSUPP ; + + lim.zoned = true; + lim.max_active_zones = p->max_active_zones; + lim.max_open_zones = p->max_open_zones; + lim.max_zone_append_sectors = p->max_zone_append_sectors; + }if (wait_for_completion_interruptible (&ub->completion) !=0 )return -EINTR ;
@@ -2222,7 +2217,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) goto out_unlock; } - disk =blk_mq_alloc_disk (&ub->tag_set,NULL ,NULL ); + disk =blk_mq_alloc_disk (&ub->tag_set, &lim,NULL );if (IS_ERR (disk)) { ret =PTR_ERR (disk); goto out_unlock;
@@ -2234,9 +2229,7 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) ub->dev_info.ublksrv_pid = ublksrv_pid; ub->ub_disk = disk; - ret =ublk_apply_params (ub); -if (ret) - goto out_put_disk; +ublk_apply_params (ub);/* don't probe partitions if any one ubq daemon is un-trusted */ if (ub->nr_privileged_daemon != ub->nr_queues_ready)
@@ -2262,7 +2255,6 @@ static int ublk_ctrl_start_dev(struct ublk_device *ub, struct io_uring_cmd *cmd) ub->dev_info.state =UBLK_S_DEV_DEAD ;ublk_put_device (ub); } -out_put_disk:if (ret)put_disk (disk); out_unlock:
Signature · 1 line
2.39.2
PATCH 17/17 mmc: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigPass the queue limit set at initialization time directly to blk_mq_alloc_disk instead of updating it right after the allocation.
This requires refactoring the code a bit so that what was mmc_setup_queue before also allocates the gendisk now and actually sets all limits.
--- drivers/mmc/core/queue.c | 97 +++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 45 deletions(-)
drivers/mmc/core/queue.c +52 -45
@@ -174,8 +174,8 @@ static struct scatterlist *mmc_alloc_sg(unsigned short sg_len, gfp_t gfp)return sg; } -static void mmc_queue_setup_discard (struct request_queue *q, -struct mmc_card *card) +static void mmc_queue_setup_discard (struct mmc_card *card, +struct queue_limits *lim) {unsigned max_discard;
@@ -183,15 +183,17 @@ static void mmc_queue_setup_discard(struct request_queue *q,if (!max_discard)return ; -blk_queue_max_discard_sectors (q, max_discard); - q->limits.discard_granularity = card->pref_erase <<9 ; -/* granularity must not be greater than max. discard */ -if (card->pref_erase > max_discard) - q->limits.discard_granularity =SECTOR_SIZE ; + lim->max_hw_discard_sectors = max_discard;if (mmc_can_secure_erase_trim (card)) -blk_queue_max_secure_erase_sectors (q, max_discard); + lim->max_secure_erase_sectors = max_discard;if (mmc_can_trim (card) && card->erased_byte ==0 ) -blk_queue_max_write_zeroes_sectors (q, max_discard); + lim->max_write_zeroes_sectors = max_discard; + +/* granularity must not be greater than max. discard */ +if (card->pref_erase > max_discard) + lim->discard_granularity =SECTOR_SIZE ; +else + lim->discard_granularity = card->pref_erase <<9 ; }static unsigned short mmc_get_max_segments (struct mmc_host *host)
@@ -341,40 +343,53 @@ static const struct blk_mq_ops mmc_mq_ops = { .timeout = mmc_mq_timed_out, }; -static void mmc_setup_queue (struct mmc_queue *mq,struct mmc_card *card) +static struct gendisk *mmc_alloc_disk (struct mmc_queue *mq, +struct mmc_card *card) {struct mmc_host *host = card->host; -unsigned block_size =512 ; +struct queue_limits lim = { }; +struct gendisk *disk; -blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); -blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);if (mmc_can_erase (card)) -mmc_queue_setup_discard (mq->queue, card); +mmc_queue_setup_discard (card, &lim);if (!mmc_dev (host)->dma_mask || !*mmc_dev (host)->dma_mask) -blk_queue_bounce_limit (mq->queue,BLK_BOUNCE_HIGH ); -blk_queue_max_hw_sectors (mq->queue, -min (host->max_blk_count, host->max_req_size /512 )); -if (host->can_dma_map_merge) -WARN (!blk_queue_can_use_dma_map_merging (mq->queue, -mmc_dev (host)), -"merging was advertised but not possible" ); -blk_queue_max_segments (mq->queue,mmc_get_max_segments (host)); - -if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) { - block_size = card->ext_csd.data_sector_size; -WARN_ON (block_size !=512 && block_size !=4096 ); - } + lim.bounce =BLK_BOUNCE_HIGH ; + + lim.max_hw_sectors =min (host->max_blk_count, host->max_req_size /512 ); + +if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) + lim.logical_block_size = card->ext_csd.data_sector_size; +else + lim.logical_block_size =512 ; + +WARN_ON_ONCE (lim.logical_block_size !=512 && + lim.logical_block_size !=4096 ); -blk_queue_logical_block_size (mq->queue, block_size);/* -* After blk_queue_can_use_dma_map_merging() was called with succeed, -* since it calls blk_queue_virt_boundary(), the mmc should not call -* both blk_queue_max_segment_size(). +* Setting a virt_boundary implicity sets a max_segment_size, so try +* to set the hardware one here. */ -if (!host->can_dma_map_merge) -blk_queue_max_segment_size (mq->queue, -round_down (host->max_seg_size, block_size)); +if (host->can_dma_map_merge) { + lim.virt_boundary_mask =dma_get_merge_boundary (mmc_dev (host)); + lim.max_segments =MMC_DMA_MAP_MERGE_SEGMENTS ; + }else { + lim.max_segment_size = +round_down (host->max_seg_size, lim.logical_block_size); + lim.max_segments = host->max_segs; + } + + disk =blk_mq_alloc_disk (&mq->tag_set, &lim, mq); +if (IS_ERR (disk)) +return disk; + mq->queue = disk->queue; + +if (mmc_host_is_spi (host) && host->use_spi_crc) +blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); +blk_queue_rq_timeout (mq->queue,60 *HZ ); + +blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); +blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);dma_set_max_seg_size (mmc_dev (host),queue_max_segment_size (mq->queue));
@@ -386,6 +401,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)init_waitqueue_head (&mq->wait);mmc_crypto_setup_queue (mq->queue, host); +return disk; }static inline bool mmc_merge_capable (struct mmc_host *host)
@@ -447,18 +463,9 @@ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)return ERR_PTR (ret); - disk =blk_mq_alloc_disk (&mq->tag_set,NULL , mq); -if (IS_ERR (disk)) { + disk =mmc_alloc_disk (mq, card); +if (IS_ERR (disk))blk_mq_free_tag_set (&mq->tag_set); -return disk; - } - mq->queue = disk->queue; - -if (mmc_host_is_spi (host) && host->use_spi_crc) -blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); -blk_queue_rq_timeout (mq->queue,60 *HZ ); - -mmc_setup_queue (mq, card);return disk; }
Signature · 1 line
2.39.2
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 8 lines · Christoph Hellwig
Pass the queue limit set at initialization time directly to
blk_mq_alloc_diskinstead of updating it right after the allocation.This requires refactoring the code a bit so that what was
mmc_setup_queuebefore also allocates the gendisk now and actually sets all limits.Signed-off-by Christoph Hellwig <[email protected]>
Looks like $subject patch, patch11 and patch12 have already been queued up as they are cooking linux-next. Normally I prefer to funnel these via my mmc tree, to avoid potential conflicts (mostly for mmc, where more active developments are ongoing).
Let's leave this as is for the moment, but if we encounter non-trivial conflicts, I assume you can drop the patches from your tree?
Kind regards
Uffe
Quoted 155 lines
--- drivers/mmc/core/queue.c | 97 +++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 45 deletions(-)drivers/mmc/core/queue.c +52
-46@@ -174,8 +174,8 @@ static struct scatterlist *mmc_alloc_sg(unsigned short sg_len, gfp_t gfp)return sg; } -static void mmc_queue_setup_discard (struct request_queue *q, -struct mmc_card *card) +static void mmc_queue_setup_discard (struct mmc_card *card, +struct queue_limits *lim) {unsigned max_discard;@@ -183,15 +183,17 @@ static void mmc_queue_setup_discard(struct request_queue *q,if (!max_discard)return ; -blk_queue_max_discard_sectors (q, max_discard); - q->limits.discard_granularity = card->pref_erase <<9 ; -/* granularity must not be greater than max. discard */ -if (card->pref_erase > max_discard) - q->limits.discard_granularity =SECTOR_SIZE ; + lim->max_hw_discard_sectors = max_discard;if (mmc_can_secure_erase_trim (card)) -blk_queue_max_secure_erase_sectors (q, max_discard); + lim->max_secure_erase_sectors = max_discard;if (mmc_can_trim (card) && card->erased_byte ==0 ) -blk_queue_max_write_zeroes_sectors (q, max_discard); + lim->max_write_zeroes_sectors = max_discard; + +/* granularity must not be greater than max. discard */ +if (card->pref_erase > max_discard) + lim->discard_granularity =SECTOR_SIZE ; +else + lim->discard_granularity = card->pref_erase <<9 ; }static unsigned short mmc_get_max_segments (struct mmc_host *host)@@ -341,40 +343,53 @@ static const struct blk_mq_ops mmc_mq_ops = { .timeout = mmc_mq_timed_out, }; -static void mmc_setup_queue (struct mmc_queue *mq,struct mmc_card *card) +static struct gendisk *mmc_alloc_disk (struct mmc_queue *mq, +struct mmc_card *card) {struct mmc_host *host = card->host; -unsigned block_size =512 ; +struct queue_limits lim = { }; +struct gendisk *disk; -blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); -blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);if (mmc_can_erase (card)) -mmc_queue_setup_discard (mq->queue, card); +mmc_queue_setup_discard (card, &lim);if (!mmc_dev (host)->dma_mask || !*mmc_dev (host)->dma_mask) -blk_queue_bounce_limit (mq->queue,BLK_BOUNCE_HIGH ); -blk_queue_max_hw_sectors (mq->queue, -min (host->max_blk_count, host->max_req_size /512 )); -if (host->can_dma_map_merge) -WARN (!blk_queue_can_use_dma_map_merging (mq->queue, -mmc_dev (host)), -"merging was advertised but not possible" ); -blk_queue_max_segments (mq->queue,mmc_get_max_segments (host)); - -if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) { - block_size = card->ext_csd.data_sector_size; -WARN_ON (block_size !=512 && block_size !=4096 ); - } + lim.bounce =BLK_BOUNCE_HIGH ; + + lim.max_hw_sectors =min (host->max_blk_count, host->max_req_size /512 ); + +if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) + lim.logical_block_size = card->ext_csd.data_sector_size; +else + lim.logical_block_size =512 ; + +WARN_ON_ONCE (lim.logical_block_size !=512 && + lim.logical_block_size !=4096 ); -blk_queue_logical_block_size (mq->queue, block_size);/* -* After blk_queue_can_use_dma_map_merging() was called with succeed, -* since it calls blk_queue_virt_boundary(), the mmc should not call -* both blk_queue_max_segment_size(). +* Setting a virt_boundary implicity sets a max_segment_size, so try +* to set the hardware one here. */ -if (!host->can_dma_map_merge) -blk_queue_max_segment_size (mq->queue, -round_down (host->max_seg_size, block_size)); +if (host->can_dma_map_merge) { + lim.virt_boundary_mask =dma_get_merge_boundary (mmc_dev (host)); + lim.max_segments =MMC_DMA_MAP_MERGE_SEGMENTS ; + }else { + lim.max_segment_size = +round_down (host->max_seg_size, lim.logical_block_size); + lim.max_segments = host->max_segs; + } + + disk =blk_mq_alloc_disk (&mq->tag_set, &lim, mq); +if (IS_ERR (disk)) +return disk; + mq->queue = disk->queue; + +if (mmc_host_is_spi (host) && host->use_spi_crc) +blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); +blk_queue_rq_timeout (mq->queue,60 *HZ ); + +blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); +blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);dma_set_max_seg_size (mmc_dev (host),queue_max_segment_size (mq->queue));@@ -386,6 +401,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)init_waitqueue_head (&mq->wait);mmc_crypto_setup_queue (mq->queue, host); +return disk; }static inline bool mmc_merge_capable (struct mmc_host *host)@@ -447,18 +463,9 @@ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)return ERR_PTR (ret); - disk =blk_mq_alloc_disk (&mq->tag_set,NULL , mq); -if (IS_ERR (disk)) { + disk =mmc_alloc_disk (mq, card); +if (IS_ERR (disk))blk_mq_free_tag_set (&mq->tag_set); -return disk; - } - mq->queue = disk->queue; - -if (mmc_host_is_spi (host) && host->use_spi_crc) -blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); -blk_queue_rq_timeout (mq->queue,60 *HZ ); - -mmc_setup_queue (mq, card);return disk; } --2.39.2
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 4 lines · Ulf Hansson
Looks like $subject patch, patch11 and patch12 have already been queued up as they are cooking linux-next. Normally I prefer to funnel these via my mmc tree, to avoid potential conflicts (mostly for mmc, where more active developments are ongoing).
None of this is in my fresh linux-next pull, which would be rather surprising anyway as I've just sent them out and Jens isn't that quick to merge unreviewed series :)
That being said it depends on prep patches in the block tree and thus I'd prefer merging this entire series through that tree.
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 10 lines · Christoph Hellwig
Quoted 4 lines · Ulf Hansson
Looks like $subject patch, patch11 and patch12 have already been queued up as they are cooking linux-next. Normally I prefer to funnel these via my mmc tree, to avoid potential conflicts (mostly for mmc, where more active developments are ongoing).
None of this is in my fresh linux-next pull, which would be rather surprising anyway as I've just sent them out and Jens isn't that quick to merge unreviewed series :)
Weird. :-)
Quoted 3 lines
That being said it depends on prep patches in the block tree and thus I'd prefer merging this entire series through that tree.
Okay, in that case, np! Next time, it would be nice to get that information upfront in a cover-letter or similar.
If not too late, feel free to add my acks on the three patches for mmc and memstick.
Kind regards
Uffe
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigHi Christoph,
Quoted 7 lines · Christoph Hellwig
Pass the queue limit set at initialization time directly to
blk_mq_alloc_diskinstead of updating it right after the allocation.This requires refactoring the code a bit so that what was
mmc_setup_queuebefore also allocates the gendisk now and actually sets all limits.Signed-off-by Christoph Hellwig <[email protected]>
Thanks for your patch, which is now commit 616f876617927732 ("mmc: pass queue_limits to blk_mq_alloc_disk") in block/for-next.
I have bisected the following failure on White-Hawk (also seen on other R-Car Gen3/4 systems) to this commit:
renesas_sdhi_internal_dmac ee140000.mmc: mmc0 base at0x00000000ee140000, max clock rate 200 MHz
mmc0: new HS400 MMC card at address 0001
------------[ cut here ]------------
WARNING: CPU: 1 PID: 20 at block/blk-settings.c:202
blk_validate_limits+0x12c/0x1e0
Modules linked in:
CPU: 1 PID: 20 Comm: kworker/1:0 Not tainted
6.8.0-rc3-white-hawk-00084-g616f87661792 #223
Hardware name: Renesas White Hawk CPU and Breakout boards based on
r8a779g0 (DT)
Workqueue: events_freezable mmc_rescan
pstate: 00000005 (nzcv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
pc : blk_validate_limits+0x12c/0x1e0
lr : blk_set_default_limits+0x14/0x1c
sp : ffffffc0829336f0
x29: ffffffc0829336f0 x28: 0000000000000000 x27: 0000000000000000
Micrel KSZ9031 Gigabit PHY e6800000.ethernet-ffffffff:00: attached
PHY driver (mii_bus:phy_addr=e6800000.ethernet-ffffffff:00, irq=30)
x26: ffffff8443afd808 x25: ffffffc0825bd000 x24: ffffffc082933878
x23: 00000000ffffffff x22: ffffffc08147b258 x21: ffffff8443ab0c10
x20: 000000000000001a x19: ffffff8443b00000 x18: 0000000043789380
x17: ffffffc0806b2ea8 x16: ffffffc0803ab8b4 x15: ffffffc0803ab444
x14: ffffffc08039c26c x13: ffffffc080506854 x12: ffffffc080506700
x11: ffffffc08050669c x10: ffffffc080506478 x9 : ffffffc0803ad1a0
x8 : ffffff8443019120 x7 : ffffffc0803ad1a0 x6 : 0000000000000000
x5 : 0000000000000000 x4 : 0000000000000a00 x3 : 0000000000000fff
x2 : 0000000000000200 x1 : 0000000000010000 x0 : ffffffc082933878
Call trace:
blk_validate_limits+0x12c/0x1e0
blk_alloc_queue+0x7c/0x244
blk_mq_alloc_queue+0x4c/0xac
__blk_mq_alloc_disk+0x1c/0xc0
mmc_alloc_disk+0x134/0x2b4
mmc_init_queue+0x114/0x12c
mmc_blk_alloc_req+0xf0/0x34c
mmc_blk_probe+0x230/0x5b8
mmc_bus_probe+0x18/0x20
really_probe+0x138/0x270
__driver_probe_device+0xec/0x104
driver_probe_device+0x4c/0xf8
__device_attach_driver+0xa8/0xc8
bus_for_each_drv+0xa4/0xc8
__device_attach+0xe4/0x144
device_initial_probe+0x10/0x18
bus_probe_device+0x38/0xa0
device_add+0x520/0x654
mmc_add_card+0x12c/0x28c
mmc_attach_mmc+0xb8/0x154
mmc_rescan+0x208/0x250
process_scheduled_works+0x2b8/0x41c
worker_thread+0x1cc/0x24c
kthread+0xd8/0xe8
ret_from_fork+0x10/0x20
irq event stamp: 434
hardirqs last enabled at (433): [<ffffffc0808e0ac0>]
_raw_spin_unlock_irq+0x2c/0x40
hardirqs last disabled at (434): [<ffffffc0808dae28>] __schedule+0x1cc/0x84c
softirqs last enabled at (192): [<ffffffc080010300>]
__do_softirq+0x1ac/0x360
softirqs last disabled at (185): [<ffffffc08001550c>]
____do_softirq+0xc/0x14
---[ end trace 0000000000000000 ]---
mmcblk: probe of mmc0:0001 failed with error -22Reverting this commit fixes the issue.
Quoted 153 lines
drivers/mmc/core/queue.c +52
-46@@ -174,8 +174,8 @@ static struct scatterlist *mmc_alloc_sg(unsigned short sg_len, gfp_t gfp)return sg; } -static void mmc_queue_setup_discard (struct request_queue *q, -struct mmc_card *card) +static void mmc_queue_setup_discard (struct mmc_card *card, +struct queue_limits *lim) {unsigned max_discard;@@ -183,15 +183,17 @@ static void mmc_queue_setup_discard(struct request_queue *q,if (!max_discard)return ; -blk_queue_max_discard_sectors (q, max_discard); - q->limits.discard_granularity = card->pref_erase <<9 ; -/* granularity must not be greater than max. discard */ -if (card->pref_erase > max_discard) - q->limits.discard_granularity =SECTOR_SIZE ; + lim->max_hw_discard_sectors = max_discard;if (mmc_can_secure_erase_trim (card)) -blk_queue_max_secure_erase_sectors (q, max_discard); + lim->max_secure_erase_sectors = max_discard;if (mmc_can_trim (card) && card->erased_byte ==0 ) -blk_queue_max_write_zeroes_sectors (q, max_discard); + lim->max_write_zeroes_sectors = max_discard; + +/* granularity must not be greater than max. discard */ +if (card->pref_erase > max_discard) + lim->discard_granularity =SECTOR_SIZE ; +else + lim->discard_granularity = card->pref_erase <<9 ; }static unsigned short mmc_get_max_segments (struct mmc_host *host)@@ -341,40 +343,53 @@ static const struct blk_mq_ops mmc_mq_ops = { .timeout = mmc_mq_timed_out, }; -static void mmc_setup_queue (struct mmc_queue *mq,struct mmc_card *card) +static struct gendisk *mmc_alloc_disk (struct mmc_queue *mq, +struct mmc_card *card) {struct mmc_host *host = card->host; -unsigned block_size =512 ; +struct queue_limits lim = { }; +struct gendisk *disk; -blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); -blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);if (mmc_can_erase (card)) -mmc_queue_setup_discard (mq->queue, card); +mmc_queue_setup_discard (card, &lim);if (!mmc_dev (host)->dma_mask || !*mmc_dev (host)->dma_mask) -blk_queue_bounce_limit (mq->queue,BLK_BOUNCE_HIGH ); -blk_queue_max_hw_sectors (mq->queue, -min (host->max_blk_count, host->max_req_size /512 )); -if (host->can_dma_map_merge) -WARN (!blk_queue_can_use_dma_map_merging (mq->queue, -mmc_dev (host)), -"merging was advertised but not possible" ); -blk_queue_max_segments (mq->queue,mmc_get_max_segments (host)); - -if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) { - block_size = card->ext_csd.data_sector_size; -WARN_ON (block_size !=512 && block_size !=4096 ); - } + lim.bounce =BLK_BOUNCE_HIGH ; + + lim.max_hw_sectors =min (host->max_blk_count, host->max_req_size /512 ); + +if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) + lim.logical_block_size = card->ext_csd.data_sector_size; +else + lim.logical_block_size =512 ; + +WARN_ON_ONCE (lim.logical_block_size !=512 && + lim.logical_block_size !=4096 ); -blk_queue_logical_block_size (mq->queue, block_size);/* -* After blk_queue_can_use_dma_map_merging() was called with succeed, -* since it calls blk_queue_virt_boundary(), the mmc should not call -* both blk_queue_max_segment_size(). +* Setting a virt_boundary implicity sets a max_segment_size, so try +* to set the hardware one here. */ -if (!host->can_dma_map_merge) -blk_queue_max_segment_size (mq->queue, -round_down (host->max_seg_size, block_size)); +if (host->can_dma_map_merge) { + lim.virt_boundary_mask =dma_get_merge_boundary (mmc_dev (host)); + lim.max_segments =MMC_DMA_MAP_MERGE_SEGMENTS ; + }else { + lim.max_segment_size = +round_down (host->max_seg_size, lim.logical_block_size); + lim.max_segments = host->max_segs; + } + + disk =blk_mq_alloc_disk (&mq->tag_set, &lim, mq); +if (IS_ERR (disk)) +return disk; + mq->queue = disk->queue; + +if (mmc_host_is_spi (host) && host->use_spi_crc) +blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); +blk_queue_rq_timeout (mq->queue,60 *HZ ); + +blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); +blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);dma_set_max_seg_size (mmc_dev (host),queue_max_segment_size (mq->queue));@@ -386,6 +401,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)init_waitqueue_head (&mq->wait);mmc_crypto_setup_queue (mq->queue, host); +return disk; }static inline bool mmc_merge_capable (struct mmc_host *host)@@ -447,18 +463,9 @@ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)return ERR_PTR (ret); - disk =blk_mq_alloc_disk (&mq->tag_set,NULL , mq); -if (IS_ERR (disk)) { + disk =mmc_alloc_disk (mq, card); +if (IS_ERR (disk))blk_mq_free_tag_set (&mq->tag_set); -return disk; - } - mq->queue = disk->queue; - -if (mmc_host_is_spi (host) && host->use_spi_crc) -blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); -blk_queue_rq_timeout (mq->queue,60 *HZ ); - -mmc_setup_queue (mq, card);return disk; } --2.39.2
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
Signature · 14 lines
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]
In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 15 lines · Geert Uytterhoeven
Quoted 7 lines · Christoph Hellwig
Pass the queue limit set at initialization time directly to
blk_mq_alloc_diskinstead of updating it right after the allocation.This requires refactoring the code a bit so that what was
mmc_setup_queuebefore also allocates the gendisk now and actually sets all limits.Signed-off-by Christoph Hellwig <[email protected]>Thanks for your patch, which is now commit
616f876617927732("mmc: passqueue_limitstoblk_mq_alloc_disk") inblock/for-next.I have bisected the following failure on White-Hawk (also seen on other R-Car Gen3/4 systems) to this commit:
Quoted 6 lines
renesas_sdhi_internal_dmacee140000.mmc: mmc0 base at0x00000000ee140000, max clock rate 200 MHzmmc0: new HS400 MMC card at address 0001 ------------[ cut here ]------------ WARNING: CPU: 1 PID: 20 at block/blk-settings.c:202
blk_validate_limits+0x12c/0x1e0
Actual capacity should be:
mmc0: new HS400 MMC card at address 0001
mmcblk0: mmc0:0001 G1M15L 29.6 GiB
mmcblk0boot0: mmc0:0001 G1M15L 31.5 MiB
mmcblk0boot1: mmc0:0001 G1M15L 31.5 MiB
mmcblk0rpmb: mmc0:0001 G1M15L 4.00 MiB, chardev (245:0)
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
In reply to Geert UytterhoevenQuoted 17 lines · Geert Uytterhoeven
Hi Christoph,
Quoted 7 lines · Christoph Hellwig
Pass the queue limit set at initialization time directly to
blk_mq_alloc_diskinstead of updating it right after the allocation.This requires refactoring the code a bit so that what was
mmc_setup_queuebefore also allocates the gendisk now and actually sets all limits.Signed-off-by Christoph Hellwig <[email protected]>Thanks for your patch, which is now commit
616f876617927732("mmc: passqueue_limitstoblk_mq_alloc_disk") inblock/for-next.I have bisected the following failure on White-Hawk (also seen on other R-Car Gen3/4 systems) to this commit:
Quoted 6 lines
renesas_sdhi_internal_dmacee140000.mmc: mmc0 base at0x00000000ee140000, max clock rate 200 MHzmmc0: new HS400 MMC card at address 0001 ------------[ cut here ]------------ WARNING: CPU: 1 PID: 20 at block/blk-settings.c:202
blk_validate_limits+0x12c/0x1e0
This is:
if (lim->virt_boundary_mask) {
if (WARN_ON_ONCE(lim->max_segment_size &&
lim->max_segment_size != UINT_MAX))
return -EINVAL;so we end up here with both a virt_boundary_mask and a max_segment_size set, which is rather bogus. I think the problem is the order of check in the core blk_validate_limits that artificially causes this. Can you try this patch?
block/blk-settings.c +10 -10
@@ -182,16 +182,6 @@ static int blk_validate_limits(struct queue_limits *lim)if (WARN_ON_ONCE (lim->seg_boundary_mask <PAGE_SIZE -1 ))return -EINVAL ; -/* -* The maximum segment size has an odd historic 64k default that -* drivers probably should override. Just like the I/O size we -* require drivers to at least handle a full page per segment. -*/ -if (!lim->max_segment_size) - lim->max_segment_size =BLK_MAX_SEGMENT_SIZE ; -if (WARN_ON_ONCE (lim->max_segment_size <PAGE_SIZE )) -return -EINVAL ; -/* * Devices that require a virtual boundary do not support scatter/gather * I/O natively, but instead require a descriptor list entry for each
@@ -203,6 +193,16 @@ static int blk_validate_limits(struct queue_limits *lim) lim->max_segment_size != UINT_MAX))return -EINVAL ; lim->max_segment_size =UINT_MAX ; + }else { +/* +* The maximum segment size has an odd historic 64k default that +* drivers probably should override. Just like the I/O size we +* require drivers to at least handle a full page per segment. +*/ +if (!lim->max_segment_size) + lim->max_segment_size =BLK_MAX_SEGMENT_SIZE ; +if (WARN_ON_ONCE (lim->max_segment_size <PAGE_SIZE )) +return -EINVAL ; }/*
Geert Uytterhoeven
Tested-byRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Hi Christoph,
Quoted 30 lines · Christoph Hellwig
Quoted 15 lines · Geert Uytterhoeven
Quoted 7 lines · Christoph Hellwig
Pass the queue limit set at initialization time directly to
blk_mq_alloc_diskinstead of updating it right after the allocation.This requires refactoring the code a bit so that what was
mmc_setup_queuebefore also allocates the gendisk now and actually sets all limits.Signed-off-by Christoph Hellwig <[email protected]>Thanks for your patch, which is now commit
616f876617927732("mmc: passqueue_limitstoblk_mq_alloc_disk") inblock/for-next.I have bisected the following failure on White-Hawk (also seen on other R-Car Gen3/4 systems) to this commit:
Quoted 6 lines
renesas_sdhi_internal_dmacee140000.mmc: mmc0 base at0x00000000ee140000, max clock rate 200 MHzmmc0: new HS400 MMC card at address 0001 ------------[ cut here ]------------ WARNING: CPU: 1 PID: 20 at block/blk-settings.c:202
blk_validate_limits+0x12c/0x1e0This is:
if (lim->virt_boundary_mask) { if (WARN_ON_ONCE(lim->max_segment_size && lim->max_segment_size != UINT_MAX)) return -EINVAL;
Quoted 4 lines
so we end up here with both a
virt_boundary_maskand amax_segment_sizeset, which is rather bogus. I think the problem is the order of check in the coreblk_validate_limitsthat artificially causes this. Can you try this patch?
Thanks, good thinking, as that fixed the issue for me!
Gr{oetje,eeting}s,
Geert
Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected] In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that. -- Linus Torvalds
Jon Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
In reply to Christoph HellwigHi Christoph,
Quoted 149 lines · Christoph Hellwig
Pass the queue limit set at initialization time directly to
blk_mq_alloc_diskinstead of updating it right after the allocation.This requires refactoring the code a bit so that what was
mmc_setup_queuebefore also allocates the gendisk now and actually sets all limits.Signed-off-by Christoph Hellwig <[email protected]>--- drivers/mmc/core/queue.c | 97 +++++++++++++++++++++------------------- 1 file changed, 52 insertions(+), 45 deletions(-)drivers/mmc/core/queue.c +52
-38@@ -174,8 +174,8 @@ static struct scatterlist *mmc_alloc_sg(unsigned short sg_len, gfp_t gfp)return sg; } -static void mmc_queue_setup_discard (struct request_queue *q, -struct mmc_card *card) +static void mmc_queue_setup_discard (struct mmc_card *card, +struct queue_limits *lim) {unsigned max_discard;@@ -183,15 +183,17 @@ static void mmc_queue_setup_discard(struct request_queue *q,if (!max_discard)return ; -blk_queue_max_discard_sectors (q, max_discard); - q->limits.discard_granularity = card->pref_erase <<9 ; -/* granularity must not be greater than max. discard */ -if (card->pref_erase > max_discard) - q->limits.discard_granularity =SECTOR_SIZE ; + lim->max_hw_discard_sectors = max_discard;if (mmc_can_secure_erase_trim (card)) -blk_queue_max_secure_erase_sectors (q, max_discard); + lim->max_secure_erase_sectors = max_discard;if (mmc_can_trim (card) && card->erased_byte ==0 ) -blk_queue_max_write_zeroes_sectors (q, max_discard); + lim->max_write_zeroes_sectors = max_discard; + +/* granularity must not be greater than max. discard */ +if (card->pref_erase > max_discard) + lim->discard_granularity =SECTOR_SIZE ; +else + lim->discard_granularity = card->pref_erase <<9 ; }static unsigned short mmc_get_max_segments (struct mmc_host *host)@@ -341,40 +343,53 @@ static const struct blk_mq_ops mmc_mq_ops = { .timeout = mmc_mq_timed_out, }; -static void mmc_setup_queue (struct mmc_queue *mq,struct mmc_card *card) +static struct gendisk *mmc_alloc_disk (struct mmc_queue *mq, +struct mmc_card *card) {struct mmc_host *host = card->host; -unsigned block_size =512 ; +struct queue_limits lim = { }; +struct gendisk *disk; -blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); -blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);if (mmc_can_erase (card)) -mmc_queue_setup_discard (mq->queue, card); +mmc_queue_setup_discard (card, &lim);if (!mmc_dev (host)->dma_mask || !*mmc_dev (host)->dma_mask) -blk_queue_bounce_limit (mq->queue,BLK_BOUNCE_HIGH ); -blk_queue_max_hw_sectors (mq->queue, -min (host->max_blk_count, host->max_req_size /512 )); -if (host->can_dma_map_merge) -WARN (!blk_queue_can_use_dma_map_merging (mq->queue, -mmc_dev (host)), -"merging was advertised but not possible" ); -blk_queue_max_segments (mq->queue,mmc_get_max_segments (host)); - -if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) { - block_size = card->ext_csd.data_sector_size; -WARN_ON (block_size !=512 && block_size !=4096 ); - } + lim.bounce =BLK_BOUNCE_HIGH ; + + lim.max_hw_sectors =min (host->max_blk_count, host->max_req_size /512 ); + +if (mmc_card_mmc (card) && card->ext_csd.data_sector_size) + lim.logical_block_size = card->ext_csd.data_sector_size; +else + lim.logical_block_size =512 ; + +WARN_ON_ONCE (lim.logical_block_size !=512 && + lim.logical_block_size !=4096 ); -blk_queue_logical_block_size (mq->queue, block_size);/* -* After blk_queue_can_use_dma_map_merging() was called with succeed, -* since it calls blk_queue_virt_boundary(), the mmc should not call -* both blk_queue_max_segment_size(). +* Setting a virt_boundary implicity sets a max_segment_size, so try +* to set the hardware one here. */ -if (!host->can_dma_map_merge) -blk_queue_max_segment_size (mq->queue, -round_down (host->max_seg_size, block_size)); +if (host->can_dma_map_merge) { + lim.virt_boundary_mask =dma_get_merge_boundary (mmc_dev (host)); + lim.max_segments =MMC_DMA_MAP_MERGE_SEGMENTS ; + }else { + lim.max_segment_size = +round_down (host->max_seg_size, lim.logical_block_size); + lim.max_segments = host->max_segs; + } + + disk =blk_mq_alloc_disk (&mq->tag_set, &lim, mq); +if (IS_ERR (disk)) +return disk; + mq->queue = disk->queue; + +if (mmc_host_is_spi (host) && host->use_spi_crc) +blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); +blk_queue_rq_timeout (mq->queue,60 *HZ ); + +blk_queue_flag_set (QUEUE_FLAG_NONROT , mq->queue); +blk_queue_flag_clear (QUEUE_FLAG_ADD_RANDOM , mq->queue);dma_set_max_seg_size (mmc_dev (host),queue_max_segment_size (mq->queue));@@ -386,6 +401,7 @@ static void mmc_setup_queue(struct mmc_queue *mq, struct mmc_card *card)init_waitqueue_head (&mq->wait);mmc_crypto_setup_queue (mq->queue, host); +return disk; }static inline bool mmc_merge_capable (struct mmc_host *host)@@ -447,18 +463,9 @@ struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card)return ERR_PTR (ret); - disk =blk_mq_alloc_disk (&mq->tag_set,NULL , mq); -if (IS_ERR (disk)) { + disk =mmc_alloc_disk (mq, card); +if (IS_ERR (disk))blk_mq_free_tag_set (&mq->tag_set); -return disk; - }
drivers/mmc/core/queue.c struct gendisk *mmc_init_queue(struct mmc_queue *mq, struct mmc_card *card) · line 471
Quoted 10 lines
drivers/mmc/core/queue.c +0
-7- mq->queue = disk->queue; - -if (mmc_host_is_spi (host) && host->use_spi_crc) -blk_queue_flag_set (QUEUE_FLAG_STABLE_WRITES , mq->queue); -blk_queue_rq_timeout (mq->queue,60 *HZ ); - -mmc_setup_queue (mq, card);return disk; }
We have just noticed that since Linux v6.9 was released, that if we build the kernel with 64kB MMU pages, then we see the following WARNING and probe failure ...
[ 2.828612] ------------[ cut here ]------------ [ 2.829243] WARNING: CPU: 1 PID: 87 at block/blk-settings.c:206 blk_validate_limits+0x1cc/0x234 [ 2.830417] Modules linked in: [ 2.830963] CPU: 1 PID: 87 Comm: kworker/1:1 Not tainted 6.10.0-rc5 #1 [ 2.831773] Hardware name: NVIDIA Jetson AGX Xavier Developer Kit (DT) [ 2.832538] Workqueue: events_freezable mmc_rescan [ 2.833341] pstate: 80400009 (Nzcv daif +PAN -UAO -TCO -DIT -SSBS BTYPE=--) [ 2.834263] pc : blk_validate_limits+0x1cc/0x234 [ 2.834927] lr : blk_set_default_limits+0x18/0x24 [ 2.835654] sp : ffff800084c4f730 [ 2.836161] x29: ffff800084c4f730 x28: 0000000000000000 x27: 0000000000000000 [ 2.837448] x26: 0000000000000000 x25: ffff000084130008 x24: 00000000ffffffff [ 2.838607] x23: ffff800082d84000 x22: ffff8000828b79c8 x21: ffff800084c4f8b8 [ 2.839754] x20: 0000000000000008 x19: ffff000084170000 x18: 0000000000000000 [ 2.840831] x17: 00000000900163fe x16: 000000008802ed71 x15: 00000000000003e8 [ 2.842228] x14: 0000000000000002 x13: 00000000000372ef x12: 0000000000002bb0 [ 2.843536] x11: 0000000000000000 x10: 0000000000004400 x9 : 0000000000000000 [ 2.847832] x8 : ffff0000841703a0 x7 : 0000000000000000 x6 : 0000000000000003 [ 2.855075] x5 : ffff000081279e00 x4 : 0000000000000000 x3 : 0000000000000200 [ 2.862140] x2 : 000000000000ffff x1 : 000000000000fe00 x0 : ffff800084c4f8b8 [ 2.869633] Call trace: [ 2.872055] blk_validate_limits+0x1cc/0x234 [ 2.876278] blk_alloc_queue+0x7c/0x260 [ 2.880038] blk_mq_alloc_queue+0x54/0xbc [ 2.884504] __blk_mq_alloc_disk+0x20/0x190 [ 2.888266] mmc_alloc_disk+0xbc/0x250 [ 2.892062] mmc_init_queue+0xe8/0x114 [ 2.896091] mmc_blk_alloc_req+0xb4/0x374 [ 2.900237] mmc_blk_probe+0x1d4/0x650 [ 2.904194] mmc_bus_probe+0x20/0x2c [ 2.907434] really_probe+0xbc/0x2a4 [ 2.911391] __driver_probe_device+0x78/0x12c [ 2.915627] driver_probe_device+0x40/0x160 [ 2.919587] __device_attach_driver+0xb8/0x134 [ 2.923881] bus_for_each_drv+0x80/0xdc [ 2.927664] __device_attach+0xa8/0x1b0 [ 2.931578] device_initial_probe+0x14/0x20 [ 2.935845] bus_probe_device+0xa8/0xac [ 2.939606] device_add+0x590/0x754 [ 2.942864] mmc_add_card+0x238/0x2dc [ 2.946691] mmc_attach_mmc+0x12c/0x174 [ 2.950494] mmc_rescan+0x27c/0x318 [ 2.954172] process_one_work+0x154/0x298 [ 2.957919] worker_thread+0x304/0x408 [ 2.961931] kthread+0x118/0x11c [ 2.965187] ret_from_fork+0x10/0x20 [ 2.968835] ---[ end trace 0000000000000000 ]--- [ 2.974440] mmcblk mmc0:0001: probe with driver mmcblk failed with error -22
Bisect points to this commit. This is very similar to the issue Geert reported [0] but we are still seeing this on the latest mainline with v6.10-rc5. When building with 4kB MMU pages we don't see this issue when testing on the same hardware. Let me know if you have any thoughts?
Thanks
Jon
Signature · 1 line
nvpublic
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 3 lines · Jon Hunter
We have just noticed that since Linux v6.9 was released, that if we build the kernel with 64kB MMU pages, then we see the following WARNING and probe failure ...
The old code upgraded the limits to the PAGE_SIZE for this case after issunig a warning. Your driver probably incorrectly advertised the lower max_segment_size. Try setting it to 64k. I would have sent you a patch for that, but I can't see what mmc host driver you are using.
Jon Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Jon Hunter
We have just noticed that since Linux v6.9 was released, that if we build the kernel with 64kB MMU pages, then we see the following WARNING and probe failure ...
The old code upgraded the limits to the
PAGE_SIZEfor this case after issunig a warning. Your driver probably incorrectly advertised the lowermax_segment_size. Try setting it to 64k. I would have sent you a patch for that, but I can't see what mmc host driver you are using.
We are using the sdhci-tegra.c driver. I don't see it set in there, but I see references to max_seg_size in the main sdhci.c driver.
Thanks,
Jon
Signature · 1 line
nvpublic
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 7 lines · Jon Hunter
Quoted 5 lines · Christoph Hellwig
Quoted 3 lines · Jon Hunter
We have just noticed that since Linux v6.9 was released, that if we build the kernel with 64kB MMU pages, then we see the following WARNING and probe failure ...
Quoted 8 lines
Quoted 4 lines
The old code upgraded the limits to the
PAGE_SIZEfor this case after issunig a warning. Your driver probably incorrectly advertised the lowermax_segment_size. Try setting it to 64k. I would have sent you a patch for that, but I can't see what mmc host driver you are using.We are using the
sdhci-tegra.cdriver. I don't see it set in there, but I see references tomax_seg_sizein the mainsdhci.cdriver.
sdhci-tegra.c sets SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC for various devices, I guess you have one od those? This sounds like the device might not actually need it, but I'll need help from the SDHCI and tegra maintainers here.
Jon Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 14 lines · Christoph Hellwig
Quoted 13 lines · Jon Hunter
Quoted 9 lines · Christoph Hellwig
Quoted 3 lines · Jon Hunter
We have just noticed that since Linux v6.9 was released, that if we build the kernel with 64kB MMU pages, then we see the following WARNING and probe failure ...
The old code upgraded the limits to the
PAGE_SIZEfor this case after issunig a warning. Your driver probably incorrectly advertised the lowermax_segment_size. Try setting it to 64k. I would have sent you a patch for that, but I can't see what mmc host driver you are using.
Quoted 7 lines
Quoted 2 lines
We are using the
sdhci-tegra.cdriver. I don't see it set in there, but I see references tomax_seg_sizein the mainsdhci.cdriver.
sdhci-tegra.csetsSDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESCfor various devices, I guess you have one od those? This sounds like the device might not actually need it, but I'll need help from the SDHCI and tegra maintainers here.
I have been testing on both Tegra194 and Tegra234. Both of these set the above quirk. This would explain why the max_segment_size is rounded down to 65024 in the mmc_alloc_disk() function.
We can check if this is needed but if it is needed then it is not clear if/how this can be fixed?
Thanks
Jon
Signature · 1 line
nvpublic
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 6 lines · Jon Hunter
I have been testing on both Tegra194 and Tegra234. Both of these set the above quirk. This would explain why the
max_segment_sizeis rounded down to 65024 in themmc_alloc_disk()function.We can check if this is needed but if it is needed then it is not clear if/how this can be fixed?
The older kernels did this:
if (max_size < PAGE_CACHE_SIZE) {
max_size = PAGE_CACHE_SIZE;
printk(KERN_INFO "%s: set to minimum %d\n",
__func__, max_size);
}
q->limits.max_segment_size = max_size;so when these kernels actually worked despite the above warning it must be ok(-ish) to just increase this value. If that is best done by dropping the quirk, or changing the logic in sdhci.c is something the maintainers that understand the hardware need to decide.
The patch below gives you the pre-6.9 behavior just without the boot time warning, but it might not be what was intended by the quirk:
drivers/mmc/host/sdhci.c +2 -5
@@ -4721,12 +4721,9 @@ int sdhci_setup_host(struct sdhci_host *host)* be larger than 64 KiB though. */ if (host->flags &SDHCI_USE_ADMA ) { -if (host->quirks &SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC ) { +if (host->quirks &SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC ) host->max_adma =65532 ;/* 32-bit alignment */ - mmc->max_seg_size =65535 ; - }else { - mmc->max_seg_size =65536 ; - } + mmc->max_seg_size =65536 ; }else { mmc->max_seg_size = mmc->max_req_size; }
Jon Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 36 lines · Christoph Hellwig
Quoted 6 lines · Jon Hunter
I have been testing on both Tegra194 and Tegra234. Both of these set the above quirk. This would explain why the
max_segment_sizeis rounded down to 65024 in themmc_alloc_disk()function.We can check if this is needed but if it is needed then it is not clear if/how this can be fixed?
The older kernels did this:
if (max_size < PAGE_CACHE_SIZE) { max_size = PAGE_CACHE_SIZE; printk(KERN_INFO "%s: set to minimum %d\n", __func__, max_size); } q->limits.max_segment_size = max_size;so when these kernels actually worked despite the above warning it must be ok(-ish) to just increase this value. If that is best done by dropping the quirk, or changing the logic in
sdhci.cis something the maintainers that understand the hardware need to decide.The patch below gives you the pre-6.9 behavior just without the boot time warning, but it might not be what was intended by the quirk:
drivers/mmc/host/sdhci.c +0
-1@@ -4721,12 +4721,9 @@ int sdhci_setup_host(struct sdhci_host *host)* be larger than 64 KiB though. */ if (host->flags &SDHCI_USE_ADMA ) { -if (host->quirks &SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC ) {
drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4729
Quoted 10 lines
drivers/mmc/host/sdhci.c +2
-4+if (host->quirks &SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC ) host->max_adma =65532 ;/* 32-bit alignment */ - mmc->max_seg_size =65535 ; - }else { - mmc->max_seg_size =65536 ; - } + mmc->max_seg_size =65536 ; }else { mmc->max_seg_size = mmc->max_req_size; }
As a quick test I removed the quirk for Tegra194 and that did work, which achieves the same thing as the above.
I guess there are two open questions here ...
1. Do we need the quirk for all the current Tegra devices? Thierry and I can confirm this.
2. For devices that need that quirk and use 64kB pages, what is the appropriate way to handle this for sdhci controllers?
Jon
Signature · 1 line
nvpublic
Adrian Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 52 lines · Jon Hunter
Quoted 38 lines · Christoph Hellwig
Quoted 6 lines · Jon Hunter
I have been testing on both Tegra194 and Tegra234. Both of these set the above quirk. This would explain why the
max_segment_sizeis rounded down to 65024 in themmc_alloc_disk()function.We can check if this is needed but if it is needed then it is not clear if/how this can be fixed?
The older kernels did this:
if (
max_size<PAGE_CACHE_SIZE) {max_size=PAGE_CACHE_SIZE;printk(KERN_INFO "%s: set to minimum %d\n", __func__, max_size);
}q->limits.max_segment_size =
max_size;so when these kernels actually worked despite the above warning it must be ok(-ish) to just increase this value. If that is best done by dropping the quirk, or changing the logic in
sdhci.cis something the maintainers that understand the hardware need to decide.The patch below gives you the pre-6.9 behavior just without the boot time warning, but it might not be what was intended by the quirk:
drivers/mmc/host/sdhci.c +1
-1@@ -4721,12 +4721,9 @@ int sdhci_setup_host(struct sdhci_host *host)* be larger than 64 KiB though. */ if (host->flags & SDHCI_USE_ADMA) { - if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) { + if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC)
host->max_adma= 65532; /* 32-bit alignment */Quoted 8 lines
-
mmc->max_seg_size= 65535;
- } else {
-mmc->max_seg_size= 65536;
- }
+mmc->max_seg_size= 65536;
} else {
mmc->max_seg_size=mmc->max_req_size;
}As a quick test I removed the quirk for Tegra194 and that did work, which achieves the same thing as the above.
Quoted 6 lines
I guess there are two open questions here ...
1. Do we need the quirk for all the current Tegra devices? Thierry and I can confirm this.
2. For devices that need that quirk and use 64kB pages, what is the appropriate way to handle this for sdhci controllers?
Probably just do what the block layer was doing e.g.
drivers/mmc/host/sdhci.c +7 -0
@@ -4724,6 +4724,13 @@ int sdhci_setup_host(struct sdhci_host *host)if (host->quirks &SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC ) { host->max_adma =65532 ;/* 32-bit alignment */ mmc->max_seg_size =65535 ; +/* +* Block layer cannot accept max_seg_size < PAGE_SIZE +* whereas sdhci_adma_table_pre() will anyway split the +* descriptor to handle size > max_adma. +*/ +if (mmc->max_seg_size <PAGE_SIZE ) + mmc->max_seg_size =PAGE_SIZE ; }else { mmc->max_seg_size =65536 ; }
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 1 line · Adrian Hunter
Probably just do what the block layer was doing e.g.
That was really just a hack due to the lack of error handling in the old blk_queue_* interfaces. If ADMA really doesn't actually have a limitation, please just don't set any max_segment_size at all.
Adrian Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 7 lines · Christoph Hellwig
Quoted 1 line · Adrian Hunter
Probably just do what the block layer was doing e.g.
That was really just a hack due to the lack of error handling in the old blk_queue_* interfaces. If ADMA really doesn't actually have a limitation, please just don't set any
max_segment_sizeat all.
There is a limitation of 64KiB max. (or less with SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) per descriptor.
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 11 lines · Adrian Hunter
Quoted 7 lines · Christoph Hellwig
Quoted 1 line · Adrian Hunter
Probably just do what the block layer was doing e.g.
That was really just a hack due to the lack of error handling in the old blk_queue_* interfaces. If ADMA really doesn't actually have a limitation, please just don't set any
max_segment_sizeat all.There is a limitation of 64KiB max. (or less with
SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) per descriptor.
Hmm, I thought the conflusion was that it can be more, which is why you proposed to increase it if the PAGE_SIZE is >= 64k. And based on Jon's report at least for his tegra setups it works with 64k.
Adrian Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 10 lines · Christoph Hellwig
Quoted 9 lines · Adrian Hunter
Quoted 7 lines · Christoph Hellwig
Quoted 1 line · Adrian Hunter
Probably just do what the block layer was doing e.g.
That was really just a hack due to the lack of error handling in the old blk_queue_* interfaces. If ADMA really doesn't actually have a limitation, please just don't set any
max_segment_sizeat all.
Quoted 6 lines
Quoted 2 lines
There is a limitation of 64KiB max. (or less with
SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) per descriptor.Hmm, I thought the conflusion was that it can be more, which is why you proposed to increase it if the
PAGE_SIZEis >= 64k. And based on Jon's report at least for his tegra setups it works with 64k.
There is a workaround in that case to split to 32KiB chunks
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 5 lines · Adrian Hunter
Quoted 3 lines
Hmm, I thought the conflusion was that it can be more, which is why you proposed to increase it if the
PAGE_SIZEis >= 64k. And based on Jon's report at least for his tegra setups it works with 64k.There is a workaround in that case to split to 32KiB chunks
Which I guess is less optimal than just using the block layer splitting? Maybe add a big fat comment explaining this?
Adrian Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Adrian Hunter
Quoted 3 lines
Hmm, I thought the conflusion was that it can be more, which is why you proposed to increase it if the
PAGE_SIZEis >= 64k. And based on Jon's report at least for his tegra setups it works with 64k.There is a workaround in that case to split to 32KiB chunks
Which I guess is less optimal than just using the block layer splitting? Maybe add a big fat comment explaining this?
Improving it looks straight forward, but then there is testing and checking the code for anything that might be assuming an sg element is not more than 64KiB.
However it doesn't seem to offer any benefit, so it is difficult to justify doing.
Jon Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Hi Adrian,
Quoted 11 lines · Adrian Hunter
Quoted 9 lines · Christoph Hellwig
Quoted 5 lines · Adrian Hunter
Quoted 3 lines
Hmm, I thought the conflusion was that it can be more, which is why you proposed to increase it if the
PAGE_SIZEis >= 64k. And based on Jon's report at least for his tegra setups it works with 64k.There is a workaround in that case to split to 32KiB chunks
Which I guess is less optimal than just using the block layer splitting? Maybe add a big fat comment explaining this?
Quoted 6 lines
Improving it looks straight forward, but then there is testing and checking the code for anything that might be assuming an sg element is not more than 64KiB.
However it doesn't seem to offer any benefit, so it is difficult to justify doing.
Did we come to any agreement on how to fix this?
Thanks
Jon
Signature · 1 line
nvpublic
Re: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
Quoted 9 lines · Jon Hunter
Quoted 6 lines
Improving it looks straight forward, but then there is testing and checking the code for anything that might be assuming an sg element is not more than 64KiB.
However it doesn't seem to offer any benefit, so it is difficult to justify doing.
Did we come to any agreement on how to fix this?
FYI, all I'm asking is to add a clear comment explaining setting a different value depending on the page size. Otherwise I'm ok with the patch from Adrian.
Jon Hunter
maintainerRe: [PATCH 17/17] mmc: pass queue_limits to blk_mq_alloc_disk
In reply to Adrian HunterQuoted 71 lines · Adrian Hunter
Quoted 52 lines · Jon Hunter
Quoted 36 lines · Christoph Hellwig
Quoted 6 lines · Jon Hunter
I have been testing on both Tegra194 and Tegra234. Both of these set the above quirk. This would explain why the
max_segment_sizeis rounded down to 65024 in themmc_alloc_disk()function.We can check if this is needed but if it is needed then it is not clear if/how this can be fixed?
The older kernels did this:
if (
max_size<PAGE_CACHE_SIZE) {max_size=PAGE_CACHE_SIZE;printk(KERN_INFO "%s: set to minimum %d\n", __func__, max_size);
}q->limits.max_segment_size =
max_size;so when these kernels actually worked despite the above warning it must be ok(-ish) to just increase this value. If that is best done by dropping the quirk, or changing the logic in
sdhci.cis something the maintainers that understand the hardware need to decide.The patch below gives you the pre-6.9 behavior just without the boot time warning, but it might not be what was intended by the quirk:
drivers/mmc/host/sdhci.c +0
-1@@ -4721,12 +4721,9 @@ int sdhci_setup_host(struct sdhci_host *host)* be larger than 64 KiB though. */ if (host->flags & SDHCI_USE_ADMA) { - if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) {drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4729
Quoted 10 lines
drivers/mmc/host/sdhci.c +2
-4+ if (host->quirks & SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC) host->max_adma = 65532; /* 32-bit alignment */ - mmc->max_seg_size = 65535; - } else { - mmc->max_seg_size = 65536; - } + mmc->max_seg_size = 65536; } else { mmc->max_seg_size = mmc->max_req_size; }As a quick test I removed the quirk for Tegra194 and that did work, which achieves the same thing as the above.
Quoted 6 lines
I guess there are two open questions here ...
1. Do we need the quirk for all the current Tegra devices? Thierry and I can confirm this.
2. For devices that need that quirk and use 64kB pages, what is the appropriate way to handle this for sdhci controllers?Probably just do what the block layer was doing e.g.
drivers/mmc/host/sdhci.c +0
-0@@ -4724,6 +4724,13 @@ int sdhci_setup_host(struct sdhci_host *host)if (host->quirks &SDHCI_QUIRK_BROKEN_ADMA_ZEROLEN_DESC ) { host->max_adma =65532 ;/* 32-bit alignment */ mmc->max_seg_size =65535 ;
drivers/mmc/host/sdhci.c int sdhci_setup_host(struct sdhci_host *host) · line 4736
Quoted 10 lines
drivers/mmc/host/sdhci.c +7
-0+/* +* Block layer cannot accept max_seg_size < PAGE_SIZE +* whereas sdhci_adma_table_pre() will anyway split the +* descriptor to handle size > max_adma. +*/ +if (mmc->max_seg_size <PAGE_SIZE ) + mmc->max_seg_size =PAGE_SIZE ; }else { mmc->max_seg_size =65536 ; }
I know that this is expected to work, but just wanted to confirm that this does work.
Jon
Signature · 1 line
nvpublic
Quoted 24 lines · Christoph Hellwig
this series converts all "simple" blk-mq drivers that don't have complex internal layering or other oddities to pass the
queue_limitstoblk_mq_alloc_disk. None of these drivers updates the limits at runtime.Diffstat:
arch/um/drivers/ubd_kern.c | 8 +- drivers/block/aoe/aoeblk.c | 15 ++--- drivers/block/floppy.c | 6 +- drivers/block/mtip32xx/mtip32xx.c | 13 ++-- drivers/block/nbd.c | 13 ++-- drivers/block/ps3disk.c | 17 +++--- drivers/block/rbd.c | 29 +++++----- drivers/block/rnbd/rnbd-clt.c | 64 +++++++++-------------- drivers/block/sunvdc.c | 18 +++--- drivers/block/ublk_drv.c | 90 +++++++++++++++------------------ drivers/cdrom/gdrom.c | 14 ++--- drivers/memstick/core/ms_block.c | 14 ++--- drivers/memstick/core/mspro_block.c | 15 ++--- drivers/mmc/core/queue.c | 97 +++++++++++++++++++----------------- drivers/mtd/mtd_blkdevs.c | 12 ++-- drivers/mtd/ubi/block.c | 6 +- drivers/s390/block/scm_blk.c | 17 +++--- 17 files changed, 222 insertions(+), 226 deletions(-)
Quoted 1 line
[...]
Applied, thanks!
[01/17] ubd: pass queue_limits to blk_mq_alloc_disk
commit: 5d6789ce33a97718564d0b8d2ea34e03d650e624
[02/17] aoe: pass queue_limits to blk_mq_alloc_disk
commit: 9999200f583107f7e244e50935d480433b7d8a3b
[03/17] floppy: pass queue_limits to blk_mq_alloc_disk
commit: 48bc8c7ba6fb39a4325b07f3abe8fe5a77361c7e
[04/17] mtip: pass queue_limits to blk_mq_alloc_disk
commit: 68c3135fb5fbd85c7b2ca851184f30f54433a9d3
[05/17] nbd: pass queue_limits to blk_mq_alloc_disk
commit: 9a0d4970288de29191fa45bf0ab4d8398bfa3a01
[06/17] ps3disk: pass queue_limits to blk_mq_alloc_disk
commit: a7f18b74dbe171625afc2751942a92f71a4dd4ba
[07/17] rbd: pass queue_limits to blk_mq_alloc_disk
commit: 24f30b770c0f450346f1c99120427b2e938cdfd0
[08/17] rnbd-clt: pass queue_limits to blk_mq_alloc_disk
commit: e6ed9892f10d7195d621ede1cedc41421f1ca607
[09/17] sunvdc: pass queue_limits to blk_mq_alloc_disk
commit: d0fa9a8b0af71b69cf3dec10feaebe19d55a72cf
[10/17] gdrom: pass queue_limits to blk_mq_alloc_disk
commit: a339cf2bbfbe6e16ead79276d608912d36065884
[11/17] ms_block: pass queue_limits to blk_mq_alloc_disk
commit: f93b43ae3feafedc5777099ca1a0e05352b92671
[12/17] mspro_block: pass queue_limits to blk_mq_alloc_disk
commit: 9f633ecd43046659e3345bc4a4404e1d2ba67463
[13/17] mtd_blkdevs: pass queue_limits to blk_mq_alloc_disk
commit: 3ec44e52bfce60f6da65165bc86eb382462d173d
[14/17] ubiblock: pass queue_limits to blk_mq_alloc_disk
commit: 21b700c0812b6aa8f794c36b971772b2b08dab9a
[15/17] scm_blk: pass queue_limits to blk_mq_alloc_disk
commit: 066be10aef5a7ddd8ad537db7a5145c6d79d4ea2
[16/17] ublk: pass queue_limits to blk_mq_alloc_disk
commit: 494ea040bcb5f4cc78c37dc53c7915752c24f739
[17/17] mmc: pass queue_limits to blk_mq_alloc_disk
commit: 616f8766179277324393f7b77e07f14cb3503825Best regards,
Signature · 1 line
Jens Axboe