queue_limits fixups and tidyups v2
Subsystems (5)
Hi Jens,
this series has a few fixes for the queue_limits conversion in the first few patches and then has a bunch more cleanups and improvements in that area.
Changes since v1:
- remove an incorrect use of a flag on the features field
- add a patch to switch to __bitwise annotations for features and flags
- update a commit log
Diffstat:
block/bio-integrity.c | 2 block/blk-map.c | 2 block/blk-settings.c | 46 +++++---------------- block/blk-sysfs.c | 9 ++-- block/blk.h | 2 block/genhd.c | 2 drivers/ata/libata-scsi.c | 3 - drivers/ata/pata_macio.c | 4 - drivers/md/md.c | 13 +++-- drivers/md/md.h | 1 drivers/md/raid0.c | 2 drivers/md/raid1.c | 2 drivers/md/raid10.c | 2 drivers/md/raid5.c | 2 drivers/scsi/scsi_lib.c | 4 - drivers/ufs/core/ufshcd.c | 9 ++-- include/linux/blkdev.h | 100 +++++++++++++++++++++++----------------------- 17 files changed, 96 insertions(+), 109 deletions(-)
PATCH 1/8 md: set md-specific flags for all queue limits
The md driver wants to enforce a number of flags to an all devices, even when not inheriting them from the underlying devices. To make sure these flags survive the queue_limits_set calls that md uses to update the queue limits without deriving them form the previous limits add a new md_init_stacking_limits helper that calls blk_set_stacking_limits and sets these flags.
--- drivers/md/md.c | 13 ++++++++----- drivers/md/md.h | 1 + drivers/md/raid0.c | 2 +- drivers/md/raid1.c | 2 +- drivers/md/raid10.c | 2 +- drivers/md/raid5.c | 2 +- 6 files changed, 13 insertions(+), 9 deletions(-)
drivers/md/md.c +8 -5
@@ -5853,6 +5853,13 @@ static void mddev_delayed_delete(struct work_struct *ws)kobject_put (&mddev->kobj); } +void md_init_stacking_limits (struct queue_limits *lim) +{ +blk_set_stacking_limits (lim); + lim->features =BLK_FEAT_WRITE_CACHE |BLK_FEAT_FUA | +BLK_FEAT_IO_STAT |BLK_FEAT_NOWAIT ; +} +struct mddev *md_alloc (dev_t dev,char *name) {/*
@@ -5871,10 +5878,6 @@ struct mddev *md_alloc(dev_t dev, char *name)int shift;int unit;int error; -struct queue_limits lim = { - .features =BLK_FEAT_WRITE_CACHE |BLK_FEAT_FUA | -BLK_FEAT_IO_STAT |BLK_FEAT_NOWAIT , - };/* * Wait for any previous instance of this device to be completely
@@ -5914,7 +5917,7 @@ struct mddev *md_alloc(dev_t dev, char *name)*/ mddev->hold_active =UNTIL_STOP ; - disk =blk_alloc_disk (&lim,NUMA_NO_NODE ); + disk =blk_alloc_disk (NULL ,NUMA_NO_NODE );if (IS_ERR (disk)) { error =PTR_ERR (disk); goto out_free_mddev;
drivers/md/md.h +1 -0
@@ -893,6 +893,7 @@ extern int strict_strtoul_scaled(const char *cp, unsigned long *res, int scale);extern int mddev_init (struct mddev *mddev);extern void mddev_destroy (struct mddev *mddev); +void md_init_stacking_limits (struct queue_limits *lim);struct mddev *md_alloc (dev_t dev,char *name);void mddev_put (struct mddev *mddev);extern int md_run (struct mddev *mddev);
drivers/md/raid0.c +1 -1
@@ -379,7 +379,7 @@ static int raid0_set_limits(struct mddev *mddev)struct queue_limits lim;int err; -blk_set_stacking_limits (&lim); +md_init_stacking_limits (&lim); lim.max_hw_sectors = mddev->chunk_sectors; lim.max_write_zeroes_sectors = mddev->chunk_sectors; lim.io_min = mddev->chunk_sectors <<9 ;
drivers/md/raid1.c +1 -1
@@ -3194,7 +3194,7 @@ static int raid1_set_limits(struct mddev *mddev)struct queue_limits lim;int err; -blk_set_stacking_limits (&lim); +md_init_stacking_limits (&lim); lim.max_write_zeroes_sectors =0 ; err =mddev_stack_rdev_limits (mddev, &lim,MDDEV_STACK_INTEGRITY );if (err) {
drivers/md/raid10.c +1 -1
@@ -3974,7 +3974,7 @@ static int raid10_set_queue_limits(struct mddev *mddev)struct queue_limits lim;int err; -blk_set_stacking_limits (&lim); +md_init_stacking_limits (&lim); lim.max_write_zeroes_sectors =0 ; lim.io_min = mddev->chunk_sectors <<9 ; lim.io_opt = lim.io_min *raid10_nr_stripes (conf);
drivers/md/raid5.c +1 -1
@@ -7708,7 +7708,7 @@ static int raid5_set_limits(struct mddev *mddev)*/ stripe =roundup_pow_of_two (data_disks * (mddev->chunk_sectors <<9 )); -blk_set_stacking_limits (&lim); +md_init_stacking_limits (&lim); lim.io_min = mddev->chunk_sectors <<9 ; lim.io_opt = lim.io_min * (conf->raid_disks - conf->max_degraded); lim.features |=BLK_FEAT_RAID_PARTIAL_STRIPES_EXPENSIVE ;
Signature · 1 line
2.43.0
Re: [PATCH 1/8] md: set md-specific flags for all queue limits
Quoted 1 line · Christoph Hellwig
The md driver wants to enforce a number of flags to an all devices, even
s/to an/for
Quoted 9 lines
when not inheriting them from the underlying devices. To make sure these flags survive the
queue_limits_setcalls that md uses to update the queue limits without deriving them form the previous limits add a newmd_init_stacking_limitshelper that callsblk_set_stacking_limitsand sets these flags.Fixes 1122c0c1cc71 ("block: move cache control settings out of queue->flags")Reported-by kernel test robot <[email protected]>Signed-off-by Christoph Hellwig <[email protected]>
Other than the above nit, looks good to me.
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 2/8 block: correctly report cache type
In reply to Christoph HellwigCheck the features flag and the override flag, otherwise we're going to always report "write through".
--- block/blk-sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
block/blk-sysfs.c +2 -1
@@ -453,7 +453,8 @@ static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,static ssize_t queue_wc_show (struct request_queue *q,char *page) { -if (q->limits.features &BLK_FLAG_WRITE_CACHE_DISABLED ) +if (!(q->limits.features &BLK_FEAT_WRITE_CACHE ) || + (q->limits.flags &BLK_FLAG_WRITE_CACHE_DISABLED ))return sprintf (page,"write through\n" );return sprintf (page,"write back\n" ); }
Signature · 1 line
2.43.0
Re: [PATCH 2/8] block: correctly report cache type
Quoted 5 lines · Christoph Hellwig
Check the features flag and the override flag, otherwise we're going to always report "write through".
Fixes 1122c0c1cc71 ("block: move cache control settings out of queue->flags")Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 2/8] block: correctly report cache type
In reply to Christoph HellwigQuoted 14 lines · Christoph Hellwig
Check the features flag and the override flag, otherwise we're going to always report "write through".
Fixes 1122c0c1cc71 ("block: move cache control settings out of queue->flags")Signed-off-by Christoph Hellwig <[email protected]>--- block/blk-sysfs.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)block/blk-sysfs.c +0
-0
block/blk-sysfs.c static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page, · line 457
Quoted 6 lines
block/blk-sysfs.c +2
-1@@ -453,7 +453,8 @@ static ssize_t queue_io_timeout_store(struct request_queue *q, const char *page,static ssize_t queue_wc_show (struct request_queue *q,char *page) { -if (q->limits.features &BLK_FLAG_WRITE_CACHE_DISABLED ) +if (!(q->limits.features &BLK_FEAT_WRITE_CACHE ) || + (q->limits.flags &BLK_FLAG_WRITE_CACHE_DISABLED ))
Could you use blk_queue_write_cache() helper here to reduce duplication?
Quoted 3 lines
block/blk-sysfs.c +0
-0return sprintf (page,"write through\n" );return sprintf (page,"write back\n" ); }
PATCH 3/8 block: rename BLK_FLAG_MISALIGNED
In reply to Christoph HellwigThis is a flag for ->flags and not a feature for ->features. And fix the one place that actually incorrectly cleared it from ->features.
--- block/blk-settings.c | 18 +++++++++--------- include/linux/blkdev.h | 2 +- 2 files changed, 10 insertions(+), 10 deletions(-)
block/blk-settings.c +9 -9
@@ -351,7 +351,7 @@ static int blk_validate_limits(struct queue_limits *lim)if (lim->alignment_offset) { lim->alignment_offset &= (lim->physical_block_size -1 ); - lim->features &= ~BLK_FEAT_MISALIGNED ; + lim->flags &= ~BLK_FLAG_MISALIGNED ; }if (!(lim->features &BLK_FEAT_WRITE_CACHE ))
@@ -564,7 +564,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,if (!(b->features &BLK_FEAT_POLL )) t->features &= ~BLK_FEAT_POLL ; - t->flags |= (b->flags &BLK_FEAT_MISALIGNED ); + t->flags |= (b->flags &BLK_FLAG_MISALIGNED ); t->max_sectors =min_not_zero (t->max_sectors, b->max_sectors); t->max_user_sectors = min_not_zero(t->max_user_sectors,
@@ -603,7 +603,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,/* Verify that top and bottom intervals line up */ if (max (top, bottom) %min (top, bottom)) { - t->flags |=BLK_FEAT_MISALIGNED ; + t->flags |=BLK_FLAG_MISALIGNED ; ret =-1 ; } }
@@ -625,28 +625,28 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,/* Physical block size a multiple of the logical block size? */ if (t->physical_block_size & (t->logical_block_size -1 )) { t->physical_block_size = t->logical_block_size; - t->flags |=BLK_FEAT_MISALIGNED ; + t->flags |=BLK_FLAG_MISALIGNED ; ret =-1 ; }/* Minimum I/O a multiple of the physical block size? */ if (t->io_min & (t->physical_block_size -1 )) { t->io_min = t->physical_block_size; - t->flags |=BLK_FEAT_MISALIGNED ; + t->flags |=BLK_FLAG_MISALIGNED ; ret =-1 ; }/* Optimal I/O a multiple of the physical block size? */ if (t->io_opt & (t->physical_block_size -1 )) { t->io_opt =0 ; - t->flags |=BLK_FEAT_MISALIGNED ; + t->flags |=BLK_FLAG_MISALIGNED ; ret =-1 ; }/* chunk_sectors a multiple of the physical block size? */ if ((t->chunk_sectors <<9 ) & (t->physical_block_size -1 )) { t->chunk_sectors =0 ; - t->flags |=BLK_FEAT_MISALIGNED ; + t->flags |=BLK_FLAG_MISALIGNED ; ret =-1 ; }
@@ -656,7 +656,7 @@ int blk_stack_limits(struct queue_limits *t, struct queue_limits *b,/* Verify that new alignment_offset is on a logical block boundary */ if (t->alignment_offset & (t->logical_block_size -1 )) { - t->flags |=BLK_FEAT_MISALIGNED ; + t->flags |=BLK_FLAG_MISALIGNED ; ret =-1 ; }
@@ -809,7 +809,7 @@ int bdev_alignment_offset(struct block_device *bdev) {struct request_queue *q =bdev_get_queue (bdev); -if (q->limits.flags &BLK_FEAT_MISALIGNED ) +if (q->limits.flags &BLK_FLAG_MISALIGNED )return -1 ;if (bdev_is_partition (bdev)) return queue_limit_alignment_offset(&q->limits,
include/linux/blkdev.h +1 -1
@@ -347,7 +347,7 @@ enum {BLK_FLAG_WRITE_CACHE_DISABLED = (1u <<0 ),/* I/O topology is misaligned */ - BLK_FEAT_MISALIGNED = (1u << 1), + BLK_FLAG_MISALIGNED = (1u << 1), }; struct queue_limits {
Signature · 1 line
2.43.0
Re: [PATCH 3/8] block: rename BLK_FLAG_MISALIGNED
Quoted 4 lines · Christoph Hellwig
This is a flag for ->flags and not a feature for ->features. And fix the one place that actually incorrectly cleared it from ->features.
Signed-off-by Christoph Hellwig <[email protected]>
I think the patch title should be "rename BLK_FEAT_MISALIGNED", but not a big deal.
Signature · 2 lines
Damien Le Moal Western Digital Research
Re: [PATCH 3/8] block: rename BLK_FLAG_MISALIGNED
In reply to Christoph HellwigPATCH 4/8 block: convert features and flags to __bitwise types
In reply to Christoph Hellwig... and let sparse help us catch mismatches or abuses.
--- block/blk-sysfs.c | 6 +-- include/linux/blkdev.h | 85 +++++++++++++++++++++--------------------- 2 files changed, 46 insertions(+), 45 deletions(-)
block/blk-sysfs.c +3 -3
@@ -288,7 +288,7 @@ static ssize_t queue_dma_alignment_show(struct request_queue *q, char *page) }static ssize_t queue_feature_store (struct request_queue *q,const char *page, -size_t count,unsigned int feature) +size_t count,blk_features_t feature) {struct queue_limits lim;unsigned long val;
@@ -418,7 +418,7 @@ static ssize_t queue_poll_delay_store(struct request_queue *q, const char *page,static ssize_t queue_poll_show (struct request_queue *q,char *page) { -return queue_var_show (q->limits.features &BLK_FEAT_POLL , page); +return queue_var_show (!!(q->limits.features &BLK_FEAT_POLL ), page); } static ssize_t queue_poll_store(struct request_queue *q, const char *page,
@@ -493,7 +493,7 @@ static ssize_t queue_fua_show(struct request_queue *q, char *page)static ssize_t queue_dax_show (struct request_queue *q,char *page) { -return queue_var_show (blk_queue_dax (q), page); +return queue_var_show (!!blk_queue_dax (q), page); }#define QUEUE_RO_ENTRY (_prefix, _name) \
include/linux/blkdev.h +43 -42
115 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 4/8] block: convert features and flags to __bitwise types
Quoted 3 lines · Christoph Hellwig
... and let sparse help us catch mismatches or abuses.
Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 5/8 block: conding style fixup for blk_queue_max_guaranteed_bio
In reply to Christoph Hellwig"static" never goes on a line of its own.
--- block/blk-settings.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
block/blk-settings.c +1 -2
@@ -142,8 +142,7 @@ static int blk_validate_integrity_limits(struct queue_limits *lim)* so we assume that we can fit in at least PAGE_SIZE in a segment, apart from * the first and last segments. */ -static -unsigned int blk_queue_max_guaranteed_bio (struct queue_limits *lim) +static unsigned int blk_queue_max_guaranteed_bio (struct queue_limits *lim) {unsigned int max_segments =min (BIO_MAX_VECS , lim->max_segments);unsigned int length;
Signature · 1 line
2.43.0
Re: [PATCH 5/8] block: conding style fixup for blk_queue_max_guaranteed_bio
Quoted 4 lines · Christoph Hellwig
"static" never goes on a line of its own.
Signed-off-by Christoph Hellwig <[email protected]>Reviewed-by John Garry <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 6/8 block: remove disk_update_readahead
In reply to Christoph HellwigMark blk_apply_bdi_limits non-static and open code disk_update_readahead in the only caller.
--- block/blk-settings.c | 8 +------- block/blk.h | 2 ++ block/genhd.c | 2 +- include/linux/blkdev.h | 1 - 4 files changed, 4 insertions(+), 9 deletions(-)
block/blk-settings.c +1 -7
@@ -55,7 +55,7 @@ void blk_set_stacking_limits(struct queue_limits *lim) }EXPORT_SYMBOL (blk_set_stacking_limits); -static void blk_apply_bdi_limits (struct backing_dev_info *bdi, +void blk_apply_bdi_limits (struct backing_dev_info *bdi,struct queue_limits *lim) {/*
@@ -434,12 +434,6 @@ int queue_limits_set(struct request_queue *q, struct queue_limits *lim) }EXPORT_SYMBOL_GPL (queue_limits_set); -void disk_update_readahead (struct gendisk *disk) -{ -blk_apply_bdi_limits (disk->bdi, &disk->queue->limits); -} -EXPORT_SYMBOL_GPL (disk_update_readahead); -/** * blk_limits_io_min - set minimum request size for a device * @limits: the queue limits
block/blk.h +2 -0
@@ -358,6 +358,8 @@ bool blk_rq_merge_ok(struct request *rq, struct bio *bio);enum elv_merge blk_try_merge (struct request *rq,struct bio *bio);int blk_set_default_limits (struct queue_limits *lim); +void blk_apply_bdi_limits (struct backing_dev_info *bdi, +struct queue_limits *lim);int blk_dev_init (void );/*
block/genhd.c +1 -1
@@ -524,7 +524,7 @@ int __must_check device_add_disk(struct device *parent, struct gendisk *disk, disk->part0->bd_dev =MKDEV (disk->major, disk->first_minor); } -disk_update_readahead (disk); +blk_apply_bdi_limits (disk->bdi, &disk->queue->limits);disk_add_events (disk);set_bit (GD_ADDED , &disk->state);return 0 ;
include/linux/blkdev.h +0 -1
@@ -973,7 +973,6 @@ static inline void blk_queue_disable_write_zeroes(struct request_queue *q)/* * Access functions for manipulating queue properties */ -void disk_update_readahead (struct gendisk *disk);extern void blk_limits_io_min (struct queue_limits *limits,unsigned int min);extern void blk_limits_io_opt (struct queue_limits *limits,unsigned int opt);extern void blk_set_queue_depth (struct request_queue *q,unsigned int depth);
Signature · 1 line
2.43.0
Re: [PATCH 6/8] block: remove disk_update_readahead
Quoted 4 lines · Christoph Hellwig
Mark
blk_apply_bdi_limitsnon-static and open codedisk_update_readaheadin the only caller.Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 7/8 block: remove the fallback case in queue_dma_alignment
In reply to Christoph HellwigNow that all updates go through blk_validate_limits the default of 511 is set at initialization time. Also remove the unused NULL check as calling this helper on a NULL queue can't happen (and doesn't make much sense to start with).
--- include/linux/blkdev.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
include/linux/blkdev.h +1 -1
@@ -1394,7 +1394,7 @@ static inline bool bdev_is_zone_start(struct block_device *bdev,static inline int queue_dma_alignment (const struct request_queue *q) { -return q ? q->limits.dma_alignment :511 ; +return q->limits.dma_alignment; } static inline unsigned int
Signature · 1 line
2.43.0
Re: [PATCH 7/8] block: remove the fallback case in queue_dma_alignment
Quoted 6 lines · Christoph Hellwig
Now that all updates go through
blk_validate_limitsthe default of 511 is set at initialization time. Also remove the unused NULL check as calling this helper on a NULL queue can't happen (and doesn't make much sense to start with).Signed-off-by Christoph Hellwig<[email protected]>
Re: [PATCH 7/8] block: remove the fallback case in queue_dma_alignment
In reply to Christoph HellwigQuoted 6 lines · Christoph Hellwig
Now that all updates go through
blk_validate_limitsthe default of 511 is set at initialization time. Also remove the unused NULL check as calling this helper on a NULL queue can't happen (and doesn't make much sense to start with).Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research
PATCH 8/8 block: move dma_pad_mask into queue_limits
In reply to Christoph Hellwigdma_pad_mask is a queue_limits by all ways of looking at it, so move it there and set it through the atomic queue limits APIs.
Add a little helper that takes the alignment and pad into account to simply the code that is touched a bit.
Note that there never was any need for the > check in blk_queue_update_dma_pad, this probably was just copy and paste from dma_update_dma_alignment.
--- block/bio-integrity.c | 2 +- block/blk-map.c | 2 +- block/blk-settings.c | 17 ----------------- drivers/ata/libata-scsi.c | 3 +-- drivers/ata/pata_macio.c | 4 ++-- drivers/scsi/scsi_lib.c | 4 ++-- drivers/ufs/core/ufshcd.c | 9 +++++---- include/linux/blkdev.h | 12 ++++++++---- 8 files changed, 20 insertions(+), 33 deletions(-)
block/bio-integrity.c +1 -1
@@ -312,7 +312,7 @@ int bio_integrity_map_user(struct bio *bio, void __user *ubuf, ssize_t bytes, u32 seed) {struct request_queue *q =bdev_get_queue (bio->bi_bdev); -unsigned int align = q->dma_pad_mask |queue_dma_alignment (q); +unsigned int align =blk_lim_dma_alignment_and_pad (&q->limits);struct page *stack_pages[UIO_FASTIOV ], **pages = stack_pages;struct bio_vec stack_vec[UIO_FASTIOV ], *bvec = stack_vec;unsigned int direction, nr_bvecs;
block/blk-map.c +1 -1
@@ -634,7 +634,7 @@ int blk_rq_map_user_iov(struct request_queue *q, struct request *rq, const struct iov_iter *iter, gfp_t gfp_mask) { bool copy = false, map_bvec = false; -unsigned long align = q->dma_pad_mask |queue_dma_alignment (q); +unsigned long align =blk_lim_dma_alignment_and_pad (&q->limits);struct bio *bio =NULL ;struct iov_iter i;int ret = -EINVAL ;
block/blk-settings.c +0 -17
@@ -768,23 +768,6 @@ bool queue_limits_stack_integrity(struct queue_limits *t, }EXPORT_SYMBOL_GPL (queue_limits_stack_integrity); -/** -* blk_queue_update_dma_pad - update pad mask -* @q: the request queue for the device -* @mask: pad mask -* -* Update dma pad mask. -* -* Appending pad buffer to a request modifies the last entry of a -* scatter list such that it includes the pad buffer. -**/ -void blk_queue_update_dma_pad (struct request_queue *q,unsigned int mask) -{ -if (mask > q->dma_pad_mask) - q->dma_pad_mask = mask; -} -EXPORT_SYMBOL (blk_queue_update_dma_pad); -/** * blk_set_queue_depth - tell the block layer about the device queue depth * @q: the request queue for the device
drivers/ata/libata-scsi.c +1 -2
@@ -1024,7 +1024,6 @@ EXPORT_SYMBOL_GPL(ata_scsi_dma_need_drain);int ata_scsi_dev_config (struct scsi_device *sdev,struct queue_limits *lim,struct ata_device *dev) { -struct request_queue *q = sdev->request_queue;int depth =1 ;if (!ata_id_has_unload (dev->id))
@@ -1038,7 +1037,7 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct queue_limits *lim, sdev->sector_size =ATA_SECT_SIZE ;/* set DMA padding */ -blk_queue_update_dma_pad (q,ATA_DMA_PAD_SZ -1 ); + lim->dma_pad_mask =ATA_DMA_PAD_SZ -1 ;/* make room for appending the drain */ lim->max_segments--;
drivers/ata/pata_macio.c +2 -2
@@ -816,7 +816,7 @@ static int pata_macio_device_configure(struct scsi_device *sdev,/* OHare has issues with non cache aligned DMA on some chipsets */ if (priv->kind == controller_ohare) { lim->dma_alignment =31 ; -blk_queue_update_dma_pad (sdev->request_queue,31 ); + lim->dma_pad_mask =31 ;/* Tell the world about it */ ata_dev_info (dev,"OHare alignment limits applied\n" );
@@ -831,7 +831,7 @@ static int pata_macio_device_configure(struct scsi_device *sdev,if (priv->kind == controller_sh_ata6 || priv->kind == controller_k2_ata6) {/* Allright these are bad, apply restrictions */ lim->dma_alignment =15 ; -blk_queue_update_dma_pad (sdev->request_queue,15 ); + lim->dma_pad_mask =15 ;/* We enable MWI and hack cache line size directly here, this * is specific to this chipset and not normal values, we happen
drivers/scsi/scsi_lib.c +2 -2
@@ -1139,9 +1139,9 @@ blk_status_t scsi_alloc_sgtables(struct scsi_cmnd *cmd)*/ count =__blk_rq_map_sg (rq->q, rq, cmd->sdb.table.sgl, &last_sg); -if (blk_rq_bytes (rq) & rq->q->dma_pad_mask) { +if (blk_rq_bytes (rq) & rq->q->limits.dma_pad_mask) {unsigned int pad_len = - (rq->q->dma_pad_mask & ~blk_rq_bytes (rq)) +1 ; + (rq->q->limits.dma_pad_mask & ~blk_rq_bytes (rq)) +1 ; last_sg->length += pad_len; cmd->extra_len += pad_len;
drivers/ufs/core/ufshcd.c +5 -4
@@ -5193,17 +5193,18 @@ static int ufshcd_change_queue_depth(struct scsi_device *sdev, int depth) }/** -* ufshcd_slave_configure - adjust SCSI device configurations +* ufshcd_device_configure - adjust SCSI device configurations * @sdev: pointer to SCSI device * * Return: 0 (success). */ -static int ufshcd_slave_configure (struct scsi_device *sdev) +static int ufshcd_device_configure (struct scsi_device *sdev, +struct queue_limits *lim) {struct ufs_hba *hba =shost_priv (sdev->host);struct request_queue *q = sdev->request_queue; -blk_queue_update_dma_pad (q,PRDT_DATA_BYTE_COUNT_PAD -1 ); + lim->dma_pad_mask =PRDT_DATA_BYTE_COUNT_PAD -1 ;/* * Block runtime-pm until all consumers are added.
@@ -8907,7 +8908,7 @@ static const struct scsi_host_template ufshcd_driver_template = { .queuecommand = ufshcd_queuecommand, .mq_poll = ufshcd_poll, .slave_alloc = ufshcd_slave_alloc, - .slave_configure = ufshcd_slave_configure, + .device_configure = ufshcd_device_configure, .slave_destroy = ufshcd_slave_destroy, .change_queue_depth = ufshcd_change_queue_depth, .eh_abort_handler = ufshcd_abort,
include/linux/blkdev.h +8 -4
@@ -401,6 +401,7 @@ struct queue_limits {* due to possible offsets. */ unsigned int dma_alignment; +unsigned int dma_pad_mask;struct blk_integrity integrity; };
@@ -509,8 +510,6 @@ struct request_queue {*/ int id; -unsigned int dma_pad_mask; -/* * queue settings */
@@ -981,7 +980,6 @@ extern int blk_stack_limits(struct queue_limits *t, struct queue_limits *b, sector_t offset);void queue_limits_stack_bdev (struct queue_limits *t,struct block_device *bdev,sector_t offset,const char *pfx); -extern void blk_queue_update_dma_pad (struct request_queue *,unsigned int );extern void blk_queue_rq_timeout (struct request_queue *,unsigned int ); struct blk_independent_access_ranges *
@@ -1433,10 +1431,16 @@ static inline bool bdev_iter_is_aligned(struct block_device *bdev, bdev_logical_block_size(bdev) - 1); } +static inline int blk_lim_dma_alignment_and_pad (struct queue_limits *lim) +{ +return lim->dma_alignment | lim->dma_pad_mask; +} +static inline int blk_rq_aligned (struct request_queue *q,unsigned long addr,unsigned int len) { -unsigned int alignment =queue_dma_alignment (q) | q->dma_pad_mask; +unsigned int alignment =blk_lim_dma_alignment_and_pad (&q->limits); +return !(addr & alignment) && !(len & alignment); }
Signature · 1 line
2.43.0
Re: [PATCH 8/8] block: move dma_pad_mask into queue_limits
Quoted 5 lines · Christoph Hellwig
dma_pad_maskis aqueue_limitsby all ways of looking at it, so move it there and set it through the atomic queue limits APIs.Add a little helper that takes the alignment and pad into account to simply the code that is touched a bit.
s/simply/simplify
Quoted 5 lines
Note that there never was any need for the > check in
blk_queue_update_dma_pad, this probably was just copy and paste fromdma_update_dma_alignment.Signed-off-by Christoph Hellwig <[email protected]>
Signature · 2 lines
Damien Le Moal Western Digital Research