From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp-out2.suse.de (smtp-out2.suse.de [195.135.223.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54A7C2D5C78 for ; Sat, 20 Sep 2025 06:33:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=195.135.223.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758350019; cv=none; b=fvAaIKDYv4cShtZRt1Ehdx0k2J9xfPPvmEne/dVB0eX0j4SwrPhrXjzy9knemDuib+gAqtgcPSngqQ8pRYvzrz/fIWxMdeI+zyoCasUSE6p1rt9eSrd8uzjWoNphN0D6+diN2g/C2kLLBZiFRAB6e7uMW6ca+vTkCjPbn0NEQ/I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1758350019; c=relaxed/simple; bh=eQQ7hAR9nUWaQKK9+1wa0UedrmpZ2j2iHLjutzK58HY=; h=Date:Message-ID:From:To:Cc:Subject:In-Reply-To:References: MIME-Version:Content-Type; b=QiUXQEBEpFJSsceXhxtrNxF5ra6vkqJjMWR6AhMtw83ClALtJWph0DN/869bJKrPXNCzBreljh1Zb05cFVRuO+5kqJ4ZJ9uRB2O+oCOUpg+SIOyMWMh0SEae9JiKxAWB+YuZDwgCTMXSau8BAeh+Y94EkLSTekizUEeVkF5q1jQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de; spf=pass smtp.mailfrom=suse.de; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=tfGpCzEr; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=1K7rWjtv; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b=tfGpCzEr; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b=1K7rWjtv; arc=none smtp.client-ip=195.135.223.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=suse.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=suse.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="tfGpCzEr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="1K7rWjtv"; dkim=pass (1024-bit key) header.d=suse.de header.i=@suse.de header.b="tfGpCzEr"; dkim=permerror (0-bit key) header.d=suse.de header.i=@suse.de header.b="1K7rWjtv" Received: from imap1.dmz-prg2.suse.org (imap1.dmz-prg2.suse.org [IPv6:2a07:de40:b281:104:10:150:64:97]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by smtp-out2.suse.de (Postfix) with ESMTPS id 6849D1F7C7; Sat, 20 Sep 2025 06:33:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1758350015; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ARoLZetUoV/xoy3KPCCrxgqpJg/9aMXXpwF6+HXIJXc=; b=tfGpCzEr92hc15Fv312tFVzyk2eCFsIW2PTwZ4J23rIFj2jDPo8IJr18AwfUDPQteOHDTH iH6NBud80/TSFD/DC9Mv8YyNwZVwB6sQSBrULhUkpBbkfZkwQU1jlQYLZh1EhpID4wKPLj ABRLkbUO0YrRJM8NlprsHivd9xhrOQ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1758350015; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ARoLZetUoV/xoy3KPCCrxgqpJg/9aMXXpwF6+HXIJXc=; b=1K7rWjtvRR98Dh5/Q8UuO0dS3B33cK7APPZhEPtRbLMfwHlHnm1sNrdfwWr3DRi7YXAVaB 32bk8kEzMCPbvRCg== Authentication-Results: smtp-out2.suse.de; dkim=pass header.d=suse.de header.s=susede2_rsa header.b=tfGpCzEr; dkim=pass header.d=suse.de header.s=susede2_ed25519 header.b=1K7rWjtv DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_rsa; t=1758350015; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ARoLZetUoV/xoy3KPCCrxgqpJg/9aMXXpwF6+HXIJXc=; b=tfGpCzEr92hc15Fv312tFVzyk2eCFsIW2PTwZ4J23rIFj2jDPo8IJr18AwfUDPQteOHDTH iH6NBud80/TSFD/DC9Mv8YyNwZVwB6sQSBrULhUkpBbkfZkwQU1jlQYLZh1EhpID4wKPLj ABRLkbUO0YrRJM8NlprsHivd9xhrOQ0= DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=suse.de; s=susede2_ed25519; t=1758350015; h=from:from:reply-to:date:date:message-id:message-id:to:to:cc:cc: mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=ARoLZetUoV/xoy3KPCCrxgqpJg/9aMXXpwF6+HXIJXc=; b=1K7rWjtvRR98Dh5/Q8UuO0dS3B33cK7APPZhEPtRbLMfwHlHnm1sNrdfwWr3DRi7YXAVaB 32bk8kEzMCPbvRCg== Received: from imap1.dmz-prg2.suse.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by imap1.dmz-prg2.suse.org (Postfix) with ESMTPS id 24A66137D2; Sat, 20 Sep 2025 06:33:35 +0000 (UTC) Received: from dovecot-director2.suse.de ([2a07:de40:b281:106:10:150:64:167]) by imap1.dmz-prg2.suse.org with ESMTPSA id sxc8B79Kzmj5LwAAD6G6ig (envelope-from ); Sat, 20 Sep 2025 06:33:35 +0000 Date: Sat, 20 Sep 2025 08:33:34 +0200 Message-ID: <871po18wg1.wl-tiwai@suse.de> From: Takashi Iwai To: "Rafael J. Wysocki" Cc: Takashi Iwai , linux-pm@vger.kernel.org, Bjorn Helgaas , linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 2/3] PCI: Use PM runtime class macro for the auto cleanup In-Reply-To: References: <20250919163147.4743-1-tiwai@suse.de> <20250919163147.4743-3-tiwai@suse.de> User-Agent: Wanderlust/2.15.9 (Almost Unreal) Emacs/27.2 Mule/6.0 Precedence: bulk X-Mailing-List: linux-pm@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 (generated by SEMI-EPG 1.14.7 - "Harue") Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Spamd-Result: default: False [-3.51 / 50.00]; BAYES_HAM(-3.00)[100.00%]; MID_CONTAINS_FROM(1.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000]; R_DKIM_ALLOW(-0.20)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; NEURAL_HAM_SHORT(-0.20)[-1.000]; MIME_GOOD(-0.10)[text/plain]; MX_GOOD(-0.01)[]; DNSWL_BLOCKED(0.00)[2a07:de40:b281:106:10:150:64:167:received,2a07:de40:b281:104:10:150:64:97:from]; FUZZY_RATELIMITED(0.00)[rspamd.com]; RCVD_VIA_SMTP_AUTH(0.00)[]; MIME_TRACE(0.00)[0:+]; ARC_NA(0.00)[]; TO_DN_SOME(0.00)[]; RECEIVED_SPAMHAUS_BLOCKED_OPENRESOLVER(0.00)[2a07:de40:b281:106:10:150:64:167:received]; RCVD_TLS_ALL(0.00)[]; DKIM_SIGNED(0.00)[suse.de:s=susede2_rsa,suse.de:s=susede2_ed25519]; FROM_EQ_ENVFROM(0.00)[]; FROM_HAS_DN(0.00)[]; RCPT_COUNT_FIVE(0.00)[6]; RCVD_COUNT_TWO(0.00)[2]; TO_MATCH_ENVRCPT_ALL(0.00)[]; DBL_BLOCKED_OPENRESOLVER(0.00)[suse.de:mid,suse.de:dkim,suse.de:email,imap1.dmz-prg2.suse.org:helo,imap1.dmz-prg2.suse.org:rdns]; DKIM_TRACE(0.00)[suse.de:+] X-Spam-Flag: NO X-Spam-Level: X-Rspamd-Queue-Id: 6849D1F7C7 X-Rspamd-Server: rspamd2.dmz-prg2.suse.org X-Rspamd-Action: no action X-Spam-Score: -3.51 On Fri, 19 Sep 2025 20:39:04 +0200, Rafael J. Wysocki wrote: > > On Fri, Sep 19, 2025 at 6:32 PM Takashi Iwai wrote: > > > > Use the newly introduced class macro to simplify the code. > > Also, add the proper error handling for the PM runtime get errors, > > too. > > > > Signed-off-by: Takashi Iwai > > --- > > drivers/pci/pci-sysfs.c | 5 +++-- > > 1 file changed, 3 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c > > index 5eea14c1f7f5..08e5cf2ba73e 100644 > > --- a/drivers/pci/pci-sysfs.c > > +++ b/drivers/pci/pci-sysfs.c > > @@ -1475,8 +1475,9 @@ static ssize_t reset_method_store(struct device *dev, > > return count; > > } > > > > - pm_runtime_get_sync(dev); > > - struct device *pmdev __free(pm_runtime_put) = dev; > > + CLASS(pm_runtime_resume_and_get, pmdev)(dev); > > + if (IS_ERR(pmdev)) > > + return -ENXIO; > > > > if (sysfs_streq(buf, "default")) { > > pci_init_reset_methods(pdev); > > -- > > I've just realized that this patch won't work and the reason why is > that __pm_runtime_resume() returns an error if runtime PM is disabled > for a device, so pmdev above will be an error pointer in that case. Good catch, this was completely forgotten... > One possible approach may be to make pm_runtime_resume_and_get_dev() > return 0 and bump up the usage counter for devices with runtime PM > disabled. Sounds reasonable. thanks, Takashi