public inbox for linux-scsi@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v1 0/2] scsi: ufs: introduce a callback to override OCS value
       [not found] <CGME20240821064152epcas2p2552e92767564272fb7e172fecd7ade3e@epcas2p2.samsung.com>
@ 2024-08-21  6:44 ` Kiwoong Kim
  2024-08-21  6:44   ` [PATCH v1 1/2] scsi: ufs: core: introduce override_cqe_ocs Kiwoong Kim
  2024-08-21  6:44   ` [PATCH v1 2/2] scsi: ufs: ufs-exynos: implement override_cqe_ocs Kiwoong Kim
  0 siblings, 2 replies; 4+ messages in thread
From: Kiwoong Kim @ 2024-08-21  6:44 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, bvanassche,
	jejb, martin.petersen, beanhuo, adrian.hunter, h10.kim, hy50.seo,
	sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
  Cc: Kiwoong Kim

UFSHCI defines OCS values but doesn't specify what exact
conditions raise them. So I think it needs another callback
to replace the original OCS value with the value that works
the way you want.

Kiwoong Kim (2):
  scsi: ufs: core: introduce override_cqe_ocs
  scsi: ufs: ufs-exynos: implement override_cqe_ocs

 drivers/ufs/core/ufshcd-priv.h | 9 +++++++++
 drivers/ufs/core/ufshcd.c      | 4 +++-
 drivers/ufs/host/ufs-exynos.c  | 9 +++++++++
 include/ufs/ufshcd.h           | 1 +
 4 files changed, 22 insertions(+), 1 deletion(-)

-- 
2.7.4


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v1 1/2] scsi: ufs: core: introduce override_cqe_ocs
  2024-08-21  6:44 ` [PATCH v1 0/2] scsi: ufs: introduce a callback to override OCS value Kiwoong Kim
@ 2024-08-21  6:44   ` Kiwoong Kim
  2024-08-22 10:38     ` kernel test robot
  2024-08-21  6:44   ` [PATCH v1 2/2] scsi: ufs: ufs-exynos: implement override_cqe_ocs Kiwoong Kim
  1 sibling, 1 reply; 4+ messages in thread
From: Kiwoong Kim @ 2024-08-21  6:44 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, bvanassche,
	jejb, martin.petersen, beanhuo, adrian.hunter, h10.kim, hy50.seo,
	sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
  Cc: Kiwoong Kim

This patch is to declare override_cqe_ocs callback to
override OCS value.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/ufs/core/ufshcd-priv.h | 9 +++++++++
 drivers/ufs/core/ufshcd.c      | 4 +++-
 include/ufs/ufshcd.h           | 1 +
 3 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/drivers/ufs/core/ufshcd-priv.h b/drivers/ufs/core/ufshcd-priv.h
index ce36154..be593d1 100644
--- a/drivers/ufs/core/ufshcd-priv.h
+++ b/drivers/ufs/core/ufshcd-priv.h
@@ -275,6 +275,15 @@ static inline int ufshcd_mcq_vops_config_esi(struct ufs_hba *hba)
 	return -EOPNOTSUPP;
 }
 
+static inline enum utp_ocs ufshcd_vops_override_cqe_ocs(struct ufs_hba *hba,
+		enum utp_ocs ocs)
+{
+	if (hba->vops && hba->vops->override_cqe_ocs)
+		return hba->vops->override_cqe_ocs(hba, ocs);
+
+	return ocs;
+}
+
 extern const struct ufs_pm_lvl_states ufs_pm_lvl_states[];
 
 /**
diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
index 0dd2605..83a1870 100644
--- a/drivers/ufs/core/ufshcd.c
+++ b/drivers/ufs/core/ufshcd.c
@@ -825,7 +825,9 @@ static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp,
 				      struct cq_entry *cqe)
 {
 	if (cqe)
-		return le32_to_cpu(cqe->status) & MASK_OCS;
+		return ufshcd_vops_override_cqe_ocs(hba,
+						    le32_to_cpu(cqe->status) &
+						    MASK_OCS);
 
 	return lrbp->utr_descriptor_ptr->header.ocs & MASK_OCS;
 }
diff --git a/include/ufs/ufshcd.h b/include/ufs/ufshcd.h
index a43b142..64444fb 100644
--- a/include/ufs/ufshcd.h
+++ b/include/ufs/ufshcd.h
@@ -382,6 +382,7 @@ struct ufs_hba_variant_ops {
 	int	(*get_outstanding_cqs)(struct ufs_hba *hba,
 				       unsigned long *ocqs);
 	int	(*config_esi)(struct ufs_hba *hba);
+	enum utp_ocs	(*override_cqe_ocs)(struct ufs_hba *hba, enum utp_ocs);
 };
 
 /* clock gating state  */
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH v1 2/2] scsi: ufs: ufs-exynos: implement override_cqe_ocs
  2024-08-21  6:44 ` [PATCH v1 0/2] scsi: ufs: introduce a callback to override OCS value Kiwoong Kim
  2024-08-21  6:44   ` [PATCH v1 1/2] scsi: ufs: core: introduce override_cqe_ocs Kiwoong Kim
@ 2024-08-21  6:44   ` Kiwoong Kim
  1 sibling, 0 replies; 4+ messages in thread
