diff mbox series

[7/7] block: move dma_pad_mask into queue_limits

Message ID 20240625110603.50885-8-hch@lst.de
State New
Headers show
Series [1/7] md: set md-specific flags for all queue limits | expand

Commit Message

Christoph Hellwig June 25, 2024, 11:05 a.m. UTC
dma_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.

Signed-off-by: Christoph Hellwig <hch@lst.de>
---
 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(-)

Comments

kernel test robot June 26, 2024, 4:44 a.m. UTC | #1
Hi Christoph,

kernel test robot noticed the following build warnings:

[auto build test WARNING on axboe-block/for-next]
[also build test WARNING on next-20240625]
[cannot apply to linus/master v6.10-rc5]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch#_base_tree_information]

url:    https://github.com/intel-lab-lkp/linux/commits/Christoph-Hellwig/block-correctly-report-cache-type/20240626-012117
base:   https://git.kernel.org/pub/scm/linux/kernel/git/axboe/linux-block.git for-next
patch link:    https://lore.kernel.org/r/20240625110603.50885-8-hch%40lst.de
patch subject: [PATCH 7/7] block: move dma_pad_mask into queue_limits
config: i386-buildonly-randconfig-002-20240626 (https://download.01.org/0day-ci/archive/20240626/202406261229.rnOxqhqJ-lkp@intel.com/config)
compiler: gcc-8 (Ubuntu 8.4.0-3ubuntu2) 8.4.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240626/202406261229.rnOxqhqJ-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202406261229.rnOxqhqJ-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/ufs/core/ufshcd.c:5203: warning: Function parameter or struct member 'lim' not described in 'ufshcd_device_configure'


vim +5203 drivers/ufs/core/ufshcd.c

4264fd613a6a4b drivers/scsi/ufs/ufshcd.c Sujit Reddy Thumma 2014-06-29  5194  
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5195  /**
95ea953ed86260 drivers/ufs/core/ufshcd.c Christoph Hellwig  2024-06-25  5196   * ufshcd_device_configure - adjust SCSI device configurations
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5197   * @sdev: pointer to SCSI device
fd4bffb54dc0f6 drivers/ufs/core/ufshcd.c Bart Van Assche    2023-07-27  5198   *
fd4bffb54dc0f6 drivers/ufs/core/ufshcd.c Bart Van Assche    2023-07-27  5199   * Return: 0 (success).
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5200   */
95ea953ed86260 drivers/ufs/core/ufshcd.c Christoph Hellwig  2024-06-25  5201  static int ufshcd_device_configure(struct scsi_device *sdev,
95ea953ed86260 drivers/ufs/core/ufshcd.c Christoph Hellwig  2024-06-25  5202  		struct queue_limits *lim)
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01 @5203  {
49615ba144a092 drivers/scsi/ufs/ufshcd.c Stanley Chu        2019-09-16  5204  	struct ufs_hba *hba = shost_priv(sdev->host);
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5205  	struct request_queue *q = sdev->request_queue;
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5206  
95ea953ed86260 drivers/ufs/core/ufshcd.c Christoph Hellwig  2024-06-25  5207  	lim->dma_pad_mask = PRDT_DATA_BYTE_COUNT_PAD - 1;
858231bdb22391 drivers/ufs/core/ufshcd.c Bart Van Assche    2023-09-21  5208  
b294ff3e34490f drivers/scsi/ufs/ufshcd.c Asutosh Das        2021-04-23  5209  	/*
b294ff3e34490f drivers/scsi/ufs/ufshcd.c Asutosh Das        2021-04-23  5210  	 * Block runtime-pm until all consumers are added.
b294ff3e34490f drivers/scsi/ufs/ufshcd.c Asutosh Das        2021-04-23  5211  	 * Refer ufshcd_setup_links().
b294ff3e34490f drivers/scsi/ufs/ufshcd.c Asutosh Das        2021-04-23  5212  	 */
b294ff3e34490f drivers/scsi/ufs/ufshcd.c Asutosh Das        2021-04-23  5213  	if (is_device_wlun(sdev))
b294ff3e34490f drivers/scsi/ufs/ufshcd.c Asutosh Das        2021-04-23  5214  		pm_runtime_get_noresume(&sdev->sdev_gendev);
b294ff3e34490f drivers/scsi/ufs/ufshcd.c Asutosh Das        2021-04-23  5215  	else if (ufshcd_is_rpm_autosuspend_allowed(hba))
49615ba144a092 drivers/scsi/ufs/ufshcd.c Stanley Chu        2019-09-16  5216  		sdev->rpm_autosuspend = 1;
71bb9ab6e3511b drivers/scsi/ufs/ufshcd.c Adrian Hunter      2022-02-28  5217  	/*
71bb9ab6e3511b drivers/scsi/ufs/ufshcd.c Adrian Hunter      2022-02-28  5218  	 * Do not print messages during runtime PM to avoid never-ending cycles
71bb9ab6e3511b drivers/scsi/ufs/ufshcd.c Adrian Hunter      2022-02-28  5219  	 * of messages written back to storage by user space causing runtime
71bb9ab6e3511b drivers/scsi/ufs/ufshcd.c Adrian Hunter      2022-02-28  5220  	 * resume, causing more messages and so on.
71bb9ab6e3511b drivers/scsi/ufs/ufshcd.c Adrian Hunter      2022-02-28  5221  	 */
71bb9ab6e3511b drivers/scsi/ufs/ufshcd.c Adrian Hunter      2022-02-28  5222  	sdev->silence_suspend = 1;
49615ba144a092 drivers/scsi/ufs/ufshcd.c Stanley Chu        2019-09-16  5223  
cb77cb5abe1f4f drivers/scsi/ufs/ufshcd.c Eric Biggers       2021-10-18  5224  	ufshcd_crypto_register(hba, q);
df043c745ea149 drivers/scsi/ufs/ufshcd.c Satya Tangirala    2020-07-06  5225  
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5226  	return 0;
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5227  }
eeda47499f0187 drivers/scsi/ufs/ufshcd.c Akinobu Mita       2014-07-01  5228
diff mbox series

Patch

diff --git a/block/bio-integrity.c b/block/bio-integrity.c
index 173ffd4d623788..356ca0d3d62f5a 100644
--- a/block/bio-integrity.c
+++ b/block/bio-integrity.c
@@ -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;
diff --git a/block/blk-map.c b/block/blk-map.c
index 71210cdb34426d..bce144091128f6 100644
--- a/block/blk-map.c
+++ b/block/blk-map.c
@@ -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;
diff --git a/block/blk-settings.c b/block/blk-settings.c
index 5f1c22881cb9d8..256b1ff3ad432a 100644
--- a/block/blk-settings.c
+++ b/block/blk-settings.c
@@ -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
diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c
index cdf29b178ddc1e..682971c4cbe418 100644
--- a/drivers/ata/libata-scsi.c
+++ b/drivers/ata/libata-scsi.c
@@ -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--;
diff --git a/drivers/ata/pata_macio.c b/drivers/ata/pata_macio.c
index 3cb455a32d9266..1b85e8bf4ef91b 100644
--- a/drivers/ata/pata_macio.c
+++ b/drivers/ata/pata_macio.c
@@ -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
diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c
index e2f7bfb2b9e450..3958a6d14bf457 100644
--- a/drivers/scsi/scsi_lib.c
+++ b/drivers/scsi/scsi_lib.c
@@ -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;
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 0cf07194bbe89d..62d20eef13537d 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -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,
diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h
index d93fba7a1f3162..4be5b9d9773190 100644
--- a/include/linux/blkdev.h
+++ b/include/linux/blkdev.h
@@ -400,6 +400,7 @@  struct queue_limits {
 	 * due to possible offsets.
 	 */
 	unsigned int		dma_alignment;
+	unsigned int		dma_pad_mask;
 
 	struct blk_integrity	integrity;
 };
@@ -508,8 +509,6 @@  struct request_queue {
 	 */
 	int			id;
 
-	unsigned int		dma_pad_mask;
-
 	/*
 	 * queue settings
 	 */
@@ -980,7 +979,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 *
@@ -1432,10 +1430,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);
 }