Skip to contentSkip to conversation

scsi: ufs: ufs-mediatek: configure individual LU queue flags

PATCH Applied [email protected] 4 participants 5 messages Oct 8, 2024 – Nov 14, 2024

Subsystems (4)

v1 of 2 Applied Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 scsi: ufs: ufs-mediatek: configure individual LU queue flags

From: Ed Tsai <[email protected]>

Previously, ufs vops config_scsi_dev was removed because there were no users. ufs-mediatek needs it to configure the queue flags for each LU individually. Therefore, bring it back and customize the queue flag as we required.

---
 drivers/ufs/core/ufshcd.c       |  3 +++
 drivers/ufs/host/ufs-mediatek.c | 10 ++++++++++
 include/ufs/ufshcd.h            |  1 +
 3 files changed, 14 insertions(+)
drivers/ufs/core/ufshcd.c +3 -0
index 7cab103112e1..be50b86269bf 100644
@@ -5253,6 +5253,9 @@ static int ufshcd_device_configure(struct scsi_device *sdev,
 	 */
 	sdev->silence_suspend = 1;
 
+	if (hba->vops && hba->vops->config_scsi_dev)
+		hba->vops->config_scsi_dev(sdev);
+
 	ufshcd_crypto_register(hba, q);
 
 	return 0;
drivers/ufs/host/ufs-mediatek.c +10 -0
index 9a5919434c4e..0b57623edca5 100644
@@ -1780,6 +1780,15 @@ static int ufs_mtk_config_esi(struct ufs_hba *hba)
 	return ufs_mtk_config_mcq(hba, true);
 }
 
+static void ufs_mtk_config_scsi_dev(struct scsi_device *sdev)
+{
+	struct ufs_hba *hba = shost_priv(sdev->host);
+
+	dev_dbg(hba->dev, "lu %llu scsi device configured", sdev->lun);
+	if (sdev->lun == 2)
+		blk_queue_flag_set(QUEUE_FLAG_SAME_FORCE, sdev->reqeust_queue);
+}
+
 /*
  * struct ufs_hba_mtk_vops - UFS MTK specific variant operations
  *
@@ -1809,6 +1818,7 @@ static const struct ufs_hba_variant_ops ufs_hba_mtk_vops = {
 	.op_runtime_config   = ufs_mtk_op_runtime_config,
 	.mcq_config_resource = ufs_mtk_mcq_config_resource,
 	.config_esi          = ufs_mtk_config_esi,
+	.config_scsi_dev     = ufs_mtk_config_scsi_dev,
 };
 
 /**
include/ufs/ufshcd.h +1 -0
index a95282b9f743..800d79dc91fc 100644
@@ -383,6 +383,7 @@ struct ufs_hba_variant_ops {
 	int	(*get_outstanding_cqs)(struct ufs_hba *hba,
 				       unsigned long *ocqs);
 	int	(*config_esi)(struct ufs_hba *hba);
+	void	(*config_scsi_dev)(struct scsi_device *sdev);
 };
 
 /* clock gating state  */
Signature · 1 line
2.45.2
#1 lore raw

drivers/ufs/host/ufs-mediatek.c static int ufs_mtk_config_esi(struct ufs_hba *hba) · line 1790

Quoted 8 lines · On 10/7/24 11:59 PM, [email protected] wrote:
drivers/ufs/host/ufs-mediatek.c +8 -0
+static void ufs_mtk_config_scsi_dev(struct scsi_device *sdev)
+{
+	struct ufs_hba *hba = shost_priv(sdev->host);
+
+	dev_dbg(hba->dev, "lu %llu scsi device configured", sdev->lun);
+	if (sdev->lun == 2)
+		blk_queue_flag_set(QUEUE_FLAG_SAME_FORCE, sdev->reqeust_queue);
+}

There are no block drivers in the upstream kernel that set QUEUE_FLAG_SAME_FORCE. An explanation is missing from the patch description why this flag is set from the UFS driver instead of by writing the value "2" into /sys/class/block/$bdev/queue/rq_affinity. Additionally, an explanation is missing why QUEUE_FLAG_SAME_FORCE is set but QUEUE_FLAG_SAME_COMP not.

Bart.

#2 lore raw
Quoted 14 lines · Bart Van Assche

drivers/ufs/host/ufs-mediatek.c static int ufs_mtk_config_esi(struct ufs_hba *hba) · line 1790

