From patchwork Wed Oct 5 19:00:06 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Adam Manzanares X-Patchwork-Id: 9363287 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 1D9566077E for ; Wed, 5 Oct 2016 19:00:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0F8C228699 for ; Wed, 5 Oct 2016 19:00:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 02CBC286A0; Wed, 5 Oct 2016 19:00:27 +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=ham 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 3665528699 for ; Wed, 5 Oct 2016 19:00:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752891AbcJETAX (ORCPT ); Wed, 5 Oct 2016 15:00:23 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:26293 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752199AbcJETAV (ORCPT ); Wed, 5 Oct 2016 15:00:21 -0400 X-IronPort-AV: E=Sophos;i="5.31,302,1473091200"; d="scan'";a="23884505" Received: from mail-by2nam03lp0056.outbound.protection.outlook.com (HELO NAM03-BY2-obe.outbound.protection.outlook.com) ([216.32.180.56]) by ob1.hgst.iphmx.com with ESMTP; 06 Oct 2016 03:00:20 +0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sharedspace.onmicrosoft.com; s=selector1-hgst-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=PVkNK7isP+fZazk2MktqmYfsZfiwIBtEbfdV7Gg6lOw=; b=ROhN/KdVch8u1Jmf9gi/oSUnzBqaUanzwqDCxjU8IpTx6B+rpqFvYYO0vrqucmbBdhSYm+2omX2DGMK5WO4OCXW6dhZr08mltLd+/LeRyQa/pZRzlzdrqWltZ9ayhDuivvYoaYuSHWoJLGzZUkHzWrb28pvQFXcD303QaqirbHU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Adam.Manzanares@hgst.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.649.16; Wed, 5 Oct 2016 19:00:17 +0000 From: Adam Manzanares To: , CC: , , Adam Manzanares Subject: [PATCH v2 1/2] ata: Enabling ATA Command Priorities Date: Wed, 5 Oct 2016 12:00:06 -0700 Message-ID: <1475694007-11999-2-git-send-email-adam.manzanares@hgst.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1475694007-11999-1-git-send-email-adam.manzanares@hgst.com> References: <1475694007-11999-1-git-send-email-adam.manzanares@hgst.com> MIME-Version: 1.0 X-Originating-IP: [199.255.44.173] X-ClientProxiedBy: BY2PR12CA0002.namprd12.prod.outlook.com (10.160.121.12) To BLUPR0401MB1713.namprd04.prod.outlook.com (10.162.215.15) X-MS-Office365-Filtering-Correlation-Id: 8eed6c92-d793-4df4-be30-08d3ed51d95c X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 2:+G1ERrHn2xyx8FuEzcfZET4iRNDjCfhEkIW/gElN4ePeu/KIpMCSBqRDwQnQzsjkFZK/MwPV9Hgp2NRdIbDDV/fR4jgaKWM35rHSyqiB1HjHfp7+E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DejD7mzETRGjbbf/GFo8Lx90aHtAtI= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 31:uQVE3osHQKzr1+EXVU65E4SDISRn0SCscTN2pwHD63CnAGJEP7s/0k8I4qAMd6pBaqjDgLCZK8RrP72gDvOCab08BClJHhX0QBuCkscxUVwqf12m6p1efSGcpLYRkb1lfKIDnlsW+M2duxGvlMyWyQWVDhzmpekQ9CrliRU93mwF6d36ROdJTTOQ1n0f3voNV5fDAgsU7f6BIg+UpOLWOAM8/zjMVJ6Ss9WOLfEDl5I4wmf6n0TirVWqN0hNQ1Fn1oaHu85hMdhFsODDC8PaQLK7PPHb44wn5yxb0RX3NXM=; 20:ZrvXI+qAZuOqzd1N63SFRHdc594kyjT361/xmGosZth1zZfi+M4IKW9p7QSLYRPLPovop+lmnxLBGLresZsVT9rvoeS/DM/PZQZ6ZGTVDofCS7T5oDoDw4WqtvM7b2pE2Orz4UykaQz+owjAXVAjciL1Xm2+plTWWn95bkitIrxuBhcRHHnQwRD2U2dRUNiygO8YAqkkvUQ8LRuhlEYg0NrTbsff+AizcN1QPyP28b7K5olfmhEvrAygt9bBXn/EdMc4ECMlECEB6fSfjI3uwp3KHkkzSAQSkYQCxkYmFrtw2AlUbPLn7sdLYu4jQyC/oYw57jf+OSQ3ovckJqX38HleGbdMMPBOcNIdqfIZFpDqZVmbyzbWUwtucxPCHNoAu8uaP0nQSbq6+ZjFuh6SXlRF/jYeCArg9sm6hqNcs+hT9xbvAVlfPAC9c6LhjBkJebAWhi8QJEv1EH5vfNVrVUGMoB4+2/yASZQhdkoM2CB+m2Vh6cVBR7Np9BTHIVMc X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(79135771888625); 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:0oU0uXWEZre2+z0R+MiT8O6tlLtvhymIetBGDYiZahArzXPfKGJzV4mR+ocH/LQ0GPZT+U7T/f8jWipw1Gz4KkrlQo3J4Jcdr9Ho5zOvwwZpi6c9pLu0N9qBznk4ql6w5xGSYIUPCxo17zsYTNV4pEgS/Pza3jCay4TUbCzWVROXksaPt6o2Ncfj1FELLA0AkoSwyZrt+C5G+uOdQrEhDnQDKdvBqQMhiqWDDcHsFCobLMQFvcDr+LtSY4h73l1KjCQMepjeDcsruDKEyyu+1zr1iKrjAEHh7AtH8lDqMZsp2nB+evqVB2SXYwjwwgHi/A4DzqBbHRwgX5dxaIl01d1ZzhwLliFng8bOPWjDePc8hFmV+PKbVfmtcKjgDavEVtCSM+jo8ATRgKeaA2E19ETim/SNfd41Jb9tSzHSRzo7uJgDkGJuPpQ4eCeVmhMmEwNfxZUjSCbChwZaEpCExA== X-Forefront-PRVS: 008663486A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10019020)(4630300001)(6009001)(7916002)(189002)(199003)(68736007)(4001430100002)(77096005)(48376002)(50466002)(6666003)(2950100002)(5003940100001)(5001770100001)(106356001)(305945005)(92566002)(586003)(50226002)(7846002)(7736002)(33646002)(3846002)(6116002)(5660300001)(19580405001)(189998001)(36756003)(66066001)(81166006)(8676002)(19580395003)(81156014)(4326007)(2906002)(97736004)(229853001)(105586002)(47776003)(42186005)(107886002)(101416001)(86362001)(50986999)(76176999)(7099028); DIR:OUT; SFP:1102; SCL:1; SRVR:BLUPR0401MB1713; H:penguito.sanjose.hgst.com; FPR:; SPF:None; PTR:InfoNoRecords; MX:1; A:1; LANG:en; Received-SPF: None (protection.outlook.com: hgst.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BLUPR0401MB1713; 23:t63d92WYhMaBeO3OSHIkSwPAHklGA+0oUfjoqdz?= =?us-ascii?Q?m6KKKMewyEbdr9+do6otaxjL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ascii?Q?87k7npl4PW4jgDgr1Xp7gSEMGiYktkOy8iz7Tbp3nUwlsK0M6cXtvsosajZu?= =?us-ascii?Q?PgY5hnOBWHTb5nI+CAU4AWWp1BfzDPHKpPk+eNu8TXVD9U+/KLu4gmCrj6kQ?= =?us-ascii?Q?ZUIwRYZdQqAYIT3mnqFHUbh9KPUPSAt/9Wu95dD8AFq20RD9x4wQ0kjvSZXg?= =?us-ascii?Q?InnL0fr3CzGTXMOjAien8GWOElSPGDfPL?= X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 6:08dRjs/ioBnHs8Ye7u/oGG3QiGLZWXBgFfhexaPBbzLl6DZtO+FcGCAwT3d9oeoyqUK0lPHi6tv5EDLvrDeypE6CAySm9UZenubJDuN4Gw29FLw+SyL9UsmphPSZMiBlTRNDOMlhF8RGG6sgTzTBj2mySig2dPxCA7m1HzknA/ogR53AbsZ3Iynh2EyySbcuKlGcZTY9SRmjrnOFIeZ3GxCALjBX4RwNiaAoggz80zgq4RQgqi/m/Q+iPv31hRSKeiZ8Ug1O4cyOwsMvHSZ0By1IOncijHoW+cJB8qnME5cKWc8XXA3IM89nBYXtWAM4Q47gtYF9m6Fw9A8eoQKGddaJfY/hEdPUS7C4JGsqgOU=; 5:MpGjusqo4U2WSLdo7Tj+NFE7/1GD3vWxlWSKTKBz5fIJQXvaBKAu16NvNrwSgFIb6C3XMoC5iffu829tE4SOb83R8vgclfyacdI8D7/dmVpJijaht2VhiEpRSDhr//bX8b4zlQ9BDadqGCODpdMbGaknmXrdctU4VshpAX2GKPY=; 24:AGgc2RgfOuIT+Uzb5p/Z6uBHWDAROqkwlEgR+0am+3jUGy884zCR20p4C5BuHI9XDFhXEli+0OgNcV4QELFMT1KAiXjAy6KpAeQbw8bGT2Y= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; BLUPR0401MB1713; 7:mmPwsevzxfHEU7p7LCdLtULS9NGUlirGNBAu9z5lp/yA/7WxC/HrzP/P66IZ1PNqQ8b6BgwdzzEaQhng7k6CKon2atMkXKjirEuuWhAN7kGCIZgVWTGoEe2BZ9BWLkRVOe6b2Mk84+dwEKh61Ghp4mI0VZsbkZYrE+yFHwKJkn1tUG+UHOABCrvEy9rYAgU8Uf4I2x+VXjnZoqMpd6dE86w2ZQZ6PD2e9fHmQt1s9/NauTvGcu7EXJmYWprqcETAb8qDVqGackT8PBDA1IGqnjy3LxUW3buo3aIA4ZGWlovzvg50ibMbAnq0U/BSQLAUbPJGIkL0cOZ03TZAEUjvDQ==; 20:9nsssIF+XS0iDfB9my2+ksZfTWmpnrIAg80qFb0bf+1wphvQa4FzhSUz1DrdvDP1s138DWPOCWX3uNguIXC9hZr3Lti/GqNGyYxgHKy6VcwtN3af39rHg0GXP4Q+msQqL1Fkt4NDPHJUm53A5p7mDDulEG4U4THMV6PmAsbBbiWaiRtnzdfN7aZj9Zh6v+/xdDc6yfjyz4wgZvQkJ+uQjFvkaKXdajtKe5/TEhUmhnbMpFdA1jvPKbTCH4T96QaV X-OriginatorOrg: hgst.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Oct 2016 19:00:17.9114 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-Transport-CrossTenantHeadersStamped: BLUPR0401MB1713 Sender: linux-block-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-block@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 and also enables request priorities in the block queue then we build a tf with a high priority command. This patch depends on patch block-Add-iocontext-priority-to-request Signed-off-by: Adam Manzanares Reviewed-by: Hannes Reinecke --- drivers/ata/libata-core.c | 35 ++++++++++++++++++++++++++++++++++- drivers/ata/libata-scsi.c | 10 +++++++++- drivers/ata/libata.h | 2 +- include/linux/ata.h | 6 ++++++ include/linux/libata.h | 18 ++++++++++++++++++ 5 files changed, 68 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..65ea15d 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 = 0; unsigned int tf_flags = 0; u64 block; u32 n_block; @@ -1822,8 +1825,13 @@ static unsigned int ata_scsi_rw_xlat(struct ata_queued_cmd *qc) qc->flags |= ATA_QCFLAG_IO; qc->nbytes = n_block * scmd->device->sector_size; + /* If queue supports req prio pass it onto the task file */ + if (blk_queue_req_prio(rq->q)) + class = IOPRIO_PRIO_CLASS(req_get_ioprio(rq)); + 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) &&