Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3269278pxv; Mon, 28 Jun 2021 00:19:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyr9cLmEPfMcTS1wTziZiEIWGwUpZ0eMI3kqysVFyWQC2gvw9fyXt9JbWnsDQbaVaeoF472 X-Received: by 2002:a92:d6cd:: with SMTP id z13mr16944357ilp.175.1624864750454; Mon, 28 Jun 2021 00:19:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1624864750; cv=none; d=google.com; s=arc-20160816; b=LpkA3Lm+GGxlILpE7Ipdt8VTypScOryLoslDdRKqYc0slsqW2/9TKcz3cI0sMRd46K /3fFls1AnJ99B9NswnTj27oXtR3xNjNNA2Jc04c8MY3Q1YsS7YQxlO0Ok1MynaSnxDt1 3LXbyHOgnLWxAvYb+GhHfm2qDIhW2FHRnLHXlPyyU9bkOlWIEVxWQjENL0ADXB9afwo/ jeFNzUFLytOKGqJ0DZIRAf/yFsrzziUjul63ulaguslOgGL9s8/FvNjGTGx4NrhWpOJy o2HASoEGMCczYD5wfdclBzrPW2kv76H6YSaycTQv6aP/QJ56bfXcAtobsUTcwdKwahzw KLUg== 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=uKsM4OsjoQR+ZWj/WMZSOh24CzDj0Tz1OAP3ZDdL3QE=; b=dqtGmxa/JI+IN6ZysHB852iClP2l/yFviJFgEcTzAzNICLmhsjwvQHNRDxoYRGTz0r KZBOzCrpXe+K7rOuHOKsRq1BHmISa0O1zpp6vIGkfr5Y8Cy0/E3F0DWzannXdg7jF6Ij 5jnkDkR0FxDFdvh8LRSSCs3hxcTbU8iQcD+u1x668YG2dVsAZj6AKoMvCRlJaVmlXb4c X695WiF/NraokZ0cGxHLMCfwSVnpUQXSUhaWJXZPO2Bw05XN4EypYMuvcm7xcGgP7tQx a/2ENeKWCrHiVbvkYgDGzieaSdo0dmjbA3GKzMdpLpnjxj6qMrjf5nLy6CMRW4YAvZwO hzLg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=DlyrcwaN; 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 c26si3870116ioo.54.2021.06.28.00.18.57; Mon, 28 Jun 2021 00:19:10 -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=DlyrcwaN; 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 S232355AbhF1HTY (ORCPT + 99 others); Mon, 28 Jun 2021 03:19:24 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:59475 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232343AbhF1HTW (ORCPT ); Mon, 28 Jun 2021 03:19:22 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1624864617; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=uKsM4OsjoQR+ZWj/WMZSOh24CzDj0Tz1OAP3ZDdL3QE=; b=DlyrcwaNxsxiam9d1adGtoSvkVeqVR+BSEw7v7hsLpv2gTvVcB4aOqHXy6iMxD1NVbs9lGJ8 zTivr+A9YxkgkDM47JYt+G56QZeF67n7nso4UD+Hr79MhPmWbItntVSo9iwWn3dKzCCmYptY XZW2DY4bGmLdoxeF+YSp7SoMiT4= X-Mailgun-Sending-Ip: 69.72.43.7 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-n04.prod.us-west-2.postgun.com with SMTP id 60d97765d2559fe392630d1c (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 28 Jun 2021 07:16:53 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 471DFC43460; Mon, 28 Jun 2021 07:16:53 +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 4D7FFC4338A; Mon, 28 Jun 2021 07:16:52 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Date: Mon, 28 Jun 2021 15:16:52 +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" , Adrian Hunter , Bean Huo , Stanley Chu , Keoseong Park , "Gustavo A. R. Silva" , Jaegeuk Kim , Kiwoong Kim , Satya Tangirala , open list Subject: Re: [PATCH v4 10/10] scsi: ufs: Apply more limitations to user access In-Reply-To: References: <1624433711-9339-1-git-send-email-cang@codeaurora.org> <1624433711-9339-12-git-send-email-cang@codeaurora.org> <89a3c8bf-bbfc-4a2a-73f0-a0db956fbf0e@acm.org> Message-ID: <0c859144bb1570331853d6eaf441fad9@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-25 06:25, Bart Van Assche wrote: > On 6/23/21 7:23 PM, Can Guo wrote: >> On 2021-06-24 05:51, Bart Van Assche wrote: >>> On 6/23/21 12:35 AM, Can Guo wrote: >>> - During system suspend, user space software is paused before the >>> device >>>   driver freeze callbacks are invoked. Hence, the >>> hba->is_sys_suspended >>>   check can be left out. >> >> is_sys_suspended indicates that system resume failed (power/clk is >> OFF). >> >>> - If a LUN is runtime suspended, it should be resumed if accessed >>> from >>>   user space instead of failing user space accesses. In other words, >>> the >>>   hba->is_wlu_sys_suspended check seems inappropriate to me. >> >> hba->is_wlu_sys_suspended indicates that wl system resume failed, >> device >> is not operational. > > Hi Can, > > Thanks for the clarification. How about converting the above two > answers > into comments inside ufshcd_is_user_access_allowed()? > Sure. > Should ufshcd_is_user_access_allowed() perhaps be called after > ufshcd_rpm_get_sync() instead of before to prevent that the value of > hba->is_sys_suspended or hba->is_wlu_sys_suspended changes after having > been checked and before the UFS device is accessed? > is_sys_suspended and is_wlu_sys_suspended only represent system PM status, not runtime PM status. My understanding is that user threads are frozen before system PM starts, so it does not matter we call ufshcd_is_user_access_allowed() before or after ufshcd_rpm_get_sync(). If my understanding is wrong, then we need to either call lock_system_sleep() in get_user_access() or wrap ufshcd_suspend_prepare/ufshcd_resume_complete() with host_sem. Thanks, Can Guo. > Thanks, > > Bart.