Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp2310711pxa; Mon, 24 Aug 2020 10:33:14 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz5c9o8ImqMO1uIjb08vIKnzp0WJIo4oBctdBD4It7mIqL+GW4d5t2lGwHdrwhLUCta/8RB X-Received: by 2002:a17:906:1a0a:: with SMTP id i10mr6923289ejf.204.1598290394499; Mon, 24 Aug 2020 10:33:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598290394; cv=none; d=google.com; s=arc-20160816; b=AN8Aua1qVtZhoByfdESImozUEs1w3WDe/KTQEI6QF1lThey61LKcBTVxV8T+Tk6Jfs Opfhcw1WNyjhEmrRbB8+1LP6+yRfWYdmfGi/rBWFzyozyLP9ottnYjHEgXv0IYmvemKh T6TL3fwvPOGhdncO41jKBaz7RReAzij43q6RsMcg8sWGCcFzfX8p6K9v4q0wpng7QsdZ srAMyBQsmXpkIqXE268A6K7G2pfxKui9ZC2VlxQv6DKtCHDUPZi1/Dxk6C3wq/5vxwJo 0RddSXyT51Z3l0aE/JX54+AQCNdkNXSgirAsda/3Qz8ZPHG4QfAghQtkPrnwB8+NkrqS gQ3A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from; bh=4BhgnbFlNKhgvfQYPb+YcnnEsS9V3d5es52CQzdmQjI=; b=gHVTc7jKD388187FYSMTPK3oHzc1PI1odFroGfYqbP7dSmv5DZE8pG7tLMO89jbyZL UywfYs5c1t5vPWXLQB9CkGwzZnQi7dpy9VGlrSZuu957nEVxT0aKQMn6kxluby7XfC4z fADs/2n7luXF44OfkEhdeUPSuWT9IygwwcidZ+StoBNP3gc4axOcVm+BWRVYLKu9ajUw YuwO6hxir/zjVJ/fMpV0xDbZIdlcMVVsUxacJB4FQ2AFcK7+EtKEUZszWN4gov5y2XBa Ud+u7QNtGvlhodqkoodpWVurV8NBIgbAVzHmzOnLl+wODyFpRA+GI2guSHliL/VhR7Le ZYOA== ARC-Authentication-Results: i=1; mx.google.com; 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 bk19si7385067ejb.731.2020.08.24.10.32.51; Mon, 24 Aug 2020 10:33:14 -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; 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 S1728486AbgHXRbO (ORCPT + 99 others); Mon, 24 Aug 2020 13:31:14 -0400 Received: from cloudserver094114.home.pl ([79.96.170.134]:52580 "EHLO cloudserver094114.home.pl" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728466AbgHXRbF (ORCPT ); Mon, 24 Aug 2020 13:31:05 -0400 Received: from 89-64-88-199.dynamic.chello.pl (89.64.88.199) (HELO kreacher.localnet) by serwer1319399.home.pl (79.96.170.134) with SMTP (IdeaSmtpServer 0.83.459) id 9706e1a0a736e6e0; Mon, 24 Aug 2020 19:31:02 +0200 From: "Rafael J. Wysocki" To: Alan Stern Cc: Linux PM , LKML , Linux ACPI , Greg Kroah-Hartman , "Rafael J. Wysocki" , Mika Westerberg Subject: Re: [PATCH] PM: sleep: core: Fix the handling of pending runtime resume requests Date: Mon, 24 Aug 2020 19:31:01 +0200 Message-ID: <3393548.q2lFjJrsnI@kreacher> In-Reply-To: <20200824150421.GD329866@rowland.harvard.edu> References: <7969920.MVx1BpXlEM@kreacher> <4922509.6NPD9QEisq@kreacher> <20200824150421.GD329866@rowland.harvard.edu> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Monday, August 24, 2020 5:04:21 PM CEST Alan Stern wrote: > On Mon, Aug 24, 2020 at 03:36:36PM +0200, Rafael J. Wysocki wrote: > > > Furthermore, by the logic used in this patch, the call to > > > pm_wakeup_event() in the original code is also redundant: Any required > > > wakeup event should have been generated when the runtime resume inside > > > pm_runtime_barrer() was carried out. > > > > It should be redundant in the real wakeup event cases, but it may cause > > spurious suspend aborts to occur when there are no real system wakeup > > events. > > > > Actually, the original code is racy with respect to system wakeup events, > > because it depends on the exact time when the runtime-resume starts. Namely, > > if it manages to start before the freezing of pm_wq, the wakeup will be lost > > unless the driver takes care of reporting it, which means that drivers really > > need to do that anyway. And if they do that (which hopefully is the case), the > > pm_wakeup_event() call in the core may be dropped. > > In other words, wakeup events are supposed to be reported at the time > the wakeup request is first noticed, right? That's correct. > We don't want to wait until > a resume or runtime_resume callback runs; thanks to this race the > callback might not run at all if the event isn't reported first. The callback will run, either through the wq or by the pm_runtime_barrier(), but if it runs through the wq, pm_runtime_barrier() will return 0 and pm_wakeup_event() will not called by the core, so it must be called from elsewhere anyway. > Therefore the reasoning behind the original code appears to have been > highly suspect. Indeed. > If there already was a queued runtime-resume request > for the device and the device was wakeup-enabled, the wakeup event > should _already_ have been reported at the time the request was queued. > And we shouldn't rely on it being reported by the runtime-resume > callback routine. Right. > > > This means that the code could be simplified to just: > > > > > > pm_runtime_barrier(dev); > > > > Yes, it could, so I'm going to re-spin the patch with this code simplification > > and updated changelog. > > > > > Will this fix the reported bug? > > > > I think so. > > Okay, we'll see! Fair enough!