Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3930881pxj; Mon, 24 May 2021 19:06:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5OA1M9glbgDDA6pMaFeVsMyPaZhMhtAVt2aAItXYZUmmZs6iGRSyKbocL5ckI/Bda+Syt X-Received: by 2002:a17:906:6dd0:: with SMTP id j16mr5587780ejt.208.1621908369492; Mon, 24 May 2021 19:06:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621908369; cv=none; d=google.com; s=arc-20160816; b=ricRsgbCmWtaPDuLlR6FC2L1HmfcVxB+O/ihr4NPBcWQK2FDwwMhCdqejUHEWW/Wsb 7h6LajZHGjBODdzahtrnytDDS3Tks28X/iNb2BT4jajX1rZsG8NwLyi6KWQOsggMZb+k bitgCSvzvaUV19wZUcA3I5w1NxsPUeV9E2bR1fWaGcuPuqrvlfrUcPnzi9crT3DjqRnj ZqOsPfB4G4WXYfvWltttzbja0v7vmcjYINyp+TbWNRJkyYbItD+wGB44ku2WASf0PsOY rHDnuuATKu6+ne+KFqaqJqXOs6YYgvRcjGfao4Lm+KeMQscqT1QnnmmKh+cBZ35I7gje dymw== 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=KBM7kBuRBC+qyoViVJY/iIDapiWA7HFCDog78oJunKs=; b=W0RFn+wFwqw3RSWIW/6CSH3JU4sF5KZfRO1mxr0Q0+1BVFPC9kvTS2O4ZeC2mYMMgD lDN7G82K0zWbLBco04XljtcUjeioHSnp7QDkHs9Oy42Mzh7zNfr9txgoP3ZEU613VsU8 ZO62dbsn4Xok0R91btspcLlobiYNpenAMJog4t91cMi/xHEBO9CXv1APzyuw/x2fCUHE oYGKsyijKoF+TwxsG7CMMqLj/ic1Kcjs3DWvWwFhcIKI5oUoDHP1GqfGihzHalJm8YT7 tWlkC5xZrq3BayzZXE4k7A/XvbFwL1espM3xH1xR3T5Watw8/CztPghGJafDYL6lxzXd PBWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=vqrfy6pv; 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 jz3si7486541ejb.9.2021.05.24.19.05.47; Mon, 24 May 2021 19:06:09 -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; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=vqrfy6pv; 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 S230062AbhEYCGC (ORCPT + 99 others); Mon, 24 May 2021 22:06:02 -0400 Received: from so254-9.mailgun.net ([198.61.254.9]:46763 "EHLO so254-9.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230008AbhEYCGB (ORCPT ); Mon, 24 May 2021 22:06:01 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1621908273; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=KBM7kBuRBC+qyoViVJY/iIDapiWA7HFCDog78oJunKs=; b=vqrfy6pvJ7opIjA4q17wC0v1r6fZLPewj8XMXMQX4oOhY6fYaF29F+QGyt1i5l92mk7dvAJm MqR/Rbr5Sh8LtcSKmsOAUZFJoV3Qe71gEqvvPvT5167jL6cars9eEeM3/jVbyaQRYpswaBWs 5s7zlQEYqTBe4vzB8M370vzPCY0= 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-n06.prod.us-west-2.postgun.com with SMTP id 60ac5b285f788b52a56016bf (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 25 May 2021 02:04:24 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 54854C4360C; Tue, 25 May 2021 02:04:24 +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 9E04CC4338A; Tue, 25 May 2021 02:04:23 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 25 May 2021 10:04:23 +0800 From: Can Guo To: Bart Van Assche Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@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 v2 5/6] scsi: ufs: Let host_sem cover the entire system suspend/resume In-Reply-To: <19b44731-1a4f-c88c-58fd-05eca5df2c2e@acm.org> References: <1621846046-22204-1-git-send-email-cang@codeaurora.org> <1621846046-22204-6-git-send-email-cang@codeaurora.org> <19b44731-1a4f-c88c-58fd-05eca5df2c2e@acm.org> Message-ID: <423285a089b7dc3fcfcb169e0a553e8a@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 Hi Bart, On 2021-05-25 00:56, Bart Van Assche wrote: > On 5/24/21 1:47 AM, Can Guo wrote: >> UFS error handling now is doing more than just re-probing, but also >> sending >> scsi cmds, e.g., for clearing UACs, and recovering runtime PM error, >> which >> may change runtime status of scsi devices. To protect system >> suspend/resume >> from being disturbed by error handling, move the host_sem from wl pm >> ops >> to ufshcd_suspend_prepare() and ufshcd_resume_complete(). > > Other SCSI LLDs can perform error handling while system suspend/resume > is in progress. Why can't the UFS driver do this? I don't know about other SCSI LLDs, but UFS error handling is basically doing a re-probe/re-initialization to UFS device. Having UFS error handling running in parallel with system suspend/resume, neither of them will end up well. I didn't design all this, it is just happening, I am trying to fix it and semaphore works well for me. I am really glad to see someone cares about error handling and fix it with better ideas (maybe using WQ_FREEZABLE) later. > > Additionally, please document what the purpose of host_sem is before > making any changes to how host_sem is used. The only documentation I > have found of host_sem is the following: "* @host_sem: semaphore used > to > serialize concurrent contexts". To me that text is less than useful > since semaphores are almost always used to serialize concurrent code. > Sure, host_sem is actually preventing cocurrency happens among any of contexts, such as sysfs access, shutdown, error handling, system suspend/resume and async probe, I will update its message in next version. Thanks, Can Guo. > Thanks, > > Bart.