Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp1534238ybi; Sat, 27 Jul 2019 11:56:08 -0700 (PDT) X-Google-Smtp-Source: APXvYqxPUpIrIWZWWCRvDCJefjkwDSuVZnkyZNYzUEtm8RzuRy3rF6tKHQx5go/BDaEn5l42DSKb X-Received: by 2002:a17:902:b48c:: with SMTP id y12mr67778521plr.202.1564253767892; Sat, 27 Jul 2019 11:56:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564253767; cv=none; d=google.com; s=arc-20160816; b=UbwFQIE2oaHPU0sJrKpgYnt8KNcJzDm6XZ0aVL3XWizkfv6qAZD4M6vdt3Kk4y8kMV 4dvQb8IGR03zeOeQcgkBdiu4iNuWPFI4ErBfOdZP2ls5itFUHIP2guVoB2sn2uJ2ABgJ ahIL34NO3fmTOEjM0JLyvjaGY7vORH3pZCUvsKT06alSqyvAL6882gRv+UZ6oNyaMaud 7EwF+ZmGTGNdM8CcSl+9oMrR5USwUf9KSbrBh7zoBUy+6VTho6yirynu4SGjnY2pDAkU JZn82Omd4rA4Ac7X+mTXk2ZZJ8UJpGRwzfmZxpDbAE1rMOJwD5w8Xu1hxrDpiW94rinE /hmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature; bh=y3DnasAilMtI3RHpffbNTgKJ99rymltM1iusWTe3er4=; b=ztLiNs5LOVzN+XMlAcPQChcNgBb7snbpRFqPHkWb+D7HehSlQ5cpxgH2ytOGdjGqOp r2+1gdb4/bNARAv8crgLNk53/9AMDQEvyLiZ6/KpdwySp63DoqMffdgFswPiy6fHovK8 VcPqBCvPuwXWkIbDzSxcJ2JulijTypmuKv+Vu+7QGulkFbEQJ6hR/GVZNQ0SO1ASolo0 KQ5PF1V/zuoyWGaaQ30pTERT2NRpRv9NzFX3FE5FGxjf8s5lfO4lvbOAelo4nIxn9cS/ 6x0Fcqi85FcB+1hokwRktRlURasbq4P0AXtaJIi9qML/DrPQ3ZWHTSXzRcOd2Uz/C0+D oCow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=Ix+I4uDU; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u38si22296102pgl.507.2019.07.27.11.55.51; Sat, 27 Jul 2019 11:56:07 -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=@gmail.com header.s=20161025 header.b=Ix+I4uDU; 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=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388131AbfG0Sxq (ORCPT + 99 others); Sat, 27 Jul 2019 14:53:46 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:37160 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387794AbfG0Sxp (ORCPT ); Sat, 27 Jul 2019 14:53:45 -0400 Received: by mail-pf1-f195.google.com with SMTP id 19so26020583pfa.4; Sat, 27 Jul 2019 11:53:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=y3DnasAilMtI3RHpffbNTgKJ99rymltM1iusWTe3er4=; b=Ix+I4uDUS+gstrellW1g3Ojk4+fwQ2/s3x9Iu03wCV2yR0JJ5oQDgFZOeqTuyGDrny EuiEnHsq8/vKBvSOmZFZNYgbsAj5t3Df70F9XY+1FyTQXCxi9ko9ktlCVNJql+pyiEfK aGaWBAkqEyp8t1mfUMmMnoBoATOQ3qzoWSC6i+oraTxhAFL/BbqkIlDwiNRb4+F/rWp7 /h4UK1pDWIa5HGI8yq51vQx1QV3PaHRUKNEwoRC6WaCOJxuTkBsQt1Gq6yYarZJsJ5we J8aiugN7hfvWBo9+a+LDXnyNur2GOzWOBj4QLKPe7ohqfhzvEWYm1k+bB/JQFtGXtA3r 4xTg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=y3DnasAilMtI3RHpffbNTgKJ99rymltM1iusWTe3er4=; b=E9tvL7LgYtG28qoqvFbpi+tlr9+FIHGpbeuZx9xZw9oASIFO9Le4Y7MyHUIbwiGcrb v4I/tJkbUMC7hkEHIwuewnMInsnG3N3/xVduBOyUegFldr3JG+hR7nGs+tuYNa8fy/GY 57fLt2nE6DryiULMlgdRcVVT75qRf9MSrwJz7XRh8tnpTB0OS76++gO0IGXr2b6bA+Fg TTonE4kNbDIB/WPziWxUa40DxBSA4GMnWJZ86a76h77ohyDtBDzG4/jDdbdMpcwmA+1u mgaVPP8GYUCsiIaJqtZs/3IjZJDZCgW7fwAaryS6t6AOiLrKRBqXJCT/xZ0xAbK9a7cH rs2w== X-Gm-Message-State: APjAAAWpjskDbYXKLo/DvALdB7l12IyuhwMnnM7FJKg7QFm/BOIrK20i miqxCelbrJdQ2HucjnoG1Von/3dVJN8= X-Received: by 2002:a62:2f06:: with SMTP id v6mr28749668pfv.195.1564253624486; Sat, 27 Jul 2019 11:53:44 -0700 (PDT) Received: from localhost.localdomain ([123.213.206.190]) by smtp.gmail.com with ESMTPSA id j10sm22023163pfn.188.2019.07.27.11.53.40 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 27 Jul 2019 11:53:43 -0700 (PDT) From: Minwoo Im To: linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Euihyeok Kwon , Sarah Cho , Sanggwan Lee , Gyeongmin Nam , Sungjun Park , Minwoo Im , Sreekanth Reddy , Suganath Prabu Subramani , Sathya Prakash , "James E . J . Bottomley" , "Martin K . Petersen" , MPT-FusionLinux.pdl@broadcom.com, Minwoo Im Subject: [RESEND PATCH] mpt3sas: support target smid for [abort|query] task Date: Sun, 28 Jul 2019 03:53:37 +0900 Message-Id: <20190727185337.19299-1-minwoo.im.dev@gmail.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Minwoo Im From: Minwoo Im We can request task management IOCTL command(MPI2_FUNCTION_SCSI_TASK_MGMT) 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_idx, 3320 struct scsi_cmnd *scmd) 3321 { 3322 struct scsiio_tracker *request = scsi_cmd_priv(scmd); 3323 unsigned int tag = scmd->request->tag; 3324 u16 smid; 3325 3326 smid = 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 Acked-by: Sreekanth Reddy 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 d4ecfbbe738c..a26c5516ea3e 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, struct mpt3_ioctl_command *karg, if (priv_data->sas_target->handle != handle) continue; st = scsi_cmd_priv(scmd); - tm_request->TaskMID = cpu_to_le16(st->smid); - found = 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 == st->smid) { + tm_request->TaskMID = cpu_to_le16(st->smid); + found = 1; + } } if (!found) { -- 2.17.1