Received: by 2002:a05:6a10:9848:0:0:0:0 with SMTP id x8csp414993pxf; Wed, 10 Mar 2021 08:43:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJyym9UTkWhuAaAHCHAavQ+9C2bG6oKzQu9IdqWwz9gkMiafaHxFU1f77au2r9pTa3/sdud4 X-Received: by 2002:a17:906:a443:: with SMTP id cb3mr4599444ejb.542.1615394636307; Wed, 10 Mar 2021 08:43:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1615394636; cv=none; d=google.com; s=arc-20160816; b=YQcaaQ6gmKZgPM48+zeh9/YtSHVvbSefdJ8cgDOq4DxIbxvI2GMxrdgE0SvjIyK+Ih vAhqthREYoMun4gOMhOjXr0q3RX/7tB6huxbL45cfBkzIs2+oa8XlWyir5PpLjYiathk lLXlFczP4e9hjEcab5XskfNKbXhBCc4O8oiP8pOnUL61meAgOzmKoLl4LnoAxdNLj2U5 DpwMPE+L78+BqHAJ14jtRLhGPpUGu0cS9YW9FtFjMg7WYn0zrVOu+thAEVfwbtz77Wi/ v3/4S9IazB5cvTCFQ+JiHveb5yHiLY/dSMKpWZGRsXNpMfLVm4yfIoRHfB2tbr7zTlej aT4Q== 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:dmarc-filter:sender:dkim-signature; bh=A3hXmK2V9BzYBLeUgSG9YZi0trl61aWRPGcB/gnH5c4=; b=jN7IRQ4hhp0bmZh5GGN1aqPI5SPCJonSqRAH+gaYTs6M7kRaVib+Mq6YhLDKguC1uY wKfMQ61kXcprvtEjoU4dCymUQ9/Tl1iHbA7+oGwwhMaa3gb+0ClTWdOzhaYuiRE0IOQy t+Jto0o8F2sK0p9lyTxrc3+DAnDlH/CaCQowV5YGFZ2fCY276HP/HaM0qXjW+6vg++B1 BppC+YtXzEwozoEE4kFuR7GJ9D/4MXsZNdbeQ0EsqhlU2EG9L7SBxRdFc1V6oCbdQTEJ mgSJHP+uknJnIzJFXjYkoTfPb7ucmhAgGTAMjrP+AIF4C3+6kDrTssY3zigJNXao/SrJ +sig== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=kR7P6PUH; 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 ce10si4196336ejb.123.2021.03.10.08.43.32; Wed, 10 Mar 2021 08:43:56 -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=kR7P6PUH; 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 S230477AbhCJQk0 (ORCPT + 99 others); Wed, 10 Mar 2021 11:40:26 -0500 Received: from m42-2.mailgun.net ([69.72.42.2]:14335 "EHLO m42-2.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232091AbhCJQkG (ORCPT ); Wed, 10 Mar 2021 11:40:06 -0500 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1615394406; h=Content-Transfer-Encoding: Content-Type: In-Reply-To: MIME-Version: Date: Message-ID: From: References: Cc: To: Subject: Sender; bh=A3hXmK2V9BzYBLeUgSG9YZi0trl61aWRPGcB/gnH5c4=; b=kR7P6PUHZdAM0yn3TdPsXHJxpR+2s0x/gA0eyBWRReB84Zx0y6VQ3jwMk2ZXWcXlqDwz8p8g fRHNgTb36fcruIznomIJlzAOuKMRoLeRn6gPo3gmtU3WHuZXRFhoPH5o0zgL4OANsWZCEiki XmXZQ9FRLOoxpaG/N1Xm/1FpGKI= X-Mailgun-Sending-Ip: 69.72.42.2 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-n03.prod.us-west-2.postgun.com with SMTP id 6048f65c0c7cf0f56c766969 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Wed, 10 Mar 2021 16:39:56 GMT Sender: asutoshd=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 899ABC4346D; Wed, 10 Mar 2021 16:39:55 +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, NICE_REPLY_A,SPF_FAIL autolearn=no autolearn_force=no version=3.4.0 Received: from [192.168.8.168] (cpe-70-95-149-85.san.res.rr.com [70.95.149.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: asutoshd) by smtp.codeaurora.org (Postfix) with ESMTPSA id 10C6EC433C6; Wed, 10 Mar 2021 16:39:51 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 10C6EC433C6 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=asutoshd@codeaurora.org Subject: Re: [PATCH v10 1/2] scsi: ufs: Enable power management for wlun To: Alan Stern Cc: Bart Van Assche , Adrian Hunter , "Rafael J. Wysocki" , cang@codeaurora.org, "Martin K. Petersen" , "open list:TARGET SUBSYSTEM" , linux-arm-msm , Alim Akhtar , Avri Altman , "James E.J. Bottomley" , Krzysztof Kozlowski , Stanley Chu , Andy Gross , Bjorn Andersson , Steven Rostedt , Ingo Molnar , Matthias Brugger , Kiwoong Kim , Bean Huo , Lee Jones , Wei Yongjun , Dinghao Liu , "Gustavo A. R. Silva" , Tomas Winkler , Jaegeuk Kim , Satya Tangirala , open list , "moderated list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , "open list:ARM/SAMSUNG S3C, S5P AND EXYNOS ARM ARCHITECTURES" , "moderated list:UNIVERSAL FLASH STORAGE HOST CONTROLLER DRIVER..." , Linux-PM mailing list References: <0576d6eae15486740c25767e2d8805f7e94eb79d.1614725302.git.asutoshd@codeaurora.org> <85086647-7292-b0a2-d842-290818bd2858@intel.com> <6e98724d-2e75-d1fe-188f-a7010f86c509@codeaurora.org> <20210306161616.GC74411@rowland.harvard.edu> <2bd90336-18a9-9acd-5abb-5b52b27fc535@codeaurora.org> <20210310031438.GB203516@rowland.harvard.edu> <6b985880-f23a-adb3-8b7a-7ee1b56e6fa7@codeaurora.org> <20210310162730.GB221857@rowland.harvard.edu> From: "Asutosh Das (asd)" Message-ID: Date: Wed, 10 Mar 2021 08:39:51 -0800 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.7.0 MIME-Version: 1.0 In-Reply-To: <20210310162730.GB221857@rowland.harvard.edu> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 3/10/2021 8:27 AM, Alan Stern wrote: > On Tue, Mar 09, 2021 at 08:04:53PM -0800, Asutosh Das (asd) wrote: >> On 3/9/2021 7:14 PM, Alan Stern wrote: >>> On Tue, Mar 09, 2021 at 07:04:34PM -0800, Asutosh Das (asd) wrote: >>>> Hello >>>> I & Can (thanks CanG) debugged this further: >>>> >>>> Looks like this issue can occur if the sd probe is asynchronous. >>>> >>>> Essentially, the sd_probe() is done asynchronously and driver_probe_device() >>>> invokes pm_runtime_get_suppliers() before invoking sd_probe(). >>>> >>>> But scsi_probe_and_add_lun() runs in a separate context. >>>> So the scsi_autopm_put_device() invoked from scsi_scan_host() context >>>> reduces the link->rpm_active to 1. And sd_probe() invokes >>>> scsi_autopm_put_device() and starts a timer. And then driver_probe_device() >>>> invoked from __device_attach_async_helper context reduces the >>>> link->rpm_active to 1 thus enabling the supplier to suspend before the >>>> consumer suspends. >>> >>>> I don't see a way around this. Please let me know if you >>>> (@Alan/@Bart/@Adrian) have any thoughts on this. >>> >>> How about changing the SCSI core so that it does a runtime_get before >>> starting an async probe, and the async probe routine does a >>> runtime_put when it is finished? In other words, don't allow a device >>> to go into runtime suspend while it is waiting to be probed. >>> >>> I don't think that would be too intrusive. >>> >>> Alan Stern >>> >> >> Hi Alan >> Thanks for the suggestion. >> >> Am trying to understand: >> >> Do you mean something like this: >> >> int scsi_sysfs_add_sdev(struct scsi_device *sdev) >> { >> >> scsi_autopm_get_device(sdev); >> pm_runtime_get_noresume(&sdev->sdev_gendev); >> [...] >> scsi_autopm_put_device(sdev); >> [...] >> } >> >> static int sd_probe(struct device *dev) >> { >> [...] >> pm_runtime_put_noidle(dev); >> scsi_autopm_put_device(sdp); >> [...] >> } >> >> This may work (I'm limited by my imagination in scsi layer :) ). > > I'm not sure about this. To be honest, I did not read the entirety of > your last message; it had way too much detail. THere's a time and place > for that, but when you're brainstorming to figure out the underlying > cause of a problem and come up with a strategy to fix it, you want to > concentrate on the overall picture, not the details. > > As I understand the situation, you've get a SCSI target with multiple > logical units, let's say A and B, and you need to make sure that A never > goes into runtime suspend unless B is already suspended. In other > words, B always has to suspend before A and resume after A. > > To do this, you register a device link with A as the supplier and B as > the consumer. Then the PM core takes care of the ordering for you. > > But I don't understand when you set up the device link. If the timing > is wrong then, thanks to async SCSI probing, you may have a situation > where A is registered before B and before the link is set up. Then > there's temporarily nothing to stop A from suspending before B. > > You also need to prevent each device from suspending before it is > probed. That's the easy part I was trying to address before (although > it may not be so easy if the drivers are in loadable modules and not > present in the kernel). > > You need to think through these issues before proposing actual changes. > >> But the pm_runtime_put_noidle() would have to be added to all registered >> scsi_driver{}, perhaps? Or may be I can check for sdp->type? > > Like this; it's too early to worry about this sort of thing. > > Alan Stern > Hi Alan Thanks. Understood. I will check the details and see if I can come up with something. I'll propose an alternate fix otherwise and drop this change altogether. Thanks! -asd -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, Linux Foundation Collaborative Project