SCSI target development
 help / color / mirror / Atom feed
From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Dmitry Bogdanov <d.bogdanov@yadro.com>,
	Thinh Nguyen <Thinh.Nguyen@synopsys.com>
Cc: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>,
	Mike Christie <michael.christie@oracle.com>,
	"Martin K. Petersen" <martin.petersen@oracle.com>,
	Roman Bolshakov <r.bolshakov@yadro.com>,
	"linux-scsi@vger.kernel.org" <linux-scsi@vger.kernel.org>,
	"target-devel@vger.kernel.org" <target-devel@vger.kernel.org>
Subject: Re: [PATCH 18/36] usb: gadget: f_tcm: Don't set static stream_id
Date: Sat, 9 Jul 2022 00:12:07 +0000	[thread overview]
Message-ID: <14f1eebc-4424-7d56-eef7-b9ee676b9f19@synopsys.com> (raw)
In-Reply-To: <20220708070026.GK23838@yadro.com>

On 7/8/2022, Dmitry Bogdanov wrote:
> On Wed, Jul 06, 2022 at 04:36:15PM -0700, Thinh Nguyen wrote:
>> Host can assign stream ID value greater than number of streams
>> allocated. The tcm function needs to keep track of which stream is
>> available to assign the stream ID. This patch doesn't track that, but at
>> least it makes sure that there's no Oops if the host send tag with a
>> value greater than the number of supported streams.
>>
>> Signed-off-by: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
>> ---
>>   drivers/usb/gadget/function/f_tcm.c | 32 +++++------------------------
>>   1 file changed, 5 insertions(+), 27 deletions(-)
>>
>> diff --git a/drivers/usb/gadget/function/f_tcm.c b/drivers/usb/gadget/function/f_tcm.c
>> index 270ec631481d..7721216dc9bc 100644
>> --- a/drivers/usb/gadget/function/f_tcm.c
>> +++ b/drivers/usb/gadget/function/f_tcm.c
>> @@ -532,6 +532,7 @@ static int uasp_prepare_r_request(struct usbg_cmd *cmd)
>>   	}
>>   
>>   	stream->req_in->is_last = 1;
>> +	stream->req_in->stream_id = cmd->tag;
>>   	stream->req_in->complete = uasp_status_data_cmpl;
>>   	stream->req_in->length = se_cmd->data_length;
>>   	stream->req_in->context = cmd;
>> @@ -556,6 +557,7 @@ static void uasp_prepare_status(struct usbg_cmd *cmd)
>>   	iu->len = cpu_to_be16(se_cmd->scsi_sense_length);
>>   	iu->status = se_cmd->scsi_status;
>>   	stream->req_status->is_last = 1;
>> +	stream->req_status->stream_id = cmd->tag;
>>   	stream->req_status->context = cmd;
>>   	stream->req_status->length = se_cmd->scsi_sense_length + 16;
>>   	stream->req_status->buf = iu;
>> @@ -786,19 +788,6 @@ static int uasp_alloc_cmd(struct f_uas *fu)
>>   	return -ENOMEM;
>>   }
>>   
>> -static void uasp_setup_stream_res(struct f_uas *fu, int max_streams)
>> -{
>> -	int i;
>> -
>> -	for (i = 0; i < max_streams; i++) {
>> -		struct uas_stream *s = &fu->stream[i];
>> -
>> -		s->req_in->stream_id = i + 1;
>> -		s->req_out->stream_id = i + 1;
>> -		s->req_status->stream_id = i + 1;
>> -	}
>> -}
>> -
>>   static int uasp_prepare_reqs(struct f_uas *fu)
>>   {
>>   	int ret;
>> @@ -819,7 +808,6 @@ static int uasp_prepare_reqs(struct f_uas *fu)
>>   	ret = uasp_alloc_cmd(fu);
>>   	if (ret)
>>   		goto err_free_stream;
>> -	uasp_setup_stream_res(fu, max_streams);
>>   
>>   	ret = usb_ep_queue(fu->ep_cmd, fu->cmd.req, GFP_ATOMIC);
>>   	if (ret)
>> @@ -995,6 +983,7 @@ static int usbg_prepare_w_request(struct usbg_cmd *cmd, struct usb_request *req)
>>   	}
>>   
>>   	req->is_last = 1;
>> +	req->stream_id = cmd->tag;
>>   	req->complete = usbg_data_write_cmpl;
>>   	req->length = se_cmd->data_length;
>>   	req->context = cmd;
>> @@ -1125,16 +1114,8 @@ static int usbg_submit_command(struct f_uas *fu,
>>   	}
>>   	memcpy(cmd->cmd_buf, cmd_iu->cdb, cmd_len);
>>   
>> -	if (fu->flags & USBG_USE_STREAMS) {
>> -		if (cmd->tag > UASP_SS_EP_COMP_NUM_STREAMS)
>> -			goto err;
>> -		if (!cmd->tag)
>> -			cmd->stream = &fu->stream[0];
>> -		else
>> -			cmd->stream = &fu->stream[cmd->tag - 1];
>> -	} else {
>> -		cmd->stream = &fu->stream[0];
>> -	}
>> +	cmd->stream = &fu->stream[cmd->tag %
>> +		UASP_SS_EP_COMP_NUM_STREAMS];
> Use USBG_NUM_CMDS instead of UASP_SS_EP_COMP_NUM_STREAMS like in other
> places.

