From patchwork Thu Nov 30 20:28:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: James Bottomley X-Patchwork-Id: 172107 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:bcd1:0:b0:403:3b70:6f57 with SMTP id r17csp665158vqy; Thu, 30 Nov 2023 12:28:45 -0800 (PST) X-Google-Smtp-Source: AGHT+IFwQvqiHgy6Mr2xPfKNo1nP+osG9pyBPq+2Ly9mUHkEgXNC7zaH8+WevW+E9pelrUepxFnb X-Received: by 2002:a17:903:234a:b0:1cf:fc5c:75c9 with SMTP id c10-20020a170903234a00b001cffc5c75c9mr9711997plh.3.1701376125224; Thu, 30 Nov 2023 12:28:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701376125; cv=none; d=google.com; s=arc-20160816; b=KDxY1wrn+mqcOENhhzFt6eSKg/ZgCnZKBhyTbVXoYrNaIkxN/OJpk0W0GFU9FF60iz C4De0cFlqyVIIkYAo33onmsyMPgp30UWwDeLXQYR4ovKaHb9JOd3XAaqFcNeACOF1Nbo piZAd7J53PFBAAjb1qSeYIIfyelOfROROPidaw2Fzrehhr2elyO3JucbbEQWaJrrxyq2 Nt7oZ1PwXLRwvTG5kYZrM81TKNVcSwF040h3qJkDlXcn4yQANmVPtSK1C39CX4aJwrau 4ckkNgglw5R9WjHzRJTURQQ7bK8LYjA8Oa/OJEoP9vb+Hz+HTRqKlx9z4jqbjYP2pulp GgPA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:date:cc:to:from:subject:message-id:dkim-signature :dkim-signature; bh=GwKu8DIOvU8lAsEj49AZXK/+RTxklgDmkbMeN0qLgyE=; fh=bF6hBOtsqZ0IG+YnlrEaFQ/qkylncIJARoC6oO9o4Qw=; b=NJRMgF9+FNB3n7UR+bJcSHsTv12X2qUtTFXqp2G9uUOm2VKo7/zkKSndOW1doEVR3l o0Gklk9pwy4+MonF4Dqr+h7TiWcUfqgS7Jrfn/vpzs0PYaadNSDKAVt4qouWBd+NP4X8 PtZ3rQHSCFYZNWmJq22GbcRCAB4WQeuuCVR1oJpVe11YAIqcAF2YYVl7t7FcNR21s7e0 dcHr4Rc3U9NPqFWjqyoF4ZDlr+9b/gYBcQyiMfDTc+9B/S5l8hkF2lnOFZfigYrQXIlF deTMYsc7cILfczRjoelaMCYyWq13jlLliMYuc14ITtt94WeRlmE73vUu5zmqySCsI2JX pW/w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=HjCDzUdQ; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=Qv7AdGnk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: from lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id w10-20020a170902a70a00b001cfee3a039bsi1752682plq.24.2023.11.30.12.28.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Nov 2023 12:28:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=HjCDzUdQ; dkim=pass header.i=@hansenpartnership.com header.s=20151216 header.b=Qv7AdGnk; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=hansenpartnership.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by lipwig.vger.email (Postfix) with ESMTP id 1F6FB801C889; Thu, 30 Nov 2023 12:28:41 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376697AbjK3U2b (ORCPT + 99 others); Thu, 30 Nov 2023 15:28:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41082 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229493AbjK3U2a (ORCPT ); Thu, 30 Nov 2023 15:28:30 -0500 Received: from bedivere.hansenpartnership.com (bedivere.hansenpartnership.com [IPv6:2607:fcd0:100:8a00::2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 88F7B10FF; Thu, 30 Nov 2023 12:28:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1701376114; bh=h309xXu2AysR4RABR++0kkIEHwY0IMWt9+lOUwuKroc=; h=Message-ID:Subject:From:To:Date:From; b=HjCDzUdQ1jMBM43jHrwZ/FPzrWSrpPDBMdFksXPsqLgcCEgZHujsLLfxNzAJpNLdo 2JD865HkLPAUjeMsiMqin375X2EC3UOJhJaNGZHb/Qj71Z5yZxOGkhJUHy11uXn3ZW EmhTpDjOJZkQHAVqk7Y3EjFd9u8HzxM6080b2X6s= Received: from localhost (localhost [127.0.0.1]) by bedivere.hansenpartnership.com (Postfix) with ESMTP id 18A23128711F; Thu, 30 Nov 2023 15:28:34 -0500 (EST) Received: from bedivere.hansenpartnership.com ([127.0.0.1]) by localhost (bedivere.hansenpartnership.com [127.0.0.1]) (amavis, port 10024) with ESMTP id 16WYGNpV01Ju; Thu, 30 Nov 2023 15:28:34 -0500 (EST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=hansenpartnership.com; s=20151216; t=1701376113; bh=h309xXu2AysR4RABR++0kkIEHwY0IMWt9+lOUwuKroc=; h=Message-ID:Subject:From:To:Date:From; b=Qv7AdGnkNBVIGgpdGPP/B6pGx6knSkqjZ0o7IRPA4Fh5yzka4cBPPak4R6YrtEezO kq1tUQQSinOZKWYzNKra4cEuO8DLKJAQgQQ9M736bSp62ccAtqVFQtgsDCkL44DJJ2 RArdEYUY8IKHwO0bWQVQJBGLFFRbkFNUSuh+s3t8= Received: from lingrow.int.hansenpartnership.com (unknown [IPv6:2601:5c4:4302:c21::a774]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (prime256v1) server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by bedivere.hansenpartnership.com (Postfix) with ESMTPSA id 145741286906; Thu, 30 Nov 2023 15:28:33 -0500 (EST) Message-ID: Subject: [GIT PULL] SCSI fixes for 6.7-rc3 From: James Bottomley To: Andrew Morton , Linus Torvalds Cc: linux-scsi , linux-kernel Date: Thu, 30 Nov 2023 15:28:27 -0500 User-Agent: Evolution 3.42.4 MIME-Version: 1.0 X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lipwig.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (lipwig.vger.email [0.0.0.0]); Thu, 30 Nov 2023 12:28:41 -0800 (PST) X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1784022171792895249 X-GMAIL-MSGID: 1784022171792895249 3 small fixes, one in drivers. The core changes are to the internal representation of flags in scsi_devices which removes space wasting bools in favour of single bit flags and to add a flag to force a runtime resume which is used by ATA devices. The patch is available here: git://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git scsi-fixes The short changelog is: Damien Le Moal (2): scsi: sd: Fix system start for ATA devices scsi: Change SCSI device boolean fields to single bit flags Peter Wang (1): scsi: ufs: core: Clear cmd if abort succeeds in MCQ mode And the diffstat: drivers/ata/libata-scsi.c | 9 +++++++-- drivers/firewire/sbp2.c | 6 +++--- drivers/scsi/sd.c | 9 ++++++++- drivers/ufs/core/ufshcd.c | 13 +++++++++++++ include/scsi/scsi_device.h | 12 +++++++++--- 5 files changed, 40 insertions(+), 9 deletions(-) With full diff below James diff --git a/drivers/ata/libata-scsi.c b/drivers/ata/libata-scsi.c index c10ff8985203..0a0f483124c3 100644 --- a/drivers/ata/libata-scsi.c +++ b/drivers/ata/libata-scsi.c @@ -1055,9 +1055,14 @@ int ata_scsi_dev_config(struct scsi_device *sdev, struct ata_device *dev) * Ask the sd driver to issue START STOP UNIT on runtime suspend * and resume and shutdown only. For system level suspend/resume, * devices power state is handled directly by libata EH. + * Given that disks are always spun up on system resume, also + * make sure that the sd driver forces runtime suspended disks + * to be resumed to correctly reflect the power state of the + * device. */ - sdev->manage_runtime_start_stop = true; - sdev->manage_shutdown = true; + sdev->manage_runtime_start_stop = 1; + sdev->manage_shutdown = 1; + sdev->force_runtime_start_on_system_start = 1; } /* diff --git a/drivers/firewire/sbp2.c b/drivers/firewire/sbp2.c index 7edf2c95282f..e779d866022b 100644 --- a/drivers/firewire/sbp2.c +++ b/drivers/firewire/sbp2.c @@ -1519,9 +1519,9 @@ static int sbp2_scsi_slave_configure(struct scsi_device *sdev) sdev->use_10_for_rw = 1; if (sbp2_param_exclusive_login) { - sdev->manage_system_start_stop = true; - sdev->manage_runtime_start_stop = true; - sdev->manage_shutdown = true; + sdev->manage_system_start_stop = 1; + sdev->manage_runtime_start_stop = 1; + sdev->manage_shutdown = 1; } if (sdev->type == TYPE_ROM) diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c index fa00dd503cbf..542a4bbb21bc 100644 --- a/drivers/scsi/sd.c +++ b/drivers/scsi/sd.c @@ -3949,8 +3949,15 @@ static int sd_resume(struct device *dev, bool runtime) static int sd_resume_system(struct device *dev) { - if (pm_runtime_suspended(dev)) + if (pm_runtime_suspended(dev)) { + struct scsi_disk *sdkp = dev_get_drvdata(dev); + struct scsi_device *sdp = sdkp ? sdkp->device : NULL; + + if (sdp && sdp->force_runtime_start_on_system_start) + pm_request_resume(dev); + return 0; + } return sd_resume(dev, false); } diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c index 8b1031fb0a44..bce0d2a9a7f3 100644 --- a/drivers/ufs/core/ufshcd.c +++ b/drivers/ufs/core/ufshcd.c @@ -6444,11 +6444,24 @@ static bool ufshcd_abort_one(struct request *rq, void *priv) struct scsi_device *sdev = cmd->device; struct Scsi_Host *shost = sdev->host; struct ufs_hba *hba = shost_priv(shost); + struct ufshcd_lrb *lrbp = &hba->lrb[tag]; + struct ufs_hw_queue *hwq; + unsigned long flags; *ret = ufshcd_try_to_abort_task(hba, tag); dev_err(hba->dev, "Aborting tag %d / CDB %#02x %s\n", tag, hba->lrb[tag].cmd ? hba->lrb[tag].cmd->cmnd[0] : -1, *ret ? "failed" : "succeeded"); + + /* Release cmd in MCQ mode if abort succeeds */ + if (is_mcq_enabled(hba) && (*ret == 0)) { + hwq = ufshcd_mcq_req_to_hwq(hba, scsi_cmd_to_rq(lrbp->cmd)); + spin_lock_irqsave(&hwq->cq_lock, flags); + if (ufshcd_cmd_inflight(lrbp->cmd)) + ufshcd_release_scsi_cmd(hba, lrbp); + spin_unlock_irqrestore(&hwq->cq_lock, flags); + } + return *ret == 0; } diff --git a/include/scsi/scsi_device.h b/include/scsi/scsi_device.h index 10480eb582b2..5ec1e71a09de 100644 --- a/include/scsi/scsi_device.h +++ b/include/scsi/scsi_device.h @@ -167,19 +167,25 @@ struct scsi_device { * power state for system suspend/resume (suspend to RAM and * hibernation) operations. */ - bool manage_system_start_stop; + unsigned manage_system_start_stop:1; /* * If true, let the high-level device driver (sd) manage the device * power state for runtime device suspand and resume operations. */ - bool manage_runtime_start_stop; + unsigned manage_runtime_start_stop:1; /* * If true, let the high-level device driver (sd) manage the device * power state for system shutdown (power off) operations. */ - bool manage_shutdown; + unsigned manage_shutdown:1; + + /* + * If set and if the device is runtime suspended, ask the high-level + * device driver (sd) to force a runtime resume of the device. + */ + unsigned force_runtime_start_on_system_start:1; unsigned removable:1; unsigned changed:1; /* Data invalid due to media change */