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=-10.7 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, NICE_REPLY_A,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=ham 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 CC7C3C432BE for ; Sat, 28 Aug 2021 09:46:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B2C4260EE5 for ; Sat, 28 Aug 2021 09:46:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233682AbhH1Jrn (ORCPT ); Sat, 28 Aug 2021 05:47:43 -0400 Received: from mga06.intel.com ([134.134.136.31]:30512 "EHLO mga06.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230444AbhH1Jrm (ORCPT ); Sat, 28 Aug 2021 05:47:42 -0400 X-IronPort-AV: E=McAfee;i="6200,9189,10089"; a="279094398" X-IronPort-AV: E=Sophos;i="5.84,359,1620716400"; d="scan'208";a="279094398" Received: from fmsmga007.fm.intel.com ([10.253.24.52]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 28 Aug 2021 02:46:52 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.84,359,1620716400"; d="scan'208";a="458084924" Received: from ahunter-desktop.fi.intel.com (HELO [10.237.72.174]) ([10.237.72.174]) by fmsmga007.fm.intel.com with ESMTP; 28 Aug 2021 02:46:48 -0700 Subject: Re: [PATCH v3 16/18] scsi: ufs: Synchronize SCSI and UFS error handling To: Bart Van Assche , "Martin K . Petersen" Cc: linux-scsi@vger.kernel.org, Jaegeuk Kim , Stanley Chu , Can Guo , Asutosh Das , Avri Altman , "James E.J. Bottomley" , Matthias Brugger , Bean Huo , Kiwoong Kim , Keoseong Park References: <20210722033439.26550-1-bvanassche@acm.org> <20210722033439.26550-17-bvanassche@acm.org> From: Adrian Hunter Organization: Intel Finland Oy, Registered Address: PL 281, 00181 Helsinki, Business Identity Code: 0357606 - 4, Domiciled in Helsinki Message-ID: <88e0dc4c-34ff-6d87-fa9f-2fc924f50369@intel.com> Date: Sat, 28 Aug 2021 12:47:20 +0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Firefox/78.0 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <20210722033439.26550-17-bvanassche@acm.org> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org On 22/07/21 6:34 am, Bart Van Assche wrote: > Use the SCSI error handler instead of a custom error handling strategy. > This change reduces the number of potential races in the UFS drivers since > the UFS error handler and the SCSI error handler no longer run concurrently. > > Cc: Adrian Hunter > Cc: Stanley Chu > Cc: Can Guo > Cc: Asutosh Das > Cc: Avri Altman > Signed-off-by: Bart Van Assche > --- Hi There is a deadlock that seems to be related to this patch, because now requests are blocked while the error handler waits on the host_sem. Example: ufshcd_err_handler() races with ufshcd_wl_suspend() for host_sem. ufshcd_wl_suspend() wins the race but now PM requests deadlock: because: scsi_queue_rq() -> scsi_host_queue_ready() -> scsi_host_in_recovery() is FALSE because: scsi_schedule_eh() has done: scsi_host_set_state(shost, SHOST_RECOVERY) == 0 || scsi_host_set_state(shost, SHOST_CANCEL_RECOVERY) == 0) Some questions for thought: Won't any holder of host_sem deadlock if it tries to do SCSI requests and the error handler is waiting on host_sem? Won't runtime resume deadlock if it is initiated by the error handler? Regards Adrian