Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp207109pxa; Fri, 31 Jul 2020 09:54:15 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwm5C7BJwq59Hthy0JQFnmWZ8+q0GHcZS6odiYdH+KJnaEgbVUVS9csld/W4e7Lk0qV/fXM X-Received: by 2002:a05:6402:16c7:: with SMTP id r7mr4838429edx.288.1596214455472; Fri, 31 Jul 2020 09:54:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596214455; cv=none; d=google.com; s=arc-20160816; b=Kms9ASyDnONiQ5EVh+Pi0vPLY8flhLlIMBXE0NBrXlMBdOl1gi8bts/UztEQmqAUVv aUi7R3PyFdplTcaxpT/vShs24COraLBPfOfYbdZi+rhjG9ZDN0/CDJEiMCUIshdKEjNq eEAs8qGIOkH5oWfojzOZA/OIj7JoiWwBX0Tx0De98h/O0scWS01k/8mGUwGvLA3aBGWp 97NB8EW+myr7cmrgYq+q4quSDiJib/dI1iXE9jjHzAlTyVaiKzK8y2VY9m/voV20ziMD ibCO8fi8RRw2zk4UYxZcw3MfMrcplPvAKFB+14aJzFjXPThwAUofOcldZnlJHkXSkhbc odPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=oLGYhoUWlZqZmJCTlVuU9mouFujuKTKpwuXuSMKojnI=; b=GQsdB0aHQzlP4PvIDN6L7FENOrfv37F+gsyRVizhyHFVmf8EBoIrUlj4faanztdPvH Pd3zEJghQ2VPhLZvvrbLwEkqzMfdfdmuX5YHTiV3dFiV/9Uvcp9TIV3eBEP/9S0LT+ez PmYLkbu0HtpfzlMN5h5JYHhyOmpaJBkKpOanBA7GS+tzEfaoxmjsBkREje1CpPcftCRX oJwJQafSh8UPNA7jquQecWeGwC6+PvB7qxwA9Gjqnxx1aDqeJrn9SOmAzrtIcfYS5OE7 E7hk6RjZIU24M1zYE9CGfjaSCaBVt73RyN5mtzACAghE0aSDDMlzMjQQaGLZh3Cz5Soo Y/Og== ARC-Authentication-Results: i=1; mx.google.com; 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 le18si5651227ejb.705.2020.07.31.09.53.53; Fri, 31 Jul 2020 09:54:15 -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; 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 S1732932AbgGaQwB (ORCPT + 99 others); Fri, 31 Jul 2020 12:52:01 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:47036 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732474AbgGaQwA (ORCPT ); Fri, 31 Jul 2020 12:52:00 -0400 Received: by mail-pf1-f194.google.com with SMTP id 74so6501039pfx.13; Fri, 31 Jul 2020 09:52:00 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:autocrypt :message-id:date:user-agent:mime-version:in-reply-to :content-language:content-transfer-encoding; bh=oLGYhoUWlZqZmJCTlVuU9mouFujuKTKpwuXuSMKojnI=; b=BBG/xB/DMyV3FaYTWXz8oaJa602pAMYrGJ0SgzGhGCFQIilGJhoR29kp7DtFYfoRJC UvcTheAFVyiqWybSV2BfXLLat+85nlrYunuXx8VF0/tjBDOs9Tg67SuxsSGE3I9qWZDG 3kO/61aCK5+eDR+FDAW1h63N7wIiI3rzAsL33rBlbbPxAPz4Mde04/Y1k1cXSAKNjDqD owDD2WNCiR2+iATEsV3igGeN/KZ4jka1lwHr+FRmwYij7NkdmpGpfQC64z5dO+zIoGwQ pyVlYhrPZvOE6HGGMnpsx9l4uoQFWa+dAuXWY5jwmxdss2Nzq3pE6s+yfaDX4tvcYfx+ KFTg== X-Gm-Message-State: AOAM533IDj88B53JA+E0rWb7s9bwDp5qaSbrtje54h4YE3Wb8QeJpuYl 5iLXFwDXPKeggwJ7d60yvKdwugeD X-Received: by 2002:a63:5b5d:: with SMTP id l29mr4578617pgm.206.1596214319572; Fri, 31 Jul 2020 09:51:59 -0700 (PDT) Received: from [192.168.50.147] (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id w82sm10344378pff.7.2020.07.31.09.51.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 31 Jul 2020 09:51:57 -0700 (PDT) Subject: Re: [PATCH v4] scsi: ufs: Cleanup completed request without interrupt notification To: Can Guo Cc: Stanley Chu , Avri Altman , linux-scsi@vger.kernel.org, martin.petersen@oracle.com, alim.akhtar@samsung.com, jejb@linux.ibm.com, beanhuo@micron.com, asutoshd@codeaurora.org, matthias.bgg@gmail.com, linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kuohong.wang@mediatek.com, peter.wang@mediatek.com, chun-hung.wu@mediatek.com, andy.teng@mediatek.com, chaotian.jing@mediatek.com, cc.chou@mediatek.com References: <20200724140246.19434-1-stanley.chu@mediatek.com> <1596159018.17247.53.camel@mtkswgap22> <97f1dfb0-41b6-0249-3e82-cae480b0efb6@acm.org> <8b0a158a7c3ee2165e09290996521ffc@codeaurora.org> From: Bart Van Assche Autocrypt: addr=bvanassche@acm.org; prefer-encrypt=mutual; keydata= mQENBFSOu4oBCADcRWxVUvkkvRmmwTwIjIJvZOu6wNm+dz5AF4z0FH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H4LvUmHYhpS+W6CiZ3ZMxjO8Hgc ++w1mLeRUvda3i4/U8wDT3SWuHcB3DWlcppECLkAEQEAAYkBHwQYAQIACQUCVI67igIbDAAK CRBxXD01xc4QCZ4dB/0QrnEasxjM0PGeXK5hcZMT9Eo998alUfn5XU0RQDYdwp6/kMEXMdmT oH0F0xB3SQ8WVSXA9rrc4EBvZruWQ+5/zjVrhhfUAx12CzL4oQ9Ro2k45daYaonKTANYG22y //x8dLe2Fv1By4SKGhmzwH87uXxbTJAUxiWIi1np0z3/RDnoVyfmfbbL1DY7zf2hYXLLzsJR mSsED/1nlJ9Oq5fALdNEPgDyPUerqHxcmIub+pF0AzJoYHK5punqpqfGmqPbjxrJLPJfHVKy goMj5DlBMoYqEgpbwdUYkH6QdizJJCur4icy8GUNbisFYABeoJ91pnD4IGei3MTdvINSZI5e Message-ID: Date: Fri, 31 Jul 2020 09:51:55 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <8b0a158a7c3ee2165e09290996521ffc@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2020-07-31 01:00, Can Guo wrote: > AFAIK, sychronization of scsi_done is not a problem here, because scsi > layer > use the atomic state, namely SCMD_STATE_COMPLETE, of a scsi cmd to prevent > the concurrency of abort and real completion of it. > > Check func scsi_times_out(), hope it helps. > > enum blk_eh_timer_return scsi_times_out(struct request *req) > { > ... >         if (rtn == BLK_EH_DONE) { >                 /* >                  * Set the command to complete first in order to prevent > a real >                  * completion from releasing the command while error > handling >                  * is using it. If the command was already completed, > then the >                  * lower level driver beat the timeout handler, and it > is safe >                  * to return without escalating error recovery. >                  * >                  * If timeout handling lost the race to a real > completion, the >                  * block layer may ignore that due to a fake timeout > injection, >                  * so return RESET_TIMER to allow error handling another > shot >                  * at this command. >                  */ >                 if (test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state)) >                         return BLK_EH_RESET_TIMER; >                 if (scsi_abort_command(scmd) != SUCCESS) { >                         set_host_byte(scmd, DID_TIME_OUT); >                         scsi_eh_scmd_add(scmd); >                 } >         } > } I am familiar with this mechanism. My concern is that both the regular completion path and the abort handler must call scsi_dma_unmap() before calling cmd->scsi_done(cmd). I don't see how test_and_set_bit(SCMD_STATE_COMPLETE, &scmd->state) could prevent that the regular completion path and the abort handler call scsi_dma_unmap() concurrently since both calls happen before the SCMD_STATE_COMPLETE bit is set? Thanks, Bart.