Received: by 2002:a05:6a10:d5a5:0:0:0:0 with SMTP id gn37csp1474895pxb; Fri, 1 Oct 2021 11:22:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMBNwNrJgw6M2yCq0jUk7wHCcISz9R4CCEn3U2zrwtOFr94b5FQQD29S/214jGnL7JtdYO X-Received: by 2002:a17:906:1dc4:: with SMTP id v4mr8029336ejh.282.1633112550797; Fri, 01 Oct 2021 11:22:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1633112550; cv=none; d=google.com; s=arc-20160816; b=tBl2pzuOfR5mspR5XDsk4E6oU9JjTgAiZ4dagfc01A1LpfswC9CH13J3PNjQJle2Kx 4Bwt4+1rk0AxkaTud6cf4RLemIEXLR7KdI11T/goBq/lPViFTAnlq3HWdpSXTfA3EhGm BIhgQHrqMEQ9wsqhHZwDevHS+++FopflKX21UePBZp1q9OXq0pzsRJK7lQ9u6McB1MCb 2XtlTDzNriA90WyX+UZlYw2sAfnzvTyBL3Jd9xKYiW882gUdOc1BlR/r8rKh+eckzdX3 TJx2C2M2LiIa0OJxn+ZRBxKIw7I3yq4sFfV9Cdt69XA0+QE92xod7P3ua5b30CP4CDRt q83g== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=Mzw/aUF/BSHboDxri1a5fVQ0vv8vO0oKP6BFDsqsvCY=; b=o4DLB6DiK+iHLZKxORI69ZI4K0WzGGpi7JBE0odItMmkX2Frv3OFBzoE+Bgm3VdqhL 9u3mD/JX+YoFt7i1LGEiRAORqoelGUooOyq1w6wPzFrIsSJdJnmTBfKa7vRRAnBaLPHY SJONCNPGTUTyJn0Hl7Q0OO8umDe1Rp0jY/lxNcQk0qKTOlwoKKG/RVZM574VSFO+WTRV VchtlWtQIHLNlzUC0awFhWFz1Ojn2FD8PQQARghUvmUwyR7rOJSi1HU2KFicV8l0sscP mAXnzT5damjzN95ir/omMlcXyqDYRNLr2WemBXBqbnnbnjbPuVy28/eCHguIOnQzDUFI LHDA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Hdhdx/kq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f15si5956491edx.534.2021.10.01.11.22.04; Fri, 01 Oct 2021 11:22:30 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="Hdhdx/kq"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1355783AbhJASWS (ORCPT + 99 others); Fri, 1 Oct 2021 14:22:18 -0400 Received: from mail.kernel.org ([198.145.29.99]:35830 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1354947AbhJASWR (ORCPT ); Fri, 1 Oct 2021 14:22:17 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 1355561ABA; Fri, 1 Oct 2021 18:20:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1633112433; bh=G7UqmYmy+/1tzb9K3PPrde7yZpsU8B6HGBfcnvwh28I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Hdhdx/kqebHsex+8VyplHzSV+ZtEbjr972zdfa8+y7W2cTMK95E1rw76kkMOvUmhQ N1wu6CTD648yFpIr3iCZJjNOhPy/NeUWEhH7bZtZoUT8yQaPLd4WuGBxZ3jX7nXrbB mC/JwXjDnrK2B3zkdFr8WvIeugow+JdSouifpT0LAHF3B/yP/BUFGnaYkJIVKQc7S9 ypdOwiwmuSb6C7187E9jPuTWh7GW061VM2QDfCQ9gkZfGkdZDBmSvZCjdVqYuPZCkB P2yumIY7cOklWbzJ4xjw1DTVMtlfejuEeX5yqvoIFnj0rtwO6uafOPHm5bhVB9YcdQ 9GYM/0S8C4K5Q== From: Jaegeuk Kim To: linux-kernel@vger.kernel.org, linux-scsi@vger.kernel.org, "Martin K . Petersen" , Bart Van Assche , Adrian Hunter , Asutosh Das , Avri Altman , Bean Huo , Stanley Chu , Can Guo Cc: Jaegeuk Kim Subject: [PATCH 1/2] scsi: ufs: retry START_STOP on UNIT_ATTENTION Date: Fri, 1 Oct 2021 11:20:14 -0700 Message-Id: <20211001182015.1347587-2-jaegeuk@kernel.org> X-Mailer: git-send-email 2.33.0.800.g4c38ced690-goog In-Reply-To: <20211001182015.1347587-1-jaegeuk@kernel.org> References: <20211001182015.1347587-1-jaegeuk@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit 57d104c153d3 ("ufs: add UFS power management support") made the UFS driver submit a REQUEST SENSE command before submitting a power management command to a WLUN to clear the POWER ON unit attention. Instead of submitting a REQUEST SENSE command before submitting a power management command, retry the power management command until it succeeds. This is the preparation to get rid of all UNIT ATTENTION code which should be handled by users. Cc: Adrian Hunter Reviewed-by: Bart Van Assche Signed-off-by: Jaegeuk Kim --- drivers/scsi/ufs/ufshcd.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 9faf02cbb9ad..7ec72de826e5 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -8676,7 +8676,7 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, struct scsi_sense_hdr sshdr; struct scsi_device *sdp; unsigned long flags; - int ret; + int ret, retries; spin_lock_irqsave(hba->host->host_lock, flags); sdp = hba->sdev_ufs_device; @@ -8711,8 +8711,14 @@ static int ufshcd_set_dev_pwr_mode(struct ufs_hba *hba, * callbacks hence set the RQF_PM flag so that it doesn't resume the * already suspended childs. */ - ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, - START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL); + for (retries = 3; retries > 0; --retries) { + ret = scsi_execute(sdp, cmd, DMA_NONE, NULL, 0, NULL, &sshdr, + START_STOP_TIMEOUT, 0, 0, RQF_PM, NULL); + if (!scsi_status_is_check_condition(ret) || + !scsi_sense_valid(&sshdr) || + sshdr.sense_key != UNIT_ATTENTION) + break; + } if (ret) { sdev_printk(KERN_WARNING, sdp, "START_STOP failed for power mode: %d, result %x\n", -- 2.33.0.800.g4c38ced690-goog