Quoted 8 lines · On 10/7/24 11:59 PM, [email protected] wrote:
drivers/ufs/host/ufs-mediatek.c +8 -0
+static void ufs_mtk_config_scsi_dev(struct scsi_device *sdev)
+{
+struct ufs_hba *hba = shost_priv(sdev->host);
+
+dev_dbg(hba->dev, "lu %llu scsi device configured", sdev->lun);
+if (sdev->lun == 2)
+blk_queue_flag_set(QUEUE_FLAG_SAME_FORCE, sdev->reqeust_queue);
+}

There are no block drivers in the upstream kernel that set QUEUE_FLAG_SAME_FORCE. An explanation is missing from the patch description why this flag is set from the UFS driver instead of by writing the value "2" into /sys/class/block/$bdev/queue/rq_affinity.

The LU probing is completed asynchronously by another thread, which means that "sdc" cannot be guaranteed to be LU2. We do not need to change the queue settings at runtime. Therefore, a simpler and more intuitive approach is to set its flag once the SCSI device is confirmed to be ready.

Quoted 2 lines

Additionally, an explanation is missing why QUEUE_FLAG_SAME_FORCE is set but QUEUE_FLAG_SAME_COMP not.

QUEUE_FLAG_SAME_COMP is the default flag for blk mq queue. As this stage, it should be set by default.

Quoted 2 lines

Bart.

#3 lore raw
In reply to [email protected]
kernel test robot noticed the following build errors:

Hi,

kernel test robot noticed the following build errors:

[auto build test ERROR on mkp-scsi/for-next]
[also build test ERROR on jejb-scsi/for-next linus/master v6.12-rc2 next-20241008] [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/ed-tsai-mediatek-com/scsi-ufs-ufs-mediatek-configure-individual-LU-queue-flags/20241008-153700
base:   https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
patch link:    https://lore.kernel.org/r/20241008065950.23431-1-ed.tsai%40mediatek.com
patch subject: [PATCH] scsi: ufs: ufs-mediatek: configure individual LU queue flags
config: arm-allyesconfig (https://download.01.org/0day-ci/archive/20241009/[email protected]/config)
compiler: arm-linux-gnueabi-gcc (GCC) 14.1.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20241009/[email protected]/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 <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/

All errors (new ones prefixed by >>):

drivers/ufs/host/ufs-mediatek.c: In function 'ufs_mtk_config_scsi_dev':

>> drivers/ufs/host/ufs-mediatek.c:1789:65: error: 'struct scsi_device' has no member named 'reqeust_queue'; did you mean 'request_queue'?
    1789 |                 blk_queue_flag_set(QUEUE_FLAG_SAME_FORCE, sdev->reqeust_queue);
         |                                                                 ^~~~~~~~~~~~~
         |                                                                 request_queue

Kconfig warnings: (for reference only)
WARNING: unmet direct dependencies detected for GET_FREE_REGION Depends on [n]: SPARSEMEM [=n]
Selected by [y]:
- RESOURCE_KUNIT_TEST [=y] && RUNTIME_TESTING_MENU [=y] && KUNIT [=y]

vim +1789 drivers/ufs/host/ufs-mediatek.c

1782
1783 static void ufs_mtk_config_scsi_dev(struct scsi_device *sdev)
1784 {
1785 struct ufs_hba *hba = shost_priv(sdev->host);
1786
1787 dev_dbg(hba->dev, "lu %llu scsi device configured", sdev->lun);
1788 if (sdev->lun == 2)

> 1789			blk_queue_flag_set(QUEUE_FLAG_SAME_FORCE, sdev->reqeust_queue);

1790 }
1791

Signature · 2 lines
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki
#4 lore raw
In reply to [email protected]
Quoted 6 lines · On Tue, 08 Oct 2024 14:59:42 +0800, [email protected] wrote:

Previously, ufs vops config_scsi_dev was removed because there were no users. ufs-mediatek needs it to configure the queue flags for each LU individually. Therefore, bring it back and customize the queue flag as we required.

Applied to 6.13/scsi-queue, thanks!

[1/1] scsi: ufs: ufs-mediatek: configure individual LU queue flags

      https://git.kernel.org/mkp/scsi/c/7670e74ff319
Signature · 1 line
Martin K. Petersen	Oracle Linux Engineering