intel-xe.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Raag Jadav <raag.jadav@intel.com>
Cc: <lucas.demarchi@intel.com>, <intel-xe@lists.freedesktop.org>,
	<riana.tauro@intel.com>, <heikki.krogerus@linux.intel.com>
Subject: Re: [PATCH v2] drm/xe/i2c: Introduce xe_i2c_present()
Date: Sun, 17 Aug 2025 12:28:44 -0400	[thread overview]
Message-ID: <aKIDPDLicQvIEgI0@intel.com> (raw)
In-Reply-To: <20250814091845.1356135-1-raag.jadav@intel.com>

On Thu, Aug 14, 2025 at 02:48:45PM +0530, Raag Jadav wrote:
> In preparation of wider usecases which require checking for I2C
> controller presence, introduce xe_i2c_present() helper.
> 
> v2: Doc fix (Riana)
> 
> Suggested-by: Riana Tauro <riana.tauro@intel.com>
> Signed-off-by: Raag Jadav <raag.jadav@intel.com>
> Reviewed-by: Heikki Krogerus <heikki.krogerus@linux.intel.com>
> Reviewed-by: Riana Tauro <riana.tauro@intel.com>

pushed to drm-xe-next

Thanks for the patch and reviews

> ---
>  drivers/gpu/drm/xe/xe_i2c.c | 18 ++++++++++++++++--
>  drivers/gpu/drm/xe/xe_i2c.h |  2 ++
>  2 files changed, 18 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/xe/xe_i2c.c b/drivers/gpu/drm/xe/xe_i2c.c
> index bc7dc2099470..044dda517b7c 100644
> --- a/drivers/gpu/drm/xe/xe_i2c.c
> +++ b/drivers/gpu/drm/xe/xe_i2c.c
> @@ -146,6 +146,20 @@ static void xe_i2c_unregister_adapter(struct xe_i2c *i2c)
>  	fwnode_remove_software_node(i2c->adapter_node);
>  }
>  
> +/**
> + * xe_i2c_present - I2C controller is present and functional
> + * @xe: xe device instance
> + *
> + * Check whether the I2C controller is present and functioning with valid
> + * endpoint cookie.
> + *
> + * Return: %true if present, %false otherwise.
> + */
> +bool xe_i2c_present(struct xe_device *xe)
> +{
> +	return xe->i2c && xe->i2c->ep.cookie == XE_I2C_EP_COOKIE_DEVICE;
> +}
> +
>  /**
>   * xe_i2c_irq_handler: Handler for I2C interrupts
>   * @xe: xe device instance
> @@ -230,7 +244,7 @@ void xe_i2c_pm_suspend(struct xe_device *xe)
>  {
>  	struct xe_mmio *mmio = xe_root_tile_mmio(xe);
>  
> -	if (!xe->i2c || xe->i2c->ep.cookie != XE_I2C_EP_COOKIE_DEVICE)
> +	if (!xe_i2c_present(xe))
>  		return;
>  
>  	xe_mmio_rmw32(mmio, I2C_CONFIG_PMCSR, PCI_PM_CTRL_STATE_MASK, (__force u32)PCI_D3hot);
> @@ -241,7 +255,7 @@ void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold)
>  {
>  	struct xe_mmio *mmio = xe_root_tile_mmio(xe);
>  
> -	if (!xe->i2c || xe->i2c->ep.cookie != XE_I2C_EP_COOKIE_DEVICE)
> +	if (!xe_i2c_present(xe))
>  		return;
>  
>  	if (d3cold)
> diff --git a/drivers/gpu/drm/xe/xe_i2c.h b/drivers/gpu/drm/xe/xe_i2c.h
> index b767ed8ce52b..ecd5f10358e2 100644
> --- a/drivers/gpu/drm/xe/xe_i2c.h
> +++ b/drivers/gpu/drm/xe/xe_i2c.h
> @@ -49,11 +49,13 @@ struct xe_i2c {
>  
>  #if IS_ENABLED(CONFIG_I2C)
>  int xe_i2c_probe(struct xe_device *xe);
> +bool xe_i2c_present(struct xe_device *xe);
>  void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl);
>  void xe_i2c_pm_suspend(struct xe_device *xe);
>  void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold);
>  #else
>  static inline int xe_i2c_probe(struct xe_device *xe) { return 0; }
> +static inline bool xe_i2c_present(struct xe_device *xe) { return false; }
>  static inline void xe_i2c_irq_handler(struct xe_device *xe, u32 master_ctl) { }
>  static inline void xe_i2c_pm_suspend(struct xe_device *xe) { }
>  static inline void xe_i2c_pm_resume(struct xe_device *xe, bool d3cold) { }
> -- 
> 2.34.1
> 

      parent reply	other threads:[~2025-08-17 16:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-14  9:18 [PATCH v2] drm/xe/i2c: Introduce xe_i2c_present() Raag Jadav
2025-08-14  9:26 ` ✓ CI.KUnit: success for drm/xe/i2c: Introduce xe_i2c_present() (rev2) Patchwork
2025-08-14 10:49 ` ✓ Xe.CI.BAT: " Patchwork
2025-08-14 12:05 ` ✗ Xe.CI.Full: failure " Patchwork
2025-08-17 16:28 ` Rodrigo Vivi [this message]

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=aKIDPDLicQvIEgI0@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=lucas.demarchi@intel.com \
    --cc=raag.jadav@intel.com \
    --cc=riana.tauro@intel.com \
    /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;
as well as URLs for NNTP newsgroup(s).