Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp292346pxj; Wed, 26 May 2021 23:38:25 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxUVysB+SUihVuqNs8XWfj3RbVXSs58AzcetLX+VVun3aYhsjBeiDHqSDA5C1N/5uat3k/Y X-Received: by 2002:aa7:d893:: with SMTP id u19mr2426056edq.258.1622097504823; Wed, 26 May 2021 23:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622097504; cv=none; d=google.com; s=arc-20160816; b=Ef0fDb5tGWYvy0NkQFJVanv+vfuyiVVKEC6WveIotgi0OsA2lcpabVB5oypd8Oiyoy kn2NU6i9gRHdv7SZC3t3xWYsOGtiSGVD3D2xFVIBaYAaCB6eIChDSGKgpORStxVXbmXW 1KigPC8S9zngdVZ5FBKneVr1ehcQYvjCBrl90NJesmpEC6tNMxD5gVNFctLd3Prw5r/3 xkDnP1Igg4NpWqjWwrsAofUIiiABK2I6jNJIf3IVVDj57oQ1Cvd8o7tuyvr1xYzg3Cke hNsscEemP61q3AwTWt7W1UUNs2lUzzsObAJuIXdUVVMeialNlGsI0K32SYR5PIKRDtVq DqlA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:message-id:references:in-reply-to :subject:cc:to:from:date:content-transfer-encoding:mime-version :sender:dkim-signature; bh=akK0YcDnlMmUdrl3whgiB7gbhZG1JABylH+StbnX3vw=; b=hLTqMhg3nyrN2G5rtZ123rmn/NKO/7FXqksF9LMevd26tYjnITsJ0EUMqzIw06jqfT CdXGwol0745E4oUl6zyJka3NF6hvP3CQmb1gTMIt9s+Hdpi/d8QSTndX8cLlmNEhVXXI 5bi3AmHo2Bn1vv+b5GInYavJP74Nb8sDfX4yKj9vrx8jsjNt98dAc1hHwtbwFcIZgKl0 vFgs/LpcFuuy7zJoGKxOYOYaHph9WHnOIC0fQOX+MV+IcL6nlqQ0PtaIg6FHKUzLDWa6 ONcen2Kq70Dq5LZiifmv1jgzMNPDgGxFItrD+QCJQ6xME/BBxXwcJh9AMF5jP7Chw2ar 0/yQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=R2oaDBdF; 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 g20si1181467edt.518.2021.05.26.23.37.57; Wed, 26 May 2021 23:38:24 -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=@mg.codeaurora.org header.s=smtp header.b=R2oaDBdF; 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 S229746AbhE0Gdb (ORCPT + 99 others); Thu, 27 May 2021 02:33:31 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:32409 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229709AbhE0Gd3 (ORCPT ); Thu, 27 May 2021 02:33:29 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1622097117; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=akK0YcDnlMmUdrl3whgiB7gbhZG1JABylH+StbnX3vw=; b=R2oaDBdFt+huB2qZNB4Rn2z+q6ezVzPRrohCTduOuPRFriFbzAd5UHSkMtRcZ7LLgq2kMhhM u5hgzAxaeLebxYC6goPhQVJwsWbePwu1VB6grzHmuQMpWYRJ2Z/H3bnaLeA2IjkqV9yD0CFC 1PaF9KWLiQcUfTzMDeUaN//C18M= X-Mailgun-Sending-Ip: 198.61.254.9 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 60af3ccb67d156359a32560b (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Thu, 27 May 2021 06:31:39 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 536FEC43460; Thu, 27 May 2021 06:31:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00, URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.codeaurora.org (localhost.localdomain [127.0.0.1]) (using TLSv1 with cipher ECDHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) (Authenticated sender: cang) by smtp.codeaurora.org (Postfix) with ESMTPSA id 55BD8C433D3; Thu, 27 May 2021 06:31:37 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Thu, 27 May 2021 14:31:37 +0800 From: Can Guo To: jongmin jeong Cc: jejb@linux.ibm.com, martin.petersen@oracle.com, alim.akhtar@samsung.com, avri.altman@wdc.com, beanhuo@micron.com, adrian.hunter@intel.com, linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/3] scsi: ufs: add quirk to support host reset only In-Reply-To: <20210527030901.88403-4-jjmin.jeong@samsung.com> References: <20210527030901.88403-1-jjmin.jeong@samsung.com> <20210527030901.88403-4-jjmin.jeong@samsung.com> Message-ID: X-Sender: cang@codeaurora.org User-Agent: Roundcube Webmail/1.3.9 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2021-05-27 11:09, jongmin jeong wrote: > samsung ExynosAuto SoC has two types of host controller interface to > support the virtualization of UFS Device. > One is the physical host(PH) that the same as conventaional UFSHCI, > and the other is the virtual host(VH) that support data transfer > function only. > > In this structure, the virtual host does support host reset handler > only. > This patch calls the host reset handler when abort or device reset > handler > has occured in the virtual host. > > Change-Id: I3f07e772415a35fe1e7374e02b3c37ef0bf5660d > Signed-off-by: jongmin jeong > --- > drivers/scsi/ufs/ufshcd.c | 7 +++++++ > drivers/scsi/ufs/ufshcd.h | 6 ++++++ > 2 files changed, 13 insertions(+) > > diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c > index 4787e40c6a2d..9d1912290f87 100644 > --- a/drivers/scsi/ufs/ufshcd.c > +++ b/drivers/scsi/ufs/ufshcd.c > @@ -6826,6 +6826,9 @@ static int ufshcd_eh_device_reset_handler(struct > scsi_cmnd *cmd) > u8 resp = 0xF, lun; > unsigned long flags; > > + if (hba->quirks & UFSHCD_QUIRK_BROKEN_RESET_HANDLER) > + return ufshcd_eh_host_reset_handler(cmd); > + > host = cmd->device->host; > hba = shost_priv(host); > > @@ -6972,6 +6975,10 @@ static int ufshcd_abort(struct scsi_cmnd *cmd) > host = cmd->device->host; > hba = shost_priv(host); > tag = cmd->request->tag; > + > + if (hba->quirks & UFSHCD_QUIRK_BROKEN_RESET_HANDLER) > + return ufshcd_eh_host_reset_handler(cmd); > + Unless you are not using runtime PM. Otherwise, when abort happens to SSU cmd (sent from pm ops), your change will lead to a live lock, because ufshcd_eh_host_reset_handler() invokes error handling and flushes it, error handling calls runtime_pm_get_sync(), which flushes pm ops, while pm ops is blocked by SSU cmd. To be on the safe side, you should move these codes after below check in ufshcd_abort(), right before sending task abort TMRs. /* * Task abort to the device W-LUN is illegal. When this command * will fail, due to spec violation, scsi err handling next step * will be to send LU reset which, again, is a spec violation. * To avoid these unnecessary/illegal steps, first we clean up * the lrb taken by this cmd and mark the lrb as in_use, then * queue the eh_work and bail. */ if (lrbp->lun == UFS_UPIU_UFS_DEVICE_WLUN) { ... goto out; } Thanks, Can Guo. > lrbp = &hba->lrb[tag]; > if (!ufshcd_valid_tag(hba, tag)) { > dev_err(hba->dev, > diff --git a/drivers/scsi/ufs/ufshcd.h b/drivers/scsi/ufs/ufshcd.h > index 0ab4c296be32..82a9c6889978 100644 > --- a/drivers/scsi/ufs/ufshcd.h > +++ b/drivers/scsi/ufs/ufshcd.h > @@ -581,6 +581,12 @@ enum ufshcd_quirks { > * support interface configuration. > */ > UFSHCD_QUIRK_SKIP_INTERFACE_CONFIGURATION = 1 << 16, > + > + /* > + * This quirk needs to be enabled if the host controller support > + * host reset handler only. > + */ > + UFSHCD_QUIRK_BROKEN_RESET_HANDLER = 1 << 17, > }; > > enum ufshcd_caps {