Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp2994884pxj; Mon, 14 Jun 2021 11:51:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzjwEEhFcBkKYqdd0/PupDqRtqKH+XjTPhLBNMhjMUk2lgOx2GzxQ3vNMLwQHVbtks7Jbh0 X-Received: by 2002:aa7:c983:: with SMTP id c3mr18360104edt.58.1623696718825; Mon, 14 Jun 2021 11:51:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623696718; cv=none; d=google.com; s=arc-20160816; b=Sza1WAQovoxIqhvymVCdT/BblnI/riA4EypCsvEKAnv7ANyiTLTsEv/RfWSKBwy2RJ fqFmnj2IBMTPK7Nb7WxX1lGFFIB9Q8PvHh3WUVsLGKmHqx61yMgGHANZOsMuDILMkg6d s9fHE93Gu8PcVTmJLmh9whV4LdXfj9Z+LqMQfVgtjpQYFK2arM1AVxK7yab/SklB56rT 6ZS12F0zEsC2TKjOKcIHHBA1w+VYvQvSOXfQ59DCfRGGbG4VmFFIaaq6OaDTUmmmKGsA fgEmSjiaEckcEzSeqVzTD4xqSV4/XSyx7lYVyZLru8yYuytWNKzH8KqQhRpDXdcifr3q ykRg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=WGsIbLf37DnRyEZ62qVe83dSenYbF1V6Z+MZPlTkNjc=; b=gebkRlUNbQdCczBpMNQrw4YCPIzEDkCjQnQbiESr+pTtFjNpIpYI+qpZ1UyCJ/Q9li cNfFMR6T112B8XyuUTYc1Me7FXjCvsDeib46v1tfflqkh9VcDYPjMChZ4uNTJAcmosmK ctucSVEfyoe1aNZXweYLOUI/AsA6TAFAw/loPeiTfbTm4isTZ8Z1CTeM5ftA2MbPlsIT jVTkeAVnaB5/Ykk9YtQKvazAeKu/As1Y39cwlIZwccq6xB6cBQPPXy1EfzpiQ/YGzbcy piiiJAwefT5CV1RH+jvdkLDz3/bf5tID9J/YNiVMNfGVnOnRUqKE3UXX0BGbqD5VThWM db1w== 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 p7si6759842ejn.515.2021.06.14.11.51.16; Mon, 14 Jun 2021 11:51:58 -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 S233930AbhFNSvR (ORCPT + 99 others); Mon, 14 Jun 2021 14:51:17 -0400 Received: from mail-pl1-f178.google.com ([209.85.214.178]:39473 "EHLO mail-pl1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232802AbhFNSvQ (ORCPT ); Mon, 14 Jun 2021 14:51:16 -0400 Received: by mail-pl1-f178.google.com with SMTP id v11so7078770ply.6; Mon, 14 Jun 2021 11:49:13 -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:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=WGsIbLf37DnRyEZ62qVe83dSenYbF1V6Z+MZPlTkNjc=; b=j1blMPrVomNk+S3KJzqDFd0q3WNowz2gPl/F6vGxrAo+P8D2pxGJKNdl8KX5XzfhAo jfM4DBJw7moK6AlRxDAUhuQkb4WfGkZM3uPNvtvzkEZmcb4Btzex89va/UzJkNU4CiKZ J4sUEoX95D/e04zs4XeZlngaOq9IODjrKY+qO5yKAbxpT5q1wx0ELy2rdW2zRsRZWUEr fxXGKUJxwwAgXbsfxGgzyQn4cDTIdPxA5bSOfBu7AIKCPLldvnQTEJvMZ5+ZtCLDyt0j eVmZQGEMfFiOC82PENCeaU1mUyxn4qZVqAYukhwRwuQwnnWf6+wRUTmJjrU1Gg5ZRdbI N8wg== X-Gm-Message-State: AOAM532piqup+4bUJZwJaqNjvu6BNSaek1eRGhvtNcHDipYzMWi/tM5M f6U7a8tvaTYz76oQtOJylvuqqjt5t/M= X-Received: by 2002:a17:90a:f58e:: with SMTP id ct14mr11056921pjb.223.1623696552723; Mon, 14 Jun 2021 11:49:12 -0700 (PDT) Received: from [192.168.3.217] (c-73-241-217-19.hsd1.ca.comcast.net. [73.241.217.19]) by smtp.gmail.com with ESMTPSA id e6sm199754pjl.3.2021.06.14.11.49.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 14 Jun 2021 11:49:11 -0700 (PDT) Subject: Re: [PATCH v3 8/9] scsi: ufs: Update the fast abort path in ufshcd_abort() for PM requests To: Can Guo 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 References: <1623300218-9454-1-git-send-email-cang@codeaurora.org> <1623300218-9454-9-git-send-email-cang@codeaurora.org> <16f5bd448c7ae1a45fcb23133391aa3f@codeaurora.org> <926d8c4a-0fbf-a973-188a-b10c9acaa444@acm.org> <75527f0ba5d315d6edbf800a2ddcf8c7@codeaurora.org> From: Bart Van Assche Message-ID: <8b27b0cc-ae16-173a-bd6f-0321a6aba01c@acm.org> Date: Mon, 14 Jun 2021 11:49:10 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: <75527f0ba5d315d6edbf800a2ddcf8c7@codeaurora.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 6/13/21 7:42 AM, Can Guo wrote: > 2. ufshcd_abort() invokes ufshcd_err_handler() synchronously can have a > live lock issue, which is why I chose the asynchronous way (from the first > day I started to fix error handling). The live lock happens when abort > happens > to a PM request, e.g., a SSU cmd sent from suspend/resume. Because UFS > error > handler is synchronized with suspend/resume (by calling > pm_runtime_get_sync() > and lock_system_sleep()), the sequence is like: > [1] ufshcd_wl_resume() sends SSU cmd > [2] ufshcd_abort() calls UFS error handler > [3] UFS error handler calls lock_system_sleep() and pm_runtime_get_sync() > > In above sequence, either lock_system_sleep() or pm_runtime_get_sync() > shall > be blocked - [3] is blocked by [1], [2] is blocked by [3], while [1] is > blocked by [2]. > > For PM requests, I chose to abort them fast to unblock suspend/resume, > suspend/resume shall fail of course, but UFS error handler recovers > PM errors anyways. In the above sequence, does [2] perhaps refer to aborting the SSU command submitted in step [1] (this is not clear to me)? If so, how about breaking the circular waiting cycle as follows: - If it can happen that SSU succeeds after more than scsi_timeout seconds, define a custom timeout handler. From inside the timeout handler, schedule a link check and return BLK_EH_RESET_TIMER. If the link is no longer operational, run the error handler. If the link cannot be recovered by the error handler, fail all pending commands. This will prevent that ufshcd_abort() is called if a SSU command takes longer than expected. See also commit 0dd0dec1677e. - Modify the UFS error handler such that it accepts a context argument. The context argument specifies whether or not the UFS error handler is called from inside a system suspend or system resume handler. If the UFS error handler is called from inside a system suspend or resume callback, skip the lock_system_sleep() and unlock_system_sleep() calls. Thanks, Bart.