Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp3712341pxb; Tue, 26 Jan 2021 02:49:13 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoHlrKs0tVVs1KyvwPVzYPjKCfrPWcZ+GwwlTgPN8sUBLXyNw5ft3scJULfJhToKBsa7C2 X-Received: by 2002:a50:bf4a:: with SMTP id g10mr3967787edk.201.1611658153242; Tue, 26 Jan 2021 02:49:13 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611658153; cv=none; d=google.com; s=arc-20160816; b=uAPbX5f8rZIR48nso/APskObizRoxTki5bwTEEvuCOsFv6LjP2iZ3RUEetJJ/nPjy2 XNoAyKaaOPhiSDTZRmUSce8B6FDq9La5Br6H1I4Z/qJskZkVhVof6BNyk/aC8eYnhDht YLY1VwKFtCaraZkts7l64/ZdsYLXnTX/KskvX6y2nUO2i6eWv3XIioi6bAkzxROjQ48D sHDesGjP8gI2kMg2qdGJPr9vVg/SnUOtKepklK6gxJFvir5WG3KZL1DgrV5QM0Uipw+r wGLuYoMcQQBOfy3HSctRGGUuNsogf2z395aR7F5KIQT2Ky8a6mGLNfd/dBUhXDG0sJTg mC4Q== 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=kBJZDG2tUANkOa6JriIfIEN3HbEWWrkMH6tsmb1Uudg=; b=ZibxGd929P/RB7kZYktGsLGWJVGnRcOqKDZdTwzBQDvWYVZ/EiWzl2PLdwI48HX/mq 9nkiU1bi9utQgCRfdxfqraKUNTBz26Wta9WzhWS/MTMSr53w15Ppjg57HEZTIukuixXj jFHqlfKWAg4OxnBNswHAlbwI6Lw3HCDhHYnIwQOgAezEYl9ycPm/ydARPNefOWQ3TBDD SrjC4xaKCKRaX6m2GqcD1yv+k2cs3NGL10u/TpwaWnU5hnfs/mZ05U5CdM/6XtpZav2f oTGiI2ZNfm2P2ReVt3alBpjAVwKp/B4/2t3yaNfbdTtAMt8CtfTqt3m8in2exTMea78q qx1w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=XAsMDjXg; 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 j20si5761188edy.141.2021.01.26.02.48.49; Tue, 26 Jan 2021 02:49:13 -0800 (PST) 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=XAsMDjXg; 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 S2404288AbhAZKrT (ORCPT + 99 others); Tue, 26 Jan 2021 05:47:19 -0500 Received: from m42-8.mailgun.net ([69.72.42.8]:62052 "EHLO m42-8.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726231AbhAZCLm (ORCPT ); Mon, 25 Jan 2021 21:11:42 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1611627075; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=kBJZDG2tUANkOa6JriIfIEN3HbEWWrkMH6tsmb1Uudg=; b=XAsMDjXgDNfw0ndtQNrHZL7aS06eKoiOgHiRbrItvZ9kdGy0Vzn3+63eUy8MnX2bOCiC6YW0 vETY1bfSHHDHU/0SI5CUFjPHba/uIxPzPYe5wBWw/hClJ1UxFFedi6A4wEmGd/xPlOshHOlj TBcZYp5FCvAO2BPr95io+jjxLVo= X-Mailgun-Sending-Ip: 69.72.42.8 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 600f7a18ad4c9e395b687c2d (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 26 Jan 2021 02:10:32 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 6FACAC43465; Tue, 26 Jan 2021 02:10:32 +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 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 92270C433CA; Tue, 26 Jan 2021 02:10:31 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 26 Jan 2021 10:10:31 +0800 From: Can Guo To: Avri Altman Cc: Bart Van Assche , jaegeuk@kernel.org, asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, Alim Akhtar , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , open list Subject: Re: [PATCH v2] scsi: ufs: Fix some problems in task management request implementation In-Reply-To: References: <1611199388-24668-1-git-send-email-cang@codeaurora.org> Message-ID: <6362e6f2117237b934eea44f700fd13a@codeaurora.org> 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-01-25 19:36, Avri Altman wrote: >> Current task management request send/compl implementation is broken, >> the >> problems and fixes are listed as below: >> >> Problem: TMR completion timeout. ufshcd_tmc_handler() calls >> blk_mq_tagset_busy_iter(fn == ufshcd_compl_tm()), but since >> blk_mq_tagset_busy_iter() only iterates over all reserved >> tags and >> started requests, so ufshcd_compl_tm() never gets a chance to >> run. >> Fix: Call blk_mq_start_request() in __ufshcd_issue_tm_cmd(). >> >> Problem: Race condition in send/compl paths. ufshcd_compl_tm() looks >> for >> all 0 bits in the REG_UTP_TASK_REQ_DOOR_BELL and call >> complete() >> for each req who has the req->end_io_data set. There can be a >> race >> condition btw tmc send/compl, because req->end_io_data is >> set, in >> __ufshcd_issue_tm_cmd(), without host lock protection, so it >> is >> possible that when ufshcd_compl_tm() checks the >> req->end_io_data, >> req->end_io_data is set but the corresponding tag has not >> been set >> in the REG_UTP_TASK_REQ_DOOR_BELL. Thus, ufshcd_tmc_handler() >> may >> wrongly complete TMRs which have not been sent. >> Fix: Protect req->end_io_data with host lock. And let >> ufshcd_compl_tm() >> only handle those tm cmds which have been completed instead >> of >> looking for 0 bits in the REG_UTP_TASK_REQ_DOOR_BELL. >> >> Problem: In __ufshcd_issue_tm_cmd(), it is not right to use hba->nutrs >> + >> req->tag as the Task Tag in one TMR UPIU. >> Fix: Directly use req->tag as Task Tag. >> >> Cc: Jaegeuk Kim > Since you are practically reverting Bart's change (69a6c269c097), > maybe cc him as well, > And add a fixes tag? > Hi Avri, It is not reverting Bart's change, but making TMR work properly based on it. I am ok with the Bart's idea of getting a tag for TMR from blk_get_request(), and this patch respects that idea. > Also, even though all those fixes are around the same place, but > fixing different issues, > You might want to consider to separate those. Whatever you think. > Thanks for the suggestion. I treat it as a whole because it is convenient for me to get it ported and tested over different platforms. I may revise it in next version after more comments come on it. Thanks, Can Guo. > Thanks, > Avri