Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp3201512rwb; Fri, 9 Dec 2022 11:13:31 -0800 (PST) X-Google-Smtp-Source: AA0mqf5f7Jy6DRexREey9DADXrNAjWfDxGMAGNnLGH/USvmwA6bErHRg55plSyRr1aRQPUiSsj4J X-Received: by 2002:a05:6402:3788:b0:467:481f:df5e with SMTP id et8-20020a056402378800b00467481fdf5emr5738988edb.19.1670613210852; Fri, 09 Dec 2022 11:13:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1670613210; cv=none; d=google.com; s=arc-20160816; b=tvLbDVvoVu7jA+ikycNraMUb4Za6Vd45yFMoCHnyvEGNFom48EO1w04UIy0rspKkV9 szvsajEKeY4Q8qZ43p3khLkTTTVD3ucm70GgyCe3auqKZD0+X804uhx8XODJ5kT9R1TC grj3spD9Y/OQQ5jiei7lsn3upD9knsVHS7CYeO4oXC0WHuuEan4yZpeyugh0qIZCRIJE bF6dahkdAnYFbo1tsJav8t7ihdGAjv/DimGpi1mKN55BH38WkeYQ3fVAkGROXa1aAYAJ 5dcIVte3uaRq0VI5E6nKVCikRP9DLuEx/ObB9kVz+IhDQr+3dJ6uoJ1WlZnp9WN9Fcdb OQyQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=+q6n80AI/p5yu9Dywj66FNMpbfZPHnd7kd9qY/cbMFk=; b=HRviMEnrwfAV2znDrKHjsFVvLzsg9Y83RuuFkTcBnl6bREshywakQ+m3FzfEtX2KFm jbw2W9KlTBEvmsWi/+JsJj9LlAHXhlaNhyJIWHMk1n+QJ7t5aKGL5zbonewmc85zp3qS 5xK661UFBeMB8fO+MD4YvEpvoGASvIiFv8JQE5itrMxDwdbJH+TqYJlMuEdqPLjJ6EC+ 4GGEbE1mDoF8yso7xxGPzNxowJGsh7iv5OR3CET3lPKhBxwXDTFy2JOvzrGiboRcfHSM 56VLtGNciirR3klpmM4/smbjPiq3klU9e75vjNmFqn4hTTmTbf40w62Tv5Ihou7y060X gGOw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=acm.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r3-20020a056402034300b0046107f951f9si1788888edw.237.2022.12.09.11.13.13; Fri, 09 Dec 2022 11:13:30 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=acm.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229777AbiLISu4 (ORCPT + 74 others); Fri, 9 Dec 2022 13:50:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37434 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229512AbiLISuy (ORCPT ); Fri, 9 Dec 2022 13:50:54 -0500 Received: from mail-pf1-f171.google.com (mail-pf1-f171.google.com [209.85.210.171]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90CCA2D1EB; Fri, 9 Dec 2022 10:50:51 -0800 (PST) Received: by mail-pf1-f171.google.com with SMTP id d82so4313996pfd.11; Fri, 09 Dec 2022 10:50:51 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=+q6n80AI/p5yu9Dywj66FNMpbfZPHnd7kd9qY/cbMFk=; b=SHCyiRYG141E4D3MkPJ9HprmgNFlS/1CigX1N3yKyDwo3TIbItECawH42AFWSQC2xS Z5ksNaz5DlQ+eQiOFZ6MCKRnjpmTfBNkDkwgg+5+HzO/8qdpo7lIix/onB2fei0Urzvm PEoPN6vxnaO9BvrMQ1+Ypa+2Vjiz5Z4yF4YrG7i5b66Lh1Uk7gOmCW4Sdve9xuCgsTiB hxaziLoLK/0nV2JiFdQClkM3RKOJ1Mg47S2urlcTLbn7hHdkU+IqZNLH3fc0DxmUs0wT iUoFIHvuKTRhZYryZLcpQzaoA5Rqm2DdSx6evUMNIFa4Y7lQ4Yp/kiIPbjefImKDa5CG hhOA== X-Gm-Message-State: ANoB5plW+K18nWiMc98vTgQ42lPYjcTMb/iSrgCSPNaFqkAY1HTCmyu9 gZKfDp8Cgb/NFqQcYBfUhsTel6t3y2c= X-Received: by 2002:aa7:8298:0:b0:56d:5de0:111b with SMTP id s24-20020aa78298000000b0056d5de0111bmr6875047pfm.33.1670611850939; Fri, 09 Dec 2022 10:50:50 -0800 (PST) Received: from ?IPV6:2620:15c:211:201:5c4e:b71f:9cdc:e100? ([2620:15c:211:201:5c4e:b71f:9cdc:e100]) by smtp.gmail.com with ESMTPSA id y29-20020aa79e1d000000b00573eb4a9a66sm1553974pfq.2.2022.12.09.10.50.49 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 09 Dec 2022 10:50:50 -0800 (PST) Message-ID: Date: Fri, 9 Dec 2022 10:50:48 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.4.0 Subject: Re: [PATCH v3 1/1] scsi: ufs: core: fix device management cmd timeout flow Content-Language: en-US To: Mason Zhang , Alim Akhtar , Avri Altman , "James E . J . Bottomley" , "Martin K . Petersen" , Matthias Brugger , Bean Huo , Stanley Chu , Jinyoung Choi Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Peter Wang , Peng Zhou , wsd_upstream@mediatek.com References: <20221209101321.30671-1-mason.zhang@mediatek.com> From: Bart Van Assche In-Reply-To: <20221209101321.30671-1-mason.zhang@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM,HEADER_FROM_DIFFERENT_DOMAINS, NICE_REPLY_A,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE, SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 12/9/22 02:13, Mason Zhang wrote: > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index b1f59a5fe632..6fe51b8d41f9 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -2979,35 +2979,31 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, > err = -ETIMEDOUT; > dev_dbg(hba->dev, "%s: dev_cmd request timedout, tag %d\n", > __func__, lrbp->task_tag); > - if (ufshcd_clear_cmds(hba, 1U << lrbp->task_tag) == 0) { > + if (ufshcd_clear_cmds(hba, 1U << lrbp->task_tag) == 0) > /* successfully cleared the command, retry if needed */ > err = -EAGAIN; > + /* > + * in case of an error, after clearing the doorbell, > + * we also need to clear the task tag bit from the > + * outstanding_reqs variable. > + */ > + spin_lock_irqsave(&hba->outstanding_lock, flags); > + pending = test_bit(lrbp->task_tag, > + &hba->outstanding_reqs); > + if (pending) { > + hba->dev_cmd.complete = NULL; > + __clear_bit(lrbp->task_tag, > + &hba->outstanding_reqs); > + } > + spin_unlock_irqrestore(&hba->outstanding_lock, flags); This patch causes the 'task_tag' bit to be cleared from outstanding_reqs even if ufshcd_clear_cmds() failed. I think that's wrong. Bart.