Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp44700pxj; Wed, 16 Jun 2021 19:50:17 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwBT4OyP/TAGGZE3CbmG/hj6PnRM6dk4wAN4qaC8svLjckbfIcYgxTVUjcbMFFeh+Ko5l5z X-Received: by 2002:a05:6402:368:: with SMTP id s8mr3479959edw.129.1623898217763; Wed, 16 Jun 2021 19:50:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623898217; cv=none; d=google.com; s=arc-20160816; b=o4PWy5P50IiJRi/C3F6FnFYW1ga8YrikcU4Ga3/gvS4kmpCZGXUEr73CkKdPPuRDnn 4uTFQs3qYyQby/OempZx+A8wZQYK6SI9z71PglY/17/H7WMfjDC+074TAguN00urZ2nH hPh8oleDC5/TxO6r8uCDHzBwK8f5/90HdU99C0c8xFZL1iczNmVdjdAus8QEtjZij8UZ WGnQY4NMRI93GnDGAfjpgUdqua7DtLRlMFetqfOEfRkua80Zx5mRi2gTDJ/oq3/8mWbw +dStm0gK0lRlY1BYWXZxaj5zsUK1oiiuKxs6JmmW8kgE+eKC85YV0fbmkf8DGG+OiBts 7QGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=PU09GkpdOebA1Js4BBORPX4b2AbSyG+VI/fibqpS/xU=; b=MvJvbotlIcVbzVQoFR0oxKd8gV1jmvl/YP3OZMuEUctvzPsu8B9qD+SoScOnvt5Pbp wJAyGk0EwBlVFgLQKbRntik2y+LmAX4ql9Lso+8XmzlpAR0ALbSnhi79utpsjPtIxxXd q7LMNL7yE/+84J+cKzjVZEfbD5sBbd25hktrSpXoju0mxyfh4F5UWPr653Hs2gG+f/QP GZABx6C5PnUsGrwxeBOab9B+NP82vT6OGt++0Mpymlq/VxPWUZ9PlD85Jyv7ufE3nmFV Ld+S4E2lqOkioA2EcK4QrUaUKAgSyFN5tMEXV6iy4Z9h4coi8UbX06bpvTtbR/kGnXLX 98nQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w19si3677361edc.458.2021.06.16.19.49.55; Wed, 16 Jun 2021 19:50:17 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230267AbhFQCvN (ORCPT + 99 others); Wed, 16 Jun 2021 22:51:13 -0400 Received: from mail-pf1-f181.google.com ([209.85.210.181]:46655 "EHLO mail-pf1-f181.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229686AbhFQCvN (ORCPT ); Wed, 16 Jun 2021 22:51:13 -0400 Received: by mail-pf1-f181.google.com with SMTP id x16so3762815pfa.13; Wed, 16 Jun 2021 19:49:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=PU09GkpdOebA1Js4BBORPX4b2AbSyG+VI/fibqpS/xU=; b=sf8zOrQic4rDYPS8wHW0Lk2Suj8Lo4ssZa2H4jo239FoXrn9Nq1gclTzEYbRec3YFW wi2xs9S73ZAlTwxx/ByJw11TrS1T+pcc6rMLj+WC7V+EGHbHIW9j65CKDKghpN6UUWkl /FWd4sLI8lXcqkLH9MS7oVGfLte/lDAqI8KSBAG+FGza6gMD4mzm6yjUfm6Vn+DY77lD nfRowxz4kBu5DuSJ3ycMvG4GLFQt6uh/Lf55VeFa3O2W0oYIHMf4zZQ4OHyTA1b0m+yM Z/TMpMQnpn6IY6X61NpZzzskQZszNf0/GOOCIonqeLV3ShgVkjIMQ2R4248orpuJC6QT wPdQ== X-Gm-Message-State: AOAM530vwvhn68saNrqUlXwA/QHlBuXHxlS0QqtGuD6EE2dxramXDEYS /kk5igmjRVdFXFP+JX51yjgiSnER1Hs2ZQ== X-Received: by 2002:a63:1f50:: with SMTP id q16mr2762916pgm.170.1623898144888; Wed, 16 Jun 2021 19:49:04 -0700 (PDT) Received: from [192.168.3.217] (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id gl13sm6517896pjb.5.2021.06.16.19.49.02 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 16 Jun 2021 19:49:04 -0700 (PDT) Subject: Re: [PATCH v1 2/3] scsi: ufs: Optimize host lock on transfer requests send/compl paths To: Can Guo , asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com Cc: Stanley Chu , Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Matthias Brugger , Bean Huo , Jaegeuk Kim , Adrian Hunter , Kiwoong Kim , Satya Tangirala , open list , "moderated list:ARM/Mediatek SoC support" , "moderated list:ARM/Mediatek SoC support" References: <1621845419-14194-1-git-send-email-cang@codeaurora.org> <1621845419-14194-3-git-send-email-cang@codeaurora.org> From: Bart Van Assche Message-ID: Date: Wed, 16 Jun 2021 19:49:01 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <1621845419-14194-3-git-send-email-cang@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 5/24/21 1:36 AM, Can Guo wrote: > @@ -2688,6 +2705,43 @@ static int ufshcd_queuecommand(struct Scsi_Host *host, struct scsi_cmnd *cmd) > + case UFSHCD_STATE_EH_SCHEDULED_FATAL: > + /* > + * pm_runtime_get_sync() is used at error handling preparation > + * stage. If a scsi cmd, e.g. the SSU cmd, is sent from hba's > + * PM ops, it can never be finished if we let SCSI layer keep > + * retrying it, which gets err handler stuck forever. Neither > + * can we let the scsi cmd pass through, because UFS is in bad > + * state, the scsi cmd may eventually time out, which will get > + * err handler blocked for too long. So, just fail the scsi cmd > + * sent from PM ops, err handler can recover PM error anyways. > + */ > + if (hba->pm_op_in_progress) { > + hba->force_reset = true; > + set_host_byte(cmd, DID_BAD_TARGET); > + cmd->scsi_done(cmd); > + goto out; > + } > + fallthrough; Hi Can, I know that this patch only moves the above code and that the above code has not been introduced by this patch. Anyway, is my understanding correct that ufshcd_err_handler() can change the host controller state from UFSHCD_STATE_EH_SCHEDULED_FATAL into UFSHCD_STATE_RESET and next into UFSHCD_STATE_OPERATIONAL? If so, if the above code completes a READ with status DID_BAD_TARGET and if recovery by the error handler succeeds, will that cause the filesystem above the UFS driver to change into read-only mode? If the above code completes a WRITE with status DID_BAD_TARGET, will that cause data corruption? Is there any other solution to prevent data corruption than merging the UFSHCD_STATE_EH_SCHEDULED_FATAL and UFSHCD_STATE_EH_SCHEDULED_NON_FATAL back into a single state and changing the ufshcd_rpm_get_sync(hba) call in ufshcd_err_handling_prepare() into a pm_runtime_get_noresume() call? Thanks, Bart.