From: Kiwoong Kim @ 2024-08-21  6:44 UTC (permalink / raw)
  To: linux-scsi, linux-kernel, alim.akhtar, avri.altman, bvanassche,
	jejb, martin.petersen, beanhuo, adrian.hunter, h10.kim, hy50.seo,
	sh425.lee, kwangwon.min, junwoo80.lee, wkon.kim
  Cc: Kiwoong Kim

Exynos host reports OCS_ABORT when a command is nullifed
or cleaned up with MCQ enabled. I think the command in those
situations should be issued again, rather than fail, because
when some conditions that caused the nullification or cleaning up
disppears after recovery, the command could be processed.

Signed-off-by: Kiwoong Kim <kwmad.kim@samsung.com>
---
 drivers/ufs/host/ufs-exynos.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/ufs/host/ufs-exynos.c b/drivers/ufs/host/ufs-exynos.c
index 16ad352..4ed06fa 100644
--- a/drivers/ufs/host/ufs-exynos.c
+++ b/drivers/ufs/host/ufs-exynos.c
@@ -1376,6 +1376,14 @@ static void exynos_ufs_fmp_resume(struct ufs_hba *hba)
 
 #endif /* !CONFIG_SCSI_UFS_CRYPTO */
 
+static enum utp_ocs exynos_ufs_override_cqe_ocs(struct ufs_hba *hba,
+						enum utp_ocs ocs)
+{
+	if (ocs == OCS_ABORTED)
+		ocs = OCS_INVALID_COMMAND_STATUS;
+	return ocs;
+}
+
 static int exynos_ufs_init(struct ufs_hba *hba)
 {
 	struct device *dev = hba->dev;
@@ -1926,6 +1934,7 @@ static const struct ufs_hba_variant_ops ufs_hba_exynos_ops = {
 	.suspend			= exynos_ufs_suspend,
 	.resume				= exynos_ufs_resume,
 	.fill_crypto_prdt		= exynos_ufs_fmp_fill_prdt,
+	.override_cqe_ocs		= exynos_ufs_override_cqe_ocs,
 };
 
 static struct ufs_hba_variant_ops ufs_hba_exynosauto_vh_ops = {
-- 
2.7.4


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v1 1/2] scsi: ufs: core: introduce override_cqe_ocs
  2024-08-21  6:44   ` [PATCH v1 1/2] scsi: ufs: core: introduce override_cqe_ocs Kiwoong Kim
@ 2024-08-22 10:38     ` kernel test robot
  0 siblings, 0 replies; 4+ messages in thread
From: kernel test robot @ 2024-08-22 10:38 UTC (permalink / raw)
  To: Kiwoong Kim, linux-scsi, linux-kernel, alim.akhtar, avri.altman,
	bvanassche, jejb, martin.petersen, beanhuo, adrian.hunter,
	h10.kim, hy50.seo, sh425.lee, kwangwon.min, junwoo80.lee,
	wkon.kim
  Cc: llvm, oe-kbuild-all, Kiwoong Kim

Hi Kiwoong,

kernel test robot noticed the following build errors:

[auto build test ERROR on jejb-scsi/for-next]
[also build test ERROR on mkp-scsi/for-next krzk/for-next linus/master v6.11-rc4 next-20240822]
[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/Kiwoong-Kim/scsi-ufs-core-introduce-override_cqe_ocs/20240821-144404
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
patch link:    https://lore.kernel.org/r/895b69ac1e938490cd1d17b5f82b6f730bcd82c2.1724222619.git.kwmad.kim%40samsung.com
patch subject: [PATCH v1 1/2] scsi: ufs: core: introduce override_cqe_ocs
config: x86_64-kexec (https://download.01.org/0day-ci/archive/20240822/202408221823.jnozM7Ys-lkp@intel.com/config)
compiler: clang version 18.1.5 (https://github.com/llvm/llvm-project 617a15a9eac96088ae5e9134248d8236e34b91b1)
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240822/202408221823.jnozM7Ys-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/202408221823.jnozM7Ys-lkp@intel.com/

All errors (new ones prefixed by >>):

>> drivers/ufs/core/ufshcd.c:828:39: error: use of undeclared identifier 'hba'
     828 |                 return ufshcd_vops_override_cqe_ocs(hba,
         |                                                     ^
   drivers/ufs/core/ufshcd.c:10344:44: warning: shift count >= width of type [-Wshift-count-overflow]
    10344 |                 if (!dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(64)))
          |                                                          ^~~~~~~~~~~~~~~~
   include/linux/dma-mapping.h:77:54: note: expanded from macro 'DMA_BIT_MASK'
      77 | #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1))
         |                                                      ^ ~~~
   1 warning and 1 error generated.


vim +/hba +828 drivers/ufs/core/ufshcd.c

   814	
   815	/**
   816	 * ufshcd_get_tr_ocs - Get the UTRD Overall Command Status
   817	 * @lrbp: pointer to local command reference block
   818	 * @cqe: pointer to the completion queue entry
   819	 *
   820	 * This function is used to get the OCS field from UTRD
   821	 *
   822	 * Return: the OCS field in the UTRD.
   823	 */
   824	static enum utp_ocs ufshcd_get_tr_ocs(struct ufshcd_lrb *lrbp,
   825					      struct cq_entry *cqe)
   826	{
   827		if (cqe)
 > 828			return ufshcd_vops_override_cqe_ocs(hba,
   829							    le32_to_cpu(cqe->status) &
   830							    MASK_OCS);
   831	
   832		return lrbp->utr_descriptor_ptr->header.ocs & MASK_OCS;
   833	}
   834	

-- 
0-DAY CI Kernel Test Service
https://github.com/intel/lkp-tests/wiki

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-08-22 10:39 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <CGME20240821064152epcas2p2552e92767564272fb7e172fecd7ade3e@epcas2p2.samsung.com>
2024-08-21  6:44 ` [PATCH v1 0/2] scsi: ufs: introduce a callback to override OCS value Kiwoong Kim
2024-08-21  6:44   ` [PATCH v1 1/2] scsi: ufs: core: introduce override_cqe_ocs Kiwoong Kim
2024-08-22 10:38     ` kernel test robot
2024-08-21  6:44   ` [PATCH v1 2/2] scsi: ufs: ufs-exynos: implement override_cqe_ocs Kiwoong Kim

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox