Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp14230786pxu; Mon, 4 Jan 2021 17:09:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwLv539kJr+mypE5AKvFv8LidKFYdDSe6N/FBiDJiTAbcx3MuEQeOiaxeGeSBTM6GxSdCLo X-Received: by 2002:a17:906:d152:: with SMTP id br18mr65372598ejb.297.1609808950562; Mon, 04 Jan 2021 17:09:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1609808950; cv=none; d=google.com; s=arc-20160816; b=kpeIJ+3qN25GiUa+UfaeIQXxetJSxKJgnlTMLiXMyrvjZueUd5B9xVhNhG4A6iefFW +SkAR73mzJr1f2zH/qHZKf1PfO1yDNo9a8815DQQ91t1XSmEXCUCycsajWjNzywWDnRw K01bSMIFDpT+s9mpHRb/UEIxtDtUAtIzSfQJnjP+iO1BnIaUyB1Ta7d/HHGTVZzzxpKy xhiHv9ug/jOZHyIF3eoEOGxNhNqwWsia31aZ3qDAIBvZ7YLCr/v2qGs+JOn0M7XdIHcv WrM2QnDXEz1gT1VBuxlIpi6IqZ5VcOEiIWPkscS87KMVllxJDTCuqz1ggnv9IUj71/YK l6Hg== 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=IUb+uoL2QPaHR3+XZA+O6oy7Xj6ruPwUwYDS5AvtzhE=; b=VJZ2PQV2SISbew04ZwDJEnsVasX1NMNpy5jznmcnPhccOlpmOI8YtfeiCT69ER4hDX QQniPPGFkcuUyh2QVkb+w5xC8sruC2J3QxJtnZT6upxrdJo9bieUwrhc0RF4cr/rpIhw LAbsX4iEMrSNTojXcI0CwMfhqJS0jBHFUkMNbfPWqZMzHbBkTJx5iH6FcnKJ3PuSJyqh U2rYR8Lqyg2LiWYHKIUQe09A0aGyMk93W03jxEJFn7Aq3W1LYiJ0Wk+bmNmzdSdw1sqL TrlxbOykGPhK8vsQ3BYs8I4JzgRdUq2T9qq0ARZd+T9RCGoFcPSUi5WYHMBCZLNxs2dZ TQCg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=fmIURB30; 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 p9si9087614ejx.554.2021.01.04.17.08.47; Mon, 04 Jan 2021 17:09:10 -0800 (PST) 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=fmIURB30; 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 S1727332AbhAEBIP (ORCPT + 99 others); Mon, 4 Jan 2021 20:08:15 -0500 Received: from so254-31.mailgun.net ([198.61.254.31]:47393 "EHLO so254-31.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727148AbhAEBIP (ORCPT ); Mon, 4 Jan 2021 20:08:15 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1609808875; h=Message-ID: References: In-Reply-To: Subject: Cc: To: From: Date: Content-Transfer-Encoding: Content-Type: MIME-Version: Sender; bh=IUb+uoL2QPaHR3+XZA+O6oy7Xj6ruPwUwYDS5AvtzhE=; b=fmIURB30ejkiaY7xtM6MPe8RNJi7fJGQPwiFRmZiXZDu/oP0sPAWoxC/H350ZajPcZ4aL/Bi mC+uDXcORBFndxxETnumHVvE6FeFybIexxBdWvPkEtBEoywWNR8GSd8dhnBFq7O+fHJwpVAk kijLQeRtGcqE6LcjTggPyzrJJYo= X-Mailgun-Sending-Ip: 198.61.254.31 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-east-1.postgun.com with SMTP id 5ff3bbce584481b01ba287e3 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Tue, 05 Jan 2021 01:07:26 GMT Sender: cang=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 4D690C4323B; Tue, 5 Jan 2021 01:07:25 +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 6007AC4346E; Tue, 5 Jan 2021 01:07:24 +0000 (UTC) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Content-Transfer-Encoding: 7bit Date: Tue, 05 Jan 2021 09:07:24 +0800 From: Can Guo To: Bean Huo Cc: asutoshd@codeaurora.org, nguyenb@codeaurora.org, hongwus@codeaurora.org, ziqichen@codeaurora.org, rnayak@codeaurora.org, linux-scsi@vger.kernel.org, kernel-team@android.com, saravanak@google.com, salyzyn@google.com, rjw@rjwysocki.net, Alim Akhtar , Avri Altman , "James E.J. Bottomley" , "Martin K. Petersen" , Stanley Chu , Bean Huo , Nitin Rawat , Adrian Hunter , Bart Van Assche , Satya Tangirala , open list Subject: Re: [PATCH 2/2] scsi: ufs: Protect PM ops and err_handler from user access through sysfs In-Reply-To: <80a15afab8024d0b61d312b57585c9322ac91958.camel@gmail.com> References: <1609595975-12219-1-git-send-email-cang@codeaurora.org> <1609595975-12219-3-git-send-email-cang@codeaurora.org> <80a15afab8024d0b61d312b57585c9322ac91958.camel@gmail.com> Message-ID: <7d49c1dfc3f648c484076f3c3a7f4e1e@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-01-05 04:05, Bean Huo wrote: > On Sat, 2021-01-02 at 05:59 -0800, Can Guo wrote: >> + * @shutting_down: flag to check if shutdown has been invoked > > I am not much sure if this flag is need, since once PM going in > shutdown path, what will be returnded by pm_runtime_get_sync()? > > If pm_runtime_get_sync() will fail, just check its return. > That depends. During/after shutdown, for UFS's case only, pm_runtime_get_sync(hba->dev) will most likely return 0, because it is already RUNTIME_ACTIVE, pm_runtime_get_sync() will directly return 0... meaning you cannot count on it. Check Stanley's change - https://lore.kernel.org/patchwork/patch/1341389/ Can Guo. > Hi Rafael > would you please help us confirm this? > > thanks, > Bean > > >> + * @host_sem: semaphore used to serialize concurrent contexts >> * @eh_wq: Workqueue that eh_work works on >> * @eh_work: Worker to handle UFS errors that require s/w attention >> * @eeh_work: Worker to handle exception events >> @@ -751,7 +753,8 @@ struct ufs_hba { >> u32 intr_mask; >> u16 ee_ctrl_mask; >> bool is_powered; >> - struct semaphore eh_sem; >> + bool shutting_down; >> + struct semaphore host_sem;