Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757203AbcK2Vrf (ORCPT ); Tue, 29 Nov 2016 16:47:35 -0500 Received: from mail-cys01nam02on0064.outbound.protection.outlook.com ([104.47.37.64]:18084 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1757117AbcK2VrL (ORCPT ); Tue, 29 Nov 2016 16:47:11 -0500 Authentication-Results: spf=fail (sender IP is 63.163.107.225) smtp.mailfrom=wdc.com; broadcom.com; dkim=none (message not signed) header.d=none;broadcom.com; dmarc=none action=none header.from=hgst.com; X-IncomingTopHeaderMarker: OriginalChecksum:;UpperCasedChecksum:;SizeAsReceived:2856;Count:16 X-AuditID: 0ac94371-a9ee698000000ee3-3b-583dedd39d6a From: Adam Manzanares To: , , , , , , , CC: Adam Manzanares Subject: [PATCH] mpt3sas: Recognize and act on iopriority info Date: Tue, 29 Nov 2016 13:13:59 -0800 Message-ID: <1480454039-2525-1-git-send-email-adam.manzanares@hgst.com> X-Mailer: git-send-email 2.7.4 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrOLMWRmVeSWpSXmKPExsXCddJ5ke7lt7YRBlvfGFncPrqDxeLt281M Fqsm5llc3jWHzaL7+g42i+XH/zFZzH3dwGSxYd4tFotnZ2IcOD1m3T/L5vHg0GYWj49Pb7F4 XDrbzuLxeZNcAGsUl01Kak5mWWqRvl0CV8aXaxtZCzZqVRzpmsrawHhIuYuRg0NCwETi4+bU LkYuDiGBpUwSb1Y8ZYVwtjFKLH26l7mLkROsaP3JgywQifWMEmdndbKCdLMJGEhMv5wIEhcR 6GaS2N83nxWkgVlAV2Lyzk9MIDXCAnYSCz85g4RZBFQlNvUuAyvhFXCX+NI5lRVivpzEzXOd ULu6WCVubtSDqBGUODnzCQvESAmJgy9eMIOMFAKac/y84ARGgVlIqmYhqVrAyLSKUSw3M6c4 Nz21wNBErzgxLyWzOFsvOT93EyMkuAt3ML6+7X2IUYCDUYmHd0KfbYQQa2JZcWXuIUYJDmYl Ed77r4FCvCmJlVWpRfnxRaU5qcWHGKU5WJTEeS9GfwwTEkhPLEnNTk0tSC2CyTJxcEo1MOZz T/mbr8F7dmt//LUN07zyz13uND6q1BzCkGDoeu5vSUKuY4Kbmo9ZQNH6lMuPy8U1ytP0ps5h eR/67Pn/KfODU7KtcxKiq1b/bfK9l+TM7e1VZMlYE8YXs+Tvmy27+p+U9f70U7xW8e2Am13C rMNJS09cfyw3VWzjxgbBow2uvkslLY0WKrEUZyQaajEXFScCAKvyFVRqAgAA X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFprPJMWRmVeSWpSXmKPExsXCtZGTTXfWe9sIgw0zrC0OrLjJZPH27WYm i1UT8ywu75rDZtF9fQebxfLj/5gs5r5uYLLYMO8Wi8WzMzEOnB6z7p9l83hwaDOLx8ent1g8 Pm+S82g/0M0UwBrFZZOSmpNZllqkb5fAlfHl2kbWgo1aFUe6prI2MB5S7mLk5JAQMJFYf/Ig SxcjF4eQwFpGiQ1HNjF3MXJwsAkYSEy/nAgSFxFoZpLYvXgKK0gDs4CuxOwpZ9hBaoQF7CQW fnIGCbMIqEps6l0GVsIr4C6x5MJMdoj5chI3z3UyT2DkXMDIsIpRLDczpzg3PbPA0EivODEv JbM4Wy85P3cTIyQIonYwXp9ofoiRiYNTqoGxsPQ8n+dU968vJF4bakfKbr5to/1w2zLBBesK TjdN+9a+pF8sz7z5EMNDp6wHRb/ZZm3vnvtp15rdRp8SlAIZFjxTDcwumduR9bw8fwqrhXHA B1f//lXd9Qw3H7+fJtN5YxYH43MZje6KYwm+R2VDo07PLDSPOHX6JN82gf9nGcR2P499z5qo xFKckWioxVxUnAgAnRK4P7IBAAA= MIME-Version: 1.0 Content-Type: text/plain X-IncomingHeaderCount: 16 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.225;IPV:NLI;CTRY:US;EFV:NLI;SFV:NSPM;SFS:(10009020)(6009001)(7916002)(2980300002)(1110001)(1109001)(339900001)(199003)(189002)(97736004)(85426001)(356003)(626004)(2270400002)(2906002)(5003940100001)(5660300001)(2201001)(189998001)(33646002)(92566002)(42882006)(6666003)(68736007)(5001770100001)(77096006)(69596002)(50226002)(106466001)(47776003)(105606002)(8936002)(50986999)(81156014)(50466002)(8676002)(36756003)(38730400001)(81166006)(7846002)(48376002)(4326007)(305945005)(32563001)(2101003);DIR:OUT;SFP:1101;SCL:1;SRVR:DM5PR02MB2219;H:milsmgep14.sandisk.com;FPR:;SPF:Fail;PTR:InfoDomainNonexistent;A:1;MX:1;LANG:en; X-Microsoft-Exchange-Diagnostics: 1;BY2FFO11OLC012;1:rrVGKe/5GMI/w3B7lMWOSYr6FmHr02zcucXuB9S1P9L7RzzXwNtmm3DN8vCY402FVmALGOmFNQprNJeRieujvM1mR+EBEMCiEaN3UHcCIDQjcidC5StZCchT6C1s3cr8xUwbW1U+LFMpoDoUC/sm4ogwR5Zkw/h6wEsok+udOjh0u/sRP46RR+jLq+hV5qAmWskOiwbT3+OdkIxRy+Wy6KcIRaziFLarad4K7kXLGpZ56CwG1nOe5n1nFHCuQWDEFTACpskUf1dItWpG5t164LAOj8JpVOG3bkJNB1lmuAEkPKtqYt0DcTMrjw3TuerpU9Ew5wigqgViZe/Uvt+P17Oo1iJBep5t0JRtU9k+C+nq84J71RsIW9T4Aj9PF6H+u+/UB2vbzYugYtjQrFdrb+QQQoGHy0TZthdw+4lOi02gSjxo/uJ8jMoRbfUzmICXbzjJjy0IUCLwtiVbA6Mfl1dm6UscejpS0ewIt5Uf5FoxK9RQTNhpGR82ZQfC6d8p X-Microsoft-Exchange-Diagnostics: 1;DM5PR02MB2219;2:XIdDDTpOjLdT6XQnA8GmQ/MdyhlWirMYN1IrVgt09z/Z14FC7z5CMaUkouB1nqK8o5l6V7MkIC15OWfVvJAYysHu7lvpMeyQkg0n0xP8+JQMaWrQdf9MWwKkooyHpScPDGvA3gupnSM2JXKN5ZlCPV6YUe81F/tvODSjHKj/sI4=;3:frmAVCTiAWE03VF/+70R4ZEoRxl7ZzE9l67YR/EssDTSFHPq8xwqoLzPNPy4YJpFRWTb1YuDOKEGyAWzZ70CxIw+CDsv0eu5EgNyNCZ/1o44LrNs2lSlpeeDWCJDX/vENSXt5Bib7cwmtCOrkXhGLl0Eet7te8yrkCawWx0dBiGSZrgNT0drZzdJpdR6MySPEFiLeCWwtNtSXgfhytrvwShHpUrUeHcttbpyPnq1yNoIq5z+NI+hcw8oMOWfe/ITVlgcNfnaP8m7R3KO4MBqEQ==;25:pDhkSRv77J5nArxasp3H8MC3yoG+QPLYceKEOPlf1aG3jlqIlN4WNfvQVDU+UmircI2xwAA4zPcuIzShTgg4AvHt8WTuBLMWndJiOlUmykmwpj+9PzZ19lk5jXKBnGB2+LSV/JZSwdyIvrk0Z1lTFlNmBxhw/4ksuLpzqQFs1nx2L7lVJ2g/WU+57sPOxIaHrpDf25t8ZB8zpnYmSNRI+O5Haujp+DnTdz5aGlWs/QileqhCPfapCp875Rdz8FIIkuoMa3eXcHTDKjYa1jsJJkLFfiaUjni4iONOGfkQCjaUG6w7kBu4Wzd2vCbk4XjD2kSlsYuoU2i6zvsTfRajHB8qKrgIuH+uU5RPM2QZgnqc+feCfgAvVo9RWn+7U04mx0My3pdZGkGc3Nk7QFsvkDoDuMminPbKKv6n4id+CsLPn7iutyupnl4fOnvMrMup3UPTnp4sFuPZOyoQEjKolA== X-MS-Office365-Filtering-Correlation-Id: cd9aca8a-dc88-45ac-ccf3-08d4189ca6e6 X-Microsoft-Antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001);SRVR:DM5PR02MB2219; X-LD-Processed: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d,ExtAddr X-Microsoft-Exchange-Diagnostics: 1;DM5PR02MB2219;31:ZSt6BZaGXoW+alBuleq9vIxuO/CnM1DoEulD84N/IBal645x45R2sEyhguFZitqWAeCv9rOc/W/4DlqsAKX00I0LSfX+Ip/pLAEPYf5WDD7018I/53bg7nZw1sqsB/HwAp1NTZSl2+SHmX5vvKgLGQCs34sxe8oUITgf8pQRdFlfMZXgV8R8KFc7wRHl9bOVnh/GSisL2CwWkYb3NxA7YyR3P70hjFhAqK3VVFbDq8uZVtbbgEuojG/LV7ZkrAE0B4NXBVpfO8liXwIlXQCk0w==;20:QcMjJqH4h/sPKMaYe/tnh7ZWE/FXAHPhcz2WA0C3Vgvk4b5MlhZ8ES1NLmtxm57x2ItquHpX6nP3ARG3u0P3GtxCo+4iZz81zAcQd2FI0hrdjDzFs+4jcit1AbVlvwjITIU/w/OpPLQM10KHUvvgll3WcIJeFp64Lvhg4iHnA/a9uSlbX9nyxbT2TaO4iCQ7uqk8m97OfPJ6NMXoCv0DhTdPSSor99LbltJdqPk6/A8Eddwfvlxx1lyvImD/k9qR6759bBGKE7b41bQ988Y5vLuGESDeFLdr23aGtSPsSaf3iOd5ZzaoU+qoK/6TCBnQBLrsWdrjQY2DmMJhZm3jyFWeTyVsz5qySGoea060l5pZZlMQy8aBRsljm3Ei/pRFyuW62lM3VLeXeR6u7PQtOSxy27X9odtER4mWQ+6b0o8H0zID0J9qQsTu8HjGwbvXisnNVe4bIkzG2SaeMlCQqdtANC4BV4QIwsdZ3uEWPArBipdNwofZWSpQPar4uwEu X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(601004)(2401047)(8121501046)(13018025)(5005006)(13016025)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123555025)(20161123562025)(20161123564025)(6072148)(6042181);SRVR:DM5PR02MB2219;BCL:0;PCL:0;RULEID:;SRVR:DM5PR02MB2219; X-Microsoft-Exchange-Diagnostics: 1;DM5PR02MB2219;4:5T5dgyocM2N0hrj+6hf2BcRRcgNqxTS2hfwij+JCbJLJMFBkWF2Wn9N+mjM/eDHDXLSOOQeplQYTVR9vRFs3WjqwE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t9uI9ZHK0yw1gAVX8rHD8HWoXLrVExGJeN0zbwxzvQmP9qtw8tHMpJBFoi2p0Lzuk2HCQsXEWyTHhCsvtpei3C+yfvtzf/EHBQdpciYWhWi+dpyOy8UDJ0 X-OriginatorOrg: sandiskcorp.onmicrosoft.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 29 Nov 2016 21:14:05.8942 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d;Ip=[63.163.107.225];Helo=[milsmgep14.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM5PR02MB2219 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 5262 Lines: 161 From: Adam Manzanares This patch adds support for request iopriority handling in the mpt3sas layer. This works only when a ATA device is behind the SATL. The ATA device also has to indicate that it supports command priorities in the identify information that is pulled from the SATL. This patch depends on block: Add iocontext priority to request Signed-off-by: Adam Manzanares --- drivers/scsi/mpt3sas/mpt3sas_base.h | 6 +++++ drivers/scsi/mpt3sas/mpt3sas_ctl.c | 43 ++++++++++++++++++++++++++++++++++-- drivers/scsi/mpt3sas/mpt3sas_scsih.c | 31 ++++++++++++++++++++++++++ 3 files changed, 78 insertions(+), 2 deletions(-) diff --git a/drivers/scsi/mpt3sas/mpt3sas_base.h b/drivers/scsi/mpt3sas/mpt3sas_base.h index 3e71bc1..354cdc7 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_base.h +++ b/drivers/scsi/mpt3sas/mpt3sas_base.h @@ -402,6 +402,9 @@ struct MPT3SAS_DEVICE { u8 block; u8 tlr_snoop_check; u8 ignore_delay_remove; + /* Iopriority Command Handling */ + u8 ncq_prio_enable; + }; #define MPT3_CMD_NOT_USED 0x8000 /* free */ @@ -1449,4 +1452,7 @@ mpt3sas_setup_direct_io(struct MPT3SAS_ADAPTER *ioc, struct scsi_cmnd *scmd, struct _raid_device *raid_device, Mpi2SCSIIORequest_t *mpi_request, u16 smid); +/* NCQ Prio Handling Check */ +bool scsih_ncq_prio_supp(struct scsi_device *sdev); + #endif /* MPT3SAS_BASE_H_INCLUDED */ diff --git a/drivers/scsi/mpt3sas/mpt3sas_ctl.c b/drivers/scsi/mpt3sas/mpt3sas_ctl.c index 26cdc12..3ad8339 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_ctl.c +++ b/drivers/scsi/mpt3sas/mpt3sas_ctl.c @@ -3290,8 +3290,6 @@ static DEVICE_ATTR(diag_trigger_mpi, S_IRUGO | S_IWUSR, /*********** diagnostic trigger suppport *** END ****************************/ - - /*****************************************/ struct device_attribute *mpt3sas_host_attrs[] = { @@ -3367,9 +3365,50 @@ _ctl_device_handle_show(struct device *dev, struct device_attribute *attr, } static DEVICE_ATTR(sas_device_handle, S_IRUGO, _ctl_device_handle_show, NULL); +/** + * _ctl_device_ncq_io_prio_show - send prioritized io commands to device + * @dev - pointer to embedded device + * @buf - the buffer returned + * + * A sysfs 'read/write' sdev attribute, only works with SATA + */ +static ssize_t +_ctl_device_ncq_prio_enable_show(struct device *dev, + struct device_attribute *attr, char *buf) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata; + + return snprintf(buf, PAGE_SIZE, "%d\n", + sas_device_priv_data->ncq_prio_enable); +} + +static ssize_t +_ctl_device_ncq_prio_enable_store(struct device *dev, + struct device_attribute *attr, + const char *buf, size_t count) +{ + struct scsi_device *sdev = to_scsi_device(dev); + struct MPT3SAS_DEVICE *sas_device_priv_data = sdev->hostdata; + bool ncq_prio_enable = 0; + + if (kstrtobool(buf, &ncq_prio_enable)) + return -EINVAL; + + if (!scsih_ncq_prio_supp(sdev)) + return -EINVAL; + + sas_device_priv_data->ncq_prio_enable = ncq_prio_enable; + return strlen(buf); +} +static DEVICE_ATTR(sas_ncq_prio_enable, S_IRUGO | S_IWUSR, + _ctl_device_ncq_prio_enable_show, + _ctl_device_ncq_prio_enable_store); + struct device_attribute *mpt3sas_dev_attrs[] = { &dev_attr_sas_address, &dev_attr_sas_device_handle, + &dev_attr_sas_ncq_prio_enable, NULL, }; diff --git a/drivers/scsi/mpt3sas/mpt3sas_scsih.c b/drivers/scsi/mpt3sas/mpt3sas_scsih.c index 209a969..e2117cc 100644 --- a/drivers/scsi/mpt3sas/mpt3sas_scsih.c +++ b/drivers/scsi/mpt3sas/mpt3sas_scsih.c @@ -4030,6 +4030,8 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) struct MPT3SAS_DEVICE *sas_device_priv_data; struct MPT3SAS_TARGET *sas_target_priv_data; struct _raid_device *raid_device; + struct request *rq = scmd->request; + int class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq)); Mpi2SCSIIORequest_t *mpi_request; u32 mpi_control; u16 smid; @@ -4085,6 +4087,10 @@ scsih_qcmd(struct Scsi_Host *shost, struct scsi_cmnd *scmd) /* set tags */ mpi_control |= MPI2_SCSIIO_CONTROL_SIMPLEQ; + /* NCQ Prio supported, make sure control indicated high priority */ + if (class == IOPRIO_CLASS_RT && + sas_device_priv_data->ncq_prio_enable) + mpi_control |= 1 << MPI2_SCSIIO_CONTROL_CMDPRI_SHIFT; /* Make sure Device is not raid volume. * We do not expose raid functionality to upper layer for warpdrive. @@ -9031,6 +9037,31 @@ scsih_pci_mmio_enabled(struct pci_dev *pdev) return PCI_ERS_RESULT_RECOVERED; } +/** + * scsih__ncq_prio_supp - Check for NCQ command priority support + * @sdev: scsi device struct + * + * This is called when a user indicates they would like to enable + * ncq command priorities. This works only on SATA devices. + */ +bool scsih_ncq_prio_supp(struct scsi_device *sdev) +{ + unsigned char *buf; + bool ncq_prio_supp = false; + + if (!scsi_device_supports_vpd(sdev)) + return ncq_prio_supp; + + buf = kmalloc(SCSI_VPD_PG_LEN, GFP_KERNEL); + if (!buf) + return ncq_prio_supp; + + if (!scsi_get_vpd_page(sdev, 0x89, buf, SCSI_VPD_PG_LEN)) + ncq_prio_supp = (buf[213] >> 4) & 1; + + kfree(buf); + return ncq_prio_supp; +} /* * The pci device ids are defined in mpi/mpi2_cnfg.h. */ -- 2.7.4