* [PATCH] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
@ 2021-08-19 9:35 Adrian Hunter
2021-08-19 18:14 ` Bart Van Assche
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2021-08-19 9:35 UTC (permalink / raw)
To: Martin K . Petersen
Cc: James E . J . Bottomley, Bart Van Assche, Avri Altman, Bean Huo,
Can Guo, Asutosh Das, linux-scsi
Samsung KLUFG8RHDA-B2D1 does not clear the unit attention condition if the
length is zero. So go back to requesting all the sense data, as it was
before patch "scsi: ufs: Request sense data asynchronously". That is
simpler than creating and maintaining a quirk for affected devices.
Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
drivers/scsi/ufs/ufshcd.c | 25 +++++++++++++++++++++----
1 file changed, 21 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c
index a3b419848f0a..c7a130bc782d 100644
--- a/drivers/scsi/ufs/ufshcd.c
+++ b/drivers/scsi/ufs/ufshcd.c
@@ -7937,7 +7937,8 @@ static int ufshcd_add_lus(struct ufs_hba *hba)
static void ufshcd_request_sense_done(struct request *rq, blk_status_t error)
{
if (error != BLK_STS_OK)
- pr_err("%s: REQUEST SENSE failed (%d)", __func__, error);
+ pr_err("%s: REQUEST SENSE failed (%d)\n", __func__, error);
+ kfree(rq->end_io_data);
blk_put_request(rq);
}
@@ -7946,22 +7947,38 @@ ufshcd_request_sense_async(struct ufs_hba *hba, struct scsi_device *sdev)
{
/*
* From SPC-6: the REQUEST SENSE command with any allocation length
- * clears the sense data.
+ * clears the sense data, but not all UFS devices behave that way.
*/
- static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, 0, 0};
+ static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, UFS_SENSE_SIZE, 0};
struct scsi_request *rq;
struct request *req;
+ char *buffer;
+ int ret;
+
+ buffer = kzalloc(UFS_SENSE_SIZE, GFP_KERNEL);
+ if (!buffer)
+ return -ENOMEM;
- req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, /*flags=*/0);
+ req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN,
+ /*flags=*/BLK_MQ_REQ_PM);
if (IS_ERR(req))
return PTR_ERR(req);
+ ret = blk_rq_map_kern(sdev->request_queue, req,
+ buffer, UFS_SENSE_SIZE, GFP_NOIO);
+ if (ret) {
+ blk_put_request(req);
+ kfree(buffer);
+ return ret;
+ }
+
rq = scsi_req(req);
rq->cmd_len = ARRAY_SIZE(cmd);
memcpy(rq->cmd, cmd, rq->cmd_len);
rq->retries = 3;
req->timeout = 1 * HZ;
req->rq_flags |= RQF_PM | RQF_QUIET;
+ req->end_io_data = buffer;
blk_execute_rq_nowait(/*bd_disk=*/NULL, req, /*at_head=*/true,
ufshcd_request_sense_done);
--
2.17.1
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
2021-08-19 9:35 [PATCH] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1 Adrian Hunter
@ 2021-08-19 18:14 ` Bart Van Assche
2021-08-20 5:37 ` Adrian Hunter
0 siblings, 1 reply; 5+ messages in thread
From: Bart Van Assche @ 2021-08-19 18:14 UTC (permalink / raw)
To: Adrian Hunter, Martin K . Petersen
Cc: James E . J . Bottomley, Avri Altman, Bean Huo, Can Guo,
Asutosh Das, linux-scsi
On 8/19/21 2:35 AM, Adrian Hunter wrote:
> * From SPC-6: the REQUEST SENSE command with any allocation length
> - * clears the sense data.
> + * clears the sense data, but not all UFS devices behave that way.
> */
How about removing the comment entirely? Comprehending the above comment
is not possible without reviewing the git history so I think it's better
to remove it.
> - static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, 0, 0};
> + static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, UFS_SENSE_SIZE, 0};
> struct scsi_request *rq;
> struct request *req;
> + char *buffer;
> + int ret;
> +
> + buffer = kzalloc(UFS_SENSE_SIZE, GFP_KERNEL);
> + if (!buffer)
> + return -ENOMEM;
>
> - req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, /*flags=*/0);
> + req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN,
> + /*flags=*/BLK_MQ_REQ_PM);
Why has the flags argument been changed from 0 into BLK_MQ_REQ_PM? MODE
SENSE is not a power management command.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
2021-08-19 18:14 ` Bart Van Assche
@ 2021-08-20 5:37 ` Adrian Hunter
2021-08-20 22:32 ` Bart Van Assche
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Hunter @ 2021-08-20 5:37 UTC (permalink / raw)
To: Bart Van Assche, Martin K . Petersen
Cc: James E . J . Bottomley, Avri Altman, Bean Huo, Can Guo,
Asutosh Das, linux-scsi
On 19/08/21 9:14 pm, Bart Van Assche wrote:
> On 8/19/21 2:35 AM, Adrian Hunter wrote:
>> * From SPC-6: the REQUEST SENSE command with any allocation length
>> - * clears the sense data.
>> + * clears the sense data, but not all UFS devices behave that way.
>> */
>
> How about removing the comment entirely? Comprehending the above comment is not possible without reviewing the git history so I think it's better to remove it.
Perhaps a comment might stop someone tempted to remove the sense size in the future. What about:
/*
* Some UFS devices clear unit attention condition only if the sense
* size used (UFS_SENSE_SIZE in this case) is non-zero.
*/
>
>> - static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, 0, 0};
>> + static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, UFS_SENSE_SIZE, 0};
>> struct scsi_request *rq;
>> struct request *req;
>> + char *buffer;
>> + int ret;
>> +
>> + buffer = kzalloc(UFS_SENSE_SIZE, GFP_KERNEL);
>> + if (!buffer)
>> + return -ENOMEM;
>> - req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN, /*flags=*/0);
>> + req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN,
>> + /*flags=*/BLK_MQ_REQ_PM);
>
> Why has the flags argument been changed from 0 into BLK_MQ_REQ_PM? MODE SENSE is not a power management command.
It is used in a PM path, it is consistent with RQF_PM also used by ufshcd_request_sense_async(), it is what __scsi_execute() does with RQF_PM, so it is what was used before "scsi: ufs: Request sense data asynchronously".
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
2021-08-20 5:37 ` Adrian Hunter
@ 2021-08-20 22:32 ` Bart Van Assche
0 siblings, 0 replies; 5+ messages in thread
From: Bart Van Assche @ 2021-08-20 22:32 UTC (permalink / raw)
To: Adrian Hunter, Martin K . Petersen
Cc: James E . J . Bottomley, Avri Altman, Bean Huo, Can Guo,
Asutosh Das, linux-scsi
On 8/19/21 10:37 PM, Adrian Hunter wrote:
> On 19/08/21 9:14 pm, Bart Van Assche wrote:
>> On 8/19/21 2:35 AM, Adrian Hunter wrote:
>>> * From SPC-6: the REQUEST SENSE command with any allocation length
>>> - * clears the sense data.
>>> + * clears the sense data, but not all UFS devices behave that way.
>>> */
>>
>> How about removing the comment entirely? Comprehending the above comment is not possible without reviewing the git history so I think it's better to remove it.
>
> Perhaps a comment might stop someone tempted to remove the sense size in the future. What about:
>
> /*
> * Some UFS devices clear unit attention condition only if the sense
> * size used (UFS_SENSE_SIZE in this case) is non-zero.
> */
That sounds good to me.
PS: we are working with the team that depends on this behavior (clearing
the unit attention condition) to implement a retry loop on top of
ioctl(SG_IO). Once that loop has been added it will be possible to drop
the code that clears the unit attention condition after a resume.
Thanks,
Bart.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1
@ 2021-08-19 22:14 kernel test robot
0 siblings, 0 replies; 5+ messages in thread
From: kernel test robot @ 2021-08-19 22:14 UTC (permalink / raw)
To: kbuild
[-- Attachment #1: Type: text/plain, Size: 16712 bytes --]
CC: clang-built-linux(a)googlegroups.com
CC: kbuild-all(a)lists.01.org
In-Reply-To: <20210819093534.17507-1-adrian.hunter@intel.com>
References: <20210819093534.17507-1-adrian.hunter@intel.com>
TO: Adrian Hunter <adrian.hunter@intel.com>
TO: "Martin K . Petersen" <martin.petersen@oracle.com>
CC: "James E . J . Bottomley" <jejb@linux.ibm.com>
CC: Bart Van Assche <bvanassche@acm.org>
CC: Avri Altman <avri.altman@wdc.com>
CC: Bean Huo <huobean@gmail.com>
CC: Can Guo <cang@codeaurora.org>
CC: Asutosh Das <asutoshd@codeaurora.org>
CC: linux-scsi(a)vger.kernel.org
Hi Adrian,
I love your patch! Perhaps something to improve:
[auto build test WARNING on mkp-scsi/for-next]
[also build test WARNING on scsi/for-next next-20210819]
[cannot apply to bvanassche/for-next v5.14-rc6]
[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]
url: https://github.com/0day-ci/linux/commits/Adrian-Hunter/scsi-ufs-Fix-ufshcd_request_sense_async-for-Samsung-KLUFG8RHDA-B2D1/20210819-173718
base: https://git.kernel.org/pub/scm/linux/kernel/git/mkp/scsi.git for-next
:::::: branch date: 13 hours ago
:::::: commit date: 13 hours ago
config: riscv-randconfig-c006-20210818 (attached as .config)
compiler: clang version 14.0.0 (https://github.com/llvm/llvm-project d2b574a4dea5b718e4386bf2e26af0126e5978ce)
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# install riscv cross compiling tool for clang build
# apt-get install binutils-riscv64-linux-gnu
# https://github.com/0day-ci/linux/commit/f923de99302b30cd626ccb6cfc7f075da31c4a89
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Adrian-Hunter/scsi-ufs-Fix-ufshcd_request_sense_async-for-Samsung-KLUFG8RHDA-B2D1/20210819-173718
git checkout f923de99302b30cd626ccb6cfc7f075da31c4a89
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=clang make.cross ARCH=riscv clang-analyzer
If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>
clang-analyzer warnings: (new ones prefixed by >>)
drivers/scsi/ufs/ufshcd.c:6114:6: note: Left side of '||' is false
drivers/scsi/ufs/ufshcd.c:6116:8: note: Assuming the condition is false
((hba->saved_err & UIC_ERROR) &&
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:6116:36: note: Left side of '&&' is false
((hba->saved_err & UIC_ERROR) &&
^
drivers/scsi/ufs/ufshcd.c:6127:2: note: Taking true branch
if (hba->saved_uic_err & UFSHCD_UIC_PA_GENERIC_ERROR) {
^
drivers/scsi/ufs/ufshcd.c:6129:13: note: Field 'saved_uic_err' is 0
if (!hba->saved_uic_err)
^
drivers/scsi/ufs/ufshcd.c:6129:3: note: Taking true branch
if (!hba->saved_uic_err)
^
drivers/scsi/ufs/ufshcd.c:6132:7: note: Calling 'ufshcd_is_pwr_mode_restore_needed'
if (ufshcd_is_pwr_mode_restore_needed(hba))
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:6032:2: note: 'mode' declared without an initial value
u32 mode;
^~~~~~~~
drivers/scsi/ufs/ufshcd.c:6034:2: note: Calling 'ufshcd_dme_get'
ufshcd_dme_get(hba, UIC_ARG_MIB(PA_PWRMODE), &mode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.h:1108:9: note: Calling 'ufshcd_dme_get_attr'
return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:3872:6: note: 'peer' is 0
if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)) {
^~~~
drivers/scsi/ufs/ufshcd.c:3872:11: note: Left side of '&&' is false
if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)) {
^
drivers/scsi/ufs/ufshcd.c:3894:20: note: 'peer' is 0
uic_cmd.command = peer ?
^~~~
drivers/scsi/ufs/ufshcd.c:3894:20: note: '?' condition is false
drivers/scsi/ufs/ufshcd.c:3901:7: note: Assuming 'ret' is not equal to 0
if (ret)
^~~
drivers/scsi/ufs/ufshcd.c:3901:3: note: Taking true branch
if (ret)
^
drivers/scsi/ufs/ufshcd.c:3902:4: note: Taking false branch
dev_dbg(hba->dev, "%s: attr-id 0x%x error code %d\n",
^
include/linux/dev_printk.h:130:2: note: expanded from macro 'dev_dbg'
if (0) \
^
drivers/scsi/ufs/ufshcd.c:3904:11: note: 'ret' is not equal to 0
} while (ret && peer && --retries);
^~~
drivers/scsi/ufs/ufshcd.c:3904:11: note: Left side of '&&' is true
drivers/scsi/ufs/ufshcd.c:3904:18: note: 'peer' is 0
} while (ret && peer && --retries);
^~~~
drivers/scsi/ufs/ufshcd.c:3904:23: note: Left side of '&&' is false
} while (ret && peer && --retries);
^
drivers/scsi/ufs/ufshcd.c:3898:2: note: Loop condition is false. Exiting loop
do {
^
drivers/scsi/ufs/ufshcd.c:3906:6: note: 'ret' is not equal to 0
if (ret)
^~~
drivers/scsi/ufs/ufshcd.c:3906:2: note: Taking true branch
if (ret)
^
drivers/scsi/ufs/ufshcd.c:3911:6: note: 'mib_val' is non-null
if (mib_val && !ret)
^~~~~~~
drivers/scsi/ufs/ufshcd.c:3911:6: note: Left side of '&&' is true
drivers/scsi/ufs/ufshcd.c:3911:18: note: 'ret' is not equal to 0
if (mib_val && !ret)
^~~
drivers/scsi/ufs/ufshcd.c:3911:2: note: Taking false branch
if (mib_val && !ret)
^
drivers/scsi/ufs/ufshcd.c:3914:6: note: 'peer' is 0
if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)
^~~~
drivers/scsi/ufs/ufshcd.c:3914:11: note: Left side of '&&' is false
if (peer && (hba->quirks & UFSHCD_QUIRK_DME_PEER_ACCESS_AUTO_MODE)
^
drivers/scsi/ufs/ufshcd.c:3918:2: note: Returning without writing to '*mib_val'
return ret;
^
drivers/scsi/ufs/ufshcd.h:1108:9: note: Returning from 'ufshcd_dme_get_attr'
return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.h:1108:2: note: Returning without writing to '*mib_val'
return ufshcd_dme_get_attr(hba, attr_sel, mib_val, DME_LOCAL);
^
drivers/scsi/ufs/ufshcd.c:6034:2: note: Returning from 'ufshcd_dme_get'
ufshcd_dme_get(hba, UIC_ARG_MIB(PA_PWRMODE), &mode);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:6036:33: note: The left operand of '>>' is a garbage value
if (pwr_info->pwr_rx != ((mode >> PWRMODE_RX_OFFSET) & PWRMODE_MASK))
~~~~ ^
>> drivers/scsi/ufs/ufshcd.c:7965:10: warning: Potential leak of memory pointed to by 'buffer' [clang-analyzer-unix.Malloc]
return PTR_ERR(req);
^
drivers/scsi/ufs/ufshcd.c:8155:6: note: Assuming 'ret' is 0
if (ret)
^~~
drivers/scsi/ufs/ufshcd.c:8155:2: note: Taking false branch
if (ret)
^
drivers/scsi/ufs/ufshcd.c:8159:8: note: Calling 'ufshcd_add_lus'
ret = ufshcd_add_lus(hba);
^~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:7907:6: note: 'ret' is 0
if (ret)
^~~
drivers/scsi/ufs/ufshcd.c:7907:2: note: Taking false branch
if (ret)
^
drivers/scsi/ufs/ufshcd.c:7910:2: note: Calling 'ufshcd_clear_ua_wluns'
ufshcd_clear_ua_wluns(hba);
^~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:8027:6: note: Assuming field 'wlun_dev_clr_ua' is true
if (!hba->wlun_dev_clr_ua)
^~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:8027:2: note: Taking false branch
if (!hba->wlun_dev_clr_ua)
^
drivers/scsi/ufs/ufshcd.c:8030:8: note: Calling 'ufshcd_clear_ua_wlun'
ret = ufshcd_clear_ua_wlun(hba, UFS_UPIU_UFS_DEVICE_WLUN);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/scsi/ufs/ufshcd.c:7994:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(hba->host->host_lock, flags);
^
include/linux/spinlock.h:384:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:274:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:8: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
include/linux/irqflags.h:237:36: note: expanded from macro 'local_irq_save'
#define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0)
^
include/linux/irqflags.h:169:2: note: expanded from macro 'raw_local_irq_save'
do { \
^
drivers/scsi/ufs/ufshcd.c:7994:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(hba->host->host_lock, flags);
^
include/linux/spinlock.h:384:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:274:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:8: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
include/linux/irqflags.h:237:31: note: expanded from macro 'local_irq_save'
#define local_irq_save(flags) do { raw_local_irq_save(flags); } while (0)
^
drivers/scsi/ufs/ufshcd.c:7994:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(hba->host->host_lock, flags);
^
include/linux/spinlock.h:384:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:274:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
^
include/linux/spinlock_api_up.h:40:31: note: expanded from macro '__LOCK_IRQSAVE'
do { local_irq_save(flags); __LOCK(lock); } while (0)
^
include/linux/spinlock_api_up.h:31:8: note: expanded from macro '__LOCK'
do { preempt_disable(); ___LOCK(lock); } while (0)
^
include/linux/preempt.h:175:27: note: expanded from macro 'preempt_disable'
#define preempt_disable() \
^
drivers/scsi/ufs/ufshcd.c:7994:2: note: Loop condition is false. Exiting loop
spin_lock_irqsave(hba->host->host_lock, flags);
^
include/linux/spinlock.h:384:2: note: expanded from macro 'spin_lock_irqsave'
raw_spin_lock_irqsave(spinlock_check(lock), flags); \
^
include/linux/spinlock.h:274:3: note: expanded from macro 'raw_spin_lock_irqsave'
_raw_spin_lock_irqsave(lock, flags); \
^
include/linux/spinlock_api_up.h:68:45: note: expanded from macro '_raw_spin_lock_irqsave'
#define _raw_spin_lock_irqsave(lock, flags) __LOCK_IRQSAVE(lock, flags)
vim +/buffer +7965 drivers/scsi/ufs/ufshcd.c
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7944
4f3e900b628226 Jaegeuk Kim 2020-11-17 7945 static int
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7946 ufshcd_request_sense_async(struct ufs_hba *hba, struct scsi_device *sdev)
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7947 {
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7948 /*
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7949 * From SPC-6: the REQUEST SENSE command with any allocation length
f923de99302b30 Adrian Hunter 2021-08-19 7950 * clears the sense data, but not all UFS devices behave that way.
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7951 */
f923de99302b30 Adrian Hunter 2021-08-19 7952 static const u8 cmd[6] = {REQUEST_SENSE, 0, 0, 0, UFS_SENSE_SIZE, 0};
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7953 struct scsi_request *rq;
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7954 struct request *req;
f923de99302b30 Adrian Hunter 2021-08-19 7955 char *buffer;
f923de99302b30 Adrian Hunter 2021-08-19 7956 int ret;
f923de99302b30 Adrian Hunter 2021-08-19 7957
f923de99302b30 Adrian Hunter 2021-08-19 7958 buffer = kzalloc(UFS_SENSE_SIZE, GFP_KERNEL);
f923de99302b30 Adrian Hunter 2021-08-19 7959 if (!buffer)
f923de99302b30 Adrian Hunter 2021-08-19 7960 return -ENOMEM;
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7961
f923de99302b30 Adrian Hunter 2021-08-19 7962 req = blk_get_request(sdev->request_queue, REQ_OP_DRV_IN,
f923de99302b30 Adrian Hunter 2021-08-19 7963 /*flags=*/BLK_MQ_REQ_PM);
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7964 if (IS_ERR(req))
ac1bc2ba060f96 Bart Van Assche 2021-07-21 @7965 return PTR_ERR(req);
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7966
f923de99302b30 Adrian Hunter 2021-08-19 7967 ret = blk_rq_map_kern(sdev->request_queue, req,
f923de99302b30 Adrian Hunter 2021-08-19 7968 buffer, UFS_SENSE_SIZE, GFP_NOIO);
f923de99302b30 Adrian Hunter 2021-08-19 7969 if (ret) {
f923de99302b30 Adrian Hunter 2021-08-19 7970 blk_put_request(req);
f923de99302b30 Adrian Hunter 2021-08-19 7971 kfree(buffer);
f923de99302b30 Adrian Hunter 2021-08-19 7972 return ret;
f923de99302b30 Adrian Hunter 2021-08-19 7973 }
f923de99302b30 Adrian Hunter 2021-08-19 7974
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7975 rq = scsi_req(req);
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7976 rq->cmd_len = ARRAY_SIZE(cmd);
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7977 memcpy(rq->cmd, cmd, rq->cmd_len);
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7978 rq->retries = 3;
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7979 req->timeout = 1 * HZ;
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7980 req->rq_flags |= RQF_PM | RQF_QUIET;
f923de99302b30 Adrian Hunter 2021-08-19 7981 req->end_io_data = buffer;
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7982
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7983 blk_execute_rq_nowait(/*bd_disk=*/NULL, req, /*at_head=*/true,
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7984 ufshcd_request_sense_done);
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7985 return 0;
ac1bc2ba060f96 Bart Van Assche 2021-07-21 7986 }
4f3e900b628226 Jaegeuk Kim 2020-11-17 7987
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
[-- Attachment #2: config.gz --]
[-- Type: application/gzip, Size: 32308 bytes --]
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2021-08-20 22:32 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-08-19 9:35 [PATCH] scsi: ufs: Fix ufshcd_request_sense_async() for Samsung KLUFG8RHDA-B2D1 Adrian Hunter
2021-08-19 18:14 ` Bart Van Assche
2021-08-20 5:37 ` Adrian Hunter
2021-08-20 22:32 ` Bart Van Assche
2021-08-19 22:14 kernel test robot
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.