From patchwork Mon Nov 23 03:17:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 330914 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3D924C6379D for ; Mon, 23 Nov 2020 03:18:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 136E821D40 for ; Mon, 23 Nov 2020 03:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727901AbgKWDSA (ORCPT ); Sun, 22 Nov 2020 22:18:00 -0500 Received: from mail-pf1-f193.google.com ([209.85.210.193]:44560 "EHLO mail-pf1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727911AbgKWDSA (ORCPT ); Sun, 22 Nov 2020 22:18:00 -0500 Received: by mail-pf1-f193.google.com with SMTP id y7so13570163pfq.11; Sun, 22 Nov 2020 19:17:59 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=NS2/LWJgfKnaWgsdnGvEKSQ6HreXoy5m6pflViridOg=; b=mPLpC1/5vBOjn4dQmMC00QMR9G5ANFc9SvPtKAMRxq4vabnmIT0Bg50aCHxsm6cFGz 1F7Jya1T0zDAhYizm5mOwx2C1fTHpfqMf6YG91L+dq3JeXwTaijWuix2tQACyBpjFKiq YfFWyubTVa/A2ODv7Z6OdgK9Vc13CMxC5L5gjbDoLCovvNMfzGNQpHWRBzPe0QyogtKQ rZkFITJPJVPlmZGaD0dHtoOJcu/VnzFE9nrMivUEl5E3EOJCKw+jYShkrQ4uJB+Hruzk +isW2RRT+lEzKFvvmajJnT3ORAtHVsdO/GIe3C8hr5fJ8eYJF3sPKDSynL+SNLfmiDmc Sfbg== X-Gm-Message-State: AOAM531pB12p49HqzRZvdRIEx1jT6cr/75WzIGF5lZZ3mKbiMwht+G8o Ja0l5eppQ7DMoznHvkrWneE= X-Google-Smtp-Source: ABdhPJzrjluYfs7/aZf3abR/AZ1d+Cy6V5LXlpx5SjvPdL7rra3+1TiI3+YBdyWDqYgU0bC9zGkMkw== X-Received: by 2002:a65:679a:: with SMTP id e26mr6737241pgr.394.1606101478901; Sun, 22 Nov 2020 19:17:58 -0800 (PST) Received: from asus.hsd1.ca.comcast.net (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id w12sm3578751pfn.136.2020.11.22.19.17.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2020 19:17:58 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jens Axboe , Christoph Hellwig , Ming Lei , linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Bart Van Assche , Alan Stern , Stanley Chu , "Rafael J . Wysocki" , stable , Can Guo Subject: [PATCH v3 1/9] block: Fix a race in the runtime power management code Date: Sun, 22 Nov 2020 19:17:41 -0800 Message-Id: <20201123031749.14912-2-bvanassche@acm.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123031749.14912-1-bvanassche@acm.org> References: <20201123031749.14912-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org With the current implementation the following race can happen: * blk_pre_runtime_suspend() calls blk_freeze_queue_start() and blk_mq_unfreeze_queue(). * blk_queue_enter() calls blk_queue_pm_only() and that function returns true. * blk_queue_enter() calls blk_pm_request_resume() and that function does not call pm_request_resume() because the queue runtime status is RPM_ACTIVE. * blk_pre_runtime_suspend() changes the queue status into RPM_SUSPENDING. Fix this race by changing the queue runtime status into RPM_SUSPENDING before switching q_usage_counter to atomic mode. Acked-by: Alan Stern Acked-by: Stanley Chu Reviewed-by: Christoph Hellwig Cc: Ming Lei Cc: Rafael J. Wysocki Cc: stable Fixes: 986d413b7c15 ("blk-mq: Enable support for runtime power management") Signed-off-by: Can Guo Signed-off-by: Bart Van Assche --- block/blk-pm.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/block/blk-pm.c b/block/blk-pm.c index b85234d758f7..17bd020268d4 100644 --- a/block/blk-pm.c +++ b/block/blk-pm.c @@ -67,6 +67,10 @@ int blk_pre_runtime_suspend(struct request_queue *q) WARN_ON_ONCE(q->rpm_status != RPM_ACTIVE); + spin_lock_irq(&q->queue_lock); + q->rpm_status = RPM_SUSPENDING; + spin_unlock_irq(&q->queue_lock); + /* * Increase the pm_only counter before checking whether any * non-PM blk_queue_enter() calls are in progress to avoid that any @@ -89,15 +93,14 @@ int blk_pre_runtime_suspend(struct request_queue *q) /* Switch q_usage_counter back to per-cpu mode. */ blk_mq_unfreeze_queue(q); - spin_lock_irq(&q->queue_lock); - if (ret < 0) + if (ret < 0) { + spin_lock_irq(&q->queue_lock); + q->rpm_status = RPM_ACTIVE; pm_runtime_mark_last_busy(q->dev); - else - q->rpm_status = RPM_SUSPENDING; - spin_unlock_irq(&q->queue_lock); + spin_unlock_irq(&q->queue_lock); - if (ret) blk_clear_pm_only(q); + } return ret; } From patchwork Mon Nov 23 03:17:42 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 330913 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7AA15C64E7A for ; Mon, 23 Nov 2020 03:18:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5AECD21973 for ; Mon, 23 Nov 2020 03:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727957AbgKWDSC (ORCPT ); Sun, 22 Nov 2020 22:18:02 -0500 Received: from mail-pf1-f196.google.com ([209.85.210.196]:42831 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727924AbgKWDSC (ORCPT ); Sun, 22 Nov 2020 22:18:02 -0500 Received: by mail-pf1-f196.google.com with SMTP id 131so13584346pfb.9; Sun, 22 Nov 2020 19:18:01 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=bOfYmfsf36OR7FSqOTiU9QwdQh/3+RIr0zxLiRH6Y84=; b=HFhIDE8IdNVBbhncY7jufVV5Iv/9jjIGMpkMlBry/CxByZAa/Fgz2p1iJNleO54zod 2pLlegdfQTN+0Si3OCaYVjsdfXedCkY2VTbEtOYC2r7XRSBLN9jDNpZXfcASh9rcuMdA 7ZzxiY9AXYxJ9tQN/Uv4hdoxSzq9Eyu6GAJWcxZnKUPE9F39MZFmxqecmTQo+A7O2Vxx GEjW1PougkEhNmbi/45Ty9eLgEa1c0E0h4jHA1RnWwY9CdKIBA4g8iIYi9+zHojncOkc FK0Uu+9V4v62u8XR1BaodCZJzhDogdfBlGmlaYHDhr110Vb6aq7fBVFHj/xM32O6LT92 7rjg== X-Gm-Message-State: AOAM530/ZJIBJsgxFSE0uSAJHFlMhNEmmr8fYPT2WybGmY0mvJ/h/uLe CwxUWDW53oaFr/g+O6KDHJE= X-Google-Smtp-Source: ABdhPJytLEqSaxApi7/AIt3WBo4glghWDB7ywozCAVbkVFuvqHi1hYUUGhS6vlb6E4loPYtaIg/D4w== X-Received: by 2002:a62:7e14:0:b029:18a:d515:dc47 with SMTP id z20-20020a627e140000b029018ad515dc47mr24461696pfc.78.1606101481169; Sun, 22 Nov 2020 19:18:01 -0800 (PST) Received: from asus.hsd1.ca.comcast.net (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id w12sm3578751pfn.136.2020.11.22.19.17.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2020 19:18:00 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jens Axboe , Christoph Hellwig , Ming Lei , linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Bart Van Assche , "David S . Miller" , Alan Stern , Can Guo , Stanley Chu , "Rafael J . Wysocki" Subject: [PATCH v3 2/9] ide: Do not set the RQF_PREEMPT flag for sense requests Date: Sun, 22 Nov 2020 19:17:42 -0800 Message-Id: <20201123031749.14912-3-bvanassche@acm.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123031749.14912-1-bvanassche@acm.org> References: <20201123031749.14912-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org RQF_PREEMPT is used for two different purposes in the legacy IDE code: 1. To mark power management requests. 2. To mark requests that should preempt another request. An (old) explanation of that feature is as follows: "The IDE driver in the Linux kernel normally uses a series of busywait delays during its initialization. When the driver executes these busywaits, the kernel does nothing for the duration of the wait. The time spent in these waits could be used for other initialization activities, if they could be run concurrently with these waits. More specifically, busywait-style delays such as udelay() in module init functions inhibit kernel preemption because the Big Kernel Lock is held, while yielding APIs such as schedule_timeout() allow preemption. This is true because the kernel handles the BKL specially and releases and reacquires it across reschedules allowed by the current thread. This IDE-preempt specification requires that the driver eliminate these busywaits and replace them with a mechanism that allows other work to proceed while the IDE driver is initializing." Since I haven't found an implementation of (2), do not set the PREEMPT flag for sense requests. This patch causes sense requests to be postponed while a drive is suspended instead of being submitted to ide_queue_rq(). If it would ever be necessary to restore the IDE PREEMPT functionality, that can be done by introducing a new flag in struct ide_request. This patch is a first step towards removing the PREEMPT flag from the block layer. Reviewed-by: Christoph Hellwig Cc: David S. Miller Cc: Alan Stern Cc: Can Guo Cc: Stanley Chu Cc: Ming Lei Cc: Rafael J. Wysocki Signed-off-by: Bart Van Assche Reviewed-by: Hannes Reinecke --- drivers/ide/ide-atapi.c | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/ide/ide-atapi.c b/drivers/ide/ide-atapi.c index 2162bc80f09e..013ad33fbbc8 100644 --- a/drivers/ide/ide-atapi.c +++ b/drivers/ide/ide-atapi.c @@ -223,7 +223,6 @@ void ide_prep_sense(ide_drive_t *drive, struct request *rq) sense_rq->rq_disk = rq->rq_disk; sense_rq->cmd_flags = REQ_OP_DRV_IN; ide_req(sense_rq)->type = ATA_PRIV_SENSE; - sense_rq->rq_flags |= RQF_PREEMPT; req->cmd[0] = GPCMD_REQUEST_SENSE; req->cmd[4] = cmd_len; From patchwork Mon Nov 23 03:17:45 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 330912 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3392EC64E8A for ; Mon, 23 Nov 2020 03:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 00C5B212CC for ; Mon, 23 Nov 2020 03:18:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728025AbgKWDSJ (ORCPT ); Sun, 22 Nov 2020 22:18:09 -0500 Received: from mail-pg1-f195.google.com ([209.85.215.195]:42185 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728014AbgKWDSI (ORCPT ); Sun, 22 Nov 2020 22:18:08 -0500 Received: by mail-pg1-f195.google.com with SMTP id w16so569661pga.9; Sun, 22 Nov 2020 19:18:07 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=FmQMTp0lq+P9F4DPfJwhzTIRpyhMssjxK7MCOpsx9a8=; b=Vggof01lu+w+NBOqzpLjm2Va5k0Hzrdyi2OVy4de/yKGAUSgRaUfSnwM9TXPpvXauL c8KdvUldVraibIjsb9S0NrVB2LyAmrSo0I21AB5FMFCAiUeuBr+FSsc5Oy0uVSRcuY2d 871jt/0F5xZzgGi+Bupox9S1bYPO9s4Z204+gDXQz5MzKhGKQ0KByNZDyoM1m5fkMbH+ rO7mrzEoOakfW5rxzsGdJlwhZl0S41sRbTBZfsv5bEhxP1F5f9YZuI9z/aUferEuYP4m B2nJ1+FuGI+9ts0nt/B4NvCCQLQnpkmmmB2kKIOu4qPCQoAJMf9cncwvWeWmfunRbiE4 scbg== X-Gm-Message-State: AOAM531QYbvI0J/75DvCK5DpigSSZmsq0nVXjPIud/wutxkfV5L/NNd9 fVPtRodB6uXCj5HB6Y4uugY= X-Google-Smtp-Source: ABdhPJzPP5qUavAY0EVdsr2dCB6LzwQHaQkCad0S4ONr4WSZR5pSiYECWKATB+yYuqSRK9IBkqeKaQ== X-Received: by 2002:aa7:86c9:0:b029:18b:b0c:53e5 with SMTP id h9-20020aa786c90000b029018b0b0c53e5mr23183332pfo.57.1606101487376; Sun, 22 Nov 2020 19:18:07 -0800 (PST) Received: from asus.hsd1.ca.comcast.net (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id w12sm3578751pfn.136.2020.11.22.19.18.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2020 19:18:06 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jens Axboe , Christoph Hellwig , Ming Lei , linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Bart Van Assche , Alan Stern , Can Guo , Stanley Chu , "Rafael J . Wysocki" Subject: [PATCH v3 5/9] scsi: Do not wait for a request in scsi_eh_lock_door() Date: Sun, 22 Nov 2020 19:17:45 -0800 Message-Id: <20201123031749.14912-6-bvanassche@acm.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123031749.14912-1-bvanassche@acm.org> References: <20201123031749.14912-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org scsi_eh_lock_door() is the only function in the SCSI error handler that calls blk_get_request(). It is not guaranteed that a request is available when scsi_eh_lock_door() is called. Hence pass the BLK_MQ_REQ_NOWAIT flag to blk_get_request(). This patch has a second purpose, namely preventing that scsi_eh_lock_door() deadlocks if sdev->request_queue is frozen and if a SCSI command is submitted to a SCSI device through a second request queue that has not been frozen. A later patch will namely modify the SPI DV code such that sdev->requeust_queue is frozen during domain validation. Reviewed-by: Alan Stern Reviewed-by: Christoph Hellwig Cc: Can Guo Cc: Stanley Chu Cc: Ming Lei Cc: Rafael J. Wysocki Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_error.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/scsi_error.c b/drivers/scsi/scsi_error.c index d94449188270..6de6e1bf3dcb 100644 --- a/drivers/scsi/scsi_error.c +++ b/drivers/scsi/scsi_error.c @@ -1993,7 +1993,12 @@ static void scsi_eh_lock_door(struct scsi_device *sdev) struct request *req; struct scsi_request *rq; - req = blk_get_request(sdev->request_queue, REQ_OP_SCSI_IN, 0); + /* + * It is not guaranteed that a request is available nor that + * sdev->request_queue is unfrozen. Hence the BLK_MQ_REQ_NOWAIT below. + */ + req = blk_get_request(sdev->request_queue, REQ_OP_SCSI_IN, + BLK_MQ_REQ_NOWAIT); if (IS_ERR(req)) return; rq = scsi_req(req); From patchwork Mon Nov 23 03:17:46 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 330911 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id AEB12C8300B for ; Mon, 23 Nov 2020 03:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 95B072137B for ; Mon, 23 Nov 2020 03:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728034AbgKWDSL (ORCPT ); Sun, 22 Nov 2020 22:18:11 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40991 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727966AbgKWDSK (ORCPT ); Sun, 22 Nov 2020 22:18:10 -0500 Received: by mail-pf1-f195.google.com with SMTP id t8so13578410pfg.8; Sun, 22 Nov 2020 19:18:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=I5c97BL1YfxE2D+K6Xbn5+xM72eGvrFC/eqxzFt88C8=; b=AO1A3q3Z+W/2oRs3LA2WXyjflMgvyINbZtlmIBJI4XYa4gHgiZZt/4GlMgPHR1kFAa f/bSHlbuw9XPJBogS3/uGioIcysms2Wtc5K2GiJlUUPWz14IDSxMeBFV7QJTGU71WUk3 RVaCCqD4wvYJK1VUUHTZSwFuLinTsuROo50lsy4YVLZr9x+LRPMy9TRqv1Ith9NKuubl w/qn52sZiWM+Oj+TaR9aiWVFgJ5EQki0PvS7AVxmuzlfGAqQBkcqbTP0rtOO1+vmDwlx j1R0wejxx6jK3P3KvzMZw4sObyiKRXQGMMNSZXU+vU0fWp9iCpe0rEeTOv4e3uCEhGvu LkZA== X-Gm-Message-State: AOAM530Gc89ZDfPo9suYmAADW9fQ+ED5Czv7G3Li+wJOdORtfPyJufgb S25nN2KIKN2UbihxdtcBsyU= X-Google-Smtp-Source: ABdhPJw+F4lLe1kxm6I2PpKyxgD5+PzXRCv9gCg4NwRWXvVG/5XbhomIGos+P6jBAyIkRRswK249jw== X-Received: by 2002:a17:90a:fed:: with SMTP id 100mr23683549pjz.65.1606101489682; Sun, 22 Nov 2020 19:18:09 -0800 (PST) Received: from asus.hsd1.ca.comcast.net (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id w12sm3578751pfn.136.2020.11.22.19.18.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2020 19:18:08 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jens Axboe , Christoph Hellwig , Ming Lei , linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Bart Van Assche , Alan Stern , James Bottomley , Woody Suwalski , Can Guo , Stanley Chu , "Rafael J . Wysocki" , Stan Johnson Subject: [PATCH v3 6/9] scsi_transport_spi: Make spi_execute() accept a request queue pointer Date: Sun, 22 Nov 2020 19:17:46 -0800 Message-Id: <20201123031749.14912-7-bvanassche@acm.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123031749.14912-1-bvanassche@acm.org> References: <20201123031749.14912-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Passing a request queue pointer to spi_execute() instead of a SCSI device pointer will allow a later patch to associate two request queues with a SCSI device. Additionally, instead of assuming that the device state is SDEV_QUIESCE before domain validation starts, read the device state. This patch does not change any functionality but makes a later patch easier to read. Reviewed-by: Alan Stern Reviewed-by: Christoph Hellwig Cc: James Bottomley Cc: Woody Suwalski Cc: Can Guo Cc: Stanley Chu Cc: Ming Lei Cc: Rafael J. Wysocki Tested-by: Stan Johnson Signed-off-by: Bart Van Assche --- drivers/scsi/scsi_transport_spi.c | 69 ++++++++++++++++--------------- 1 file changed, 36 insertions(+), 33 deletions(-) diff --git a/drivers/scsi/scsi_transport_spi.c b/drivers/scsi/scsi_transport_spi.c index f3d5b1bbd5aa..959990f66865 100644 --- a/drivers/scsi/scsi_transport_spi.c +++ b/drivers/scsi/scsi_transport_spi.c @@ -104,7 +104,7 @@ static int sprint_frac(char *dest, int value, int denom) return result; } -static int spi_execute(struct scsi_device *sdev, const void *cmd, +static int spi_execute(struct request_queue *q, const void *cmd, enum dma_data_direction dir, void *buffer, unsigned bufflen, struct scsi_sense_hdr *sshdr) @@ -117,7 +117,7 @@ static int spi_execute(struct scsi_device *sdev, const void *cmd, sshdr = &sshdr_tmp; for(i = 0; i < DV_RETRIES; i++) { - result = scsi_execute(sdev, cmd, dir, buffer, bufflen, sense, + result = __scsi_execute(q, cmd, dir, buffer, bufflen, sense, sshdr, DV_TIMEOUT, /* retries */ 1, REQ_FAILFAST_DEV | REQ_FAILFAST_TRANSPORT | @@ -620,13 +620,14 @@ enum spi_compare_returns { /* This is for read/write Domain Validation: If the device supports * an echo buffer, we do read/write tests to it */ static enum spi_compare_returns -spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, - u8 *ptr, const int retries) +spi_dv_device_echo_buffer(struct scsi_device *sdev, struct request_queue *q, + u8 *buffer, u8 *ptr, const int retries) { int len = ptr - buffer; int j, k, r, result; unsigned int pattern = 0x0000ffff; struct scsi_sense_hdr sshdr; + enum scsi_device_state sdev_state = sdev->sdev_state; const char spi_write_buffer[] = { WRITE_BUFFER, 0x0a, 0, 0, 0, 0, 0, len >> 8, len & 0xff, 0 @@ -671,11 +672,10 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, } for (r = 0; r < retries; r++) { - result = spi_execute(sdev, spi_write_buffer, DMA_TO_DEVICE, + result = spi_execute(q, spi_write_buffer, DMA_TO_DEVICE, buffer, len, &sshdr); if(result || !scsi_device_online(sdev)) { - - scsi_device_set_state(sdev, SDEV_QUIESCE); + scsi_device_set_state(sdev, sdev_state); if (scsi_sense_valid(&sshdr) && sshdr.sense_key == ILLEGAL_REQUEST /* INVALID FIELD IN CDB */ @@ -693,9 +693,9 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, } memset(ptr, 0, len); - spi_execute(sdev, spi_read_buffer, DMA_FROM_DEVICE, - ptr, len, NULL); - scsi_device_set_state(sdev, SDEV_QUIESCE); + spi_execute(q, spi_read_buffer, DMA_FROM_DEVICE, ptr, len, + NULL); + scsi_device_set_state(sdev, sdev_state); if (memcmp(buffer, ptr, len) != 0) return SPI_COMPARE_FAILURE; @@ -706,11 +706,12 @@ spi_dv_device_echo_buffer(struct scsi_device *sdev, u8 *buffer, /* This is for the simplest form of Domain Validation: a read test * on the inquiry data from the device */ static enum spi_compare_returns -spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer, - u8 *ptr, const int retries) +spi_dv_device_compare_inquiry(struct scsi_device *sdev, struct request_queue *q, + u8 *buffer, u8 *ptr, const int retries) { int r, result; const int len = sdev->inquiry_len; + enum scsi_device_state sdev_state = sdev->sdev_state; const char spi_inquiry[] = { INQUIRY, 0, 0, 0, len, 0 }; @@ -718,11 +719,11 @@ spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer, for (r = 0; r < retries; r++) { memset(ptr, 0, len); - result = spi_execute(sdev, spi_inquiry, DMA_FROM_DEVICE, - ptr, len, NULL); + result = spi_execute(q, spi_inquiry, DMA_FROM_DEVICE, ptr, len, + NULL); if(result || !scsi_device_online(sdev)) { - scsi_device_set_state(sdev, SDEV_QUIESCE); + scsi_device_set_state(sdev, sdev_state); return SPI_COMPARE_FAILURE; } @@ -742,9 +743,10 @@ spi_dv_device_compare_inquiry(struct scsi_device *sdev, u8 *buffer, } static enum spi_compare_returns -spi_dv_retrain(struct scsi_device *sdev, u8 *buffer, u8 *ptr, - enum spi_compare_returns - (*compare_fn)(struct scsi_device *, u8 *, u8 *, int)) +spi_dv_retrain(struct scsi_device *sdev, struct request_queue *q, u8 *buffer, + u8 *ptr, enum spi_compare_returns + (*compare_fn)(struct scsi_device *, struct request_queue *, + u8 *, u8 *, int)) { struct spi_internal *i = to_spi_internal(sdev->host->transportt); struct scsi_target *starget = sdev->sdev_target; @@ -754,7 +756,7 @@ spi_dv_retrain(struct scsi_device *sdev, u8 *buffer, u8 *ptr, for (;;) { int newperiod; - retval = compare_fn(sdev, buffer, ptr, DV_LOOPS); + retval = compare_fn(sdev, q, buffer, ptr, DV_LOOPS); if (retval == SPI_COMPARE_SUCCESS || retval == SPI_COMPARE_SKIP_TEST) @@ -800,7 +802,8 @@ spi_dv_retrain(struct scsi_device *sdev, u8 *buffer, u8 *ptr, } static int -spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer) +spi_dv_device_get_echo_buffer(struct scsi_device *sdev, + struct request_queue *q, u8 *buffer) { int l, result; @@ -824,8 +827,8 @@ spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer) * (reservation conflict, device not ready, etc) just * skip the write tests */ for (l = 0; ; l++) { - result = spi_execute(sdev, spi_test_unit_ready, DMA_NONE, - NULL, 0, NULL); + result = spi_execute(q, spi_test_unit_ready, DMA_NONE, NULL, 0, + NULL); if(result) { if(l >= 3) @@ -836,8 +839,8 @@ spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer) } } - result = spi_execute(sdev, spi_read_buffer_descriptor, - DMA_FROM_DEVICE, buffer, 4, NULL); + result = spi_execute(q, spi_read_buffer_descriptor, DMA_FROM_DEVICE, + buffer, 4, NULL); if (result) /* Device has no echo buffer */ @@ -847,7 +850,8 @@ spi_dv_device_get_echo_buffer(struct scsi_device *sdev, u8 *buffer) } static void -spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) +spi_dv_device_internal(struct scsi_device *sdev, struct request_queue *q, + u8 *buffer) { struct spi_internal *i = to_spi_internal(sdev->host->transportt); struct scsi_target *starget = sdev->sdev_target; @@ -859,7 +863,7 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) DV_SET(offset, 0); DV_SET(width, 0); - if (spi_dv_device_compare_inquiry(sdev, buffer, buffer, DV_LOOPS) + if (spi_dv_device_compare_inquiry(sdev, q, buffer, buffer, DV_LOOPS) != SPI_COMPARE_SUCCESS) { starget_printk(KERN_ERR, starget, "Domain Validation Initial Inquiry Failed\n"); /* FIXME: should probably offline the device here? */ @@ -875,9 +879,8 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) if (i->f->set_width && max_width) { i->f->set_width(starget, 1); - if (spi_dv_device_compare_inquiry(sdev, buffer, - buffer + len, - DV_LOOPS) + if (spi_dv_device_compare_inquiry(sdev, q, buffer, buffer + len, + DV_LOOPS) != SPI_COMPARE_SUCCESS) { starget_printk(KERN_ERR, starget, "Wide Transfers Fail\n"); i->f->set_width(starget, 0); @@ -946,7 +949,7 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) DV_SET(width, max_width); /* Do the read only INQUIRY tests */ - spi_dv_retrain(sdev, buffer, buffer + sdev->inquiry_len, + spi_dv_retrain(sdev, q, buffer, buffer + sdev->inquiry_len, spi_dv_device_compare_inquiry); /* See if we actually managed to negotiate and sustain DT */ if (i->f->get_dt) @@ -958,7 +961,7 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) * negotiated DT */ if (len == -1 && spi_dt(starget)) - len = spi_dv_device_get_echo_buffer(sdev, buffer); + len = spi_dv_device_get_echo_buffer(sdev, q, buffer); if (len <= 0) { starget_printk(KERN_INFO, starget, "Domain Validation skipping write tests\n"); @@ -970,7 +973,7 @@ spi_dv_device_internal(struct scsi_device *sdev, u8 *buffer) len = SPI_MAX_ECHO_BUFFER_SIZE; } - if (spi_dv_retrain(sdev, buffer, buffer + len, + if (spi_dv_retrain(sdev, q, buffer, buffer + len, spi_dv_device_echo_buffer) == SPI_COMPARE_SKIP_TEST) { /* OK, the stupid drive can't do a write echo buffer @@ -1030,7 +1033,7 @@ spi_dv_device(struct scsi_device *sdev) starget_printk(KERN_INFO, starget, "Beginning Domain Validation\n"); - spi_dv_device_internal(sdev, buffer); + spi_dv_device_internal(sdev, sdev->request_queue, buffer); starget_printk(KERN_INFO, starget, "Ending Domain Validation\n"); From patchwork Mon Nov 23 03:17:48 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 330910 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-16.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F0524C8300F for ; Mon, 23 Nov 2020 03:18:20 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D9D5D2158C for ; Mon, 23 Nov 2020 03:18:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728056AbgKWDSQ (ORCPT ); Sun, 22 Nov 2020 22:18:16 -0500 Received: from mail-pf1-f195.google.com ([209.85.210.195]:36255 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727960AbgKWDSP (ORCPT ); Sun, 22 Nov 2020 22:18:15 -0500 Received: by mail-pf1-f195.google.com with SMTP id n137so3555889pfd.3; Sun, 22 Nov 2020 19:18:14 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=ZNSYB5hdUq+AWfxqSu9aBx8GQBXJWmk5hR/A0CL6JqY=; b=LLnlyNHe84ZAWDIx0+KtJ6BZnEIHl9JPoFHhbsUaRPkyGpA3BF5UymPAbISN6mWLfy yX9oB5PljdN+hhhOrqGyeozauVAFegRdn9lWLMDPWiZxp7YZC1ftGGW6W+M1qJx52Aj2 0yR1eANkTthCU6iTKVCiSpOfTer6daSkrnAa3rlljudReA+8MP9JQglpabLPuTJg8dXS IKlsNYRekeK2NV1uDbLkKMRS/NJGByqWX0Q4/4BB0NeLvOkPYOWhmeYDUnUHe44mbVSA wGtGEc1T6JXsazsVESSW1RYioef1JckVnzRDujMxwUfOVEUJrhuvAx3arzdusuntrkf5 gv8Q== X-Gm-Message-State: AOAM5306zR0BePpRPudd9px/xr9qeeosDtD9fE9yph2+FOdnWEILcBDi /jTvc158dTb+TXVox4qQc+8= X-Google-Smtp-Source: ABdhPJxvMXhyKa2ShNMgCt7x82XO1q/CLt1Mvhum9EOlWJwVU7tqM85HexZxi2NTdqUguQWS8Xl+qw== X-Received: by 2002:a63:1619:: with SMTP id w25mr25649632pgl.34.1606101494119; Sun, 22 Nov 2020 19:18:14 -0800 (PST) Received: from asus.hsd1.ca.comcast.net (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id w12sm3578751pfn.136.2020.11.22.19.18.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 Nov 2020 19:18:13 -0800 (PST) From: Bart Van Assche To: "Martin K . Petersen" Cc: "James E . J . Bottomley" , Jens Axboe , Christoph Hellwig , Ming Lei , linux-scsi@vger.kernel.org, linux-block@vger.kernel.org, Bart Van Assche , Can Guo , Stanley Chu , Alan Stern , "Rafael J . Wysocki" , Martin Kepplinger Subject: [PATCH v3 8/9] block, scsi, ide: Only process PM requests if rpm_status != RPM_ACTIVE Date: Sun, 22 Nov 2020 19:17:48 -0800 Message-Id: <20201123031749.14912-9-bvanassche@acm.org> X-Mailer: git-send-email 2.29.2 In-Reply-To: <20201123031749.14912-1-bvanassche@acm.org> References: <20201123031749.14912-1-bvanassche@acm.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Instead of submitting all SCSI commands submitted with scsi_execute() to a SCSI device if rpm_status != RPM_ACTIVE, only submit RQF_PM (power management requests) if rpm_status != RPM_ACTIVE. Remove flag RQF_PREEMPT since it is no longer necessary. Reviewed-by: Christoph Hellwig Reviewed-by: Can Guo Reviewed-by: Stanley Chu Cc: Alan Stern Cc: Ming Lei Cc: Rafael J. Wysocki Tested-by: Martin Kepplinger Signed-off-by: Bart Van Assche --- block/blk-core.c | 6 +++--- block/blk-mq-debugfs.c | 1 - block/blk-mq.c | 4 ++-- drivers/ide/ide-io.c | 3 +-- drivers/ide/ide-pm.c | 2 +- drivers/scsi/scsi_lib.c | 27 ++++++++++++++------------- include/linux/blk-mq.h | 4 ++-- include/linux/blkdev.h | 6 +----- 8 files changed, 24 insertions(+), 29 deletions(-) diff --git a/block/blk-core.c b/block/blk-core.c index 2db8bda43b6e..a00bce9f46d8 100644 --- a/block/blk-core.c +++ b/block/blk-core.c @@ -424,11 +424,11 @@ EXPORT_SYMBOL(blk_cleanup_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 and/or BLK_MQ_REQ_PM */ int blk_queue_enter(struct request_queue *q, blk_mq_req_flags_t flags) { - const bool pm = flags & BLK_MQ_REQ_PREEMPT; + const bool pm = flags & BLK_MQ_REQ_PM; while (true) { bool success = false; @@ -630,7 +630,7 @@ 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)); req = blk_mq_alloc_request(q, op, flags); if (!IS_ERR(req) && q->mq_ops->initialize_rq_fn) diff --git a/block/blk-mq-debugfs.c b/block/blk-mq-debugfs.c index 3094542e12ae..9336a6f8d6ef 100644 --- a/block/blk-mq-debugfs.c +++ b/block/blk-mq-debugfs.c @@ -297,7 +297,6 @@ static const char *const rqf_name[] = { RQF_NAME(MIXED_MERGE), RQF_NAME(MQ_INFLIGHT), RQF_NAME(DONTPREP), - RQF_NAME(PREEMPT), RQF_NAME(FAILED), RQF_NAME(QUIET), RQF_NAME(ELVPRIV), diff --git a/block/blk-mq.c b/block/blk-mq.c index 1b25ec2fe9be..d50504888b68 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c @@ -292,8 +292,8 @@ static struct request *blk_mq_rq_ctx_init(struct blk_mq_alloc_data *data, rq->mq_hctx = data->hctx; rq->rq_flags = 0; rq->cmd_flags = data->cmd_flags; - if (data->flags & BLK_MQ_REQ_PREEMPT) - rq->rq_flags |= RQF_PREEMPT; + if (data->flags & BLK_MQ_REQ_PM) + rq->rq_flags |= RQF_PM; if (blk_queue_io_stat(data->q)) rq->rq_flags |= RQF_IO_STAT; INIT_LIST_HEAD(&rq->queuelist); diff --git a/drivers/ide/ide-io.c b/drivers/ide/ide-io.c index 1a53c7a75224..beb850679fa9 100644 --- a/drivers/ide/ide-io.c +++ b/drivers/ide/ide-io.c @@ -522,8 +522,7 @@ blk_status_t ide_issue_rq(ide_drive_t *drive, struct request *rq, * state machine. */ if ((drive->dev_flags & IDE_DFLAG_BLOCKED) && - ata_pm_request(rq) == 0 && - (rq->rq_flags & RQF_PREEMPT) == 0) { + ata_pm_request(rq) == 0) { /* there should be no pending command at this point */ ide_unlock_port(hwif); goto plug_device; diff --git a/drivers/ide/ide-pm.c b/drivers/ide/ide-pm.c index 192e6c65d34e..82ab308f1aaf 100644 --- a/drivers/ide/ide-pm.c +++ b/drivers/ide/ide-pm.c @@ -77,7 +77,7 @@ 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; ide_req(rq)->special = &rqpm; rqpm.pm_step = IDE_PM_START_RESUME; diff --git a/drivers/scsi/scsi_lib.c b/drivers/scsi/scsi_lib.c index fef4708f3778..08f99573c383 100644 --- a/drivers/scsi/scsi_lib.c +++ b/drivers/scsi/scsi_lib.c @@ -248,7 +248,8 @@ int __scsi_execute(struct request_queue *q, const unsigned char *cmd, int ret = DRIVER_ERROR << 24; req = blk_get_request(q, 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, + rq_flags & RQF_PM ? BLK_MQ_REQ_PM : 0); if (IS_ERR(req)) return ret; rq = scsi_req(req); @@ -1204,6 +1205,8 @@ static blk_status_t scsi_device_state_check(struct scsi_device *sdev, struct request *req) { switch (sdev->sdev_state) { + case SDEV_CREATED: + return BLK_STS_OK; case SDEV_OFFLINE: case SDEV_TRANSPORT_OFFLINE: /* @@ -1230,18 +1233,18 @@ scsi_device_state_check(struct scsi_device *sdev, struct request *req) return BLK_STS_RESOURCE; case SDEV_QUIESCE: /* - * If the devices is blocked we defer normal commands. + * If the device is blocked we only accept power management + * commands. */ - if (req && !(req->rq_flags & RQF_PREEMPT)) + if (req && WARN_ON_ONCE(!(req->rq_flags & RQF_PM))) return BLK_STS_RESOURCE; return BLK_STS_OK; default: /* * For any other not fully online state we only allow - * special commands. In particular any user initiated - * command is not allowed. + * power management commands. */ - if (req && !(req->rq_flags & RQF_PREEMPT)) + if (req && !(req->rq_flags & RQF_PM)) return BLK_STS_IOERR; return BLK_STS_OK; } @@ -2503,15 +2506,13 @@ void sdev_evt_send_simple(struct scsi_device *sdev, EXPORT_SYMBOL_GPL(sdev_evt_send_simple); /** - * scsi_device_quiesce - Block user issued commands. + * scsi_device_quiesce - Block all commands except power management. * @sdev: scsi device to quiesce. * * 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. + * state, only power management requests will be accepted, all others will + * be deferred. * * Must be called with user context, may sleep. * @@ -2572,12 +2573,12 @@ void scsi_device_resume(struct scsi_device *sdev) * device deleted during suspend) */ mutex_lock(&sdev->state_mutex); + if (sdev->sdev_state == SDEV_QUIESCE) + scsi_device_set_state(sdev, SDEV_RUNNING); if (sdev->quiesced_by) { sdev->quiesced_by = NULL; blk_clear_pm_only(sdev->request_queue); } - if (sdev->sdev_state == SDEV_QUIESCE) - scsi_device_set_state(sdev, SDEV_RUNNING); mutex_unlock(&sdev->state_mutex); } EXPORT_SYMBOL(scsi_device_resume); diff --git a/include/linux/blk-mq.h b/include/linux/blk-mq.h index b23eeca4d677..1fa350592830 100644 --- a/include/linux/blk-mq.h +++ b/include/linux/blk-mq.h @@ -444,8 +444,8 @@ enum { BLK_MQ_REQ_NOWAIT = (__force blk_mq_req_flags_t)(1 << 0), /* allocate from reserved pool */ BLK_MQ_REQ_RESERVED = (__force blk_mq_req_flags_t)(1 << 1), - /* set RQF_PREEMPT */ - BLK_MQ_REQ_PREEMPT = (__force blk_mq_req_flags_t)(1 << 3), + /* set RQF_PM */ + BLK_MQ_REQ_PM = (__force blk_mq_req_flags_t)(1 << 3), }; 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 639cae2c158b..7d4b746f7e6a 100644 --- a/include/linux/blkdev.h +++ b/include/linux/blkdev.h @@ -79,9 +79,6 @@ 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. */ -#define RQF_PREEMPT ((__force req_flags_t)(1 << 8)) /* vaguely specified driver internal error. Ignored by the block layer */ #define RQF_FAILED ((__force req_flags_t)(1 << 10)) /* don't warn about errors */ @@ -430,8 +427,7 @@ struct request_queue { unsigned long queue_flags; /* * Number of contexts that have called blk_set_pm_only(). If this - * counter is above zero then only RQF_PM and RQF_PREEMPT requests are - * processed. + * counter is above zero then only RQF_PM requests are processed. */ atomic_t pm_only;