Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8751216ybi; Tue, 23 Jul 2019 14:29:37 -0700 (PDT) X-Google-Smtp-Source: APXvYqxJqmKVY4Tc52GzPQmkrAqGXyjBG+tZVE8b/Lrb8QsHcYjc1GCvg3xkQj34pX0csLOpQpOK X-Received: by 2002:a17:902:6847:: with SMTP id f7mr80622895pln.311.1563917377896; Tue, 23 Jul 2019 14:29:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563917377; cv=none; d=google.com; s=arc-20160816; b=MxCxFbCwJJj5/6cWMZ6+YDu3SnDS2BQDjWUca0jhwa0rsuwBG7mxo80shlBsWuZhUo djJm3xKo+AVuCH+RLcVm0jyodAfpWDxsDo4MFCoS6M1DeNDTZ6x6D3+uO7zgcELfjS+v 95ta0L0MQZgk4nuUEffmycXptcQKTtqAba2eeWqjtIat45vyxNuuPBVASj8s/zUGxF+C z2b8G52gEP83B9/3ZnJZtjbLiQ8qgnjz7ZY1GBfhdVXe7bCGck6f/OFATK+3vpTWy/a9 lU31okt0Hp+hQVJn+5ZfM69MYovY3KuMIxg0vJNkB8BlWTs6DrgY2YXNUSUdsm7LSHR2 hCaw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=M085sQxZRNbz0OBDy5dlhICQwU4DuRFnxzjIAf3um2Q=; b=Rk79Kg7fitBgkOiaKvvVoI+4TpxrRiZMMP8BPNGO2k/Jg8XM4+UgVC/Ib/Ay1eKH/f 7/91dVZuizZqb+BXwgTIrmOYoFp5v1nRF8NcdxHQZxU7ztTJZNuizAGkN4wVeoe0olwK F6fszK9LnUUwppkbl9UsRn8hNTMRumARDRiTYWD4OywR+e2TX3SOt9OLDfXuuLEgind4 sIJynf+G6wRuoOAOpdMueaVOkQwnxpR+E/4Rz0x71I12XD4gt5tU93V6FLCLDPV2YA/t KwGGi0rd6X/OwcN07degeMggiyA7h7snQz9hykSkxVkFwitwE/MxpS16QRCQ0wE37+el HpDw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="Y/HU4gBu"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x22si14712118pfo.255.2019.07.23.14.29.22; Tue, 23 Jul 2019 14:29:37 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@broadcom.com header.s=google header.b="Y/HU4gBu"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=broadcom.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389341AbfGWL2B (ORCPT + 99 others); Tue, 23 Jul 2019 07:28:01 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:39626 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728103AbfGWL2B (ORCPT ); Tue, 23 Jul 2019 07:28:01 -0400 Received: by mail-pg1-f193.google.com with SMTP id u17so19287618pgi.6 for ; Tue, 23 Jul 2019 04:28:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=M085sQxZRNbz0OBDy5dlhICQwU4DuRFnxzjIAf3um2Q=; b=Y/HU4gBu9cfcIksRpnfWvBh3ybK9Bdyb0tmjGu2jg+zF1zDuRdlJGxKPMPadJiVqQS 9jIk1wVgo+/DmqjMa8XIFinj35cZdfffqzX94lAcwGZpjzd0kOUHhJ4OjM1RNhdkPzFA 3CUz89uvZhtOmr12Jxz1gVcaI1WmTk3pE4n40= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc:content-transfer-encoding; bh=M085sQxZRNbz0OBDy5dlhICQwU4DuRFnxzjIAf3um2Q=; b=iMU5DntVR1Yc9PuSTK+hQIoO0synrA1zJDt9zmuWdV15X6ayEzUazLWXi2mHNSjB8x mYeoIJfr3UwIJ+31Ex/y/v6GwW1zi2TKCoNOfOQetO0a1pcbtlY+09WcueW4tcmA/SfC 1P+Hi49nkUtL7/Q9ZyuH8YZLzX3M/7gUvicCz1psf+4M8d+FPFsAgAfkzOBBxNzjkpfq LbZufPIXTaC0UMyYFPcWseV6u/j/jeKpmly9sj3XjhxErdQ7BAFIO2EJbbNdoTtwnpMv d5381LfITLXcuXkZUXMguTSPlTaRkZIJGSyOj7/H1gPUGFAb17gdvs/IpoA5fh0XEZWM acsg== X-Gm-Message-State: APjAAAX+BiY/OI12fjRszFzxfEmkT+WVKbegVgKRJNDrnSD3zeVwABJM cxeMH7/4Pfh08qOAUBmQ0sOnZqxLfvNCwg+Wjn8X3w== X-Received: by 2002:a63:b346:: with SMTP id x6mr76347800pgt.218.1563881280431; Tue, 23 Jul 2019 04:28:00 -0700 (PDT) MIME-Version: 1.0 References: <20190714034415epcms2p25f9787cb71993a30f58524d2f355b543@epcms2p2> <860cc8cf-6419-c649-b2d9-19b82f6ebc99@suse.de> In-Reply-To: <860cc8cf-6419-c649-b2d9-19b82f6ebc99@suse.de> From: Sreekanth Reddy Date: Tue, 23 Jul 2019 16:57:49 +0530 Message-ID: Subject: Re: [PATCH V2] mpt3sas: support target smid for [abort|query] task To: Hannes Reinecke Cc: minwoo.im@samsung.com, "sathya.prakash@broadcom.com" , "suganath-prabu.subramani@broadcom.com" , "jejb@linux.ibm.com" , "martin.petersen@oracle.com" , "MPT-FusionLinux.pdl@broadcom.com" , "linux-kernel@vger.kernel.org" , "linux-scsi@vger.kernel.org" , "linux-block@vger.kernel.org" , Euihyeok Kwon , Sarah Cho , Sanggwan Lee , Gyeongmin Nam , Sungjun Park , "minwoo.im.dev@gmail.com" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Jul 15, 2019 at 11:43 AM Hannes Reinecke wrote: > > On 7/14/19 5:44 AM, Minwoo Im wrote: > > We can request task management IOCTL command(MPI2_FUNCTION_SCSI_TASK_MG= MT) > > to /dev/mpt3ctl. If the given task_type is either abort task or query > > task, it may need a field named "Initiator Port Transfer Tag to Manage" > > in the IU. > > > > Current code does not support to check target IPTT tag from the > > tm_request. This patch introduces to check TaskMID given from the > > userspace as a target tag. We have a rule of relationship between > > (struct request *req->tag) and smid in mpt3sas_base.c: > > > > 3318 u16 > > 3319 mpt3sas_base_get_smid_scsiio(struct MPT3SAS_ADAPTER *ioc, u8 cb_id= x, > > 3320 struct scsi_cmnd *scmd) > > 3321 { > > 3322 struct scsiio_tracker *request =3D scsi_cmd_priv(scmd); > > 3323 unsigned int tag =3D scmd->request->tag; > > 3324 u16 smid; > > 3325 > > 3326 smid =3D tag + 1; > > > > So if we want to abort a request tagged #X, then we can pass (X + 1) to > > this IOCTL handler. Otherwise, user space just can pass 0 TaskMID to > > abort the first outstanding smid which is legacy behaviour. > > > > Cc: Sreekanth Reddy > > Cc: Suganath Prabu Subramani > > Cc: Sathya Prakash > > Cc: James E.J. Bottomley > > Cc: Martin K. Petersen > > Cc: MPT-FusionLinux.pdl@broadcom.com > > Signed-off-by: Minwoo Im > > --- > > drivers/scsi/mpt3sas/mpt3sas_ctl.c | 12 ++++++++++-- > > 1 file changed, 10 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/= mpt3sas_ctl.c > > index b2bb47c14d35..f6b8fd90610a 100644 > > --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c > > +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c > > @@ -596,8 +596,16 @@ _ctl_set_task_mid(struct MPT3SAS_ADAPTER *ioc, str= uct mpt3_ioctl_command *karg, > > if (priv_data->sas_target->handle !=3D handle) > > continue; > > st =3D scsi_cmd_priv(scmd); > > - tm_request->TaskMID =3D cpu_to_le16(st->smid); > > - found =3D 1; > > + > > + /* > > + * If the given TaskMID from the user space is zero, then= the > > + * first outstanding smid will be picked up. Otherwise, > > + * targeted smid will be the one. > > + */ > > + if (!tm_request->TaskMID || tm_request->TaskMID =3D=3D st= ->smid) { > > + tm_request->TaskMID =3D cpu_to_le16(st->smid); > > + found =3D 1; > > + } > > } > > > > if (!found) { > > > I think this is fundamentally wrong. > ABORT_TASK is used to abort a single task, which of course has to be > known beforehand. If you don't know the task, what exactly do you hope > to achieve here? Aborting random I/O? > Or, even worse, aborting I/O the driver uses internally and corrupt the > internal workflow of the driver? > > We should simply disallow any ABORT TASK from userspace if the TaskMID > is zero. And I would even argue to disabllow ABORT TASK from userspace > completely, as the smid is never relayed to userland, and as such the > user cannot know which task should be aborted. Hannes, This interface was added long time back in mpt2sas driver and I don't have exact reason of adding this interface at that time. But I know that this interface is still used by BRCM test team & few customers only for some functionality and regression testing. Thanks, Sreekanth > > Cheers, > > Hannes > -- > Dr. Hannes Reinecke Teamlead Storage & Networking > hare@suse.de +49 911 74053 688 > SUSE LINUX GmbH, Maxfeldstr. 5, 90409 N=C3=BCrnberg > GF: Felix Imend=C3=B6rffer, Mary Higgins, Sri Rasiah > HRB 21284 (AG N=C3=BCrnberg)