Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp100853rwb; Wed, 18 Jan 2023 14:48:35 -0800 (PST) X-Google-Smtp-Source: AMrXdXs3TMw9dWDRhMBgmm0cZSUgr/1Po6YSTqS+NOLY3/aB+7pwbxNU0kwNDPmKs94lzOQ0pUPH X-Received: by 2002:a17:906:13cc:b0:870:1090:66b4 with SMTP id g12-20020a17090613cc00b00870109066b4mr4472766ejc.26.1674082114903; Wed, 18 Jan 2023 14:48:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674082114; cv=none; d=google.com; s=arc-20160816; b=n+ksn/M6h5/b/94ZWV/QoDrPBgl3W2BRLEOirw8oRIhrdx4dvuehSWCqjwuhi9hRax ugnINHbgD15Nbf+/Kvr6wtyW0cevWoIcJIsd85JLfOkMkDECJ32DHCi/zJ/jh+ZhF97f DIGq/fv1XwtlhGvpJL2q8yAxJYACT5zaoXwj7yQ3P/rXbcaDO5Nn9BLPXTOryAGUzTyH 0vBRE5CkaIi2jeIV0ho6rugYm27KlpHqYlfmGElS4WENWYA6qE3pvHm3426G3EUfVc11 +dSSp0tbQUkA3X1Eexv2bZlPumhOY0mP5SoesJkgh0A7FKj15Vov4vXFqEfN0lMF8Kd+ JmyA== 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=Q5Lvd5Mvxqck3fJBa5/+a5U8omDaF2GvQNzIqnYVLL0=; b=qkSgQQlaOOGGTHUmD+JBstA4+XJPPjXCymhWOl10TVS6/VK/izBGNlrbfFx1V5MRj+ +4DWO4m6O4InliqPXRNmPbWwi7ZYejeuU2g6rfZ8MOw6gDj8KL7QIN/TLOh5vLezYUMS LZaYjxFritYsJZCVNRhnzNyVCvlAYQ0Uh8KbzhQ2c0+SCPnI9iWBKfc3p3FV7zNRhLsz q8aa/YY34LRkdd2lAqM5cvwl3kEO5DxufMvGjJBbiyO1a1AhWgjtHQve9gZQeV6hOmOA 5hA3H3ILXU5BLgpVYPNA120dAE4Y/pp2m/yXu9dM8whMt/bz82hc4jqKS3dgpwVuGvW+ 93eg== 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 g16-20020a1709065d1000b0084d1a0d90cdsi39245893ejt.674.2023.01.18.14.48.24; Wed, 18 Jan 2023 14:48:34 -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 S229811AbjARV7r (ORCPT + 44 others); Wed, 18 Jan 2023 16:59:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48202 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229608AbjARV7k (ORCPT ); Wed, 18 Jan 2023 16:59:40 -0500 Received: from mail-pl1-f172.google.com (mail-pl1-f172.google.com [209.85.214.172]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 143A65EFB4; Wed, 18 Jan 2023 13:59:40 -0800 (PST) Received: by mail-pl1-f172.google.com with SMTP id y1so480091plb.2; Wed, 18 Jan 2023 13:59:40 -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=Q5Lvd5Mvxqck3fJBa5/+a5U8omDaF2GvQNzIqnYVLL0=; b=g0I3M9JpaPXCdnK5sQU1LXAUREXYcKu63qOVs66rnMKDdtBc6G48p/gl5xYpO3UNwz aTWSed+kWYzYhvJLYVIKR7mLH+ea7M235yZIFPDACUVDbWansklQ22n+aoKjx8aNcEC7 YVmbNenl/KeyOsCxh3m1OE88ryvMEmfXlB9JfKwusYvpgI/iJNc/UCBu/M49eacNH0nN slS4yO5+JveWNzELC3MGNat2/MVDyd6VglNPL/kw3FjRbdOALIDiuzqJpjQ7YuGjMffI 8QF4T78caEK6RwYjt3cr6NSV/iQkr6EEmIUprDUt02GNQP9u3MVJC0v+y38hynfsbXno 5JPQ== X-Gm-Message-State: AFqh2kq9dMSw4jmP6nUCW+wZeyMBhZs2NFAYiQtoh/YyPHAvujNYF7i4 yD4tLn/cNy3wOF/ix2Q6jsc= X-Received: by 2002:a17:902:bd83:b0:193:2bc9:eb25 with SMTP id q3-20020a170902bd8300b001932bc9eb25mr8807142pls.20.1674079179442; Wed, 18 Jan 2023 13:59:39 -0800 (PST) Received: from ?IPV6:2620:15c:211:201:22ae:3ae3:fde6:2308? ([2620:15c:211:201:22ae:3ae3:fde6:2308]) by smtp.gmail.com with ESMTPSA id a7-20020a1709027e4700b00192740bb02dsm22260907pln.45.2023.01.18.13.59.37 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 18 Jan 2023 13:59:38 -0800 (PST) Message-ID: <4bedb8bf-241f-03d8-9f84-1e070ab4c3d8@acm.org> Date: Wed, 18 Jan 2023 13:59:36 -0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH v4 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: <20221216032532.1280-1-mason.zhang@mediatek.com> From: Bart Van Assche In-Reply-To: <20221216032532.1280-1-mason.zhang@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-1.5 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/15/22 19:25, Mason Zhang wrote: > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c > index b1f59a5fe632..fa86ce80f350 100644 > --- a/drivers/ufs/core/ufshcd.c > +++ b/drivers/ufs/core/ufshcd.c > @@ -3008,6 +3008,22 @@ static int ufshcd_wait_for_dev_cmd(struct ufs_hba *hba, > } else { > dev_err(hba->dev, "%s: failed to clear tag %d\n", > __func__, lrbp->task_tag); > + > + spin_lock_irqsave(&hba->outstanding_lock, flags); > + pending = test_bit(lrbp->task_tag, > + &hba->outstanding_reqs); > + if (pending) > + hba->dev_cmd.complete = NULL; > + spin_unlock_irqrestore(&hba->outstanding_lock, flags); > + > + if (!pending) { > + /* > + * The completion handler ran while we tried to > + * clear the command. > + */ > + time_left = 1; > + goto retry; > + } > } > } Reviewed-by: Bart Van Assche