From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 562B2C48BDF for ; Sun, 13 Jun 2021 13:30:43 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 2C80E610A0 for ; Sun, 13 Jun 2021 13:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231809AbhFMNcm (ORCPT ); Sun, 13 Jun 2021 09:32:42 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:59818 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231733AbhFMNcm (ORCPT ); Sun, 13 Jun 2021 09:32:42 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1623591041; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=v8jXqJ5ky/IEKt0B6ubAeEGws7ANAZpKE8P/QO1P2dQ=; b=jg+wu9oPSQeRP7/pcJv0jms0FNXQnSpDnx6IFr6aD7qOzsiF34wyqpvVKOAULDu8lz9ZzkBM LTwgRa6gMpop0ofeOjUnFvUhCyE4L+VNsYeook5NTcdK7Z618MrGqPlnGjb3wauXUDHUE+qS NGQlPir/V6rI7XouYK5Z4IIEknM= 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-n01.prod.us-west-2.postgun.com with SMTP id 60c608748491191eb301e441 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Sun, 13 Jun 2021 13:30:28 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 3F5E6C4323A; Sun, 13 Jun 2021 13:30:28 +0000 (UTC) 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 68092C433F1; Sun, 13 Jun 2021 13:30:27 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Sun, 13 Jun 2021 21:30:27 +0800 From: Can Guo To: Bart Van Assche Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, ziqichen@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Jaegeuk Kim , open list Subject: Re: [PATCH v3 4/9] scsi: ufs: Complete the cmd before returning in queuecommand In-Reply-To: <5df201d5-ab7f-a9fc-36aa-6dd174e9cee2@acm.org> References: <1623300218-9454-1-git-send-email-cang@codeaurora.org> <1623300218-9454-5-git-send-email-cang@codeaurora.org> <80926df7e3e41088e59ce5e0dbdec28a@codeaurora.org> <5df201d5-ab7f-a9fc-36aa-6dd174e9cee2@acm.org> Message-ID: <3f39da79b40b53240636e848cd65feac@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-06-12 23:50, Bart Van Assche wrote: > On 6/12/21 12:38 AM, Can Guo wrote: >> On 2021-06-12 04:52, Bart Van Assche wrote: >>> On 6/9/21 9:43 PM, Can Guo wrote: >>>> @@ -2768,15 +2778,6 @@ static int ufshcd_queuecommand(struct >>>> Scsi_Host *host, struct scsi_cmnd *cmd) >>>>      WARN_ON(ufshcd_is_clkgating_allowed(hba) && >>>>          (hba->clk_gating.state != CLKS_ON)); >>>> >>>> -    if (unlikely(test_bit(tag, &hba->outstanding_reqs))) { >>>> -        if (hba->wl_pm_op_in_progress) >>>> -            set_host_byte(cmd, DID_BAD_TARGET); >>>> -        else >>>> -            err = SCSI_MLQUEUE_HOST_BUSY; >>>> -        ufshcd_release(hba); >>>> -        goto out; >>>> -    } >>>> - >>>>      lrbp = &hba->lrb[tag]; >>>>      WARN_ON(lrbp->cmd); >>>>      lrbp->cmd = cmd; >>> >>> Can the code under "if (unlikely(test_bit(tag, >>> &hba->outstanding_reqs)))" be deleted instead of moving it? I don't >>> think that it is useful to verify whether the block layer tag >>> allocator >>> works correctly. Additionally, I'm not aware of any similar code in >>> any >>> other SCSI LLD. >> >> ufshcd_abort() aborts PM requests differently from other requests - >> it simply evicts the cmd from lrbp [1], schedules error handler and >> returns SUCCESS (the reason why I am doing it this way is in patch >> #8). >> >> After ufshcd_abort() returns, the tag shall be released, the logic >> here is to prevent subsequent cmds re-use the lrbp [1] before error >> handler recovers the device and host. > > Thanks for the background information. However, this approach sounds > cumbersome to me. For PM requests, please change the UFS driver such > that calling scsi_done() for aborted requests is postponed until error > handling has finished and delete the code shown above from > ufshcd_queuecommand(). I will delete the code in next version, since I believe the hba_state checks before the code is enough to achieve the same purpose, so this code becomes redundant. Thanks, Can Guo. > > Thanks, > > Bart.