From patchwork Thu Aug 9 19:41:38 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561855 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D7B8513B4 for ; Thu, 9 Aug 2018 19:42:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C778C2B979 for ; Thu, 9 Aug 2018 19:42:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B9A962B97F; Thu, 9 Aug 2018 19:42:11 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 DAFC92B979 for ; Thu, 9 Aug 2018 19:42:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726971AbeHIWI2 (ORCPT ); Thu, 9 Aug 2018 18:08:28 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWI1 (ORCPT ); Thu, 9 Aug 2018 18:08:27 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843729; x=1565379729; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=wZHkDWD6raDrix7kY0p1HxuExgX2CoczUoBMuy66/nA=; b=B5cnOe2wkUzpfHI7h+uHmIIZhdKRnRlqGCsbZ0bG3/vSlXupiAqpnyiT ix8qtniD/5kW0aQsYd/q0cf/lae4QQDletKgwgYM8ABXdgFATDt0F0YED NN1OyztNCK9aNMOPOiVXDKXnbIpYfNvQz3XASDv1QVG9DfHQCRN39CR89 Od0O/bvCT1ayODedA0D44amYw0rCYBGWvRS60dgftIDc98YcgwW9odCR5 0zclF+seyO98RwXb6CkWohGQCqW2RlwpsSnzw/iN7uwbI9ATkyAA2xoD+ 9a5Yrt0655Sv9NmUCIUkA0K48PQ2nhR4waSCB+iXb2yrz13E3rutasjP7 Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119591" Received: from mail-sn1nam01lp0119.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.119]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:08 +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:X-MS-Exchange-SenderADCheck; bh=pvqTkTJB1FRQXxzNI7s7Sev7m4F5xEJmloH08kikT9E=; b=Ed0xoZmnsTkEV5sWGYgNCmPe88r1f2u+CSwidjcb5yuQG3LGOIIgy5EWCLoYgK1QlVmVrSmtEWCKINpm0XEl7FoYt/lEPx3fYM93LGp+vIO2NVWsqI8m0Ic53OjwIrvne54FtX2TUo01v5qlpVx9ZE5RSd2r6YCGDkcsf3UCx1o= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:04 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , "David S . Miller" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 01/12] block, scsi: Introduce request flag RQF_DV Date: Thu, 9 Aug 2018 12:41:38 -0700 Message-Id: <20180809194149.15285-2-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 37c595b2-de51-4642-c349-08d5fe302f73 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:SvObngyIWSHCvlkM35Gw7yjYJ8M5EbZpcBNLU94jT2oTAWRM+MBD2IOHwsuja+dlfyoMuyGdYRUwRrSMyPsP/HqfavOiEasv5b6sD7oAzHp1ItH8hkvIJK58RdtlhvtJU7pgl3Ds0XSqzrfpcYgXscx03xdRLrn9gXcgyddi6nWTAcai/L925dlDf/YVvzOP0EWAfOzoLrNgfipBv1wIdo/MMfGuq2OOrbVHSJkWnctNuIF96sJL6X48j+yai170;25:LFLKJBQEsILHHxB/W2xWF0YT0x9vAp/xurBw5J0iR15RL/HZ7qdDokztZUF8JsX/HCZflof16QKv6JtB19O2HqzcFqANWawV8hvy8NWC02OiFyiWY1N8GyMe2TwU8mfS3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PW8Lu6LWFFsQjOOhaBN3q71p/wNaTOGJ63ybfro3E3FNNFe82OKRVbIzxZiVAgY3/CgUY4AOdOR/UFWd2H/ZsCS2wmkJUqTthsLF3XJvmVMVm+4lRfuED0CalpcOERKH1kj0qzF1XWk/vIWnHW8oGUAtY3yD8ljsr/4sGILhUarPTla2mMJhEhSRntTH6Lc0JD5I64f1/qPoYvtToGXrJPTCTIKDCGd9HbnN/kCp+h+DCjQkCJNwowGeBCl+ciWtbmxkeS6mANqxyADIgPaSbt1nM6QeAE78SBu8bv4hYdA1BDnSi8LQqm1wLIqzR3uCZjXOj+lgcB+S6GoEb0xvZIBPXQGs4vxKUtJFWSNQ= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(575784001)(186003)(7416002)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:O045RCZO2gnGfuv7F9csU/KhtTN2ytJi+9ytaZmtcRaHYmP1RZ37XRlxKOTaQSGidDNWHGK+OHAci2Ua0L99MGPxeX7JPzcQNXsczHiBvho167TgrNNsXP3hJ7peVSeq4PLhwgVPUV46EMPrwLPmV5txaQslUzhCKG326p2QtoX0OZIw+3o6J/0FHhSQ30mIvtEQxHfKZokqYgXTsiWexGc3RHUxbPrcp+7Y2uCFg/58mOTdgSPqmnKZ/045mTxvOFvSkKYeEO+86ZA05U2OKmYndVF+MACpE7zfk/6e6ipOZcYyqQmSwecqf3srFWCXf6ZcA7jvK2aWD48XRJ++LBqAve24rfU47mLG0PpZ3dge25LIGrNNI3XnOJq4H13l4Yun+VkNiRams/M2wg5moY9g2yDhewZ2P3b5GXKPkHSe9+9Ost0BBd7cccjPfFmoiz+kvwOsAtnvwqGS1LtD1OzkMuUKuJKv1fcOXx3GDpmpxJkoyNN2OwueUbkYVG27elXuc3O105RjKqClbKMCXshAUlu/BmvHg+I/RC3NARRzCpMCFOmZmFfNwiyIcfnserjYKjeP0+auUO373assetw35UOaLuI9LlokuGu4CZLsP6OJkexmZkzkvGUHI2xgg/N0QmKINd2N6tBkNPshPUV8TB3eR7xHOT8Sc/3O2q/bIt1JcPE630r8lg8EvqI8VMnt1BdPLIuknJCPq5//LjjUPcigsz4IWQ9mwiugY6KH0++nzFlIEm4o4K/oVOV9rLq1NTl2sNLSOqxPANJ6uqlc7Dly+ulzTcA4W3SgZcirsFzYrjOhVYsQ7Eb5jc7Si8goH4W0mdjDF8hrkacAKjrcyZSnRSgLBbp1D0rqnzkjLR5NGxxqGJodL/oRWBCEF0XwHCnVpZPBaWJL++OUeybieg7vYIAaEZZhoTe3/onYhLb3JsYL5d3LlDL4V/sTBx8PnMVUfcfKoESUDP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/efMgSY0yOERU1JcDR/njxQDt8y0AaQbMKohr/oOez+JoDlyL9IYt3XPZ4kES/Opu8ZHXHMnmS12X7kaRYn0fAgPewwG5cpg2I2KOm/7g0dqFXzLqgYQ0ax4oKsKw5KCktPqfg==;5:Y63TGCrgfreJoujdyq1ZS31yLAP2i67vwX7XvSOb0waIrZoRB8dr0gtGJHAACDRD/bDoM+8tPuFnUsbvSBDRf/oOYyjT+hyBhZXklaR77osY2Ut6/rrrX73N5t+a39OBm6shot3hbFU5AfAE5CjtJpc+DV9qrsTsP8ADwiETQSw=;7:8dfDQyQbGvBgKYY2zHAr9l7eDj/Scsq9pBoVNZNxHp6Tr63KV7RAUL6ta5D6Nn3qlJQTs/raqOeVKRgc7vmk+TlcV/cBsG9cWD2LfbqCZOpRrC0F+uVdCkXiAd7ixZFPW97hndjwGy3j437P/VRwmjC2anomPRyit5FUVEAedvmdUEcw8+09udx848dbPP/d3DrRaF+wuhOKuPIMW8r+tLWUklZcc3jsxp81Do4rDJlZIR6sXBWy+ycrT1NIQZrl SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:Mq3MUnoS6lCYtE1VPHFI2ggh20oIWht/AOhtOHXjGbYhVWySEQmabiwXqssNq4uPuEW1GyJAh69OFWzatG8RWoglua1ome6EYoLNwrz/WT17oVZza5+OgU5b2gZqSYxkOg443L983lOloQff1kI1GCjpQgL24Ppit/ENkfdF95A= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:04.6390 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 37c595b2-de51-4642-c349-08d5fe302f73 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Instead of marking all power management, SCSI domain validation and IDE preempt requests with RQF_PREEMPT, only mark IDE preempt requests with RQF_PREEMPT. Use RQF_DV to mark requests submitted by scsi_execute() and RQF_PM to mark power management requests. Most but not all power management requests already have the RQF_PM flag set. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: David S. Miller Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-core.c | 11 +++++------ block/blk-mq-debugfs.c | 1 + block/blk-mq.c | 2 -- drivers/ide/ide-pm.c | 3 ++- drivers/scsi/scsi_lib.c | 11 ++++++++--- include/linux/blk-mq.h | 6 ++++-- include/linux/blkdev.h | 5 +++-- 7 files changed, 23 insertions(+), 16 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 12550340418d..c4ff58491758 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -913,11 +913,11 @@ EXPORT_SYMBOL(blk_alloc_queue); /** * blk_queue_enter() - try to increase q->q_usage_counter * @q: request queue pointer - * @flags: BLK_MQ_REQ_NOWAIT and/or BLK_MQ_REQ_PREEMPT + * @flags: BLK_MQ_REQ_NOWAIT, BLK_MQ_REQ_PM and/or BLK_MQ_REQ_DV */ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) { - const bool preempt = flags & BLK_MQ_REQ_PREEMPT; + const bool preempt = flags & (BLK_MQ_REQ_PM | BLK_MQ_REQ_DV); while (true) { bool success = false; @@ -1436,8 +1436,6 @@ static struct request *__get_request(struct request_list *rl, unsigned int op, blk_rq_set_rl(rq, rl); rq->cmd_flags = op; rq->rq_flags = rq_flags; - if (flags & BLK_MQ_REQ_PREEMPT) - rq->rq_flags |= RQF_PREEMPT; /* init elvpriv */ if (rq_flags & RQF_ELVPRIV) { @@ -1575,7 +1573,7 @@ static struct request *get_request(struct request_queue *q, unsigned int op, goto retry; } -/* flags: BLK_MQ_REQ_PREEMPT and/or BLK_MQ_REQ_NOWAIT. */ +/* flags: BLK_MQ_REQ_NOWAIT, BLK_MQ_REQ_PM and/or BLK_MQ_REQ_DV. */ static struct request *blk_old_get_request(struct request_queue *q, unsigned int op, blk_mq_req_flags_t flags) { @@ -1618,7 +1616,8 @@ struct request *blk_get_request(struct request_queue *q, unsigned int op, struct request *req; WARN_ON_ONCE(op & REQ_NOWAIT); - WARN_ON_ONCE(flags & ~(BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_PREEMPT)); + WARN_ON_ONCE(flags & ~(BLK_MQ_REQ_NOWAIT | BLK_MQ_REQ_PM | + BLK_MQ_REQ_DV)); if (q->mq_ops) { req = blk_mq_alloc_request(q, op, flags); diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index cb1e6cf7ac48..b4e722311ae1 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -330,6 +330,7 @@ static const char *const rqf_name[] = { RQF_NAME(SPECIAL_PAYLOAD), RQF_NAME(ZONE_WRITE_LOCKED), RQF_NAME(MQ_POLL_SLEPT), + RQF_NAME(DV), }; #undef RQF_NAME diff --git a/block/blk-mq.c b/block/blk-mq.c index 72a0033ccee9..2a0eb058ba5a 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -300,8 +300,6 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, rq->rq_flags = rq_flags; rq->cpu = -1; rq->cmd_flags = op; - if (data->flags & BLK_MQ_REQ_PREEMPT) - rq->rq_flags |= RQF_PREEMPT; if (blk_queue_io_stat(data->q)) rq->rq_flags |= RQF_IO_STAT; INIT_LIST_HEAD(&rq->queuelist); diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c index 59217aa1d1fb..8bf378164aee 100644 --- a/drivers/ide/ide-pm.c +++ b/drivers/ide/ide-pm.c @@ -90,8 +90,9 @@ int generic_ide_resume(struct device *dev) } memset(&rqpm, 0, sizeof(rqpm)); - rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, BLK_MQ_REQ_PREEMPT); + rq = blk_get_request(drive->queue, REQ_OP_DRV_IN, BLK_MQ_REQ_PM); ide_req(rq)->type = ATA_PRIV_PM_RESUME; + rq->rq_flags |= RQF_PM; rq->special = &rqpm; rqpm.pm_step = IDE_PM_START_RESUME; rqpm.pm_state = PM_EVENT_ON; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 9cb9a166fa0c..a65a03e2bcc4 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -263,11 +263,16 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, { struct request *req; struct scsi_request *rq; + blk_mq_req_flags_t blk_mq_req_flags = 0; int ret = DRIVER_ERROR << 24; + if (rq_flags & RQF_PM) + blk_mq_req_flags |= BLK_MQ_REQ_PM; + rq_flags |= RQF_DV; + blk_mq_req_flags |= BLK_MQ_REQ_DV; req = blk_get_request(sdev->request_queue, data_direction == DMA_TO_DEVICE ? - REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, BLK_MQ_REQ_PREEMPT); + REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, blk_mq_req_flags); if (IS_ERR(req)) return ret; rq = scsi_req(req); @@ -1356,7 +1361,7 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req) /* * If the devices is blocked we defer normal commands. */ - if (req && !(req->rq_flags & RQF_PREEMPT)) + if (req && !(req->rq_flags & (RQF_PM | RQF_DV))) ret = BLKPREP_DEFER; break; default: @@ -1365,7 +1370,7 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req) * special commands. In particular any user initiated * command is not allowed. */ - if (req && !(req->rq_flags & RQF_PREEMPT)) + if (req && !(req->rq_flags & (RQF_PM | RQF_DV))) ret = BLKPREP_KILL; break; } diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index 1da59c16f637..4ac964eeabc8 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -221,8 +221,10 @@ enum { BLK_MQ_REQ_RESERVED = (__force blk_mq_req_flags_t)(1 << 1), /* allocate internal/sched tag */ BLK_MQ_REQ_INTERNAL = (__force blk_mq_req_flags_t)(1 << 2), - /* set RQF_PREEMPT */ - BLK_MQ_REQ_PREEMPT = (__force blk_mq_req_flags_t)(1 << 3), + /* RQF_PM will be set by the caller */ + BLK_MQ_REQ_PM = (__force blk_mq_req_flags_t)(1 << 3), + /* RQF_DV will be set by the caller */ + BLK_MQ_REQ_DV = (__force blk_mq_req_flags_t)(1 << 4), }; struct request *blk_mq_alloc_request(struct request_queue *q, unsigned int op, diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index d6869e0e2b64..938725ef492b 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -97,8 +97,7 @@ typedef __u32 __bitwise req_flags_t; #define RQF_MQ_INFLIGHT ((__force req_flags_t)(1 << 6)) /* don't call prep for this one */ #define RQF_DONTPREP ((__force req_flags_t)(1 << 7)) -/* set for "ide_preempt" requests and also for requests for which the SCSI - "quiesce" state must be ignored. */ +/* set for "ide_preempt" requests */ #define RQF_PREEMPT ((__force req_flags_t)(1 << 8)) /* contains copies of user pages */ #define RQF_COPY_USER ((__force req_flags_t)(1 << 9)) @@ -127,6 +126,8 @@ typedef __u32 __bitwise req_flags_t; #define RQF_MQ_POLL_SLEPT ((__force req_flags_t)(1 << 20)) /* ->timeout has been called, don't expire again */ #define RQF_TIMED_OUT ((__force req_flags_t)(1 << 21)) +/* set for SCSI domain validation requests */ +#define RQF_DV ((__force req_flags_t)(1 << 22)) /* flags that prevent us from merging requests: */ #define RQF_NOMERGE_FLAGS \ From patchwork Thu Aug 9 19:41:39 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561853 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9A0F790E3 for ; Thu, 9 Aug 2018 19:42:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8A7302B979 for ; Thu, 9 Aug 2018 19:42:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7E63D2B97F; Thu, 9 Aug 2018 19:42:10 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 B3A762B97D for ; Thu, 9 Aug 2018 19:42:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726961AbeHIWI1 (ORCPT ); Thu, 9 Aug 2018 18:08:27 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWI0 (ORCPT ); Thu, 9 Aug 2018 18:08:26 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843728; x=1565379728; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=la2tM5lVPV68V9GjAgWjh6p3WO/+Dy/yPPWGR7FUCxs=; b=Nx7ST7dwn2eJw5by449nuGnMG1mDSig/bG9OcFbqjk/MGF89wakSeXAb 1zKzudymZkhpyR7cKKfXIOV7jpwFJmD/oEbWF0EIcDe/f9251G2R+lSnl 1xzhJTxtdSctB9ksYJSJG60iJUP06ExC9KcTiU+Rq96ujt9fwQC8WO3vt TCU6HYmv8/cnKr/4G7nkVMCzrlBrdbfSoYUMNbu5jMu2qNTeySTBQBC/7 G3PG2YrO+5mGn7worLfJkHpgBlJg0ZgrX5wbbtTqqkfRhPhcfSXpuJSI8 SaIUTJuj5DAGuWNZWh2xMV48WXEbf+Z66/TS2Tyu8svSjq4nr1DemexN6 Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119588" Received: from mail-sn1nam01lp0119.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.119]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:07 +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:X-MS-Exchange-SenderADCheck; bh=J668CqFV+Zum0lM2ipoVnOBDKILXv4aMiiHTopuGCdg=; b=Zzv2x7ta+l8V/Ddksr2KeoCnP1B9hT/+X0dHEqfDaccSMn9QqijlLWfX0ps1PgTtBaJJwQLazrmmDk4hhDJr598he1PCHDJbQ4U57BtgeuU/SqtOW7o2zz18m4jw1OeciINSqV5joHIrmHwLdPRJS7GG67DrYnGrKOWniyuEj/A= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:05 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 02/12] scsi: Alter handling of RQF_DV requests Date: Thu, 9 Aug 2018 12:41:39 -0700 Message-Id: <20180809194149.15285-3-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: c6b3af67-83c5-4887-5b0f-08d5fe302fe9 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:nWet6JcqX1MQ5ApFO8qe8/8x8j3F98ezPsTXThgeqTlKKDI+OyhW00F6VbzD1AMXUELGzMoAeNYdqkGZXZkFswGfHkiAzV1APW9xbqpH41B9YPNBKL0C8ETBN5DHqolFnPxF6EH8SK2WOUMnl/uur67vCptXCRJuXaNlsoepBZLkK96M1clbabT782QOjj5HkQ0zvF4yutQDJrG7bF7nH3LXOgWTupNqfp7JLuUPTSxe6jOyhrALjcRbTjSd4rhE;25:T3pYzalT4Ycroe6ke00ZYenBxJpyyvyRh2KASTuVZsJvJEUq6q/jq05KvhiVFP/7IwMEPLlA2xniSeT7b6l2m3BASFbmKakpzMFc+NNxSrfDCVxMwcdPD+Nx0aHQxaRyw/92sxyhkPrpI/IOumjpd8Toh7+YJJK7RWDLcOp47mI8x+mnO7sCXUPhBnihcuVagob978vBfmCg2LGEOkiObHZVtjjd1fpHHcs2UC7d8gDAP8qDdzAjgQicHb22iXHo7vqG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/YvHbHXv7GT3WsTfbbmarF99VI1Elq6wGvHvh4a1wk2c1hHkLLue3q+R2URpkMyb67DB8mV09UWDc/mBH+JRtTbit0CJjuKsnvesqFDu0qSscsRqTpFgt1/JjYv4YX/erQlwGzl0zjTkuC4f2tVcUl2BfIEkCGz6mwVS2ck8L2Y57qU/fzdCOBqoMPRw0nXSc6ah+bX5LTL2lVkCe/fMWQKkqV00kXbTtXDlzyiE3CjETE X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(209352067349851)(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:Y7e4zzuokKUTzqd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caK8fOHS7F7CHKUsa+nfM0g4y4nBwy8ATfczcNuUuWnVC2FNpzVGnXzQEAUVG1qXZYTSGHFBxqM+4hCOFbPtOt5xzDTZjURWoVIwXL8ivl7Y0HOGf9cLH52FrCLCimCGkPQsB7aE8EvBiAhmUibDgfrALzjM=;7:vLM7uVi88mcy0lBwR/3TsnJd1FPA984phzLHndplx9LouW+vXNBzjOqhtWmjEvzMFkmKYzMvIIzQhuFUFuF6yWjrqRQOCwlK7U8pjSpilgSnlVPvjnFp6E9b1h6E0O6dEMFylBTqZ/bSbL/Hmhv7uCjIATxq/C/EIz3HLUswg0LMUsCGp5OhAP+Uz2D4wYFJ7iX7D6jY+jAqawctfxKvvBunSrtqX6BtILfqZudEvzbtX7b2MMgduTc1MtJ2Q1Y3 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:dUVr88rBhfzlKR375o9yZQNnmpGa6Zh03HD5rNdBhWin8ejwFaiVyHgCjqlaRZ87DWOogNlW4OEyU9ft9ZZ0I+Zm1c9C1PkcM4FlxreZOQh1oupTbzl1xIY9deOxNCErrRh7uCuMPbyzrmOnSKy2zg4FFOzOAOFTEvpvre4MC60= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:05.4457 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: c6b3af67-83c5-4887-5b0f-08d5fe302fe9 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Process all requests in state SDEV_CREATED instead of only RQF_DV requests. This does not change the behavior of the SCSI core because the SCSI device state is modified into another state before SCSI devices become visible in sysfs and before any device nodes are created in /dev. Do not process RQF_DV requests in state SDEV_CANCEL because only power management requests should be processed in this state. Handle all SCSI device states explicitly in scsi_prep_state_check() instead of using a default case in the switch/case statement in scsi_prep_state_check(). This allows the compiler to verify whether all states have been handled. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- drivers/scsi/scsi_lib.c | 78 +++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index a65a03e2bcc4..8685704f6c8b 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1331,49 +1331,43 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req) * If the device is not in running state we will reject some * or all commands. */ - if (unlikely(sdev->sdev_state != SDEV_RUNNING)) { - switch (sdev->sdev_state) { - case SDEV_OFFLINE: - case SDEV_TRANSPORT_OFFLINE: - /* - * If the device is offline we refuse to process any - * commands. The device must be brought online - * before trying any recovery commands. - */ - sdev_printk(KERN_ERR, sdev, - "rejecting I/O to offline device\n"); - ret = BLKPREP_KILL; - break; - case SDEV_DEL: - /* - * If the device is fully deleted, we refuse to - * process any commands as well. - */ - sdev_printk(KERN_ERR, sdev, - "rejecting I/O to dead device\n"); - ret = BLKPREP_KILL; - break; - case SDEV_BLOCK: - case SDEV_CREATED_BLOCK: + switch (sdev->sdev_state) { + case SDEV_RUNNING: + case SDEV_CREATED: + break; + case SDEV_OFFLINE: + case SDEV_TRANSPORT_OFFLINE: + /* + * If the device is offline we refuse to process any commands. + * The device must be brought online before trying any + * recovery commands. + */ + sdev_printk(KERN_ERR, sdev, + "rejecting I/O to offline device\n"); + ret = BLKPREP_KILL; + break; + case SDEV_DEL: + /* + * If the device is fully deleted, we refuse to process any + * commands as well. + */ + sdev_printk(KERN_ERR, sdev, "rejecting I/O to dead device\n"); + ret = BLKPREP_KILL; + break; + case SDEV_BLOCK: + case SDEV_CREATED_BLOCK: + ret = BLKPREP_DEFER; + break; + case SDEV_QUIESCE: + /* Only allow RQF_PM and RQF_DV requests. */ + if (!(req->rq_flags & (RQF_PM | RQF_DV))) ret = BLKPREP_DEFER; - break; - case SDEV_QUIESCE: - /* - * If the devices is blocked we defer normal commands. - */ - if (req && !(req->rq_flags & (RQF_PM | RQF_DV))) - ret = BLKPREP_DEFER; - break; - default: - /* - * For any other not fully online state we only allow - * special commands. In particular any user initiated - * command is not allowed. - */ - if (req && !(req->rq_flags & (RQF_PM | RQF_DV))) - ret = BLKPREP_KILL; - break; - } + break; + case SDEV_CANCEL: + /* Only allow RQF_PM requests. */ + if (!(req->rq_flags & RQF_PM)) + ret = BLKPREP_KILL; + break; } return ret; } From patchwork Thu Aug 9 19:41:40 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561857 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76A3B13BB for ; Thu, 9 Aug 2018 19:42:13 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 659432B97D for ; Thu, 9 Aug 2018 19:42:13 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 58FBD2B979; Thu, 9 Aug 2018 19:42:13 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A232B2B979 for ; Thu, 9 Aug 2018 19:42:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726997AbeHIWIa (ORCPT ); Thu, 9 Aug 2018 18:08:30 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWI3 (ORCPT ); Thu, 9 Aug 2018 18:08:29 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843731; x=1565379731; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=TuwmJ1dPM3f2L/zl7hvEbMUxi24nkapUm/BPnHdZY5M=; b=huWnR3EmX49oJUOyE/qam0tMH73tnOfjtON/EmI6Xa4UlVLoBc1nxaS5 EcB3+a+o4QxNKS58Ar9WF+Nzs9sjqD5UOH1EijUpD1hMv2kgIF/YyggU6 fyIvQq2CPfWnvTlnXbMuvsQu0Ddlz3X1nLVaR+Z7hjhsCAk6KWwg0L6fK /yX78Ji/ob9SFnCHXl+An/fAPUf4kmH6igCrtd4odDp17JOGlxtcAge4D AwK4J/8u0AK+qSZl57C1iJWnt1RVEfjI5uUxdbfHqF08CPBW+kQmAYsin RG/Lsc+ePjmvqXfjX8pTfvwqUhy18WgPKqEECm4JyQa2kly78h7iXADtm g==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119593" Received: from mail-sn1nam01lp0119.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.119]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:10 +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:X-MS-Exchange-SenderADCheck; bh=Srf3S9AcR8hnikPHhEAez1wc6e1/u2ufzfZ/ejIH6oo=; b=a4kz/k/2y2OHWFDrlgWzaQlGGtgPISkbASOiiJpfl9tWvZ42m8ECqHsIbLQ/mOqwRYRx+2iUSqTYH30rSIOBUyu1wEBHz0LooeS60YhAygcHJuxz9w5eNMfYj2L1s8IJ8BD3VEEdz4LljGhv+4I5rknRb+79ekNo5KYvTOrHJYw= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:06 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 03/12] scsi: Only set RQF_DV for requests used for domain validation Date: Thu, 9 Aug 2018 12:41:40 -0700 Message-Id: <20180809194149.15285-4-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 0ffd0efc-85b7-41ea-d090-08d5fe303051 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:BGX3Xmu2zrZBg6YCMRd4mJ1P6fqg0IK0p5fbcmCNlN+/TtRIgTnnzI+jCvAsFrb0I2ty78fP+v3cvyTGG+NOMN919Xc1Vgjx3dj08JMB41UQ8cssA1WWq8caf4oSSyItD1cnEFyxYlA3UAxjLvbN0Up/LY1A5elJUNCmVg4F09UQ1QVer5jAnLQWF4ct8EYWDBkqTP2xBkDKXN0blgpFJHknjBbHX1ypKTP3VPfWAYJuyu3W1KWnGaK/CJjXJa2D;25:BP241tZ/kMd0z9tk/Sq/6T0IXj/+lsLv7DxoIZV1Pp9fAZrBP9GSErrNzdALe1+UWRLfaKXkidx4MSJHfav7ib6N/XR4AbRIOBi4xuW34C6mTHEIZf/6vE0lPxw+OC11Ja4m4Mi01y7mjzv/BSeIRWLEILz0atmav+vopjG05eg20sKowEM/o9x463W+/Tn/E8yS6L73AEC880qQN/Cqh9eYup8LeMaB+1l5iX2ZU36RLAL4BbLp9LUYzOzKqtySXBYB6GgMauOO2bKhJkZXM3aaq9PBuPhk0OJiyZNPuIkq/zlw6VWbCplKQyJhTmvtfcInzx/f5gCqUd/WKCdxWA==;31:dhShgeatAgd8Dsy1txadppoM0nldkqHhlEydkzagLEHPUdkDIK2Dx3oUIwX9ED9XhLZ4MW26Fcf4aPozefzLQzmtMNw6BFPJ7sGPelKtp8P30Lbrcc1pjPpknLeWx+iX05P4b1ANtilnDDCfcGEcv78NOaCy6g86Vf5/+GOLo2K4dcGADxDIrq3D5YMZDIoS+cxnkO1wZeRFNVbyoWzKm/ksSeFHbEMeP+Zcn8XW7/o= X-MS-TrafficTypeDiagnostic: MWHPR04MB1198: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:jHOfTDNEcI1AuSI0jk/o/lzzlkddGwd2fgN0RLs7gPmSh7Kmq2s3o9NCqptxwX9yb477nwCJ4JfEPQoKq2TredyWiv07Edm4Jdp4ASwLWSGtZKD1HyMbbGNXnRIg0/NNpnxGDHhhIW9rrW6WGLuscUB0Wm5ELgz8Cyu6RtqIZhpjZ4DV8YN9DANF0jV6ihzuz+yXj2h312x7R/YozlgKvD9H8IsfVqgOK131bOVQAY/8n1Lo+rPsM8MyuQ71rNREkzkWUaL21wDwjKaG6joVTtbPlTMLV06qQ1lnzwinVAUoWQf5mxKxJJP1RIJV1nRCUS7V3Zcw49oIxf5BYoTw0FIHgJ2ZHMHrFy/gU2JHX9xI/ixZD9wfFT5qO3Go5YpatggcdvKRY1yuc2+qhwd5FLE6FC/La0c5HwgKOoI8l8orTBlmOzen4I4t8cmI6AWcy8tylukHTkEv8L8Sr6xPO1zJLMY+JHy4YuADwEF4/mN/NAgfkaM4dh6mtTjrvGWO;4:q8bn/UmXT5qpsMQFvb72oSgdmL36B88E5SKQC4Wxrk4jTjrcXPSYHRaw970Sd4wZmWVwVoEntF+TyB3At69e1O1U59B4wBZCTFnf7Nw5ndG8TfQZCYsWDZgQuiigPfAUj96VNhtGXVq+qAgpMkB8Nh3WE42kxkCpdgotHRD/Exn6bRSHzfngu2hGGz+25F0YYHQP+NIXRk4t7dAQibZ8BXNO5rb4Xw9P0Zhhbv7LlcV7LYnF6qSM2RmY78YdXrr/1ZZGDJtrmYXmmyoyDcQu/cH+l/0EHft3wrnjhg/X7JiTgVJzznsjKS4oejEsZ54Qz3vOlZiYgHScUJF7fu/uOJ6CSESSeS29K3Yc/lGRQNZlyQKXh/RsMxqPVTS/+my4 X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640)(17755550239193); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(575784001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:q9hHtEhEHlKInB4X5Qpg+QX/nS7jzGRlhKJ5HvFoSKprszOGy5guYdwsPW9A+kPFaLaYCwpT7sy5vGZ6PO9Ijmm8gZf1j4vMAJmkf1coueTIbi0amwq/mqOYDbUrcasRoUgBiwMbf3Q5O93vlW/BxJ48o+cw+KAj3ybG9Uscf11ZGKcR89uZwefxsYUyyIIDCw3Lhd1sffxMqjfSq4G2XehqrEv+ne2NlaTJxFaB73d43TVedSHTwBylCNDoqMy0Cwkf9q97YpuCfKmAu6C7uzpUiPVvdc9lBboQL0o5GMdLAsAT7q0ohF8grzHPEdRTAtEXfrjIXLQcQvgcQjLHQPoFkeSB+aoYRNCjGqAMSauJcuhL011YSK5aOK9hQdaYAUdFo6xxTRDEh6umqzv6b7JRM+NP0X27GrGecfptRjdQ2FhrNizvMTwSbpPLFVDJj39/fnV09chWZ2Kl7R0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pamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:yHdUFYCTM7X9bsSILCWeihghAKIxg1qTe+OdhWO0pbkzgcf2dIx3TLsmN5n92eOtKKxodfI8POTBAxEfbWIjcLc73hamXqaEpkkCDghQhZTe5e/2AJv4Dy4E0LfHTimGPtpaTqEoYb8o5BNnDkF+1YZUVwtSckZsC5T/42ORJFc= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:06.1363 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 0ffd0efc-85b7-41ea-d090-08d5fe303051 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Instead of setting RQF_DV for all requests submitted by scsi_execute(), only set that flag for requests that are used for domain validation. Move the SCSI Parallel Interface (SPI) domain validation status from the transport data to struct scsi_target such that this status information can be accessed easily from inside scsi_execute(). This patch prevents that e.g. event checking can occur during domain validation. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- drivers/scsi/scsi_lib.c | 6 ++++-- drivers/scsi/scsi_transport_spi.c | 9 +++------ include/scsi/scsi_device.h | 1 + include/scsi/scsi_transport_spi.h | 1 - 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 8685704f6c8b..4d7411a7985f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -268,8 +268,10 @@ int __scsi_execute(struct scsi_device *sdev, const unsigned char *cmd, if (rq_flags & RQF_PM) blk_mq_req_flags |= BLK_MQ_REQ_PM; - rq_flags |= RQF_DV; - blk_mq_req_flags |= BLK_MQ_REQ_DV; + if (scsi_target(sdev)->spi_dv_context == current) { + rq_flags |= RQF_DV; + blk_mq_req_flags |= BLK_MQ_REQ_DV; + } req = blk_get_request(sdev->request_queue, data_direction == DMA_TO_DEVICE ? REQ_OP_SCSI_OUT : REQ_OP_SCSI_IN, blk_mq_req_flags); diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 2ca150b16764..bf6b18768e79 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -66,7 +66,6 @@ static struct { }; /* Private data accessors (keep these out of the header file) */ -#define spi_dv_in_progress(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_in_progress) #define spi_dv_mutex(x) (((struct spi_transport_attrs *)&(x)->starget_data)->dv_mutex) struct spi_internal { @@ -268,7 +267,6 @@ static int spi_setup_transport_attrs(struct transport_container *tc, spi_pcomp_en(starget) = 0; spi_hold_mcs(starget) = 0; spi_dv_pending(starget) = 0; - spi_dv_in_progress(starget) = 0; spi_initial_dv(starget) = 0; mutex_init(&spi_dv_mutex(starget)); @@ -1018,14 +1016,12 @@ spi_dv_device(struct scsi_device *sdev) */ lock_system_sleep(); - if (unlikely(spi_dv_in_progress(starget))) + if (unlikely(starget->spi_dv_context)) goto unlock; if (unlikely(scsi_device_get(sdev))) goto unlock; - spi_dv_in_progress(starget) = 1; - buffer = kzalloc(len, GFP_KERNEL); if (unlikely(!buffer)) @@ -1043,7 +1039,9 @@ spi_dv_device(struct scsi_device *sdev) starget_printk(KERN_INFO, starget, "Beginning Domain Validation\n"); + starget->spi_dv_context = current; spi_dv_device_internal(sdev, buffer); + starget->spi_dv_context = NULL; starget_printk(KERN_INFO, starget, "Ending Domain Validation\n"); @@ -1057,7 +1055,6 @@ spi_dv_device(struct scsi_device *sdev) out_free: kfree(buffer); out_put: - spi_dv_in_progress(starget) = 0; scsi_device_put(sdev); unlock: unlock_system_sleep(); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 202f4d6a4342..440834f4252e 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -310,6 +310,7 @@ struct scsi_target { char scsi_level; enum scsi_target_state state; + struct task_struct *spi_dv_context; void *hostdata; /* available to low-level driver */ unsigned long starget_data[0]; /* for the transport */ /* starget_data must be the last element!!!! */ diff --git a/include/scsi/scsi_transport_spi.h b/include/scsi/scsi_transport_spi.h index a4fa52b4d5c5..36934ac0a5ca 100644 --- a/include/scsi/scsi_transport_spi.h +++ b/include/scsi/scsi_transport_spi.h @@ -56,7 +56,6 @@ struct spi_transport_attrs { unsigned int support_qas; /* supports quick arbitration and selection */ /* Private Fields */ unsigned int dv_pending:1; /* Internal flag: DV Requested */ - unsigned int dv_in_progress:1; /* Internal: DV started */ struct mutex dv_mutex; /* semaphore to serialise dv */ }; From patchwork Thu Aug 9 19:41:41 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561859 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 9DB6113BB for ; Thu, 9 Aug 2018 19:42:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D5AB2B979 for ; Thu, 9 Aug 2018 19:42:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 816882B97F; Thu, 9 Aug 2018 19:42:14 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 8FDAB2B979 for ; Thu, 9 Aug 2018 19:42:13 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727025AbeHIWIa (ORCPT ); Thu, 9 Aug 2018 18:08:30 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWIa (ORCPT ); Thu, 9 Aug 2018 18:08:30 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843732; x=1565379732; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=pbMXdEWeUW4tvLeIQHDxjdCjtxl4S3H9A0eBlQedDlo=; b=lFBuMc19o0EURmDH4RX5N9DuGuVDLG3xRyuSv+4rVOZuihQ+P9A+aj2O OmSipLd94crKuJs0WtdJkzTI42ki7yBamBDusHCosvh05abpFGWCF/s9A J7q3KV7XQBXNsfwo9qO0mXyjD9bOSpp0KaCisWcQYRsw6tDAodRcMeKXR rSGdg+PLO7bADboagOzG8gCg5c5NveI2295PevdFUi1Pn0adzra78zldz 8Ld/q+fsWUFDvERbguGjgKyBVH916kKZbwdtBnXciqqVXda4SAwJLmKfJ R8QLMk4TqV5miV3fj8/t8NfCt6cglSck9Tw8L+WhRil8APsEHLTyzrVkO Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119596" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:11 +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:X-MS-Exchange-SenderADCheck; bh=UIhtvZyjT3MesRVGauD7qo/IrxCVCgke7YSs08HYsvY=; b=NIoH1nRQ9tC9YFB9gTEhsV0yujTnOYCU7pKtWeVv2FGrm2goRUsBq9MUl20GlWhFgOOPuZ3HlOEbfOeAA8hvSCjVv6fUkTiYYj/s5UaLkv0SD/wDu/wfklmxP6nE+HpnPwsusJc1iFk4QiUEvjF9Ho73aiJbIrfgRnqW/4SPKHU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:06 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 04/12] scsi: Introduce the SDEV_SUSPENDED device status Date: Thu, 9 Aug 2018 12:41:41 -0700 Message-Id: <20180809194149.15285-5-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ae75a4f8-d8bc-4aca-b1ac-08d5fe3030d4 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:2OTjQ4Oaxtt7cSuoofFn0j1Oaftew+atRswuOHyfcd41VTxKwMofTNW3AgRncbrld2Nq67MAOmaMLoxWwvAs2dBruwu4HF1TkjqnIEEtPMx0LZ27+fBXvaOJbVG0Y9f1dABjor2wn8fNm1zvc9ijmbqsslVjj4nhGyiOAUfPly9RUKGEEu5dJqfT8HYcTEGgmzEHaaMcpDTHBtT8d9lBY3axykfiel1HPKph3OUqba8oC2c4BPiVgZHAfTPyeBYa;25:lS7B0r1lC1fhUku+qKAAC5wz66EP0UgTJRzVrzNtSrOqye2dWeuurKG4fdlYJ9cXK0+V1X5HULUMPob2Hcou2c23ZeQwNF7rwDaxgcnjeWA5VXg2jIeSiiyiecnl6UpXNuU8AdQxZ9rzRP2oNVaMzQhYL9aAMkDqegenPcEg5phB6p0YzUekF19wUMGFWZMPhPVXy6irgEMSKI0NxvjAkznHn3JW5V5xJm1o+OVVN1SoCZX+fIXjm/mdQsUeVAhgxGlHWu4BwN64GDpQBN7wwCzxDwluWrQjNW0RP2xza1j0gs4nDyO71y8+hXgTlaUPSXM5qXYFQYnQEnTph+M+Kg==;31:Ad8bUO2DfQK6MCnZZnWoyYTXibp3GUckV2hVcW5+uBfhppMTcyqDCGgOEhMXZHaygCLYs5qv2mh0xELOGDaKmHl/zHW+zlhAIAk+hbULF+0iM9FaCa5tW9+1jO0PUMFUnTkumCf6Vi4cA5bvDElCNNRCL3G5ixNoNUal6aKAIAKFHqIN/jf1KP64phKe4ap8ClGLMv0muI4KeRyd+qL1Hty0MgXlQe4ptUWq0iFQ+To= X-MS-TrafficTypeDiagnostic: MWHPR04MB1198: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:DbEOaXq9mPn3+ZsV1yAyd97lGasbXZIK/vbidsTTK1R+t6e9ntMEdFeMiv3ZifAmVBHcLMi8kuMLGRncPQXXixkh3Pd8V0w6OhXFWNCdWabY8xZ9yE03VH1Pw7JBRh86o8JQTYCaSMnuxmzmtsLNTEnrED+wplMXl8g2wVfr5P4NeOfKnvFCmMYtZYqxSbvSpnLBsPDxVB/5Q2cTdAGbMwtfn/S+04xHQd5W4D+6jown5opoqtO7VJbcavLE9kKYkU7zPjcqLpOTN0REEx9V8xs1clVjA4ixscmvnREJRT9sRvAgIJOtbiCOkbAKNY06tOtP899QNB1M9bBAuBzhtipA2LZ/rkC/PDj4Tl3159bAKZRQyqhVp39lqDTcyvKRJvYk+rfSvXFArcGG8hKSfmz9dAWBSC1x8DXDyyaqkFuNF5T79iegrsaVoLCu2Kx1OzYCdHPUXPhQc/GUl5iPQwNvt4cF4t3V5sqbpvO9fPpTBOcExvomPOBiQ34ps+Er;4:STxzFNGoE6+BMi2Aeedv8yf/LaMa7TPXpj8IMmMOV+olpHlJxQ96jEKf7a9VBVV3V/tIeW11AQZgOBybNu/aucC2ujJ8nRp6fcruKCDd9CN+2rfQ63QuZsBM+LoZMaTxyaqnCvA2Ss5u+9BUlU2CXkAnovFAhvcHKH1bLs+yf8OFkDyDRKmnTrD0m+HR+w/03Z9M0y9LAjQXqgVXvPbW2YB3sz0CwA0JVZFnk3lVzo832xTOaMDBmAK70/TdhgnoKgddx4HqpoTtk/bVq2c6KEzR4niPLy6OtZSdkOeoa7TmpUMX+fjAV/yOUf/seJkH6Koyh9liUscMX+N2+D0ey45L5k1ch6LJSSqlnQwmiTg= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(966005)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007)(6306002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:xI7jS/CbhVhDdHvWDdl4287iGwXd6LQoXDCemsM44Exj7Ieeeth2qZ7CfQSdNQC21Jd9SD+nwrmZMVHj25BFqTnzi9nPCZZcf0EYt4Pm/w09E9UytumJh84RXRpoIUHswo6XJw6kZDroaZ8XX3o25ZDPrgbcXpwvyyfmBU1FjLUvUsXHceKrC0ipzGUqOraTevyI/EzpzUY8eemFNA1LTCqN9ixG/J5fRtIlMvKI/2FjLvK8Vm/w58IHwuHiYFOFgI6eNgJDquR1zdZ6iWFgu+Yo9F4IVfil+TXwJ4cFWDtxRLY18Tzd8//dkHDgszkSiM/usEZ2dhN4B2svZtMy7Yi7IqKz1O9vKRww+3V23WTvSpXhOYA+xMvbWI9viqIw9+AucNuzLHVosxoGufl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E/cL3ttj9tM/ZuFiA7AIZHftQf7BGBo+VlWO1QRHD8fMPqXI+4jnNniNNdbttjPAgh68 SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:q/hl3cOjL3K9DAVnHuaeJjsfMhopFCCd6GZshygPv8owpPILIJlqOgqKdTn0G1ws/OwtqtcGXzADVUieiiutYTUt6Z1ezWozc/NakfkqSbZZSy80yl0Sb6p33zR+1TkOBwm8NrExxucI/sbEKeMH4NaRuH2rul1bK5niucVUDcQ= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:06.9900 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: ae75a4f8-d8bc-4aca-b1ac-08d5fe3030d4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Instead of using the SDEV_QUIESCE state for both SCSI domain validation and runtime suspend, use the SDEV_QUIESCE state only for SCSI domain validation. Keep using scsi_device_quiesce() and scsi_device_unquiesce() for SCSI domain validation. Add new functions scsi_device_suspend() and scsi_device_unsuspend() for power management. Rename scsi_device_resume() into scsi_device_unquiesce() to avoid confusion. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- drivers/scsi/scsi_lib.c | 138 ++++++++++++++++++++++++------ drivers/scsi/scsi_pm.c | 6 +- drivers/scsi/scsi_sysfs.c | 1 + drivers/scsi/scsi_transport_spi.c | 2 +- include/scsi/scsi_device.h | 13 +-- 5 files changed, 125 insertions(+), 35 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index 4d7411a7985f..eb914d8e17fd 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1365,6 +1365,11 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req) if (!(req->rq_flags & (RQF_PM | RQF_DV))) ret = BLKPREP_DEFER; break; + case SDEV_SUSPENDED: + /* Process RQF_PM requests only. */ + if (!(req->rq_flags & RQF_PM)) + ret = BLKPREP_DEFER; + break; case SDEV_CANCEL: /* Only allow RQF_PM requests. */ if (!(req->rq_flags & RQF_PM)) @@ -2669,6 +2674,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: case SDEV_QUIESCE: + case SDEV_SUSPENDED: case SDEV_BLOCK: break; default: @@ -2677,6 +2683,7 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) break; case SDEV_QUIESCE: + case SDEV_SUSPENDED: switch (oldstate) { case SDEV_RUNNING: case SDEV_OFFLINE: @@ -2970,19 +2977,103 @@ static void scsi_wait_for_queuecommand(struct scsi_device *sdev) } /** - * scsi_device_quiesce - Block user issued commands. - * @sdev: scsi device to quiesce. + * scsi_device_suspend - only process RQF_PM requests + * @sdev: scsi device to suspend. + * + * This works by trying to transition to the SDEV_SUSPENDED state (which must be + * a legal transition). When the device is in this state, only RQF_DV + * requests will be accepted, all others will be deferred. + * + * Must be called with user context, may sleep. + * + * Returns zero if unsuccessful or an error if not. + */ +int +scsi_device_suspend(struct scsi_device *sdev) +{ + struct request_queue *q = sdev->request_queue; + int err; + + if (sdev->sdev_state == SDEV_SUSPENDED) + return 0; + + blk_set_preempt_only(q); + + blk_mq_freeze_queue(q); + /* + * Ensure that the effect of blk_set_preempt_only() will be visible + * for percpu_ref_tryget() callers that occur after the queue + * unfreeze even if the queue was already frozen before this function + * was called. See also https://lwn.net/Articles/573497/. + */ + synchronize_rcu(); + blk_mq_unfreeze_queue(q); + + mutex_lock(&sdev->state_mutex); + err = scsi_device_set_state(sdev, SDEV_SUSPENDED); + if (err) + blk_clear_preempt_only(q); + mutex_unlock(&sdev->state_mutex); + + return err; +} +EXPORT_SYMBOL(scsi_device_suspend); + +/** + * scsi_device_unsuspend - unsuspend processing non-RQF_DV requests + * @sdev: scsi device to unsuspend. * - * This works by trying to transition to the SDEV_QUIESCE state - * (which must be a legal transition). When the device is in this - * state, only special requests will be accepted, all others will - * be deferred. Since special requests may also be requeued requests, - * a successful return doesn't guarantee the device will be - * totally quiescent. + * Moves the device from suspended back to running and restarts the queues. * - * Must be called with user context, may sleep. + * Must be called with user context, may sleep. + */ +void scsi_device_unsuspend(struct scsi_device *sdev) +{ + mutex_lock(&sdev->state_mutex); + blk_clear_preempt_only(sdev->request_queue); + if (sdev->sdev_state == SDEV_SUSPENDED) + scsi_device_set_state(sdev, SDEV_RUNNING); + mutex_unlock(&sdev->state_mutex); +} +EXPORT_SYMBOL(scsi_device_unsuspend); + +static void +device_suspend_fn(struct scsi_device *sdev, void *data) +{ + scsi_device_suspend(sdev); +} + +void +scsi_target_suspend(struct scsi_target *starget) +{ + starget_for_each_device(starget, NULL, device_suspend_fn); +} +EXPORT_SYMBOL(scsi_target_suspend); + +static void +device_unsuspend_fn(struct scsi_device *sdev, void *data) +{ + scsi_device_unsuspend(sdev); +} + +void +scsi_target_unsuspend(struct scsi_target *starget) +{ + starget_for_each_device(starget, NULL, device_unsuspend_fn); +} +EXPORT_SYMBOL(scsi_target_unsuspend); + +/** + * scsi_device_quiesce - only process RQF_DV requests + * @sdev: scsi device to quiesce. * - * Returns zero if unsuccessful or an error if not. + * This works by trying to transition to the SDEV_QUIESCE state (which must be + * a legal transition). When the device is in this state, only RQF_DV + * requests will be accepted, all others will be deferred. + * + * Must be called with user context, may sleep. + * + * Returns zero if unsuccessful or an error if not. */ int scsi_device_quiesce(struct scsi_device *sdev) @@ -3022,20 +3113,15 @@ scsi_device_quiesce(struct scsi_device *sdev) EXPORT_SYMBOL(scsi_device_quiesce); /** - * scsi_device_resume - Restart user issued commands to a quiesced device. - * @sdev: scsi device to resume. + * scsi_device_unquiesce - unquiesce processing non-RQF_DV requests + * @sdev: scsi device to unquiesce. * - * Moves the device from quiesced back to running and restarts the - * queues. + * Moves the device from quiesced back to running and restarts the queues. * - * Must be called with user context, may sleep. + * Must be called with user context, may sleep. */ -void scsi_device_resume(struct scsi_device *sdev) +void scsi_device_unquiesce(struct scsi_device *sdev) { - /* check if the device state was mutated prior to resume, and if - * so assume the state is being managed elsewhere (for example - * device deleted during suspend) - */ mutex_lock(&sdev->state_mutex); WARN_ON_ONCE(!sdev->quiesced_by); sdev->quiesced_by = NULL; @@ -3044,7 +3130,7 @@ void scsi_device_resume(struct scsi_device *sdev) scsi_device_set_state(sdev, SDEV_RUNNING); mutex_unlock(&sdev->state_mutex); } -EXPORT_SYMBOL(scsi_device_resume); +EXPORT_SYMBOL(scsi_device_unquiesce); static void device_quiesce_fn(struct scsi_device *sdev, void *data) @@ -3060,17 +3146,17 @@ scsi_target_quiesce(struct scsi_target *starget) EXPORT_SYMBOL(scsi_target_quiesce); static void -device_resume_fn(struct scsi_device *sdev, void *data) +device_unquiesce_fn(struct scsi_device *sdev, void *data) { - scsi_device_resume(sdev); + scsi_device_unquiesce(sdev); } void -scsi_target_resume(struct scsi_target *starget) +scsi_target_unquiesce(struct scsi_target *starget) { - starget_for_each_device(starget, NULL, device_resume_fn); + starget_for_each_device(starget, NULL, device_unquiesce_fn); } -EXPORT_SYMBOL(scsi_target_resume); +EXPORT_SYMBOL(scsi_target_unquiesce); /** * scsi_internal_device_block_nowait - try to transition to the SDEV_BLOCK state diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index b44c1bb687a2..6300e168701d 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c @@ -57,11 +57,11 @@ static int scsi_dev_type_suspend(struct device *dev, /* flush pending in-flight resume operations, suspend is synchronous */ async_synchronize_full_domain(&scsi_sd_pm_domain); - err = scsi_device_quiesce(to_scsi_device(dev)); + err = scsi_device_suspend(to_scsi_device(dev)); if (err == 0) { err = cb(dev, pm); if (err) - scsi_device_resume(to_scsi_device(dev)); + scsi_device_unsuspend(to_scsi_device(dev)); } dev_dbg(dev, "scsi suspend: %d\n", err); return err; @@ -74,7 +74,7 @@ static int scsi_dev_type_resume(struct device *dev, int err = 0; err = cb(dev, pm); - scsi_device_resume(to_scsi_device(dev)); + scsi_device_unsuspend(to_scsi_device(dev)); dev_dbg(dev, "scsi resume: %d\n", err); if (err == 0) { diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 7943b762c12d..496c5eff4859 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -36,6 +36,7 @@ static const struct { { SDEV_CANCEL, "cancel" }, { SDEV_DEL, "deleted" }, { SDEV_QUIESCE, "quiesce" }, + { SDEV_SUSPENDED, "suspended" }, { SDEV_OFFLINE, "offline" }, { SDEV_TRANSPORT_OFFLINE, "transport-offline" }, { SDEV_BLOCK, "blocked" }, diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index bf6b18768e79..16bec4884249 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -1048,7 +1048,7 @@ spi_dv_device(struct scsi_device *sdev) mutex_unlock(&spi_dv_mutex(starget)); spi_dv_pending(starget) = 0; - scsi_target_resume(starget); + scsi_target_unquiesce(starget); spi_initial_dv(starget) = 1; diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 440834f4252e..a2e3edf8be12 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -42,9 +42,8 @@ enum scsi_device_state { * Only error handler commands allowed */ SDEV_DEL, /* device deleted * no commands allowed */ - SDEV_QUIESCE, /* Device quiescent. No block commands - * will be accepted, only specials (which - * originate in the mid-layer) */ + SDEV_QUIESCE, /* Only RQF_DV requests are accepted. */ + SDEV_SUSPENDED, /* Only RQF_PM requests are accepted. */ SDEV_OFFLINE, /* Device offlined (by error handling or * user request */ SDEV_TRANSPORT_OFFLINE, /* Offlined by transport class error handler */ @@ -415,9 +414,13 @@ extern void sdev_evt_send(struct scsi_device *sdev, struct scsi_event *evt); extern void sdev_evt_send_simple(struct scsi_device *sdev, enum scsi_device_event evt_type, gfp_t gfpflags); extern int scsi_device_quiesce(struct scsi_device *sdev); -extern void scsi_device_resume(struct scsi_device *sdev); +extern void scsi_device_unquiesce(struct scsi_device *sdev); extern void scsi_target_quiesce(struct scsi_target *); -extern void scsi_target_resume(struct scsi_target *); +extern void scsi_target_unquiesce(struct scsi_target *); +extern int scsi_device_suspend(struct scsi_device *sdev); +extern void scsi_device_unsuspend(struct scsi_device *sdev); +extern void scsi_target_suspend(struct scsi_target *); +extern void scsi_target_unsuspend(struct scsi_target *); extern void scsi_scan_target(struct device *parent, unsigned int channel, unsigned int id, u64 lun, enum scsi_scan_mode rescan); From patchwork Thu Aug 9 19:41:42 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561861 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 14B4013B4 for ; Thu, 9 Aug 2018 19:42:16 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 049E62B97D for ; Thu, 9 Aug 2018 19:42:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC76C2B97F; Thu, 9 Aug 2018 19:42:15 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 1D2B62B979 for ; Thu, 9 Aug 2018 19:42:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbeHIWIc (ORCPT ); Thu, 9 Aug 2018 18:08:32 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWIc (ORCPT ); Thu, 9 Aug 2018 18:08:32 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843733; x=1565379733; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=bxvMCPZ6GBwylZMkltVuldxTL61qyD5LYS9MuJ6aSfM=; b=YS9mO1vA+w97Nxb9wKtFywgOiBjTiWWe3Zz0Btvkud3H2IHFJ/DNYiK4 OiNX4t9GSnVuQDx5zeb9Z/aIyOmbWytKZUkLgM4kZ0cz9YVboACcQavc0 eQLJu+7pKBTNruaLFr/elHB1Dz0VLQvSli3MFaN+byn4iTl0/GatkWPyM 4NFXuMNP5LNm/jhfXoJwxKGKM63QIxYwP1f4D4IokVNiyT/bq3/UI1Yw6 VjdC7p3EbpkkzBuSR4w7qRJSU4Rzs7IoM+QXFIHBZXXoN4mOUa3pBEjfP N1bAZLPWUU8w0udPIUs+dff8JD6CO3w985jtnCJGTdopkeCDXvCeqh252 g==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119598" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:12 +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:X-MS-Exchange-SenderADCheck; bh=h4UzdQ0z5lL0tkKZN0l3IWXM8h3gGc/ZcQVDlLees2g=; b=LbGJToPS7jsSsdnfcS+FtPGcouImnr5krOPW8ukFHfEU3IzXKkk3cbT2aJgdGUIXxrKN8qLPAuyZoftJGDf4SIVnvyfUoIfe9cYIlML1T1A7uv0lhYfU1q9TCAZIPfpRm8ZpqGKxlTmKcy7kGdMTOwR68zq+i+VxL17Jyfq+puU= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:07 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 05/12] block, scsi: Rename QUEUE_FLAG_PREEMPT_ONLY into DV_ONLY and introduce PM_ONLY Date: Thu, 9 Aug 2018 12:41:42 -0700 Message-Id: <20180809194149.15285-6-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 492e4db4-f53c-4265-3156-08d5fe303142 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:9DDM0PLEirBdDyVOBYKdVUZ0LEwohjb4F1m1l9ruC2xCa+UTr7pNv68N17MjWlD4hXdlOBsrazVpju4tB+pG1leZzmIWbNzL9iBaBN4s+ezZh8VHu0IX9b2DbRNa3JgKRuD4AUUg2LBHqj39keL8Rq5A4PDrzqsVc88AJuHzULC5pcDm1GY9PeFOtGTitfdmnjuPukn5mA3w4uAGhrurnnaikF0+8+VyfUD2s8rIcDBozXNoImBze68U2mgNwEDo;25:NYXqdzOP84SMk4YxzSt1DK5ohwoYXsEbSLyR5z7M8UwiTy9nECMZc3P2xrSeEjTZLI/ft/97LAULAHfo/lKMoRUplxrLpfd/WaZNKXzlHLg2mPjOePGrR96yc7SKRckLIJINJfhz4z87He8N4fGq8SDi9A3ASvxoQlNCZXH/BqV6Br6EsXQQ/WahDYB6GkxOicW8+DBzcJd4oclY9jg8YBmOTd3ASnKFMRE9ilsUDvMZwrR39gm9DDbvP7/VwP8FFcJqln9svGw19kbvM1MMhNWBWaTd/6kEm+ZVo82zGF5sBfEYeBvfHEkXEngjn+Huc9SOHs4k0jAwxGjnntvywg==;31:sDkoKgSAmomgYnU3uOaO4tPBAvsTCVrkyeIBxX7yUPPt8628CS3v5WLOyvCrjfYVjmXv0nupJSDlnc/ZO0YyATDkTgi1aWmqhb6Fnm9G46wER8c4JqsFIYEQeluEmDPUlYzWRCydU9p6KDWyAjdJiFzzkUGeFP7oeyZCXcfXhrDuDEJvs3+x/ofx5j9YiVEFEHA0smZ7BxAqE291tY+3oWLnhISgPj6uBzcpkVDR1cM= X-MS-TrafficTypeDiagnostic: MWHPR04MB1198: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:YxCFdX4FR5Ft+7YyCcrlbWlU0KXT5gxvEXqpWZ5WBbPfkd5uuXLBvAh76T3qXylZT6ViF3xr/2y7GSXt7Jy2XpTFyqzUJbPB9YDg4RhECLuHBsAG7fTD2p9Sj4db4GgnTYEqLbdCpRbN9K/8O9yKaFODQbg2fb8Ct3H9x/QZHQlLK2MpMgRzx6f6k0kTUn3FJvTgcCotvyp7YD9TpjXOGOGJlVUgNz4R4NKu8cD/AO4D/IXPhL/UlgsYEMXjwgiXcDr/26FbnHtIbWYucPW6p8nL4D7g6r6RwGT1WFNkLSg3pz5KbnPrlkPN7QGUK7BnGGPqp4hpit7rWD9KCcsG1hk8QkDs+4UBQSitXWljA630nxJfChE4aIw4w11Gb5QbWzWR7GnUBesumj8f4ie3tzqKsig6Mif80uIWMTwe692IQrRjdz2OQXLadnzEgU7bk7H2Iwfh1UeAsbxztLDKLcT4Vhrvs67RwEusCpKcplTP/IzHwq9Tp3d+5AvwSK1r;4:DBF2XPIhgs1GRCiaeN9e9ETnx4yoofM4rn70s2I7OE8lGuUW2cSi8wiULbZ4RLOB3harSJu+hbDnvRC553Nwvj841AWSKdjjme5O6ofZHU1xCDIQ0Op+/Zxs3IPZEAm0rZ58cz5apAovf05QOmMyX2Bkef0wbNsVx7dVqwgGO48EVmcnjJB1nR6rjmFp96ngLaNHV4JleUlqxVOa87N4Dt/bAGcCg9es68jVUHyuiVs2z1nnKKEHD4YfmmAq8k5kWiGA7UTHBqhZx6f7o6Ihev/MwKo78TE6yFHWNXzXYkdEM9i7crp92YLHm9k5o4W65bOlmSDJbJGzuyhoQj9o7sXz/ikfrCh9K4fiH946zTc= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(966005)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007)(6306002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:AwUWf9+BrasrWYGgzdt0Bpulkg54OWedRVE+0bHGPEbbEpbp79YNNXgJ3CAqdSr9mARp9HPhFFY/gIkL7c38yTDh935pujdpQUb5DoB0t3/vu529sEi1+Gj5ZByLwqJ3aImiDP5DBnt4h/0iX/sPklYkvw4B4PxC2TzioWvBrCYUnEtcU4xQx7gKjPu30C0V0o1XvnQ1Q6t/XuYWtRMjc/DXReAXo4r+CXQpc6tGZNav3vpafQQKf0+lYcXoHl3elgnlsKuSoafv/NCNGbEvJl0SUFqHnFaAydZy4nVMyc6+nusF3vcomdElAYpOSGbW2wx4W9PTndCsOxqusHRI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5s+mtt0KsrARkvo/xHioNGLC8YaC/SrFBpuJLrt8EaD7R9D7MZHUHwEyJ/qHBjCekgPpqpxQwOO1+gqCNkUZyqZb3RnQ1Fjp70mGkkovJTvkYivnAk5yIba7Sa SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:4myuhesQ++AHkkjTQOzgjlcFNiHceWCfyUGyyiTAJv7Yd3fNfGu/pUnlqCuYM9EuM0lSIYnYmMgnFtimjuLaZswZdRKV1tVkC99knSIXqG2tHU0oDbUpkywx7BMxphaTJ4W0HCroHTQ8Lnzbak1CPwHqC/Yj/q/SEaheM/ush4Y= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:07.7076 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 492e4db4-f53c-4265-3156-08d5fe303142 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Instead of having one queue state (PREEMPT_ONLY) in which both power management and SCSI domain validation requests are processed, rename the PREEMPT_ONLY state into DV_ONLY and introduce a new queue flag QUEUE_FLAG_PM_ONLY. Provide the new functions blk_set_pm_only() and blk_clear_pm_only() for power management and blk_set_dv_only() and blk_clear_dv_only() functions for SCSI domain validation purposes. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-core.c | 65 ++++++++++++++++++++++++++++++----------- block/blk-mq-debugfs.c | 3 +- drivers/scsi/scsi_lib.c | 16 +++++----- include/linux/blkdev.h | 13 +++++---- 4 files changed, 66 insertions(+), 31 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index c4ff58491758..401f4927a8db 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -421,24 +421,44 @@ void blk_sync_queue(struct request_queue *q) EXPORT_SYMBOL(blk_sync_queue); /** - * blk_set_preempt_only - set QUEUE_FLAG_PREEMPT_ONLY + * blk_set_dv_only - set QUEUE_FLAG_DV_ONLY * @q: request queue pointer * - * Returns the previous value of the PREEMPT_ONLY flag - 0 if the flag was not + * Returns the previous value of the DV_ONLY flag - 0 if the flag was not * set and 1 if the flag was already set. */ -int blk_set_preempt_only(struct request_queue *q) +int blk_set_dv_only(struct request_queue *q) { - return blk_queue_flag_test_and_set(QUEUE_FLAG_PREEMPT_ONLY, q); + return blk_queue_flag_test_and_set(QUEUE_FLAG_DV_ONLY, q); } -EXPORT_SYMBOL_GPL(blk_set_preempt_only); +EXPORT_SYMBOL_GPL(blk_set_dv_only); -void blk_clear_preempt_only(struct request_queue *q) +void blk_clear_dv_only(struct request_queue *q) { - blk_queue_flag_clear(QUEUE_FLAG_PREEMPT_ONLY, q); + blk_queue_flag_clear(QUEUE_FLAG_DV_ONLY, q); wake_up_all(&q->mq_freeze_wq); } -EXPORT_SYMBOL_GPL(blk_clear_preempt_only); +EXPORT_SYMBOL_GPL(blk_clear_dv_only); + +/** + * blk_set_pm_only - set QUEUE_FLAG_PM_ONLY + * @q: request queue pointer + * + * Returns the previous value of the PM_ONLY flag - 0 if the flag was not + * set and 1 if the flag was already set. + */ +int blk_set_pm_only(struct request_queue *q) +{ + return blk_queue_flag_test_and_set(QUEUE_FLAG_PM_ONLY, q); +} +EXPORT_SYMBOL_GPL(blk_set_pm_only); + +void blk_clear_pm_only(struct request_queue *q) +{ + blk_queue_flag_clear(QUEUE_FLAG_PM_ONLY, q); + wake_up_all(&q->mq_freeze_wq); +} +EXPORT_SYMBOL_GPL(blk_clear_pm_only); /** * __blk_run_queue_uncond - run a queue whether or not it has been stopped @@ -910,6 +930,20 @@ struct request_queue *blk_alloc_queue(gfp_t gfp_mask) } EXPORT_SYMBOL(blk_alloc_queue); +/* + * Whether or not blk_queue_enter() should proceed. RQF_PM requests are always + * allowed. RQF_DV requests are allowed if the PM_ONLY queue flag has not been + * set. Other requests are only allowed if neither PM_ONLY nor DV_ONLY has been + * set. + */ +static inline bool blk_enter_allowed(struct request_queue *q, + blk_mq_req_flags_t flags) +{ + return flags & BLK_MQ_REQ_PM || + (!blk_queue_pm_only(q) && + (flags & BLK_MQ_REQ_DV || !blk_queue_dv_only(q))); +} + /** * blk_queue_enter() - try to increase q->q_usage_counter * @q: request queue pointer @@ -917,23 +951,20 @@ EXPORT_SYMBOL(blk_alloc_queue); */ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) { - const bool preempt = flags & (BLK_MQ_REQ_PM | BLK_MQ_REQ_DV); - while (true) { bool success = false; rcu_read_lock(); if (percpu_ref_tryget_live(&q->q_usage_counter)) { /* - * The code that sets the PREEMPT_ONLY flag is - * responsible for ensuring that that flag is globally - * visible before the queue is unfrozen. + * The code that sets the PM_ONLY or DV_ONLY queue + * flags is responsible for ensuring that that flag is + * globally visible before the queue is unfrozen. */ - if (preempt || !blk_queue_preempt_only(q)) { + if (blk_enter_allowed(q, flags)) success = true; - } else { + else percpu_ref_put(&q->q_usage_counter); - } } rcu_read_unlock(); @@ -954,7 +985,7 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) wait_event(q->mq_freeze_wq, (atomic_read(&q->mq_freeze_depth) == 0 && - (preempt || !blk_queue_preempt_only(q))) || + blk_enter_allowed(q, flags)) || blk_queue_dying(q)); if (blk_queue_dying(q)) return -ENODEV; diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index b4e722311ae1..2ac9949bf68e 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -132,7 +132,8 @@ static const char *const blk_queue_flag_name[] = { QUEUE_FLAG_NAME(REGISTERED), QUEUE_FLAG_NAME(SCSI_PASSTHROUGH), QUEUE_FLAG_NAME(QUIESCED), - QUEUE_FLAG_NAME(PREEMPT_ONLY), + QUEUE_FLAG_NAME(PM_ONLY), + QUEUE_FLAG_NAME(DV_ONLY), }; #undef QUEUE_FLAG_NAME diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index eb914d8e17fd..d466f846043f 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -2997,11 +2997,11 @@ scsi_device_suspend(struct scsi_device *sdev) if (sdev->sdev_state == SDEV_SUSPENDED) return 0; - blk_set_preempt_only(q); + blk_set_pm_only(q); blk_mq_freeze_queue(q); /* - * Ensure that the effect of blk_set_preempt_only() will be visible + * Ensure that the effect of blk_set_pm_only() will be visible * for percpu_ref_tryget() callers that occur after the queue * unfreeze even if the queue was already frozen before this function * was called. See also https://lwn.net/Articles/573497/. @@ -3012,7 +3012,7 @@ scsi_device_suspend(struct scsi_device *sdev) mutex_lock(&sdev->state_mutex); err = scsi_device_set_state(sdev, SDEV_SUSPENDED); if (err) - blk_clear_preempt_only(q); + blk_clear_pm_only(q); mutex_unlock(&sdev->state_mutex); return err; @@ -3030,7 +3030,7 @@ EXPORT_SYMBOL(scsi_device_suspend); void scsi_device_unsuspend(struct scsi_device *sdev) { mutex_lock(&sdev->state_mutex); - blk_clear_preempt_only(sdev->request_queue); + blk_clear_pm_only(sdev->request_queue); if (sdev->sdev_state == SDEV_SUSPENDED) scsi_device_set_state(sdev, SDEV_RUNNING); mutex_unlock(&sdev->state_mutex); @@ -3088,11 +3088,11 @@ scsi_device_quiesce(struct scsi_device *sdev) */ WARN_ON_ONCE(sdev->quiesced_by && sdev->quiesced_by != current); - blk_set_preempt_only(q); + blk_set_dv_only(q); blk_mq_freeze_queue(q); /* - * Ensure that the effect of blk_set_preempt_only() will be visible + * Ensure that the effect of blk_set_dv_only() will be visible * for percpu_ref_tryget() callers that occur after the queue * unfreeze even if the queue was already frozen before this function * was called. See also https://lwn.net/Articles/573497/. @@ -3105,7 +3105,7 @@ scsi_device_quiesce(struct scsi_device *sdev) if (err == 0) sdev->quiesced_by = current; else - blk_clear_preempt_only(q); + blk_clear_dv_only(q); mutex_unlock(&sdev->state_mutex); return err; @@ -3125,7 +3125,7 @@ void scsi_device_unquiesce(struct scsi_device *sdev) mutex_lock(&sdev->state_mutex); WARN_ON_ONCE(!sdev->quiesced_by); sdev->quiesced_by = NULL; - blk_clear_preempt_only(sdev->request_queue); + blk_clear_dv_only(sdev->request_queue); if (sdev->sdev_state == SDEV_QUIESCE) scsi_device_set_state(sdev, SDEV_RUNNING); mutex_unlock(&sdev->state_mutex); diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 938725ef492b..7717b71c6da3 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -699,7 +699,8 @@ struct request_queue { #define QUEUE_FLAG_REGISTERED 26 /* queue has been registered to a disk */ #define QUEUE_FLAG_SCSI_PASSTHROUGH 27 /* queue supports SCSI commands */ #define QUEUE_FLAG_QUIESCED 28 /* queue has been quiesced */ -#define QUEUE_FLAG_PREEMPT_ONLY 29 /* only process REQ_PREEMPT requests */ +#define QUEUE_FLAG_PM_ONLY 29 /* only process RQF_PM requests */ +#define QUEUE_FLAG_DV_ONLY 30 /* only process RQF_DV requests */ #define QUEUE_FLAG_DEFAULT ((1 << QUEUE_FLAG_IO_STAT) | \ (1 << QUEUE_FLAG_SAME_COMP) | \ @@ -737,12 +738,14 @@ bool blk_queue_flag_test_and_clear(unsigned int flag, struct request_queue *q); ((rq)->cmd_flags & (REQ_FAILFAST_DEV|REQ_FAILFAST_TRANSPORT| \ REQ_FAILFAST_DRIVER)) #define blk_queue_quiesced(q) test_bit(QUEUE_FLAG_QUIESCED, &(q)->queue_flags) -#define blk_queue_preempt_only(q) \ - test_bit(QUEUE_FLAG_PREEMPT_ONLY, &(q)->queue_flags) +#define blk_queue_pm_only(q) test_bit(QUEUE_FLAG_PM_ONLY, &(q)->queue_flags) +#define blk_queue_dv_only(q) test_bit(QUEUE_FLAG_DV_ONLY, &(q)->queue_flags) #define blk_queue_fua(q) test_bit(QUEUE_FLAG_FUA, &(q)->queue_flags) -extern int blk_set_preempt_only(struct request_queue *q); -extern void blk_clear_preempt_only(struct request_queue *q); +extern int blk_set_pm_only(struct request_queue *q); +extern void blk_clear_pm_only(struct request_queue *q); +extern int blk_set_dv_only(struct request_queue *q); +extern void blk_clear_dv_only(struct request_queue *q); static inline int queue_in_flight(struct request_queue *q) { From patchwork Thu Aug 9 19:41:43 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561863 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 058FA13B4 for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E960A2B979 for ; Thu, 9 Aug 2018 19:42:16 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DD3742B980; Thu, 9 Aug 2018 19:42:16 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 01EBE2B979 for ; Thu, 9 Aug 2018 19:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727068AbeHIWId (ORCPT ); Thu, 9 Aug 2018 18:08:33 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWId (ORCPT ); Thu, 9 Aug 2018 18:08:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843735; x=1565379735; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=EgPiQzzz6Fpmtd7fVuvWHby5pKn7rmPLzxwYObnw5Vk=; b=cP5EOFzKLe6MC04dcpX330qTvneJ7V9MOzhLGCKQrQPw6a9nrNddsMUj zam/TEZYy2kv6T8il8k6U5P7UcCDPd0D35EK8NjqnGmu8XMcawkD6fkLw jKz8J2k0NFnYWLV9KnplClZObZrbxStW9Ur++8kXkNUl8zqGOuwa8gHY+ x1WSy3Wo1TBdz4TJvfGDianq247yM7EPRuYIHskSQ4SQgqr6+nee1hUoX VMUSZqOEjxZQkOnErgP9IKV9LzvDQl+H/FXnxJjAf2uw3jzMbEm/tWy1q 34nbZtUkuoe1/+VOjIbLW0JqMAE9+hZqL5VVtD1zMK/M7SzxJGnqPtzsX w==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119599" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:13 +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:X-MS-Exchange-SenderADCheck; bh=81Su0FNYEY6XUIk/2psOkQFY3q1rbV4XU7ZmwTaeW18=; b=U4KkXh/yguAY3xxpZ3YKsTls3CUtV/X4IeZRvxjbwlIpONohacvbPv983c1XqxG1hMEOc5rPHrrUBEMVrbp/mcTjRQhSb5pJelPofEe/rIW7nkoSdEkAAKdbGkfp3TdITWKE5QlCzk6ggcYDjteREGg2TiIrSrwjCx+W+hmI6BA= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:08 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Woody Suwalski , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 06/12] scsi: Reallow SPI domain validation during system suspend Date: Thu, 9 Aug 2018 12:41:43 -0700 Message-Id: <20180809194149.15285-7-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 76ed03ea-518f-4133-49a0-08d5fe3031b2 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:2fIOAM0Ws19dHKfMlk15OqAcLj23MLVxlGiZgLz+pMY5iVtrIH8p+LX1LzBFSK5za/edJDWOI4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dshESKKQOJ5iMRr18X2w7DcDahUIsdo3DSNNtEPoOZCB6IqjjqqxKMMIOD9mVhbUEc/TwgELlMZOACPQUBZkkZW/NpHaa7w1ybql8dKvP55ItWCqLVlgy71Ia8d1KpMzlwuBg2lFMGHbuiypbZZnZvz4+C4fFGXTpNASlDHsdrv1e6KmWZOOryAk7LPNk3eGSe/gwiwgmbuuNgnY8QAXUKvxJzwEnSpzj47pX7XssKhaoJsN2X1cN7Bc7sRx90lbyf82se1x2+DHMAWvGmWf9OwBukVB3D;4:Fwmq1yM2WXfE50kgTQgcma1yzV2f427y5NG5J/zjti3wzYjL7KCT4JKvAxTL9vZyZ7zzBteYWU/bJjQDxQshQxdvC5IG/caW+NahXCOqia3THVlz35rmMXXT7R5ds8hOAi4pJvtpWTy1yAZVgT4TcTmekjj0abS2ttfoKcw/kmdCNjjLU3vO5un1WXlElyPssMyXKKwGgPnUz6c/1DGxbCK/glc6dqCMFcMqtApxZ41u/CpVFvinwBkvpPNYSJ9Q2sPULAdKmd7X2zLvEW9fYGxR9Cx26JvCuwFKuD8rinlkvdBhk4CPWweFQK/PRn0q4uJ0embQFxH8UhvG/CYtOiaZlkOEuPTOX4TXXBVqvpHqseDrL7/38uevfplGFWZn X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(85827821059158)(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(39060400002)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(15650500001)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(7416002)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:5ELabSzF8OpQPlwzJsmiTxNTetDuH1yVR/R3i1QJgW2i/YDxiCsbq0Qij3Hv7/ftLkD3acyVZOcjxdfrr0inRi4WhvCUNyrN8JbS4+LEZboSd7odYNkd2AenB75zCDzocKnKML23Ko0rmOXa6k2TU+m+VSVp61DQFYCD/UFGk2hj1pATvf02urcq30dk43sdqzkARGdHEoXjnHN8rqVq1gEhHv06dFGXNuMxY6e4SH5nNKC7ZAvFt62BKTSoLqZ0vvMtsWPQ+cAOW8SXi2fTXpaJAIUV0lLpHnu2tVtXF+H86di0iz2C7zZwsRFrZdYFgHq0c1NAcTJezG5dkWoQwBimOAFbVswprwTnMjkybErjvl1v52PrmLz7SfZNH5kw/DQNryw08bkoHAu+597sI0s9uYnJPaVKSIMWRue4pQ8C80D47jsCnB7AgCcvniPGduooD2/xA3Q3FLTTUdd4aoz0zC0/9uBRbhR0MsH4DvsXjIe2D2qHRl6gYZQuU8xNJiQ9VJ+8pqOKvBrwOUN210iAmgC5osUz2ZZRQFpc1Sp3MtkjM9mn4KtK7wA1bToMhNOWxb0zeJSSclpzztLPRWIYzbNFh8j9W+d0Rg2BXv5UoeTUGmccnaAVv1ES123mocSGk1tyA4c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y6uNzxFcguEjTLSJ89QLtk9lXaYhZRE+V/3DaGRz1K+wvma6N2zpLpjG2t4PDdz3vH/dxgx16GJGKNeqKxFrCY8= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:08.4162 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 76ed03ea-518f-4133-49a0-08d5fe3031b2 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Now that SCSI power management and SPI domain validation use different mechanisms for blocking SCSI command execution, remove the mechanism again that prevents system suspend during SPI domain validation. This patch reverts 203f8c250e21 ("block, scsi: Fix race between SPI domain validation and system suspend"). Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Woody Suwalski Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- drivers/scsi/scsi_lib.c | 37 +++++++++++++++++++++++++++++-- drivers/scsi/scsi_sysfs.c | 1 + drivers/scsi/scsi_transport_spi.c | 15 ++----------- include/scsi/scsi_device.h | 1 + 4 files changed, 39 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index d466f846043f..89f790e73ed6 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -1366,6 +1366,7 @@ scsi_prep_state_check(struct scsi_device *sdev, struct request *req) ret = BLKPREP_DEFER; break; case SDEV_SUSPENDED: + case SDEV_QUIESCED_SUSPENDED: /* Process RQF_PM requests only. */ if (!(req->rq_flags & RQF_PM)) ret = BLKPREP_DEFER; @@ -2683,6 +2684,17 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) break; case SDEV_QUIESCE: + switch (oldstate) { + case SDEV_RUNNING: + case SDEV_QUIESCED_SUSPENDED: + case SDEV_OFFLINE: + case SDEV_TRANSPORT_OFFLINE: + break; + default: + goto illegal; + } + break; + case SDEV_SUSPENDED: switch (oldstate) { case SDEV_RUNNING: @@ -2694,6 +2706,15 @@ scsi_device_set_state(struct scsi_device *sdev, enum scsi_device_state state) } break; + case SDEV_QUIESCED_SUSPENDED: + switch (oldstate) { + case SDEV_QUIESCE: + break; + default: + goto illegal; + } + break; + case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: switch (oldstate) { @@ -2994,8 +3015,13 @@ scsi_device_suspend(struct scsi_device *sdev) struct request_queue *q = sdev->request_queue; int err; - if (sdev->sdev_state == SDEV_SUSPENDED) + switch (sdev->sdev_state) { + case SDEV_SUSPENDED: + case SDEV_QUIESCED_SUSPENDED: return 0; + default: + break; + } blk_set_pm_only(q); @@ -3011,6 +3037,8 @@ scsi_device_suspend(struct scsi_device *sdev) mutex_lock(&sdev->state_mutex); err = scsi_device_set_state(sdev, SDEV_SUSPENDED); + if (err) + err = scsi_device_set_state(sdev, SDEV_QUIESCED_SUSPENDED); if (err) blk_clear_pm_only(q); mutex_unlock(&sdev->state_mutex); @@ -3031,8 +3059,13 @@ void scsi_device_unsuspend(struct scsi_device *sdev) { mutex_lock(&sdev->state_mutex); blk_clear_pm_only(sdev->request_queue); - if (sdev->sdev_state == SDEV_SUSPENDED) + switch (sdev->sdev_state) { + case SDEV_SUSPENDED: + case SDEV_QUIESCED_SUSPENDED: scsi_device_set_state(sdev, SDEV_RUNNING); + default: + break; + } mutex_unlock(&sdev->state_mutex); } EXPORT_SYMBOL(scsi_device_unsuspend); diff --git a/drivers/scsi/scsi_sysfs.c b/drivers/scsi/scsi_sysfs.c index 496c5eff4859..8c152e35ff77 100644 --- a/drivers/scsi/scsi_sysfs.c +++ b/drivers/scsi/scsi_sysfs.c @@ -37,6 +37,7 @@ static const struct { { SDEV_DEL, "deleted" }, { SDEV_QUIESCE, "quiesce" }, { SDEV_SUSPENDED, "suspended" }, + { SDEV_QUIESCED_SUSPENDED, "quiesced-suspended" }, { SDEV_OFFLINE, "offline" }, { SDEV_TRANSPORT_OFFLINE, "transport-offline" }, { SDEV_BLOCK, "blocked" }, diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index 16bec4884249..582b18efc3fb 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -26,7 +26,6 @@ #include #include #include -#include #include #include "scsi_priv.h" #include @@ -1008,19 +1007,11 @@ spi_dv_device(struct scsi_device *sdev) u8 *buffer; const int len = SPI_MAX_ECHO_BUFFER_SIZE*2; - /* - * Because this function and the power management code both call - * scsi_device_quiesce(), it is not safe to perform domain validation - * while suspend or resume is in progress. Hence the - * lock/unlock_system_sleep() calls. - */ - lock_system_sleep(); - if (unlikely(starget->spi_dv_context)) - goto unlock; + return; if (unlikely(scsi_device_get(sdev))) - goto unlock; + return; buffer = kzalloc(len, GFP_KERNEL); @@ -1056,8 +1047,6 @@ spi_dv_device(struct scsi_device *sdev) kfree(buffer); out_put: scsi_device_put(sdev); -unlock: - unlock_system_sleep(); } EXPORT_SYMBOL(spi_dv_device); diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index a2e3edf8be12..a67dc459b70d 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -44,6 +44,7 @@ enum scsi_device_state { * no commands allowed */ SDEV_QUIESCE, /* Only RQF_DV requests are accepted. */ SDEV_SUSPENDED, /* Only RQF_PM requests are accepted. */ + SDEV_QUIESCED_SUSPENDED,/* Only RQF_PM requests are accepted. */ SDEV_OFFLINE, /* Device offlined (by error handling or * user request */ SDEV_TRANSPORT_OFFLINE, /* Offlined by transport class error handler */ From patchwork Thu Aug 9 19:41:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561869 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 63E6113B4 for ; Thu, 9 Aug 2018 19:42:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 530412B979 for ; Thu, 9 Aug 2018 19:42:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 46BD52B97F; Thu, 9 Aug 2018 19:42:18 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 C1D102B97D for ; Thu, 9 Aug 2018 19:42:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727137AbeHIWIe (ORCPT ); Thu, 9 Aug 2018 18:08:34 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41000 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbeHIWId (ORCPT ); Thu, 9 Aug 2018 18:08:33 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843736; x=1565379736; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=wbRBX8xo+4YgHfQJKOVQXAEyisqulqv5Hvk3HGBTtzs=; b=aeTT4kXVBL6hTnc+2dNrvQktr3Seo1cV0Rs/+IsCshQgrQY3sh4AJMt2 jzCIrN88LvhSKplzWJiUXIReA9+EnJ0KVv0lUlWsTEpq0xGFRY18VrWnk C+BlyhRTe/O2uOmDiO/9SUNJtqlco7p+LD+gtMPj+CnNuvzgKOX7HbFiQ ji9wQqIOO5GLoZ7zCuYnZToowcRnXCg2qr1N888r9Ujmz7qkbTAHx+APG zRiZVQbguCLBQgHFKFo/Yf7StbsokZAohTwZqpL6Km+6BxTCbOVjjBccI niGpgIpVLzyosBFaoVvdFFkpL6NGihErVmRF+ZB4YGrQpj65ihEW9THbJ Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="90927376" Received: from mail-sn1nam01lp0111.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.111]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:14 +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:X-MS-Exchange-SenderADCheck; bh=CFkeiDfuA5u7gKb+mdPKV9KAo6AhEfJOYN4139rEiQI=; b=MzItXu0xDIBUMHfffeENIiNliEl7yg07IYVUC8kNfBW6/+BO5gJEScjm5K4WDX/Gor6JNgAZ3tBFFi+UyXdV7bRtTUykYRKVZ4DGyb4BsAqpfQyPISN/EugVUbKnC+hbVVBUYgAVEjmzTDPKuv/1UIJqsPFg8GliHta7JkaXPS0= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:09 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 07/12] block: Move power management code into a new source file Date: Thu, 9 Aug 2018 12:41:44 -0700 Message-Id: <20180809194149.15285-8-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9dc38b1e-1266-4e4b-5163-08d5fe303216 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:EVzo07E7k7EzrIGjvgm9r1zXTLoKkxRPJeeFcGdqYxHLPwCxpO562XuhazZ3mQZHX1o0LDH+djowHQEGlAqwVcbXtyHVgt0RxsEOLJ3qdVGUqD8ICnMMY67JFdV5GfKj9BCUQSYeRwGKasypcU1CdHPXMTvPhcbu5i7ADlJdvyheOiuIts90jkLr1Z8vvDVjrw1O0DRk+zP+3i4RbiAwM9af69Mg7p1J4QcEBYhyUY8I3x/ZJzmRB+zFN96Ti0GL;25:inXA/phnxwoOxCjC4hX1evlcQWIKS0WLUpiHC4M4blu3mj4JymD6qdjhCaBqJaWwF3IBoSajQ0BzfXbTs8Nam6vK48IKhgaDBmlypydrf0Mhi8hLLtH0ZWKX0beYkxnDi32/+3CkBhQLdCx/aA+j5ZABgVwTVpACMME7fjDbZ/ls+uqGjgU5qtSF4N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B0RhrUn2/5S8hOeKVUxXSBDDshH/Z8V+l95bHY5LYRcQrAqMQnk73LVsK3gKjUnK8vShIku+kxsTBbdSWy8ujABKnCqzld1Gm39toOQjN+my8VYnpkWK1f/9keXxG0f9Z5BQF5oRcDAr++tA8ufyhQiggE5i8KkHPNBzrewV2X6D3JIJNkyJ6zoRzKrgp+OzBo3V7h/pGXI/DJI85iGuu0wzl6/cf1IYuXU1Cn4cp0oll5Nu3NvD9+2EBDX/99X2QF+ux7NHHJxyqO4oGFupetH+y5Zp5FQKMmCM= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(50944005)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(575784001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(7520500002)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNo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D6uosr1cCrvjjKyoUcek3GrFkQQyjd/TPIM/jdY+yUMuZt2m1gi3n0nX0cuYztibwSYCI26QGiaqS8JcFKaoFzgjjHbUh5FRIDoVO8SiJ82lu2HLaJILxEg==;5:M5uFQrjbrWXfwAad4khF0JkDp6CK0hgHsRRDtFguYoTU7coqyrmr3JJOXeyWn5XAICc3wLwSvVjrdS8hi2q3eYkEcZ977OCqxwyW9AzFtXDPY5LbcEKVrk+jJc/TrwUMsNIFODLizNobThU6DWR0/Mn57jNJEPq2Ra08eOfOgg0=;7:cmqp6fHetOMGnN0YGnLPX3oF++WyUSxhWUaJLIZFSp4qPE0gzP1DvUbuF3BQnC8XHpCxUxd3/nGScQBOFvhneeLM32IoQt43OdqSuWDH6L2XqTAlT5Lq4wixTEMfSn/6u3g+SyNFEd4IQ7APAMx3lqCkW22UjIgqarIBWDoSD4hRvrRSWczlmPSvkoylaU5KeX8RUosnnYNP1/SHGYgMNM/tBPcujeLPdZA1ioViKtGXZNgccPsET9zn319rzIfF SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:MsZLonoyh8jumXxfR/ZkMfMYrZolmoi7kF8rQGmSdFKsEQp7DOFaID1IaRMJFHFoxYShnw5i6soRXEUooMszsy/GwmQ+BLId5ks+Y/xGUt7xJiWnGtNZleHNFA7es3SRqUe5nIGN03q3HcrrsGtvfOUyCzsRa+G/BBeOrk9hZTs= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:09.1338 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 9dc38b1e-1266-4e4b-5163-08d5fe303216 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Move the code for runtime power management from blk-core.c into the new source file blk-pm.c. Move the corresponding declarations from into . For CONFIG_PM=n, leave out the declarations of the functions that are not used in that mode. This patch not only reduces the number of #ifdefs in the block layer core code but also reduces the size of header file and hence should help to reduce the build time of the Linux kernel if CONFIG_PM is not defined. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/Kconfig | 5 ++ block/Makefile | 1 + block/blk-core.c | 196 +---------------------------------------- block/blk-pm.c | 188 +++++++++++++++++++++++++++++++++++++++ block/blk-pm.h | 43 +++++++++ block/elevator.c | 22 +---- drivers/scsi/scsi_pm.c | 1 + drivers/scsi/sd.c | 1 + drivers/scsi/sr.c | 1 + include/linux/blk-pm.h | 24 +++++ include/linux/blkdev.h | 23 ----- 11 files changed, 266 insertions(+), 239 deletions(-) create mode 100644 block/blk-pm.c create mode 100644 block/blk-pm.h create mode 100644 include/linux/blk-pm.h diff --git a/block/Kconfig b/block/Kconfig index 1f2469a0123c..e213d90a5e64 100644 --- a/block/Kconfig +++ b/block/Kconfig @@ -228,4 +228,9 @@ config BLK_MQ_RDMA depends on BLOCK && INFINIBAND default y +config BLK_PM + bool + depends on BLOCK && PM + default y + source block/Kconfig.iosched diff --git a/block/Makefile b/block/Makefile index 572b33f32c07..27eac600474f 100644 --- a/block/Makefile +++ b/block/Makefile @@ -37,3 +37,4 @@ obj-$(CONFIG_BLK_WBT) += blk-wbt.o obj-$(CONFIG_BLK_DEBUG_FS) += blk-mq-debugfs.o obj-$(CONFIG_BLK_DEBUG_FS_ZONED)+= blk-mq-debugfs-zoned.o obj-$(CONFIG_BLK_SED_OPAL) += sed-opal.o +obj-$(CONFIG_BLK_PM) += blk-pm.o diff --git a/block/blk-core.c b/block/blk-core.c index 401f4927a8db..3770a36e85be 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -42,6 +42,7 @@ #include "blk.h" #include "blk-mq.h" #include "blk-mq-sched.h" +#include "blk-pm.h" #include "blk-rq-qos.h" #ifdef CONFIG_DEBUG_FS @@ -1757,16 +1758,6 @@ void part_round_stats(struct request_queue *q, int cpu, struct hd_struct *part) } EXPORT_SYMBOL_GPL(part_round_stats); -#ifdef CONFIG_PM -static void blk_pm_put_request(struct request *rq) -{ - if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending) - pm_runtime_mark_last_busy(rq->q->dev); -} -#else -static inline void blk_pm_put_request(struct request *rq) {} -#endif - void __blk_put_request(struct request_queue *q, struct request *req) { req_flags_t rq_flags = req->rq_flags; @@ -3783,191 +3774,6 @@ void blk_finish_plug(struct blk_plug *plug) } EXPORT_SYMBOL(blk_finish_plug); -#ifdef CONFIG_PM -/** - * blk_pm_runtime_init - Block layer runtime PM initialization routine - * @q: the queue of the device - * @dev: the device the queue belongs to - * - * Description: - * Initialize runtime-PM-related fields for @q and start auto suspend for - * @dev. Drivers that want to take advantage of request-based runtime PM - * should call this function after @dev has been initialized, and its - * request queue @q has been allocated, and runtime PM for it can not happen - * yet(either due to disabled/forbidden or its usage_count > 0). In most - * cases, driver should call this function before any I/O has taken place. - * - * This function takes care of setting up using auto suspend for the device, - * the autosuspend delay is set to -1 to make runtime suspend impossible - * until an updated value is either set by user or by driver. Drivers do - * not need to touch other autosuspend settings. - * - * The block layer runtime PM is request based, so only works for drivers - * that use request as their IO unit instead of those directly use bio's. - */ -void blk_pm_runtime_init(struct request_queue *q, struct device *dev) -{ - /* Don't enable runtime PM for blk-mq until it is ready */ - if (q->mq_ops) { - pm_runtime_disable(dev); - return; - } - - q->dev = dev; - q->rpm_status = RPM_ACTIVE; - pm_runtime_set_autosuspend_delay(q->dev, -1); - pm_runtime_use_autosuspend(q->dev); -} -EXPORT_SYMBOL(blk_pm_runtime_init); - -/** - * blk_pre_runtime_suspend - Pre runtime suspend check - * @q: the queue of the device - * - * Description: - * This function will check if runtime suspend is allowed for the device - * by examining if there are any requests pending in the queue. If there - * are requests pending, the device can not be runtime suspended; otherwise, - * the queue's status will be updated to SUSPENDING and the driver can - * proceed to suspend the device. - * - * For the not allowed case, we mark last busy for the device so that - * runtime PM core will try to autosuspend it some time later. - * - * This function should be called near the start of the device's - * runtime_suspend callback. - * - * Return: - * 0 - OK to runtime suspend the device - * -EBUSY - Device should not be runtime suspended - */ -int blk_pre_runtime_suspend(struct request_queue *q) -{ - int ret = 0; - - if (!q->dev) - return ret; - - spin_lock_irq(q->queue_lock); - if (q->nr_pending) { - ret = -EBUSY; - pm_runtime_mark_last_busy(q->dev); - } else { - q->rpm_status = RPM_SUSPENDING; - } - spin_unlock_irq(q->queue_lock); - return ret; -} -EXPORT_SYMBOL(blk_pre_runtime_suspend); - -/** - * blk_post_runtime_suspend - Post runtime suspend processing - * @q: the queue of the device - * @err: return value of the device's runtime_suspend function - * - * Description: - * Update the queue's runtime status according to the return value of the - * device's runtime suspend function and mark last busy for the device so - * that PM core will try to auto suspend the device at a later time. - * - * This function should be called near the end of the device's - * runtime_suspend callback. - */ -void blk_post_runtime_suspend(struct request_queue *q, int err) -{ - if (!q->dev) - return; - - spin_lock_irq(q->queue_lock); - if (!err) { - q->rpm_status = RPM_SUSPENDED; - } else { - q->rpm_status = RPM_ACTIVE; - pm_runtime_mark_last_busy(q->dev); - } - spin_unlock_irq(q->queue_lock); -} -EXPORT_SYMBOL(blk_post_runtime_suspend); - -/** - * blk_pre_runtime_resume - Pre runtime resume processing - * @q: the queue of the device - * - * Description: - * Update the queue's runtime status to RESUMING in preparation for the - * runtime resume of the device. - * - * This function should be called near the start of the device's - * runtime_resume callback. - */ -void blk_pre_runtime_resume(struct request_queue *q) -{ - if (!q->dev) - return; - - spin_lock_irq(q->queue_lock); - q->rpm_status = RPM_RESUMING; - spin_unlock_irq(q->queue_lock); -} -EXPORT_SYMBOL(blk_pre_runtime_resume); - -/** - * blk_post_runtime_resume - Post runtime resume processing - * @q: the queue of the device - * @err: return value of the device's runtime_resume function - * - * Description: - * Update the queue's runtime status according to the return value of the - * device's runtime_resume function. If it is successfully resumed, process - * the requests that are queued into the device's queue when it is resuming - * and then mark last busy and initiate autosuspend for it. - * - * This function should be called near the end of the device's - * runtime_resume callback. - */ -void blk_post_runtime_resume(struct request_queue *q, int err) -{ - if (!q->dev) - return; - - spin_lock_irq(q->queue_lock); - if (!err) { - q->rpm_status = RPM_ACTIVE; - __blk_run_queue(q); - pm_runtime_mark_last_busy(q->dev); - pm_request_autosuspend(q->dev); - } else { - q->rpm_status = RPM_SUSPENDED; - } - spin_unlock_irq(q->queue_lock); -} -EXPORT_SYMBOL(blk_post_runtime_resume); - -/** - * blk_set_runtime_active - Force runtime status of the queue to be active - * @q: the queue of the device - * - * If the device is left runtime suspended during system suspend the resume - * hook typically resumes the device and corrects runtime status - * accordingly. However, that does not affect the queue runtime PM status - * which is still "suspended". This prevents processing requests from the - * queue. - * - * This function can be used in driver's resume hook to correct queue - * runtime PM status and re-enable peeking requests from the queue. It - * should be called before first request is added to the queue. - */ -void blk_set_runtime_active(struct request_queue *q) -{ - spin_lock_irq(q->queue_lock); - q->rpm_status = RPM_ACTIVE; - pm_runtime_mark_last_busy(q->dev); - pm_request_autosuspend(q->dev); - spin_unlock_irq(q->queue_lock); -} -EXPORT_SYMBOL(blk_set_runtime_active); -#endif - int __init blk_dev_init(void) { BUILD_BUG_ON(REQ_OP_LAST >= (1 << REQ_OP_BITS)); diff --git a/block/blk-pm.c b/block/blk-pm.c new file mode 100644 index 000000000000..9b636960d285 --- /dev/null +++ b/block/blk-pm.c @@ -0,0 +1,188 @@ +// SPDX-License-Identifier: GPL-2.0 + +#include +#include +#include + +/** + * blk_pm_runtime_init - Block layer runtime PM initialization routine + * @q: the queue of the device + * @dev: the device the queue belongs to + * + * Description: + * Initialize runtime-PM-related fields for @q and start auto suspend for + * @dev. Drivers that want to take advantage of request-based runtime PM + * should call this function after @dev has been initialized, and its + * request queue @q has been allocated, and runtime PM for it can not happen + * yet(either due to disabled/forbidden or its usage_count > 0). In most + * cases, driver should call this function before any I/O has taken place. + * + * This function takes care of setting up using auto suspend for the device, + * the autosuspend delay is set to -1 to make runtime suspend impossible + * until an updated value is either set by user or by driver. Drivers do + * not need to touch other autosuspend settings. + * + * The block layer runtime PM is request based, so only works for drivers + * that use request as their IO unit instead of those directly use bio's. + */ +void blk_pm_runtime_init(struct request_queue *q, struct device *dev) +{ + /* Don't enable runtime PM for blk-mq until it is ready */ + if (q->mq_ops) { + pm_runtime_disable(dev); + return; + } + + q->dev = dev; + q->rpm_status = RPM_ACTIVE; + pm_runtime_set_autosuspend_delay(q->dev, -1); + pm_runtime_use_autosuspend(q->dev); +} +EXPORT_SYMBOL(blk_pm_runtime_init); + +/** + * blk_pre_runtime_suspend - Pre runtime suspend check + * @q: the queue of the device + * + * Description: + * This function will check if runtime suspend is allowed for the device + * by examining if there are any requests pending in the queue. If there + * are requests pending, the device can not be runtime suspended; otherwise, + * the queue's status will be updated to SUSPENDING and the driver can + * proceed to suspend the device. + * + * For the not allowed case, we mark last busy for the device so that + * runtime PM core will try to autosuspend it some time later. + * + * This function should be called near the start of the device's + * runtime_suspend callback. + * + * Return: + * 0 - OK to runtime suspend the device + * -EBUSY - Device should not be runtime suspended + */ +int blk_pre_runtime_suspend(struct request_queue *q) +{ + int ret = 0; + + if (!q->dev) + return ret; + + spin_lock_irq(q->queue_lock); + if (q->nr_pending) { + ret = -EBUSY; + pm_runtime_mark_last_busy(q->dev); + } else { + q->rpm_status = RPM_SUSPENDING; + } + spin_unlock_irq(q->queue_lock); + return ret; +} +EXPORT_SYMBOL(blk_pre_runtime_suspend); + +/** + * blk_post_runtime_suspend - Post runtime suspend processing + * @q: the queue of the device + * @err: return value of the device's runtime_suspend function + * + * Description: + * Update the queue's runtime status according to the return value of the + * device's runtime suspend function and mark last busy for the device so + * that PM core will try to auto suspend the device at a later time. + * + * This function should be called near the end of the device's + * runtime_suspend callback. + */ +void blk_post_runtime_suspend(struct request_queue *q, int err) +{ + if (!q->dev) + return; + + spin_lock_irq(q->queue_lock); + if (!err) { + q->rpm_status = RPM_SUSPENDED; + } else { + q->rpm_status = RPM_ACTIVE; + pm_runtime_mark_last_busy(q->dev); + } + spin_unlock_irq(q->queue_lock); +} +EXPORT_SYMBOL(blk_post_runtime_suspend); + +/** + * blk_pre_runtime_resume - Pre runtime resume processing + * @q: the queue of the device + * + * Description: + * Update the queue's runtime status to RESUMING in preparation for the + * runtime resume of the device. + * + * This function should be called near the start of the device's + * runtime_resume callback. + */ +void blk_pre_runtime_resume(struct request_queue *q) +{ + if (!q->dev) + return; + + spin_lock_irq(q->queue_lock); + q->rpm_status = RPM_RESUMING; + spin_unlock_irq(q->queue_lock); +} +EXPORT_SYMBOL(blk_pre_runtime_resume); + +/** + * blk_post_runtime_resume - Post runtime resume processing + * @q: the queue of the device + * @err: return value of the device's runtime_resume function + * + * Description: + * Update the queue's runtime status according to the return value of the + * device's runtime_resume function. If it is successfully resumed, process + * the requests that are queued into the device's queue when it is resuming + * and then mark last busy and initiate autosuspend for it. + * + * This function should be called near the end of the device's + * runtime_resume callback. + */ +void blk_post_runtime_resume(struct request_queue *q, int err) +{ + if (!q->dev) + return; + + spin_lock_irq(q->queue_lock); + if (!err) { + q->rpm_status = RPM_ACTIVE; + __blk_run_queue(q); + pm_runtime_mark_last_busy(q->dev); + pm_request_autosuspend(q->dev); + } else { + q->rpm_status = RPM_SUSPENDED; + } + spin_unlock_irq(q->queue_lock); +} +EXPORT_SYMBOL(blk_post_runtime_resume); + +/** + * blk_set_runtime_active - Force runtime status of the queue to be active + * @q: the queue of the device + * + * If the device is left runtime suspended during system suspend the resume + * hook typically resumes the device and corrects runtime status + * accordingly. However, that does not affect the queue runtime PM status + * which is still "suspended". This prevents processing requests from the + * queue. + * + * This function can be used in driver's resume hook to correct queue + * runtime PM status and re-enable peeking requests from the queue. It + * should be called before first request is added to the queue. + */ +void blk_set_runtime_active(struct request_queue *q) +{ + spin_lock_irq(q->queue_lock); + q->rpm_status = RPM_ACTIVE; + pm_runtime_mark_last_busy(q->dev); + pm_request_autosuspend(q->dev); + spin_unlock_irq(q->queue_lock); +} +EXPORT_SYMBOL(blk_set_runtime_active); diff --git a/block/blk-pm.h b/block/blk-pm.h new file mode 100644 index 000000000000..1ffc8ef203ec --- /dev/null +++ b/block/blk-pm.h @@ -0,0 +1,43 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _BLOCK_BLK_PM_H_ +#define _BLOCK_BLK_PM_H_ + +#include + +#ifdef CONFIG_PM +static inline void blk_pm_requeue_request(struct request *rq) +{ + if (rq->q->dev && !(rq->rq_flags & RQF_PM)) + rq->q->nr_pending--; +} + +static inline void blk_pm_add_request(struct request_queue *q, + struct request *rq) +{ + if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 && + (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING)) + pm_request_resume(q->dev); +} + +static inline void blk_pm_put_request(struct request *rq) +{ + if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending) + pm_runtime_mark_last_busy(rq->q->dev); +} +#else +static inline void blk_pm_requeue_request(struct request *rq) +{ +} + +static inline void blk_pm_add_request(struct request_queue *q, + struct request *rq) +{ +} + +static inline void blk_pm_put_request(struct request *rq) +{ +} +#endif + +#endif /* _BLOCK_BLK_PM_H_ */ diff --git a/block/elevator.c b/block/elevator.c index fa828b5bfd4b..4c15f0240c99 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -41,6 +41,7 @@ #include "blk.h" #include "blk-mq-sched.h" +#include "blk-pm.h" #include "blk-wbt.h" static DEFINE_SPINLOCK(elv_list_lock); @@ -557,27 +558,6 @@ void elv_bio_merged(struct request_queue *q, struct request *rq, e->type->ops.sq.elevator_bio_merged_fn(q, rq, bio); } -#ifdef CONFIG_PM -static void blk_pm_requeue_request(struct request *rq) -{ - if (rq->q->dev && !(rq->rq_flags & RQF_PM)) - rq->q->nr_pending--; -} - -static void blk_pm_add_request(struct request_queue *q, struct request *rq) -{ - if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 && - (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING)) - pm_request_resume(q->dev); -} -#else -static inline void blk_pm_requeue_request(struct request *rq) {} -static inline void blk_pm_add_request(struct request_queue *q, - struct request *rq) -{ -} -#endif - void elv_requeue_request(struct request_queue *q, struct request *rq) { /* diff --git a/drivers/scsi/scsi_pm.c b/drivers/scsi/scsi_pm.c index 6300e168701d..eb790b679eaf 100644 --- a/drivers/scsi/scsi_pm.c +++ b/drivers/scsi/scsi_pm.c @@ -8,6 +8,7 @@ #include #include #include +#include #include #include diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index bbebdc3769b0..69ab459abb98 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -45,6 +45,7 @@ #include #include #include +#include #include #include #include diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index 3f3cb72e0c0c..de4413e66eca 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -43,6 +43,7 @@ #include #include #include +#include #include #include #include diff --git a/include/linux/blk-pm.h b/include/linux/blk-pm.h new file mode 100644 index 000000000000..b80c65aba249 --- /dev/null +++ b/include/linux/blk-pm.h @@ -0,0 +1,24 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _BLK_PM_H_ +#define _BLK_PM_H_ + +struct device; +struct request_queue; + +/* + * block layer runtime pm functions + */ +#ifdef CONFIG_PM +extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev); +extern int blk_pre_runtime_suspend(struct request_queue *q); +extern void blk_post_runtime_suspend(struct request_queue *q, int err); +extern void blk_pre_runtime_resume(struct request_queue *q); +extern void blk_post_runtime_resume(struct request_queue *q, int err); +extern void blk_set_runtime_active(struct request_queue *q); +#else +static inline void blk_pm_runtime_init(struct request_queue *q, + struct device *dev) {} +#endif + +#endif /* _BLK_PM_H_ */ diff --git a/include/linux/blkdev.h b/include/linux/blkdev.h index 7717b71c6da3..7560c88a0fe2 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -1284,29 +1284,6 @@ struct request_queue *blk_alloc_queue_node(gfp_t gfp_mask, int node_id, extern void blk_put_queue(struct request_queue *); extern void blk_set_queue_dying(struct request_queue *); -/* - * block layer runtime pm functions - */ -#ifdef CONFIG_PM -extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev); -extern int blk_pre_runtime_suspend(struct request_queue *q); -extern void blk_post_runtime_suspend(struct request_queue *q, int err); -extern void blk_pre_runtime_resume(struct request_queue *q); -extern void blk_post_runtime_resume(struct request_queue *q, int err); -extern void blk_set_runtime_active(struct request_queue *q); -#else -static inline void blk_pm_runtime_init(struct request_queue *q, - struct device *dev) {} -static inline int blk_pre_runtime_suspend(struct request_queue *q) -{ - return -ENOSYS; -} -static inline void blk_post_runtime_suspend(struct request_queue *q, int err) {} -static inline void blk_pre_runtime_resume(struct request_queue *q) {} -static inline void blk_post_runtime_resume(struct request_queue *q, int err) {} -static inline void blk_set_runtime_active(struct request_queue *q) {} -#endif - /* * blk_plug permits building a queue of related requests by holding the I/O * fragments for a short period. This allows merging of sequential requests From patchwork Thu Aug 9 19:41:45 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561865 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B2E6113BB for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A4B6B2B979 for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 995012B982; Thu, 9 Aug 2018 19:42:17 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 1A70E2B979 for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727038AbeHIWIe (ORCPT ); Thu, 9 Aug 2018 18:08:34 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726744AbeHIWIe (ORCPT ); Thu, 9 Aug 2018 18:08:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843736; x=1565379736; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=FTGqDOhuZEzQvGNsqN5f7CD0NpBd9iVe5zVTm1gzBF4=; b=qmBkPLgcof400BQWKYAOSg1RQyRj/IL2Kdyl4UcLG8y57ei4KepJz6Nh feRljfjtqtiqmj8JHcIahsNmFEQZO+C4QjRRSsucCxOOxH04fR1oaqdsc nbuJfIaHoIHTH9YxEltagGfP8YCYuSFzU3S+yb4RnGmFe22doHM7yviKe N/ZdvkKknNRfbWLb2KYw+5WLfD/9pS1zCoNVrFNvKCxoBCkNsnbU1rDrg 85nLNYEUe3UYLPrVEnRqo8fEEamvosSYysAILJeykeoeooaw9RNE9BtAi acw/0fQn26HoT+jf3nRDMvMUicCbN4Epj3KJZhWM/R4oyKjn7rjB3gwF4 A==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119603" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:15 +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:X-MS-Exchange-SenderADCheck; bh=wI+s4MwBrSmy5NNqSWT/DtiAZ5iYPWdEiEdzNNuZvJk=; b=WJ9s0hMm0ayg2ZvFTarrSjXABmZKyBvPvexCjiwBblzyHwC4xC9w/NzU2S4+d0y+wE3DMfbNdWR5TJiFq9fqnsHLt73srjjVBLrPCIuyc3+f7LpCdjYl3zpI6j4VKptmbSnrQIcQQCih414FDoHriPi5CKFEismHUbOI63ZniUY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:09 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 08/12] block, scsi: Introduce blk_pm_runtime_exit() Date: Thu, 9 Aug 2018 12:41:45 -0700 Message-Id: <20180809194149.15285-9-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7eef31ac-c1e9-4f5e-9732-08d5fe30328d X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:rSTZHJRKdhP9Ogut2pMmnIXvzs9OcuZdD6aI5bma781SbudO4GtL9krJifyTOlyb2S6I9iMESx848lc2dmmO8hKKvyGNWkqdtPIa5gpwjdawgqgFOYvdIVJEcXXaTaZuSQnNfRaJ2NXOOB3MuVmCrQFH7MCuIPu7zFZHaeAM5h3bRqaw6cvg2ArlH9nHhsJmxjMlgPHV92YZ3cywoFLxPn3XFWyR2zmybnFPBiYzHlrk8mZ5U73TlSSzEl7BEiX9;25:wZ+dH7aijOapnSd69TijTFc6pVVuRg0k+mS/rDasGzaDWFLhYtXnwGHyo2ZlmhI+BpcmRupTQcetNAT2M/eXO/grYdGTMtpyyDU/3X1jtl8i/7uiI1Had52oHq7Nuy2ajk321AJsVt26cP08PSjUbtHOgAvke4M91s6LsbBcWNa4pMCM0HtaxkPJOpqRuG0mpKD8vl3cnHh1xUT4mKDANRdJsleZ+9kMwezKlCiQkxxvw0jJCqurjoN70cpMysOn0As45R/Jd6Yyzc0DApMPRl9LpyFESqKLc7b2MYw33eDOCAhVcznHL5vfe24KhIg/9EVVjohXTTe23W2sGMMLEw==;31:8nnMG4fx2fZzIQXdM+Et0rwchSsk6ZMDjgFPR3tv4HSbM9rH14J3YbPCWSfErMYDohlZpOxMq+97DQTwx7Ov7BQP4oPbzQSREt2E9a26d0pkK/Yj2jmuHQRedH0g28tndS7NhwWhgW/oFSz6eq2Fc4A2BH/iKC9drnoiNB3QO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test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:9d/Er6RK7+MomaD8hZ+/rybVS8bPzjNaQlQzGJg6CHyRHKRv+/d5IYL48K6sLKCYCCuPx/IhrmCmKHtvcN0EVR3pM4DfggOVq+lo1C2lNIVX1uJ57CueYLU/8Nu9HN/VRWanVWW+Jfnte9gKlpPkLz1RTHDrf0B0JctwFg01YEBUSzVRIGnVselqC//emd+HytTcuBYwePwATOjzRFIGqS9/P5i4R9iZsom2ebheenPE/IYdDPWPp9/rDNstRYcMpTjWNj7yJkWFkFtw5PnbmoSGY2GjZNz+TRWvjYNt72rof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xPY85Dp/62jO+/A1Ru4bQsaufKVwimy1MXOqPvdtQKa6TXSaa/2k9hNKn9Zngw+YU9qTGoOh3QsjcTTBbjR0e2+z9bPdv/szVdWpYrMjmdKrBRV7pjNTDQ370r7AaXiBxrjhe9x7Bx SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:x8rmQRP9kVp/zJ/eqjDtUm5DXRA/6z4G4vBV5TQidbRBM8vQmtO7FhEbRYA86IHYkvZOn2tdA82jaxcAolPhLzjkeP5/SmBfF2wfWCg+EHBUFGZg2Uaw+yiyVQKagtuIygmHTHqWeBP/eTAcRL/1Bg7MkJg2DandelIF68suaIE= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:09.8815 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7eef31ac-c1e9-4f5e-9732-08d5fe30328d X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Since it is possible to unbind a SCSI ULD and since unbinding removes the association between a request queue and struct device, the q->dev pointer has to be reset during unbind. Hence introduce a function in the block layer that clears request_queue.dev. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-pm.c | 18 ++++++++++++++++++ drivers/scsi/sd.c | 9 ++++----- drivers/scsi/sr.c | 3 ++- include/linux/blk-pm.h | 2 ++ 4 files changed, 26 insertions(+), 6 deletions(-) diff --git a/block/blk-pm.c b/block/blk-pm.c index 9b636960d285..bf8532da952d 100644 --- a/block/blk-pm.c +++ b/block/blk-pm.c @@ -40,6 +40,24 @@ void blk_pm_runtime_init(struct request_queue *q, struct device *dev) } EXPORT_SYMBOL(blk_pm_runtime_init); +/** + * blk_pm_runtime_exit - runtime PM exit routine + * @q: the queue of the device + * + * This function should be called from the device_driver.remove() callback + * function to avoid that further calls to runtime power management functions + * occur. + */ +void blk_pm_runtime_exit(struct request_queue *q) +{ + if (!q->dev) + return; + + pm_runtime_get_sync(q->dev); + q->dev = NULL; +} +EXPORT_SYMBOL(blk_pm_runtime_exit); + /** * blk_pre_runtime_suspend - Pre runtime suspend check * @q: the queue of the device diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index 69ab459abb98..5537762dfcfd 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3420,12 +3420,11 @@ static int sd_probe(struct device *dev) **/ static int sd_remove(struct device *dev) { - struct scsi_disk *sdkp; - dev_t devt; + struct scsi_disk *sdkp = dev_get_drvdata(dev); + struct scsi_device *sdp = sdkp->device; + dev_t devt = disk_devt(sdkp->disk); - sdkp = dev_get_drvdata(dev); - devt = disk_devt(sdkp->disk); - scsi_autopm_get_device(sdkp->device); + blk_pm_runtime_exit(sdp->request_queue); async_synchronize_full_domain(&scsi_sd_pm_domain); async_synchronize_full_domain(&scsi_sd_probe_domain); diff --git a/drivers/scsi/sr.c b/drivers/scsi/sr.c index de4413e66eca..476987f7ed48 100644 --- a/drivers/scsi/sr.c +++ b/drivers/scsi/sr.c @@ -1002,8 +1002,9 @@ static void sr_kref_release(struct kref *kref) static int sr_remove(struct device *dev) { struct scsi_cd *cd = dev_get_drvdata(dev); + struct scsi_device *sdev = cd->device; - scsi_autopm_get_device(cd->device); + blk_pm_runtime_exit(sdev->request_queue); del_gendisk(cd->disk); dev_set_drvdata(dev, NULL); diff --git a/include/linux/blk-pm.h b/include/linux/blk-pm.h index b80c65aba249..6d654f41acbf 100644 --- a/include/linux/blk-pm.h +++ b/include/linux/blk-pm.h @@ -11,6 +11,7 @@ struct request_queue; */ #ifdef CONFIG_PM extern void blk_pm_runtime_init(struct request_queue *q, struct device *dev); +extern void blk_pm_runtime_exit(struct request_queue *q); extern int blk_pre_runtime_suspend(struct request_queue *q); extern void blk_post_runtime_suspend(struct request_queue *q, int err); extern void blk_pre_runtime_resume(struct request_queue *q); @@ -19,6 +20,7 @@ extern void blk_set_runtime_active(struct request_queue *q); #else static inline void blk_pm_runtime_init(struct request_queue *q, struct device *dev) {} +static inline void blk_pm_runtime_exit(struct request_queue *q) {} #endif #endif /* _BLK_PM_H_ */ From patchwork Thu Aug 9 19:41:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561867 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1D37B90E3 for ; Thu, 9 Aug 2018 19:42:18 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0C97D2B979 for ; Thu, 9 Aug 2018 19:42:18 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 014762B980; Thu, 9 Aug 2018 19:42:17 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 4C4792B97F for ; Thu, 9 Aug 2018 19:42:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726744AbeHIWIe (ORCPT ); Thu, 9 Aug 2018 18:08:34 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41000 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbeHIWIe (ORCPT ); Thu, 9 Aug 2018 18:08:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843737; x=1565379737; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=4di6bzFeWiQPieZqKCg4CuU1sOsrRYNgeXmuiqIbZrk=; b=Sp0OWkbQPPam3Cfw1WV6DVWURpJfMMCyzKH+8oK7s8uQhcFbHOnUrws8 zZ682t30HFpvFrUPEaC4ypGLqqVcwdD8hLNsm2DyrYnkCbpW0rbblSBve QXeJI8lNQyTml2yFBPDwiHFBYUTFoudeQ2eN496te2V1XZhCfoiCzFbi6 HsH5l+mlkdoD1RI96uFVhsuom8bxXAlJiuhh8PetCwAtuPauOjzybK3jJ gU4dGgDriDVICmvq3agdATn84u5xRj0paBNYLKNlctsmLhuzrSErlcHYQ 7S6kZfBmJqEG4Q0xICzfjGtX7yYhv8Ki+Ok/YMCq8FKMs4qh6SeyW0Cac Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="90927377" Received: from mail-sn1nam01lp0111.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.111]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:16 +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:X-MS-Exchange-SenderADCheck; bh=qVlk2rHmOkj+F7oZZsIlCYH+uJ04c1hAUsYGtmLXZX8=; b=Vrfy3+tbqQPDXE0TpqKtrADm0u1S4o/noLjDcT8w0L1i22d3FaN9gRb/A7LHKahIRy8vcKn1MM8Jn3LFZE5nhHR5ukzEVIBn/iZOJT+xZhO+hfuwvy+tBtq0kiRN8rOXGZNhHTNm24iFo3YsvUq93dU7w1+m2Z6Apj7ZPOpYeSc= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:10 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , "Martin K . Petersen" , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 09/12] block: Split blk_pm_add_request() and blk_pm_put_request() Date: Thu, 9 Aug 2018 12:41:46 -0700 Message-Id: <20180809194149.15285-10-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 90654b71-50dc-47ea-d3ef-08d5fe3032f4 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:mC8XbuGsUl3CDOPZWw6N2DnPb29qSqM+xHZzW22nV1YIR4/bpn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2vTtsLvnbidFZa8lNlZS73YfiD7it3PpjVXqGkPz2fmeYz7ROkBbol1D3YhjR29kpgxLVqR125TFowcch181g0tpfW75jAww9BPz1H8A6dHBBbyUgOLMsRKc6voVPO/SQa/wG7wA4n5iJa2s1bZaJ7L/H5hlKOk9CjU9iT+TMMgcn75fkemUae78lE2MdYXa6bYZvu2n6Fg5QC0BYynMjKTQ7Y8hlYBgzdDSpiMuyo5vA8801JsEBNOQDxLWWKWn7bhXGGtQy1iuYM6f0KdGY8+dSQ8s0npD+AbN/3JAycWMSSSRvjf+9zW;4:F/tt/Vjj7oNPuM2NHcGH28KtsfmJXzWEJASG5qCOjQMGZxGHmBi9ozd3ZCgfYQby732O83bNoR1DLlVUpI7arls10ssG9D0KqAjaEWPMGxX3OMcDb3aKVEDarsggkGTALd2RgzOZWeGhYXSAk7LNm9qa3/vGhRI4yHXOU3IsYeFzB+bOvPKiI1HaEysUC/rxjkZ8uwPK27vnc5TfMUHoyUEHvklJTw9bjzp0zVHx56+baL9mcdjyfCJCSvAUE+p6gvj+nD0K8c4ElieZLSSa/mQhiQd3Z8VeoaETHldMvvFdWl8R0z1Hc/5j536EzDPa4HmZHeICMBECowEsGGCxcVOC5FudNGXpIec0H+XJJ/w= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:jaYu0gqzzzFjEcrNFa9Bt3O/rSkoe40KqwuETd526HAVQxq2hnkzy7biInXXdAZjxdekDjfm/eDwDu7accMWsDT19JuT0Ug2k+iqx/FVnOvr+vkN+MKfGbj4BGipWExC5mfH2chu3WYCKJSO0PQYDTAiPy4/j8nu7jmfYq/ZDpRW+d4ZspvKhrZ80YhKnqyD+J4O962Sh2VVoQYnkTrd39Oa5m9//Lm7/4f9rQCvg06FocSZYCKqcawiZQgdlq6MiS0hkgqi4N121LPZLRlOU5r3m0SLTRyQREFolhf3UkZlF3olvoFpzhXFvg+CPuYynlvu7G5qn+ERMJVF6VMTt2cYfBpJx3/9RsK4mqX/TIpuHdTFHfSw4r7rrB6dQYIAXta1E6RMoVyt5IVHYDKSqZHiJgbnezRh6cyJEI3bzk1CSFc9r1QPvHUy62wkBcOpZLnWhWb0y7Pi1T2woty/cmnHxlZrhkbFrmzpOJjZ/8ERt/qhCz4D38/WNQAUBg1rngO5DxniPj0pOfLKFsTfNtwVfkVQwrYhA5kk4ZKRNkYOL/Iric1NAI7iZYOgOldnSVp8czVsODOyvGRXQ1nSJd9OAVs1B5qv/LJG4Dnz0C1PsRQbu4OeLbv5eUMCc3o4Z9hwkghX2CF01A8y3Oz+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riginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:10.5610 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 90654b71-50dc-47ea-d3ef-08d5fe3032f4 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Move the pm_request_resume() and pm_runtime_mark_last_busy() calls into two new functions. Signed-off-by: Bart Van Assche Cc: Martin K. Petersen Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-core.c | 1 + block/blk-pm.h | 36 +++++++++++++++++++++++++++++++----- block/elevator.c | 1 + 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 3770a36e85be..59dd98585eb0 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -1774,6 +1774,7 @@ void __blk_put_request(struct request_queue *q, struct request *req) blk_req_zone_write_unlock(req); blk_pm_put_request(req); + blk_pm_mark_last_busy(req); elv_completed_request(q, req); diff --git a/block/blk-pm.h b/block/blk-pm.h index 1ffc8ef203ec..a8564ea72a41 100644 --- a/block/blk-pm.h +++ b/block/blk-pm.h @@ -6,8 +6,23 @@ #include #ifdef CONFIG_PM +static inline void blk_pm_request_resume(struct request_queue *q) +{ + if (q->dev && (q->rpm_status == RPM_SUSPENDED || + q->rpm_status == RPM_SUSPENDING)) + pm_request_resume(q->dev); +} + +static inline void blk_pm_mark_last_busy(struct request *rq) +{ + if (rq->q->dev && !(rq->rq_flags & RQF_PM)) + pm_runtime_mark_last_busy(rq->q->dev); +} + static inline void blk_pm_requeue_request(struct request *rq) { + lockdep_assert_held(rq->q->queue_lock); + if (rq->q->dev && !(rq->rq_flags & RQF_PM)) rq->q->nr_pending--; } @@ -15,17 +30,28 @@ static inline void blk_pm_requeue_request(struct request *rq) static inline void blk_pm_add_request(struct request_queue *q, struct request *rq) { - if (q->dev && !(rq->rq_flags & RQF_PM) && q->nr_pending++ == 0 && - (q->rpm_status == RPM_SUSPENDED || q->rpm_status == RPM_SUSPENDING)) - pm_request_resume(q->dev); + lockdep_assert_held(q->queue_lock); + + if (q->dev && !(rq->rq_flags & RQF_PM)) + q->nr_pending++; } static inline void blk_pm_put_request(struct request *rq) { - if (rq->q->dev && !(rq->rq_flags & RQF_PM) && !--rq->q->nr_pending) - pm_runtime_mark_last_busy(rq->q->dev); + lockdep_assert_held(rq->q->queue_lock); + + if (rq->q->dev && !(rq->rq_flags & RQF_PM)) + --rq->q->nr_pending; } #else +static inline void blk_pm_request_resume(struct request_queue *q) +{ +} + +static inline void blk_pm_mark_last_busy(struct request *rq) +{ +} + static inline void blk_pm_requeue_request(struct request *rq) { } diff --git a/block/elevator.c b/block/elevator.c index 4c15f0240c99..00c5d8dbce16 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -601,6 +601,7 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where) trace_block_rq_insert(q, rq); blk_pm_add_request(q, rq); + blk_pm_request_resume(q); rq->q = q; From patchwork Thu Aug 9 19:41:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561871 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3CEBC13BB for ; Thu, 9 Aug 2018 19:42:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2CE7A2B97D for ; Thu, 9 Aug 2018 19:42:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 20E732B982; Thu, 9 Aug 2018 19:42:19 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 A4F7B2B97D for ; Thu, 9 Aug 2018 19:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727139AbeHIWIf (ORCPT ); Thu, 9 Aug 2018 18:08:35 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbeHIWIf (ORCPT ); Thu, 9 Aug 2018 18:08:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843737; x=1565379737; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=jAomS7kEcoVvjk0cGPw7MTND4ebQT+wlPNiLqXeVgrw=; b=qWhh6PL3bOF7Bg5juHSnbWAQcfw4iUZE0I1JJA900pVrxH5GZZ+sm+3l XYKEBtJfHnUN7b/YEEvYs965PoJoziX/R0x2L8A+/1FnwJx4/w0vhJbpO pRLIUb/BHOsFm/uU2d0Ghp1F0FRpGBdm5RU3GtiwejqaJKpjpliGE5vaO ahyxk28KOIBzv4WDLJNbqEui//BaDL3Ipk6FHdDMisVGoGN3H+S4aRJLb El/5k+5pdwQYwKmk9HXdUu2d27s1bPGm4i1F/OhaALzZvie8vF4dlR0ZB nMXRyHs/gt18KHBFFhL8f+LBKwKRgFYn60APPeoBgmje1wSO+ig+AFCZP A==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119604" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:16 +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:X-MS-Exchange-SenderADCheck; bh=J8QNuA9B9rv+zLCBaC+gSIUGEUR91p435QmFrkk186Y=; b=bf2Hr1tc5eZmkFnHGVhuvqPcKar2ev/4hjGGRtjR6CcatVVRrjJZWunZzEeE7NVA1bQScP+tSbZqy3nbR0VfVifb3YywlbnD4/R9sdG1zPyOnPzoirwHM/2pfP0e29LxQtBqZycz76oag3IAd4DwLAXZ38vpQDxDwwBl8PdKgQY= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:11 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 10/12] block: Change the runtime power management approach (1/2) Date: Thu, 9 Aug 2018 12:41:47 -0700 Message-Id: <20180809194149.15285-11-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 857e5981-5f3b-4f83-0817-08d5fe30336b X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:NUUQeMsk1O5N9BhseENMLhnWzTgxU/VLnQ8ZqJ8HgQHI8Qcmb9dB3PzkelZ7cYPQxO5fxOOugLnFvQKmAWtAerw9HTzYhm5rze8Q+j+lr79XoT+2qupW+n3pix1qKWMp2QhI/YVsl2oN9kFU2LI4A7flkDC4h9snChjCChp8lRquSLkXaWVu44GNyY8DGGU/1u3qgwn8xe55omhHWS7Yzc+Cf9/D58hQpeKEGi48oE7yHl/h7ZPTVCqlAW8D/0hd;25:JAZTU1lhqddlb1kGcMeWdFP60EzBmXiuzWiOp/e2Irxw0lH1tS7rPSCBlc6OmF9T+AzEDpfFFH2qGyFhKJJTIiWVSVT5Eb9IqAYh/KgB+huXMdWDXNWFsRbR7+Jc2P8qIsfPD6gQGOJ/pMCI1wnOT3i1BYVXBXJIUs7K2qM8Jbw5RnNXpmc5zNNOGW0TrIBETnBiwoNqrZ3bXwpuXq6mArqJR4NBbNVsiATrwosJAdy4vvOxTkBSRwp/qsaI6Kw80OO9eafwEC2QbTStHtotWNTfdwa2TJiB9THtDJqOkf787haBZnKneTq8ykbIkcO59g2UP/upW5TTxeJZ8hMJ1A==;31:o7QePt/w4EH/YEui30ZWBAn3cRmZE/W6FwWNFz3Q2X6z+4XBklsb56UW0mEfmlsESeABybgBD75NczlwRUuUgsUM6T7lbmPXgzrxzU1/rtXXPvXecIvk6S5dZUcjLTRN3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UVHR0Y= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(575784001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:B7TXk0xSkqx0vxal4vwGykO006QTUl75B79MFXGjiWACjPckeb38l7lewqZoEu9//geJKpYuaAiyytKS56kqVa+x2i1NNXor4bQNqRE52FS/dO1N53lhyqx4ivibIhpCDWOIfcZrejXAjX8bbALEXstGawAd+lsnDaT3RoXEMMp+Ou/BgPLZap+0IGUcvL7dBWOb4w4VufAhzR0BceaLGfB4Yng0b8WXO3siCcNuExrJSqSsGvl/3G+OMFIMQJ3UD3Us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y6VDK5IEoPZTxbwkzEZcSwqkLlRQ1K8fDsBF6mFcr8ohuneOKVD1eTzpVPAcK2Pz+AkwTGmLlNyUgELdV/iF22qDznhwOcNVkDAufzieZTdRGZKA7eMb4VAuqu61GnVMIna2RKPFes6HjaiqzX3WQ4u74AIoBl+YZ4LdVjYf2WfJtg7EufqlQ8Cjz6irZ/8l SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:J0lycX1n/ZnH+JfQogmYWhI45Ayw2X2BDe/qWSti8cvvVtdwP7mn+O03L+23a/zuMO3raAKpj/CQBYpM6ISUZrZT3UVOKEXKxTmBVhKEOz99qaU8HgwEMtu5eJaoA9TVYbfBtdCa45S+WLFCRBQakmTx8hGvtJOwrUMk0zXmjvc= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:11.3697 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 857e5981-5f3b-4f83-0817-08d5fe30336b X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Instead of scheduling runtime resume of a request queue after a request has been queued, schedule asynchronous resume during request allocation. The new pm_request_resume() calls occur after blk_queue_enter() has increased the q_usage_counter request queue member. This change is needed for a later patch that will make request allocation block while the queue status is not RPM_ACTIVE. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-core.c | 2 ++ block/blk-mq.c | 2 ++ block/elevator.c | 1 - 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/block/blk-core.c b/block/blk-core.c index 59dd98585eb0..f30545fb2de2 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -972,6 +972,8 @@ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) if (success) return 0; + blk_pm_request_resume(q); + if (flags & BLK_MQ_REQ_NOWAIT) return -EBUSY; diff --git a/block/blk-mq.c b/block/blk-mq.c index 2a0eb058ba5a..24439735f20b 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -33,6 +33,7 @@ #include "blk-mq.h" #include "blk-mq-debugfs.h" #include "blk-mq-tag.h" +#include "blk-pm.h" #include "blk-stat.h" #include "blk-mq-sched.h" #include "blk-rq-qos.h" @@ -473,6 +474,7 @@ static void __blk_mq_free_request(struct request *rq) struct blk_mq_hw_ctx *hctx = blk_mq_map_queue(q, ctx->cpu); const int sched_tag = rq->internal_tag; + blk_pm_mark_last_busy(rq); if (rq->tag != -1) blk_mq_put_tag(hctx, hctx->tags, ctx, rq->tag); if (sched_tag != -1) diff --git a/block/elevator.c b/block/elevator.c index 00c5d8dbce16..4c15f0240c99 100644 --- a/block/elevator.c +++ b/block/elevator.c @@ -601,7 +601,6 @@ void __elv_add_request(struct request_queue *q, struct request *rq, int where) trace_block_rq_insert(q, rq); blk_pm_add_request(q, rq); - blk_pm_request_resume(q); rq->q = q; From patchwork Thu Aug 9 19:41:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561875 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 17DEA13B4 for ; Thu, 9 Aug 2018 19:42:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 06CE82B979 for ; Thu, 9 Aug 2018 19:42:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EEC6B2B97F; Thu, 9 Aug 2018 19:42:20 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 6EBFC2B979 for ; Thu, 9 Aug 2018 19:42:18 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727141AbeHIWIf (ORCPT ); Thu, 9 Aug 2018 18:08:35 -0400 Received: from esa3.hgst.iphmx.com ([216.71.153.141]:41000 "EHLO esa3.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727139AbeHIWIf (ORCPT ); Thu, 9 Aug 2018 18:08:35 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843738; x=1565379738; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=WGINhsKce1VX+PJBG+XVK6Bprksx1tcX3kRRsIWfRzM=; b=rRyQSSzl71upW9wOQRYGyyqorLYt1McFRfWUzqAFtNAfdU4vY/YI0LGH BIQvuVq4n0cVFt/8hFkMghmQrCtdTfIFKRHaDP7h2K9qkOdJh3HZGsY6W DCB1weG3rMX8uiRzmy9w/AfJK6r0SoxdilcRxmhCfae9QEDIjs5JvLU/V R1Bm1Lvf0/T5GBAyZZhzIvPaShPEBP3zMREfdzktP0fIwylGuJwQyhe6G onZpQBAjI8GaHvwVX6LRWNXY4xBTsJQSXO2DPNXb2h32PMI21hfXi1S3J D3xxgSz9Eahxjo4VVA7PHWMOKgarwho+0tR21eUhThilO+X16xokFv2N2 w==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="90927380" Received: from mail-sn1nam01lp0111.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.111]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:17 +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:X-MS-Exchange-SenderADCheck; bh=30Gm0FC2H6EtXIhKstBXcVr8j83+VOpuhB+08kwHXfg=; b=C9puPwPO36MOSX+R2LiQ0I+zuPTa24FuA3Rn9mOHv7ryYYoP7tRAhbgco/GDCg4aDPcPzLcz54q+4bOo12kvj3YWkxcU6cv5j6cr83FDIGWcRZ6U8x7k155rivSNYWGx+Wupu/J33p1HmB34np1BS4539rI3XsD2C+3GR1lqD4E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:11 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 11/12] block: Change the runtime power management approach (2/2) Date: Thu, 9 Aug 2018 12:41:48 -0700 Message-Id: <20180809194149.15285-12-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1f9544cf-5402-4ed6-01e6-08d5fe3033cc X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:nbufttFaBWzWjSBY8dZFqSz/AsaMDKZJ/KDMUTWpw12VLpjpO3vEoKDimyJmi5lGNC6VbNPKrJG/jOJeIKYruKmNIkOH75y4B1YJGSu33Id9LXwBHl/29Gy4pvwHCxaSGvikJIOguVb40TlRsxrDHsMd1wxE0pKMhqeuEdk2cXmU+DDjjXKrGMovHkU+qmtK+Hl9lDp4S2Z1yhM5bNUTocSP2AVmevL49bJ14FTCl8V+YcG6qbCw14M0VHEDgH1b;25:1kO8LHfelVqUNvGD9V6Cvm8mousY279Qkua8zIj0+5OanIs9EMYjY5NsfyOl/vkPU/vXL3JIenI/nckgJR3H329/452XowIE9bLPDWzuXNchsw7vichTH7qMJ1PUtiHO4AiTmXBSrt3uO0Cn6klqs9LYezFqnAwP1YHj36B6Xjv9fH1xg96k0kSn7EWUMEDspc0k5jhQHKvJNKRrk/VOkLyKiUVUBdW2QE6FSnUb3lsBwqfvc3m3ipahvBI0jWt7v9JXM2DwSN1IT+G8sQZrywmqtYzu/d0aQDXWMsDUcG5GVVzcUYy8pfgV0OSrW76DjZJgbLJI6TSZys/aF3QJpA==;31:HahrEkoQimp64yFsNJMBbQE+hZCMnd+K5tAhIyreQsRXhGFkEnDmPekynyirAQyHhJSjqGjOR3UlTHpsCixEv69r5WIbfj1k78ALOYTOwjCaBsQtoZg6c3gBKfaHVIInW+uOMkqUJNxwao0kPRzAu8CP4pLZiAybIErh+NhGfD9gpdd5weNVv4z431scDhC28Sq4Qyq96gb/ZRRM2/SPIMT7d+Muh9XCh6nw9cGdyWo= X-MS-TrafficTypeDiagnostic: MWHPR04MB1198: WDCIPOUTBOUND: EOP-TRUE X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:Rtr3zXd68uqtW8YLWfHuWNRlu8xAYNo4N0g2kyJODVwTupc+N/ToFxfrBivPYOaQ0p2ILtJbcKZjgB+NvjaL1JsUQ4Onx/2fLQZbWVGnNZ9ulYoLyVE9tjvTT8zwsagpckC9DtfcWNQHwO86HAq6vy3o/A+nV01ggWmhcVfqGBLZLGEyd+9W4wj+eE6Utrmjd8GgX+Bpa/08aU3gP/XRTruetmWrAt11SLklzKgk7HhoUFyooqzmcNZljD2VkW6u88FsuxqzZnNdoZmkXs+UYkqt17BgoAo88Myt2cgHjr7fQHeBM29Os/N6K6xCkHePtXh70PNZAk9FHLXFlsld8vJVhrIHz/YcndQLWnUQWnDTr5PO1NRRgpXhitJ2XRfQDHNonw7wFzNC4T/yE466DjhUj0QLDA/gmoP0roeVqs3WB5oJFOJARCay6aHpkJzy5ea0TsKv3U3U2z6ZJGsapqkLfK/LyZspMJz2uAbtUgYMZtbhV2PMVGe0C4M6Ku9k;4:NAqgjwFKPeLM78WyA0NjEu4YUsqeUfsxxld4qxQRnOUnGLQJKIVaYqnTTXiXWHqOOrRKMfL+0MaNTKezRw2P2mP8bblmIOdd2eyHRKRd2ARnUgc7PIyGgFg289NWlQUksAKLs30an+frUnM8bUL4esqQ7N3MmynHU6helX0LgU8aBt6vi8ou39eFTh/SlDOqR7SlI2GWGZCBXZWZ8iBCoS97SWxHU+biN9T/OhFWGFaqPB1p4qs58lgd+K/24eEA/CAhOAwJg/zRlAvwC/DHg+1UWjfxJpP7OReLxuVgwtZj9x2xrf8mKGKhzTTDqcWjJYITYMMigfblrSydkhDxEtyKn2t4OwY9sK6eHzh8aV8= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(966005)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(53376002)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(575784001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007)(6306002);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:2hD2eBkzvCqcGC+Z4g2T5UzkyXGl+BW2tFE6j+pzrGIBSNKCBJ1nN94me5WgTEFDRKgqxIvBwCoRB+jcXFAoDmQSI2WytebdY7vxRFMYVMYqo07FlS4vlYET94ocqP/IUorjUNQyFLfXPgYSMLGan2AbIUerAypexPz3WIvdIVbH8D5BnlIxSAw8nMiVXRQRjn1d/5ewgGK0wSXFPwbVbk9wYcntqvKhc1+zYfK/xCKgrdc5gT+ugkHr82TXk+q7eM5ZoX16EWLFnWXVoiUU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MD8eK9x7ZLWKyAWm35aWWlCpuDxQeigkBQT05NU3po+jqbanW0fA8yug5gwm6n6x8MFbVcN+pIcVGg2aCEJeLbv5PiqDiixRpFkbNFNR6vKHjlW8APp3pYRCgoT6fCViStdosHq/oj4DcMYqDlott+YQlctMltyliyxugBd7OeK0ggOMfg8fGTLq2MmDYaGCobpuT5g8sl1DDYR3z33b5oc2UFRJCh91BOiP1FKbJzWBDKrlOba SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:GGMEosi5vGYnrWsNmoey6n+yOZw2E0qSXhLl4Je/eRd0dvBNykCUyoDL00rCPEyqX4jAndh1A0VB5iRQGUZANkEu92F0faWsZauI/RIbDa+GZqUTeNzGEgO5nxFr2CtV2Dy7gxTkLR6A79lTY3sm0yF6tGLApTuXxKA6kGtjm80= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:11.9993 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1f9544cf-5402-4ed6-01e6-08d5fe3033cc X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Instead of allowing requests that are not power management requests to enter the queue in runtime suspended status (RPM_SUSPENDED), make the blk_get_request() caller block. This change fixes a starvation issue: it is now guaranteed that power management requests will be executed no matter how many blk_get_request() callers are waiting. Instead of maintaining the q->nr_pending counter, rely on q->q_usage_counter. Call pm_runtime_mark_last_busy() every time a request finishes instead of only if the queue depth drops to zero. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-core.c | 37 ++++++------------------- block/blk-pm.c | 72 ++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 75 insertions(+), 34 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index f30545fb2de2..b0bb6b5320fe 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -2772,30 +2772,6 @@ void blk_account_io_done(struct request *req, u64 now) } } -#ifdef CONFIG_PM -/* - * Don't process normal requests when queue is suspended - * or in the process of suspending/resuming - */ -static bool blk_pm_allow_request(struct request *rq) -{ - switch (rq->q->rpm_status) { - case RPM_RESUMING: - case RPM_SUSPENDING: - return rq->rq_flags & RQF_PM; - case RPM_SUSPENDED: - return false; - default: - return true; - } -} -#else -static bool blk_pm_allow_request(struct request *rq) -{ - return true; -} -#endif - void blk_account_io_start(struct request *rq, bool new_io) { struct hd_struct *part; @@ -2841,11 +2817,14 @@ static struct request *elv_next_request(struct request_queue *q) while (1) { list_for_each_entry(rq, &q->queue_head, queuelist) { - if (blk_pm_allow_request(rq)) - return rq; - - if (rq->rq_flags & RQF_SOFTBARRIER) - break; +#ifdef CONFIG_PM + /* + * If a request gets queued in state RPM_SUSPENDED + * then that's a kernel bug. + */ + WARN_ON_ONCE(q->rpm_status == RPM_SUSPENDED); +#endif + return rq; } /* diff --git a/block/blk-pm.c b/block/blk-pm.c index bf8532da952d..977beffdccd2 100644 --- a/block/blk-pm.c +++ b/block/blk-pm.c @@ -1,8 +1,11 @@ // SPDX-License-Identifier: GPL-2.0 +#include #include #include #include +#include "blk-mq.h" +#include "blk-mq-tag.h" /** * blk_pm_runtime_init - Block layer runtime PM initialization routine @@ -58,6 +61,36 @@ void blk_pm_runtime_exit(struct request_queue *q) } EXPORT_SYMBOL(blk_pm_runtime_exit); +struct in_flight_data { + struct request_queue *q; + int in_flight; +}; + +static void blk_count_in_flight(struct blk_mq_hw_ctx *hctx, struct request *rq, + void *priv, bool reserved) +{ + struct in_flight_data *in_flight = priv; + + if (rq->q == in_flight->q) + in_flight->in_flight++; +} + +/* + * Count the number of requests that are in flight for request queue @q. Use + * @q->nr_pending for legacy queues. Iterate over the tag set for blk-mq + * queues. Use blk_mq_queue_tag_busy_iter() instead of + * blk_mq_tagset_busy_iter() because the latter only considers requests that + * have already been started. + */ +static int blk_requests_in_flight(struct request_queue *q) +{ + struct in_flight_data in_flight = { .q = q }; + + if (q->mq_ops) + blk_mq_queue_tag_busy_iter(q, blk_count_in_flight, &in_flight); + return q->nr_pending + in_flight.in_flight; +} + /** * blk_pre_runtime_suspend - Pre runtime suspend check * @q: the queue of the device @@ -86,14 +119,38 @@ int blk_pre_runtime_suspend(struct request_queue *q) if (!q->dev) return ret; + WARN_ON_ONCE(q->rpm_status != RPM_ACTIVE); + + blk_set_pm_only(q); + /* + * This function only gets called if the most recent + * pm_request_resume() call occurred at least autosuspend_delay_ms + * ago. Since blk_queue_enter() is called by the request allocation + * code before pm_request_resume(), if no requests have a tag assigned + * it is safe to suspend the device. + */ + ret = -EBUSY; + if (blk_requests_in_flight(q) == 0) { + /* + * Call synchronize_rcu() such that later blk_queue_enter() + * calls see the preempt-only state. See also + * http://lwn.net/Articles/573497/. + */ + synchronize_rcu(); + if (blk_requests_in_flight(q) == 0) + ret = 0; + } + spin_lock_irq(q->queue_lock); - if (q->nr_pending) { - ret = -EBUSY; + if (ret < 0) pm_runtime_mark_last_busy(q->dev); - } else { + else q->rpm_status = RPM_SUSPENDING; - } spin_unlock_irq(q->queue_lock); + + if (ret) + blk_clear_pm_only(q); + return ret; } EXPORT_SYMBOL(blk_pre_runtime_suspend); @@ -124,6 +181,9 @@ void blk_post_runtime_suspend(struct request_queue *q, int err) pm_runtime_mark_last_busy(q->dev); } spin_unlock_irq(q->queue_lock); + + if (err) + blk_clear_pm_only(q); } EXPORT_SYMBOL(blk_post_runtime_suspend); @@ -171,13 +231,15 @@ void blk_post_runtime_resume(struct request_queue *q, int err) spin_lock_irq(q->queue_lock); if (!err) { q->rpm_status = RPM_ACTIVE; - __blk_run_queue(q); pm_runtime_mark_last_busy(q->dev); pm_request_autosuspend(q->dev); } else { q->rpm_status = RPM_SUSPENDED; } spin_unlock_irq(q->queue_lock); + + if (!err) + blk_clear_pm_only(q); } EXPORT_SYMBOL(blk_post_runtime_resume); From patchwork Thu Aug 9 19:41:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 10561873 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 61B1013BB for ; Thu, 9 Aug 2018 19:42:20 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5252B2B97D for ; Thu, 9 Aug 2018 19:42:20 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 469B72B97F; Thu, 9 Aug 2018 19:42:20 +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=-7.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI 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 308EB2B983 for ; Thu, 9 Aug 2018 19:42:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727146AbeHIWIg (ORCPT ); Thu, 9 Aug 2018 18:08:36 -0400 Received: from esa1.hgst.iphmx.com ([68.232.141.245]:1352 "EHLO esa1.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727123AbeHIWIg (ORCPT ); Thu, 9 Aug 2018 18:08:36 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=wdc.com; i=@wdc.com; q=dns/txt; s=dkim.wdc.com; t=1533843738; x=1565379738; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=HVQd5D2ZGcql0/6laoel+99luuFVPfcqfMXijqthEFY=; b=HA2yzBHyKKb+6IVR58+2DU83ybj3w4Hx5qrYKWjynPd4PESndgdKjSGM 2XM4UN/0xMpgeKqpq8fXx30X+B/Kzqq0ZHxRm6lFBIBEhkar0vH0Tl2fI 9FuYSCjQ9mNVHE21/hQgakkWPzsba88KfW0Sm4x3RdHa4UE+sfZwQsSNI wrpSTvyDVYGYIs1c2KXbT1oQgNfoSb5kvsYizJ6PGQQ5toNEQmxHqM4tJ 5J24ausYgtGNJES7iV0aXBA43ai3hc267RJa2ePEPnAHlUFoOQPmmjESb xM8dv/gZa58e7Z4TQC/wsNKBZwAHng0LWiIa5iLsBqu9A2+cAkJAJz13y Q==; X-IronPort-AV: E=Sophos;i="5.53,215,1531756800"; d="scan'208";a="191119607" Received: from mail-sn1nam01lp0115.outbound.protection.outlook.com (HELO NAM01-SN1-obe.outbound.protection.outlook.com) ([207.46.163.115]) by ob1.hgst.iphmx.com with ESMTP; 10 Aug 2018 03:42:17 +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:X-MS-Exchange-SenderADCheck; bh=YRCjT5Xvu0FwwnkxLL31tUUEilw6A1Rpa2M3qiFlREg=; b=UAyRMAc3YxV5KaWKcp1gh68mcRixzTgDy/tH0KP0anJ2SRtpu0FPwcLFuCpQTU4mmOELbAhUSSh/AZnt3rTBf7VGQNvHQ15pbSRTXf2g1fCaILwJBD9L8jZXf9fUcW6qBBZAdulbnda5znk//CcrDyWCGW94ksAe568VFgvSF2E= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Bart.VanAssche@wdc.com; Received: from asus.hsd1.ca.comcast.net (174.62.111.89) by MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.1038.23; Thu, 9 Aug 2018 19:42:12 +0000 From: Bart Van Assche To: Jens Axboe Cc: linux-block@vger.kernel.org, Christoph Hellwig , Bart Van Assche , Ming Lei , Jianchao Wang , Hannes Reinecke , Johannes Thumshirn , Alan Stern Subject: [PATCH v6 12/12] blk-mq: Enable support for runtime power management Date: Thu, 9 Aug 2018 12:41:49 -0700 Message-Id: <20180809194149.15285-13-bart.vanassche@wdc.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180809194149.15285-1-bart.vanassche@wdc.com> References: <20180809194149.15285-1-bart.vanassche@wdc.com> MIME-Version: 1.0 X-Originating-IP: [174.62.111.89] X-ClientProxiedBy: MWHPR2201CA0066.namprd22.prod.outlook.com (2603:10b6:301:5e::19) To MWHPR04MB1198.namprd04.prod.outlook.com (2603:10b6:300:71::23) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: f54f702b-f5f8-4aac-293f-08d5fe303434 X-MS-Office365-Filtering-HT: Tenant X-Microsoft-Antispam: BCL:0;PCL:0;RULEID:(7020095)(4652040)(8989117)(4534165)(4627221)(201703031133081)(201702281549075)(8990107)(5600074)(711020)(4618075)(2017052603328)(7153060)(7193020);SRVR:MWHPR04MB1198; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;3:fihPxSOfqk6OPEYm0MvzZOVGVf3IzwY76nOV/7xuqI51M03is1q0SaRaZ9QHUbw6skAzeVH7tsTa/qUzLTXQUq2oOhLaksSoHG05IEMY0RRwGVHqhpVl0EM3+JPgicugAlbLy7S6RwRheb/glyja0SrBw2+a4gJsCfNDt2g/V0bIVw2Y3u9PbReRFjUO8JAe+qLxKdQk42jid1WyWDA4tT/+mf3FBnHDYGR2UkvIiZcNVR1FAqjjidDgLCEyq84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fenX7B8kazCiWyUpH+c0zGiWj0d5ESwFNgItPvCoIx8rU/vYlU1XSqRb1B+lrKtyxgJouS6jqK2vTmv3Dk7gwFSpummrsBr5O48fNd11KVZ19TIJkDt+M9c8;4:A70Av22mJrvy+CoXBeOPdNHIjL/UTYGCGT5Hx2pN3UUC/RD3QYpGeSm6x3lsLiEoLjRiHs65R06wT+sXO6gP8IHb5XavSOelV56FTsizrxa8t5T7X00Kq4vRjldKeEN1JDEcxrsIK0xoOAz0xuvf0PX4VQaHN6s1ALgud3CMzKX+89L8OYUTn0blyfiIsPEVyV0TlmthHsIlSeYoEMLlFy2yF7Lf1OB5+voi++bMxbcKbWIPYZQEqYFkJrLeVGQ+m23Di3wQznZrEwvIbrz6nQwmMugYEL+sZkNZ66TAhzL34mlAelv8hpxMcslzDNtoe899TurT9ABes/yDOTcKhyJUoUvF5mglii4PIOq3myY= X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(35762410373642)(146099531331640); X-MS-Exchange-SenderADCheck: 1 X-Exchange-Antispam-Report-CFA-Test: BCL:0;PCL:0;RULEID:(6040522)(2401047)(8121501046)(5005006)(93006095)(93001095)(3231311)(944501410)(52105095)(3002001)(10201501046)(6055026)(149027)(150027)(6041310)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123558120)(20161123564045)(20161123560045)(6072148)(201708071742011)(7699016);SRVR:MWHPR04MB1198;BCL:0;PCL:0;RULEID:;SRVR:MWHPR04MB1198; X-Forefront-PRVS: 0759F7A50A X-Forefront-Antispam-Report: SFV:NSPM;SFS:(10019020)(396003)(39860400002)(136003)(366004)(346002)(376002)(199004)(189003)(76176011)(50466002)(476003)(51416003)(4326008)(478600001)(52116002)(6486002)(105586002)(72206003)(48376002)(5660300001)(47776003)(305945005)(2616005)(956004)(7736002)(6916009)(6666003)(486006)(8936002)(2906002)(68736007)(36756003)(66066001)(186003)(446003)(81166006)(50226002)(8676002)(81156014)(316002)(6506007)(386003)(106356001)(97736004)(25786009)(11346002)(16586007)(54906003)(14444005)(6116002)(1076002)(3846002)(86362001)(26005)(16526019)(53936002)(6512007);DIR:OUT;SFP:1102;SCL:1;SRVR:MWHPR04MB1198;H:asus.hsd1.ca.comcast.net;FPR:;SPF:None;LANG:en;PTR:InfoNoRecords;A:1;MX:1; X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;23:TfT3rhA/Eo7F/M8wUZ+kcUYY99gIM80P3offlG/wuytAepDpD4eKMNVYInqQsHipMJwtTHHVps45G5fv5OjYh/GI3/n2w9c5CDvYk83ImMM/Z6lXqXjYWq9njobrYWyAqp3hxIBQnHoX/Z2Dl/niCxMeLB0ijQPptOFFvLcnmFXB8OFOFPQwKCYYw2esRibW8oWHkFpZ1arldklnYSsw1W/spcr6Cv+knktcbmjX4ZN/SVLXJqF0z9ADgzCQhVOVHgfyYD4gq5XqWuNxqW00dBa7XI4DQ5W6rpr70hcI/GWebt6XGyN0tTVqHJ4n86lR7iiq39EsAR0n09eFG1gTQ0jrCN2VN6SbK+cIEUseUgVnC+Cf0a/XBfB0Wj1Ks3u77gpMjYR9Oyk9v0IIbWCIITlkrO42FudQi2c/PnquNAz4QgfaaBOHlUz/Z5mXtbFP16m6yGuGUVdJYSGCR+ODg2AC+G/tGZtH39padLXDH26t7O5DZL1uWgJNlv3Lthq/kO466RG918AFV21UI9+voY1REw0/Wk8YU4YOla81f7COdoSS5g5r24MXhmE/zWMaFvMtRG0wOcmbVJGsA0my61razblcdV3uGFPrYiv/k5r8nYL+6zRbY4O/10PUL+dz4C/5kfNDpiwHU8XLN/2CRW7I/dlYzGfP9ZYpikPbhDxvMoxsODguZmX/6KWT6mbKdFPJkvnHyikRbKXJszszBglnuL+Y9Nwp/lMPdGdboawBjtvMMXrqoZ3JVvbu7ixKSuKdm66QZV0OTDM4CSPIYFFsDiFscSLV+sRFTD2kyogEIf00LX3HtOTEDqKm7H6+dT4N1ef7sMuZzCBzYVwvw5TaGx7BXiyibsX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N19gejbQ2/woFQcfLlMXPFKQY2YahcxG7kpFIbDjNBnJMPQTZ5IUmgx/zbqx2AWfShk1gydTtMeU+1p42sQm9Wq8EkRNY9FGaVZrxQbqOaibq41Tue3IL0W1ae92ewXD0q/Bbl9U1Wb5IhWT2bWtkv9Dao+3HRJrQYtptlHWkQ/rr2cQ31L8NZY42w1rI3Ju0MvMQ==;5:T8sVctdY3E4O4xSpbPlqzBCQneHjEsIQXwm95iv7wNTFBp6fwGaA+ikpwnA19u4w8r8g2o6yklW4+Bn5rk1b+nTHMbVE1JCYmruCAmKZHH4gAywgiVBM1kse750ngxwMIVQwl34RXEAhjzCq/8Mw44p88uflc8vQGztM4HzYixQ=;7:b/foXiQXTf7QGH/xarRVWZq/j2U/BG/ubB+JupH8O4g5T09y1ctCRZEqxNueiZT8TZ7PKj2aseh2HfhF/FxgKqanOYyK5RtLeTRM62J9ahsGawo8DNpkaRX3Dn/lKr0ztmif84Jf4ZH7fb58Twcyq0bUIgpMJD5xSX9Wwnf5vi3+cSRTxLt1lwYHAgFmR19reKHWyj2HNeGQnxEpq9L617BUVuWzLiZqIohEZJ90H7ytF9kGBVSrVkDnM4dgiAOM SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1;MWHPR04MB1198;20:a38tRx4yzKrPh1Y5jy/7wx7IihKAOXmzwsHV0ku2PFbST4V2WbhAwhBhIpClyhAq9jYzMchrSBrUXnpPMrTNcAS3FCih0AP8F0DwO6cHBtV8lTneSkGn3axxRzKuAL/A14x0zeyYXf/PqahX1AXgkeiTxWwjFxee1MYPkqKSRXw= X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Aug 2018 19:42:12.6879 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: f54f702b-f5f8-4aac-293f-08d5fe303434 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR04MB1198 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 Now that the blk-mq core processes power management requests (marked with RQF_PREEMPT) in other states than RPM_ACTIVE, enable runtime power management for blk-mq. Signed-off-by: Bart Van Assche Cc: Christoph Hellwig Cc: Ming Lei Cc: Jianchao Wang Cc: Hannes Reinecke Cc: Johannes Thumshirn Cc: Alan Stern --- block/blk-pm.c | 6 ------ 1 file changed, 6 deletions(-) diff --git a/block/blk-pm.c b/block/blk-pm.c index 977beffdccd2..e76d85dcdd67 100644 --- a/block/blk-pm.c +++ b/block/blk-pm.c @@ -30,12 +30,6 @@ */ void blk_pm_runtime_init(struct request_queue *q, struct device *dev) { - /* Don't enable runtime PM for blk-mq until it is ready */ - if (q->mq_ops) { - pm_runtime_disable(dev); - return; - } - q->dev = dev; q->rpm_status = RPM_ACTIVE; pm_runtime_set_autosuspend_delay(q->dev, -1);