From patchwork Thu Oct 13 23:00:30 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Manzanares X-Patchwork-Id: 9375947 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 359496075E for ; Thu, 13 Oct 2016 23:03:06 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 206CD2A205 for ; Thu, 13 Oct 2016 23:03:06 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 0F3EE2A208; Thu, 13 Oct 2016 23:03:06 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 58DF92A204 for ; Thu, 13 Oct 2016 23:03:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1757405AbcJMXCt (ORCPT ); Thu, 13 Oct 2016 19:02:49 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:30415 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751041AbcJMXB6 (ORCPT ); Thu, 13 Oct 2016 19:01:58 -0400 X-IronPort-AV: E=Sophos;i="5.31,490,1473091200"; d="scan'";a="25178992" Received: from mail-dm3nam03lp0021.outbound.protection.outlook.com (HELO NAM03-DM3-obe.outbound.protection.outlook.com) ([207.46.163.21]) by ob1.hgst.iphmx.com with ESMTP; 14 Oct 2016 07:00:58 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-wdc-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=p+EFMGohvssfYGFEoXH9OABY3GGYZ+OMy1z5oTsyF2o=; b=LTpypTBXQPmcoV5Wb9OLU4w/K4fBbiFcYDqUxIOZk5yKzi42Mp46UP6cP8Cr5ZO8Xwa9IUTcw40bJEs8ptSQujlG1r7Rf5tDcuMDf4jJCRyjBKT9n+4REuQgiCC3byh5RZ1E9Bj3LDutwpHFCgRCxMSkoxPAQUyyC38Mq+azgoU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Adam.Manzanares@wdc.com; Received: from penguito.sanjose.hgst.com (199.255.44.173) by BLUPR0401MB1713.namprd04.prod.outlook.com (10.162.215.15) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.659.11; Thu, 13 Oct 2016 23:00:54 +0000 From: Adam Manzanares To: , , , , , , , , , , CC: , , , , , Adam Manzanares , Adam Manzanares Subject: [PATCH v5 3/4] ata: Enabling ATA Command Priorities Date: Thu, 13 Oct 2016 16:00:30 -0700 Message-ID: <1476399631-5799-4-git-send-email-adam.manzanares@hgst.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1476399631-5799-1-git-send-email-adam.manzanares@hgst.com> References: <1476399631-5799-1-git-send-email-adam.manzanares@hgst.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: BY1PR13CA0002.namprd13.prod.outlook.com (10.162.107.140) To BLUPR0401MB1713.namprd04.prod.outlook.com (10.162.215.15) X-MS-Office365-Filtering-Correlation-Id: 1cbece2a-1daf-49cf-ce40-08d3f3bcca4d X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 2:chxXRG0sqqhvU70veqY9cynr6DWhos/KoGuDc7sghq81AAxOSyhOiJPUYG9j/ECpfk9mUnyGnCSX97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fgb+yzRiUz7iABVRKbrva1SP7iJmi9zkT; 20:7QrSlaFTpPklN9z0eg214t1Xs/IEPicP/vzMrkNzMWwkGh0ylVmvICLlxEFUdGebnl1jrGBnF4CwgE8lDRMBiRFASnkWVyWcBCgdziGxnJFI1DpFp9j90jjPTqXKZpScnVgqDowytV0L898xP0vxTslDXBo/YmkLX1g4kf8F7KNvOEaCMajmgpf5gU6ZYQkm/HWB266jjXjDvIE9FZmJM0F0j+N+jNZs2tphFm/sJTyoXun2cjWXICfcTf5/eAaCA6mj5H2WuEXb5T3Y8r+1gFXbrsq2jSEFEn85+qdjCLZjMSWLBDG1U0vwSQUaAYqy+GZmE8/AhdaP0vAWlDT/bV1KB5A6/lcC1wPF0mwzPrZLVQT24K3Z7JX4Lnc4Ni35QYEmpxU24ukjzHVkdjGtYQJkcxbl26a1m9r1QCk7KGABEROG9QPRqWr/5iDy5jJgmrmw0OLx9Z2U2hzBVo2cGK0YAsU27JfJQb/zFMC3dlEcl0Lvxo2QQl9A95QvwOTY X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:; X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040176)(601004)(2401047)(5005006)(8121501046)(10201501046)(3002001)(6055026); SRVR:BLUPR0401MB1713; BCL:0; PCL:0; RULEID:; SRVR:BLUPR0401MB1713; X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 4:6s27O9CUjin2dq78+2HDmLs+H6Ch2RKJ9w5PMHCIppdG6IGIlPs9HyEpPTngyxgAhpctaasBre2AFm3gzO0yxaTFLa12lJ0owoiRlsa9dgIc8ZfmyxCUTBRv17L0qEuLoLcScOuwhuQldZYzE0Yg0nHte57AXnioJG8EUYp4p60DpWMaNa4DJbwpiy/KuagT0sNZnMCgfIyfBxRimQN17qf7TPEhItA7XNYOl+Z/qmIHKZKqn4obUa7QOL8k2ntdGwEYiViW2edvSR17AmcPJtWIzcn8ZzWbrhKVLdb6i22JASYsdXguCJ8/U2UdW363XqQ/alZo/1Z9nyf7sPVDIwXX39ZaFTJzaWLgElkKxpHGzAmS2FfQtda8/3bwImQ02ljjDFvPAGXDYgZj+OuOa9dFTp6KKazHEgktp7D4tgI= X-Forefront-PRVS: 0094E3478A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(199003)(189002)(92566002)(4326007)(42882006)(7416002)(3846002)(36756003)(106356001)(7846002)(305945005)(6116002)(2906002)(50226002)(97736004)(105586002)(19580395003)(47776003)(2201001)(2950100002)(48376002)(33646002)(586003)(7736002)(66066001)(19580405001)(76176999)(6666003)(42186005)(5003940100001)(189998001)(50466002)(77096005)(229853001)(5001770100001)(68736007)(50986999)(5660300001)(8676002)(81166006)(81156014)(101416001)(7099028)(921003)(1121003)(2101003)(83996005); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0401MB1713; H:penguito.sanjose.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: wdc.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0401MB1713; 23:vjVS5fSzLD0wQhJBpI17ioku3LpMQ9rv1WzxABU?= =?us-ascii?Q?dkR6w0dnnSec7RUxuHXbm7TYcSNQ+ofFFLOkcLu/XUE8wVwylKTSg5jZVDW8?= =?us-ascii?Q?sMrwLVHv2KFLgxkth1Rwg6xlcRgFL4TT1aKbd3pdc5ZMzTSzdcCeq7M/CbLn?= =?us-ascii?Q?D5GrRfddEvHuvrY3qmR0Nt+Ja4Jhe08eWe5axWalVTi6pyI6BQpXmscq/HVY?= =?us-ascii?Q?abepBkvISl10ycNoymm2RTn1MhewFNTpMYCMG/GfUhBZ9s91/RCEUtM03pkW?= =?us-ascii?Q?n/Tw97czKlEdzMGU7nLImuA5NthT1l4OXS4VC4XIL9Cf9CBWRpD2CKY6g7eA?= =?us-ascii?Q?Cd8PoNgHDgquQA+BcdoG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-Diagnostics: 1; BLUPR0401MB1713; 6:iVr61KlAMy/Tk8WyDyPGsL/WRMTZEe5EuQMZwYlZq/wkCuD3n0vaN/2sH29j3hjLNUBk12klaTtSUbe6EwZTlcIG0RrnTYEuXAFhcf31fIRX3luBPH+j2k5BmnazDe2R5byvuO2HPa9wzXQtVmRplqX92uIfOIWabPimem3BH2miTAelMpfa1DScMORhZ2qAPNLwOKChLtXqexLbGrDXy8monM/5V7rlXPXItngwvsKQ96RKpDDjUIYWUxKJvJuIn7iLiDJpw3bLbexXbeQGVMGntAJ3cBLEgrrawVD8kQ/bp4B6HX07xShFcn8CIcBGRjp4u5Hv5U55siquVo4D1eBixUAMvxpMgu7rf174LOk=; 5:wUpeQs/UBeak8zqXms96mbpb9z1tY+lDtowngyHL0nxiIw9bWPT4w7tbo2mY8E2RtHl8mijwgFSOqdWVNf576PfiTSu3xiQXVGJuHq81MhAzOVkvDvp0hWSZptZhRjNp21DB/91UZ0gFn0r/0EbdfE7nlqAsildt6Pl2u8wz6Sk=; 24:882nH/cTtXdaRzwQShD7/IfhiI6d9cSzab/pdJoZ9zwsywoDDaqdRKDeFTCUgFwfCSNcj+B978IdaeHihrpgXHRNFk/VY9HaYEYt+9nY1JI= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 7:b7VBf8zyb6cmavCCCI4rntoM6iVPjqa9WYhBEqjqJXNX7NyojjsgpST1QvUouWNlkrTULPDdgykABIyeW4xhM3zdOSaUeLXOUGHCX5Z8XmEfh12npwHmda3IrChF4LonfDKAVgSq7i0s+1tZbuNolWtIJasdL3N28QrpLjIsRp8BAEK/UNIATsrF4IoVNFM5hMmsmICAUb8cOFThr0udJSo08U9GBhWXUEbNPH1TUXupVWmI3qalgEOeVcg3H/8kBxQFopekmLMoy0cq2J+V4rNpp2oIP2yMqJv9vt3VcagsgJd9Kc1PEwbwcnF7s29JOg37t83sjpzzSuvKiEf8mbUSVhGQbNN9Tb0+77D1XMo=; 20:GJhLXCQzaQNOuANlnkhLHXW6pVO15ucMBd1e8CeG7ft4PJcEpK3fWj/ZkAxY5mF7ukJ6Yu24Jj94vJrQS/e6HIa6uqPemAZB9/YfWBoEY/pkODux5xJ5EfOzO2UJBhbKmq8wWNX4RiFNLPny4wPJFFw1CO+Uim6cuzKLxGfKKsSFYDJVREkb8N9kbK7mH6H+64/C6fnXescfFiW6cnbAjT4MbQiDcPBOaH8T/iWfS0qCQnTQT/jGj4b6FHLHiLgq X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 13 Oct 2016 23:00:54.8176 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0401MB1713 Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch checks to see if an ATA device supports NCQ command priorities. If so and the user has specified an iocontext that indicates IO_PRIO_CLASS_RT then we build a tf with a high priority command. This is done to improve the tail latency of commands that are high priority by passing priority to the device. Signed-off-by: Adam Manzanares --- drivers/ata/libata-core.c | 35 ++++++++++++++++++++++++++++++++++- drivers/ata/libata-scsi.c | 6 +++++- drivers/ata/libata.h | 2 +- include/linux/ata.h | 6 ++++++ include/linux/libata.h | 18 ++++++++++++++++++ 5 files changed, 64 insertions(+), 3 deletions(-) diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index 223a770..181b530 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c @@ -739,6 +739,7 @@ u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev) * @n_block: Number of blocks * @tf_flags: RW/FUA etc... * @tag: tag + * @class: IO priority class * * LOCKING: * None. @@ -753,7 +754,7 @@ u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev) */ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, u64 block, u32 n_block, unsigned int tf_flags, - unsigned int tag) + unsigned int tag, int class) { tf->flags |= ATA_TFLAG_ISADDR | ATA_TFLAG_DEVICE; tf->flags |= tf_flags; @@ -785,6 +786,12 @@ int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, tf->device = ATA_LBA; if (tf->flags & ATA_TFLAG_FUA) tf->device |= 1 << 7; + + if (ata_ncq_prio_enabled(dev)) { + if (class == IOPRIO_CLASS_RT) + tf->hob_nsect |= ATA_PRIO_HIGH << + ATA_SHIFT_PRIO; + } } else if (dev->flags & ATA_DFLAG_LBA) { tf->flags |= ATA_TFLAG_LBA; @@ -2156,6 +2163,30 @@ static void ata_dev_config_ncq_non_data(struct ata_device *dev) } } +static void ata_dev_config_ncq_prio(struct ata_device *dev) +{ + struct ata_port *ap = dev->link->ap; + unsigned int err_mask; + + err_mask = ata_read_log_page(dev, + ATA_LOG_SATA_ID_DEV_DATA, + ATA_LOG_SATA_SETTINGS, + ap->sector_buf, + 1); + if (err_mask) { + ata_dev_dbg(dev, + "failed to get Identify Device data, Emask 0x%x\n", + err_mask); + return; + } + + if (ap->sector_buf[ATA_LOG_NCQ_PRIO_OFFSET] & BIT(3)) + dev->flags |= ATA_DFLAG_NCQ_PRIO; + else + ata_dev_dbg(dev, "SATA page does not support priority\n"); + +} + static int ata_dev_config_ncq(struct ata_device *dev, char *desc, size_t desc_sz) { @@ -2205,6 +2236,8 @@ static int ata_dev_config_ncq(struct ata_device *dev, ata_dev_config_ncq_send_recv(dev); if (ata_id_has_ncq_non_data(dev->id)) ata_dev_config_ncq_non_data(dev); + if (ata_id_has_ncq_prio(dev->id)) + ata_dev_config_ncq_prio(dev); } return 0; diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index e207b33..18629e8 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -50,6 +50,7 @@ #include #include #include +#include #include "libata.h" #include "libata-transport.h" @@ -1757,6 +1758,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) { struct scsi_cmnd *scmd = qc->scsicmd; const u8 *cdb = scmd->cmnd; + struct request *rq = scmd->request; + int class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq)); unsigned int tf_flags = 0; u64 block; u32 n_block; @@ -1823,7 +1826,8 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) qc->nbytes = n_block * scmd->device->sector_size; rc = ata_build_rw_tf(&qc->tf, qc->dev, block, n_block, tf_flags, - qc->tag); + qc->tag, class); + if (likely(rc == 0)) return 0; diff --git a/drivers/ata/libata.h b/drivers/ata/libata.h index 3b301a4..8f3a559 100644 --- a/drivers/ata/libata.h +++ b/drivers/ata/libata.h @@ -66,7 +66,7 @@ extern u64 ata_tf_to_lba48(const struct ata_taskfile *tf); extern struct ata_queued_cmd *ata_qc_new_init(struct ata_device *dev, int tag); extern int ata_build_rw_tf(struct ata_taskfile *tf, struct ata_device *dev, u64 block, u32 n_block, unsigned int tf_flags, - unsigned int tag); + unsigned int tag, int class); extern u64 ata_tf_read_block(const struct ata_taskfile *tf, struct ata_device *dev); extern unsigned ata_exec_internal(struct ata_device *dev, diff --git a/include/linux/ata.h b/include/linux/ata.h index adbc812..ebe4c3b 100644 --- a/include/linux/ata.h +++ b/include/linux/ata.h @@ -347,6 +347,7 @@ enum { ATA_LOG_DEVSLP_DETO = 0x01, ATA_LOG_DEVSLP_VALID = 0x07, ATA_LOG_DEVSLP_VALID_MASK = 0x80, + ATA_LOG_NCQ_PRIO_OFFSET = 0x09, /* NCQ send and receive log */ ATA_LOG_NCQ_SEND_RECV_SUBCMDS_OFFSET = 0x00, @@ -897,6 +898,11 @@ static inline bool ata_id_has_ncq_non_data(const u16 *id) return id[ATA_ID_SATA_CAPABILITY_2] & BIT(5); } +static inline bool ata_id_has_ncq_prio(const u16 *id) +{ + return id[ATA_ID_SATA_CAPABILITY] & BIT(12); +} + static inline bool ata_id_has_trim(const u16 *id) { if (ata_id_major_version(id) >= 7 && diff --git a/include/linux/libata.h b/include/linux/libata.h index e37d4f9..244f261 100644 --- a/include/linux/libata.h +++ b/include/linux/libata.h @@ -165,6 +165,7 @@ enum { ATA_DFLAG_NO_UNLOAD = (1 << 17), /* device doesn't support unload */ ATA_DFLAG_UNLOCK_HPA = (1 << 18), /* unlock HPA */ ATA_DFLAG_NCQ_SEND_RECV = (1 << 19), /* device supports NCQ SEND and RECV */ + ATA_DFLAG_NCQ_PRIO = (1 << 20), /* device supports NCQ priority */ ATA_DFLAG_INIT_MASK = (1 << 24) - 1, ATA_DFLAG_DETACH = (1 << 24), @@ -341,7 +342,9 @@ enum { ATA_SHIFT_PIO = 0, ATA_SHIFT_MWDMA = ATA_SHIFT_PIO + ATA_NR_PIO_MODES, ATA_SHIFT_UDMA = ATA_SHIFT_MWDMA + ATA_NR_MWDMA_MODES, + ATA_SHIFT_PRIO = 6, + ATA_PRIO_HIGH = 2, /* size of buffer to pad xfers ending on unaligned boundaries */ ATA_DMA_PAD_SZ = 4, @@ -1609,6 +1612,21 @@ static inline int ata_ncq_enabled(struct ata_device *dev) ATA_DFLAG_NCQ)) == ATA_DFLAG_NCQ; } +/** + * ata_ncq_prio_enabled - Test whether NCQ prio is enabled + * @dev: ATA device to test for + * + * LOCKING: + * spin_lock_irqsave(host lock) + * + * RETURNS: + * 1 if NCQ prio is enabled for @dev, 0 otherwise. + */ +static inline int ata_ncq_prio_enabled(struct ata_device *dev) +{ + return (dev->flags & ATA_DFLAG_NCQ_PRIO) == ATA_DFLAG_NCQ_PRIO; +} + static inline bool ata_fpdma_dsm_supported(struct ata_device *dev) { return (dev->flags & ATA_DFLAG_NCQ_SEND_RECV) &&