mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Bjorn Helgaas <helgaas@kernel.org>
To: "Habil Eren Türker" <habilerenturker@hotmail.com>
Cc: "bhelgaas@google.com" <bhelgaas@google.com>,
	"andriy.shevchenko@intel.com" <andriy.shevchenko@intel.com>,
	"bp@alien8.de" <bp@alien8.de>,
	"dave.hansen@linux.intel.com" <dave.hansen@linux.intel.com>,
	"hpa@zytor.com" <hpa@zytor.com>,
	"mingo@redhat.com" <mingo@redhat.com>,
	"tglx@kernel.org" <tglx@kernel.org>,
	"linux-pci@vger.kernel.org" <linux-pci@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"x86@kernel.org" <x86@kernel.org>
Subject: Re: [PATCH v2 1/4] PCI: Add pci_power_t helper functions
Date: Thu, 19 Nov 2026 11:23:20 -0600	[thread overview]
Message-ID: <20261119172320.GA817954@bhelgaas> (raw)
In-Reply-To: <29fcfa729d7f687f66578781c2e23db9e3367c86.1795097970.git.habilerenturker@hotmail.com>

On Thu, Nov 19, 2026 at 02:35:46PM +0000, Habil Eren Türker wrote:
> Add helper functions to extract, set and compare PCI power
> states in the Power Management Control/Status register.
> 
> This follows the discussion with Andy Shevchenko and
> Bjorn Helgaas in response to:
> 
> "[PATCH] x86/quirks: Cast PCI_D0 to u16 in apple_airport_reset()"
> https://lore.kernel.org/lkml/20261118161559.63617-1-habilerenturker@hotmail.com/

Andy had good comments about the style of references like this, but
IMO if your cover letter includes links to previous versions of the
series, that's enough of a breadcrumb, and previous review comments
and suggestions don't need to be explicitly called out.

https://lore.kernel.org/all/20261112-vfct-regression-v7-0-69b1e0cf45c2@amd.com
is a good example of the previous version link documentation in the
cover letter.

> @@ -2953,4 +2954,31 @@ void pci_uevent_ers(struct pci_dev *pdev, enum  pci_ers_result err_type);
>  	WARN_ONCE(condition, "%s %s: " fmt, \
>  		  dev_driver_string(&(pdev)->dev), pci_name(pdev), ##arg)
>  
> +/* Helper functions for PCI power management */

I think these should go right next to the pci_power_t definitions,
e.g., right after pci_power_name(), so they are easy to find when
using PCI_D0 etc.

> +static inline pci_power_t pci_power_t_get(u32 csr)
> +{
> +	return (pci_power_t __force)FIELD_GET(PCI_PM_CTRL_STATE_MASK, csr);
> +}
> +
> +static inline void pci_power_t_set(u16 *csr, pci_power_t state)
> +{
> +	*csr &= ~PCI_PM_CTRL_STATE_MASK;
> +	*csr |= FIELD_PREP(PCI_PM_CTRL_STATE_MASK, (__force u32)state);

FIELD_MODIFY().

> +}
> +
> +static inline bool pci_power_eq(u32 csr, pci_power_t state)
> +{
> +	return pci_power_t_get(csr) == state;
> +}
> +
> +static inline bool pci_power_gt(u32 csr, pci_power_t state)
> +{
> +	return pci_power_t_get(csr) > state;

I'm not a __bitwise expert, but I'm surprised this works.  I expected
that __bitwise values would not be ordered, so only testing for
equality would be legit.

I do think these should take two pci_power_t values instead of a PMCSR
value and a pci_power_t.  The extra internal conversion on one
argument feels a little bit non-intuitive.

> +}
> +
> +static inline bool pci_power_lt(u32 csr, pci_power_t state)
> +{
> +	return pci_power_t_get(csr) < state;
> +}
> +
>  #endif /* LINUX_PCI_H */
> -- 
> 2.47.3
> 

  parent reply	other threads:[~2026-11-19 17:23 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-19 14:35 [PATCH v2 0/4] " Habil Eren Türker
2026-11-19 14:35 ` [PATCH v2 1/4] " Habil Eren Türker
2026-11-19 16:51   ` andriy.shevchenko
2026-11-19 17:07     ` Bjorn Helgaas
2026-11-19 17:18       ` andriy.shevchenko
2026-11-19 17:23   ` Bjorn Helgaas [this message]
2026-11-19 14:35 ` [PATCH v2 2/4] PCI: Convert pci.c to pci_power_t helpers Habil Eren Türker
2026-11-19 17:09   ` andriy.shevchenko
2026-11-19 14:35 ` [PATCH v2 3/4] PCI: Convert quirks.c " Habil Eren Türker
2026-11-19 17:11   ` andriy.shevchenko
2026-11-19 14:35 ` [PATCH v2 4/4] x86/quirks: Use pci_power_eq() in apple_airport_reset() Habil Eren Türker
2026-11-19 17:14   ` andriy.shevchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261119172320.GA817954@bhelgaas \
    --to=helgaas@kernel.org \
    --cc=andriy.shevchenko@intel.com \
    --cc=bhelgaas@google.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=habilerenturker@hotmail.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@kernel.org \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®