Received: by 2002:ac0:e350:0:0:0:0:0 with SMTP id g16csp2533209imn; Tue, 2 Aug 2022 06:37:41 -0700 (PDT) X-Google-Smtp-Source: AA6agR7TFO1N3d0+rsOmn63iCh0h+LH2aThWriuA+a0cycx/obTMng2QQrLT0ztAkGTAbRw/XNNM X-Received: by 2002:aa7:941a:0:b0:52d:e57c:cf43 with SMTP id x26-20020aa7941a000000b0052de57ccf43mr2278977pfo.77.1659447460999; Tue, 02 Aug 2022 06:37:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1659447460; cv=none; d=google.com; s=arc-20160816; b=tXzxXRqNfT5et4eJodKUVc3WbZRIriTiRvFlO/V3ZEcyHzXLfEmCcSpPrNOeXcOp+A 3QdTtrRYo9YBXWii0kW0UJGrrTmeFUP67IKOBffd73PpOF7VQUZy0vLxQ5IWqRuPD6cb 3o1O8EOJVqKwiVBLktRj/pBm8t6ZEu7mnB4WIVsYPcXjfvaj4l7Iox2eTw0rthLwBmP2 CKPADFxrvckdCpiYof0v/MrEWAp1LfLtSWq6N01IbiswWygmpJAxTCKSiMQS3CRbSy7j rAocRAKxbAU/AZ9irETcksSZ1pd/v+1NV0KyzUdXwnLvvrUVGbTPPA7pZD1nSW4df2x0 1ZVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject; bh=91KMrBI31v/WKHjeVd0x9OUOZOsFBuPUdnXOunG1JS8=; b=mipwqTczhPvGVJ6AzXZLm9c7vWo+ITAOqknym48E6tQWuOucEeU9NFCOHfcMi0B/E8 B9+ErjWHAS+TAPlcQY+Hbzsd3r9/364q67IOtBXrFfOoP6UXgtnLCJnpBc0VV6K3ywzi cmRs5Yox2t4MDCrHfOCYmCX7Ejx0OZIAIJweDqmdoLxwz7ul6iLZ3HGnnHDD0y4l4tBx 0wq4TfYX5hAx+g7vveH9ihekCYHElN/civXMc+QFugCsYm6sNquKSKFgApW3K1/TmWox 34omhrKn9B8ojUf3fYAOhErDotUJd5uJZ+nYDigR2NgJn+pYORDjV6O2n5HN2VGNWsoE hu6g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id p2-20020a170902b08200b0016ca0533a62si13973719plr.306.2022.08.02.06.37.27; Tue, 02 Aug 2022 06:37:40 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236750AbiHBNdY (ORCPT + 99 others); Tue, 2 Aug 2022 09:33:24 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232569AbiHBNdW (ORCPT ); Tue, 2 Aug 2022 09:33:22 -0400 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 32B8A17A8C; Tue, 2 Aug 2022 06:33:21 -0700 (PDT) X-UUID: bd5af5aef97c4ce797f25be4b413af80-20220802 X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.8,REQID:8bf43c17-354f-4ee3-a470-c1b6138fc2f2,OB:0,LO B:0,IP:0,URL:5,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,RULE:Release_Ham,ACTI ON:release,TS:5 X-CID-META: VersionHash:0f94e32,CLOUDID:133c0f25-a982-4824-82d2-9da3b6056c2a,C OID:IGNORED,Recheck:0,SF:nil,TC:nil,Content:0,EDM:-3,IP:nil,URL:1,File:nil ,QS:nil,BEC:nil,COL:0 X-UUID: bd5af5aef97c4ce797f25be4b413af80-20220802 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 267675943; Tue, 02 Aug 2022 21:33:15 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Tue, 2 Aug 2022 21:33:14 +0800 Received: from [172.21.84.99] (172.21.84.99) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Tue, 2 Aug 2022 21:33:14 +0800 Subject: Re: [PATCH v1] PM-runtime: Check supplier_preactivated before release supplier To: "Rafael J. Wysocki" CC: "Rafael J. Wysocki" , Greg Kroah-Hartman , Linux PM , LKML References: <20220613120755.14306-1-peter.wang@mediatek.com> <12028598.O9o76ZdvQC@kreacher> <90b5f619-2dd6-817b-fe2d-f895be0b5b98@mediatek.com> <7c3ec17e-296f-ab15-6055-fd59a7d8f036@mediatek.com> <5c9a3908-a2c6-76d7-db6d-d762503d640a@mediatek.com> From: Peter Wang Message-ID: <80a67ef6-ea29-5b96-9596-6fbbb34c4961@mediatek.com> Date: Tue, 2 Aug 2022 21:33:14 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset="utf-8"; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 8/2/22 7:01 PM, Rafael J. Wysocki wrote: > On Tue, Aug 2, 2022 at 5:19 AM Peter Wang wrote: >> >>> Hi Rafael, >>> >>> Yes, it is very clear! >>> I miss this important key point that usage_count is always > >>> rpm_active 1. >>> I think this patch could work. >>> >>> Thanks. >>> Peter >>> >>> >>> >>> >> Hi Rafael, >> >> After test with commit ("887371066039011144b4a94af97d9328df6869a2 PM: >> runtime: Fix supplier device management during consumer probe") past weeks, >> The supplier still suspend when consumer is active "after" >> pm_runtime_put_suppliers. >> Do you have any idea about that? > Well, this means that the consumer probe doesn't bump up the > supplier's PM-runtime usage counter as appropriate. > > You need to tell me more about what happens during the consumer probe. > Which driver is this? Hi Rafael, I have the same idea with you. But I still don't know how it could happen. It is upstream ufs driver in scsi system. Here is call flow do_scan_async (process 1)     do_scsi_scan_host         scsi_scan_host_selected             scsi_scan_channel                 __scsi_scan_target                     scsi_probe_and_add_lun                         scsi_alloc_sdev                             slave_alloc     -> setup link                         scsi_add_lun                             slave_configure    -> enable rpm                             scsi_sysfs_add_sdev                                 scsi_autopm_get_device    <- get runtime pm                                 device_add                <- invoke sd_probe in process 2                                 scsi_autopm_put_device    <- put runtime pm, point 1 driver_probe_device (process 2)     __driver_probe_device         pm_runtime_get_suppliers             really_probe                 sd_probe                     scsi_autopm_get_device                <- get runtime pm, point 2                     pm_runtime_set_autosuspend_delay    <- set rpm delay to 2s                     scsi_autopm_put_device                <- put runtime pm         pm_runtime_put_suppliers                        <- (link->rpm_active = 1) After process 1 call scsi_autopm_put_device(point 1) let consumer enter suspend, process 2 call scsi_autopm_get_device(point 2) may have chance resume consumer but not bump up the supplier's PM-runtime usage counter as appropriate. Thanks. Peter