Sure, I'll do that.

Thanks,
Thinh

>>   
>>   	switch (cmd_iu->prio_attr & 0x7) {
>>   	case UAS_HEAD_TAG:
>> @@ -1161,9 +1142,6 @@ static int usbg_submit_command(struct f_uas *fu,
>>   	queue_work(tpg->workqueue, &cmd->work);
>>   
>>   	return 0;
>> -err:
>> -	usbg_release_cmd(&cmd->se_cmd);
>> -	return -EINVAL;
>>   }
>>   
>>   static void bot_cmd_work(struct work_struct *work)


  reply	other threads:[~2022-07-09  0:12 UTC|newest]

Thread overview: 84+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-07-06 23:34 [PATCH 00/36] usb: gadget: f_tcm: Enhance UASP driver Thinh Nguyen
2022-07-06 23:34 ` [PATCH 01/36] target: Handle MI_REPORT_SUPPORTED_OPERATION_CODES Thinh Nguyen
2022-07-07  8:01   ` Oliver Neukum
2022-07-07 11:44   ` kernel test robot
2022-07-06 23:34 ` [PATCH 02/36] target: Add overlapped response to tmrsp_table Thinh Nguyen
2022-07-06 23:34 ` [PATCH 03/36] target: Don't drain empty list Thinh Nguyen
2022-07-07 12:42   ` Dmitry Bogdanov
2022-07-06 23:34 ` [PATCH 04/36] target: Does tmr notify on aborted command Thinh Nguyen
2022-07-07 12:56   ` Dmitry Bogdanov
2022-07-08 23:11     ` Thinh Nguyen
2022-07-11  9:44       ` Dmitry Bogdanov
2022-07-12  2:57         ` Thinh Nguyen
2022-07-11 10:31       ` Bodo Stroesser
2022-07-12  3:09         ` Thinh Nguyen
2022-07-06 23:34 ` [PATCH 05/36] target: Don't remove command too early Thinh Nguyen
2022-07-07 13:16   ` Dmitry Bogdanov
2022-07-08 23:40     ` Thinh Nguyen
2022-07-06 23:35 ` [PATCH 06/36] target: Return Function Complete Thinh Nguyen
2022-07-07 13:34   ` Dmitry Bogdanov
2022-07-08 23:51     ` Thinh Nguyen
2022-07-11  9:53       ` Dmitry Bogdanov
2022-07-06 23:35 ` [PATCH 07/36] target: Don't do tmr_notify on empty aborted list Thinh Nguyen
2022-07-07 13:36   ` Dmitry Bogdanov
2022-07-08 23:53     ` Thinh Nguyen
2022-07-06 23:35 ` [PATCH 08/36] target: Refactor core_tmr_abort_task Thinh Nguyen
2022-07-07 13:40   ` Dmitry Bogdanov
2022-07-09  0:02     ` Thinh Nguyen
2022-07-06 23:35 ` [PATCH 09/36] target: Add common Task Management values Thinh Nguyen
2022-07-07 19:36   ` Dmitry Bogdanov
2022-07-09  0:04     ` Thinh Nguyen
2022-07-06 23:35 ` [PATCH 10/36] target: Implement TMR_ABORT_TASK_SET Thinh Nguyen
2022-07-07 19:40   ` Dmitry Bogdanov
2022-07-08  9:50     ` Dmitry Bogdanov
2022-07-09  0:46       ` Thinh Nguyen
2022-07-06 23:35 ` [PATCH 11/36] target: Properly set Sense Data Length of CHECK CONDITION Thinh Nguyen
2022-07-07  8:24   ` Oliver Neukum
2022-07-07 10:21     ` Thinh Nguyen
2022-07-07 20:27   ` Dmitry Bogdanov
2022-07-09  0:11     ` Thinh Nguyen
2022-07-06 23:35 ` [PATCH 12/36] target: Properly set Sense data length when copy sense Thinh Nguyen
2022-07-07 20:53   ` Dmitry Bogdanov
2022-07-09  0:11     ` Thinh Nguyen
2022-07-06 23:35 ` [PATCH 13/36] target: Don't respond TMR_LUN_DOES_NOT_EXIST for all TMR failure Thinh Nguyen
2022-07-06 23:35 ` [PATCH 14/36] target: Introduce target_submit_tmr_fail_response Thinh Nguyen
2022-07-06 23:35 ` [PATCH 15/36] target: Include INQUIRY length Thinh Nguyen
2022-07-07 10:11   ` Konstantin Shelekhin
2022-07-14  1:42     ` Thinh Nguyen
2022-07-06 23:36 ` [PATCH 16/36] usb: gadget: f_tcm: Increase stream count Thinh Nguyen
2022-07-06 23:36 ` [PATCH 17/36] usb: gadget: f_tcm: Increase bMaxBurst Thinh Nguyen
2022-07-06 23:36 ` [PATCH 18/36] usb: gadget: f_tcm: Don't set static stream_id Thinh Nguyen
2022-07-08  7:00   ` Dmitry Bogdanov
2022-07-09  0:12     ` Thinh Nguyen [this message]
2022-07-06 23:36 ` [PATCH 19/36] usb: gadget: f_tcm: Allocate matching number of commands to streams Thinh Nguyen
2022-07-06 23:36 ` [PATCH 20/36] usb: gadget: f_tcm: Limit number of sessions Thinh Nguyen
2022-07-07  6:57   ` Greg Kroah-Hartman
2022-07-07 10:31     ` Thinh Nguyen
2022-07-06 23:36 ` [PATCH 21/36] usb: gadget: f_tcm: Handle multiple commands in parallel Thinh Nguyen
2022-07-06 23:36 ` [PATCH 22/36] usb: gadget: f_tcm: Use extra number of commands Thinh Nguyen
2022-07-06 23:36 ` [PATCH 23/36] usb: gadget: f_tcm: Return ATA cmd direction Thinh Nguyen
2022-07-06 23:36 ` [PATCH 24/36] usb: gadget: f_tcm: Execute command on write completion Thinh Nguyen
2022-07-06 23:36 ` [PATCH 25/36] usb: gadget: f_tcm: Minor cleanup redundant code Thinh Nguyen
2022-07-06 23:37 ` [PATCH 26/36] usb: gadget: f_tcm: Don't free command immediately Thinh Nguyen
2022-07-06 23:37 ` [PATCH 27/36] usb: gadget: f_tcm: Translate error to sense Thinh Nguyen
2022-07-06 23:37 ` [PATCH 28/36] usb: gadget: f_tcm: Cleanup unused variable Thinh Nguyen
2022-07-06 23:37 ` [PATCH 29/36] usb: gadget: f_tcm: Update state on data write Thinh Nguyen
2022-07-06 23:37 ` [PATCH 30/36] usb: gadget: f_tcm: Handle abort command Thinh Nguyen
2022-07-06 23:37 ` [PATCH 31/36] usb: gadget: f_tcm: Cleanup requests on ep disable Thinh Nguyen
2022-07-06 23:37 ` [PATCH 32/36] usb: gadget: f_tcm: Send sense reason Thinh Nguyen
2022-07-08  7:35   ` Dmitry Bogdanov
2022-07-09  0:13     ` Thinh Nguyen
2022-07-06 23:37 ` [PATCH 33/36] usb: gadget: f_tcm: Save CPU ID per command Thinh Nguyen
2022-07-06 23:37 ` [PATCH 34/36] usb: gadget: f_tcm: Free tags earlier Thinh Nguyen
2022-07-07  9:14   ` Dmitriy Bogdanov
2022-07-07 10:11     ` Thinh Nguyen
2022-07-07 12:37       ` Dmitry Bogdanov
2022-07-06 23:38 ` [PATCH 35/36] usb: gadget: f_tcm: Handle TASK_MANAGEMENT commands Thinh Nguyen
2022-07-08  9:07   ` Dmitry Bogdanov
2022-07-09  0:41     ` Thinh Nguyen
2022-07-06 23:38 ` [PATCH 36/36] usb: gadget: f_tcm: Comply with UAS Task Management requirement Thinh Nguyen
2022-07-07  4:38 ` [PATCH 00/36] usb: gadget: f_tcm: Enhance UASP driver Christoph Hellwig
2022-07-07  4:50   ` Thinh Nguyen
2022-07-07  6:59 ` Greg Kroah-Hartman
2022-07-07 10:15   ` Thinh Nguyen
2022-07-07 11:15     ` Greg Kroah-Hartman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=14f1eebc-4424-7d56-eef7-b9ee676b9f19@synopsys.com \
    --to=thinh.nguyen@synopsys.com \
    --cc=balbi@kernel.org \
    --cc=d.bogdanov@yadro.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=martin.petersen@oracle.com \
    --cc=michael.christie@oracle.com \
    --cc=r.bolshakov@yadro.com \
    --cc=target-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox