Intel-XE Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: "Michael J. Ruhl" <michael.j.ruhl@intel.com>
Cc: <platform-driver-x86@vger.kernel.org>,
	<intel-xe@lists.freedesktop.org>, <hansg@kernel.org>,
	<ilpo.jarvinen@linux.intel.com>, <matthew.brost@intel.com>,
	<thomas.hellstrom@linux.intel.com>, <airlied@gmail.com>,
	<simona@ffwll.ch>, <david.e.box@linux.intel.com>,
	<anoop.c.vijay@intel.com>, <badal.nilawar@intel.com>,
	<matthew.d.roper@intel.com>, <james.ausmus@intel.com>,
	<karthik.poosa@intel.com>
Subject: Re: [PATCH v8 03/20] platform/x86/intel/pmt: refactor rc with a return value
Date: Mon, 14 Sep 2026 12:01:28 -0400	[thread overview]
Message-ID: <aqgaWFcJBxZx-M-Q@intel.com> (raw)
In-Reply-To: <20260911201148.1610547-25-michael.j.ruhl@intel.com>

On Fri, Sep 11, 2026 at 01:11:51PM -0700, Michael J. Ruhl wrote:
> Upcoming changes will include possible failures from HW accesses.
> 
> Refactor pmt_crashlog_rw() with a return value.
> 
> Update all necessary usage to use the return code.
> 
> Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>

Reviewed-by: Rodrigo Vivi <rodrigo.vivi@intel.com>

> ---
>  drivers/platform/x86/intel/pmt/crashlog.c | 101 ++++++++++++++++------
>  1 file changed, 74 insertions(+), 27 deletions(-)
> 
> diff --git a/drivers/platform/x86/intel/pmt/crashlog.c b/drivers/platform/x86/intel/pmt/crashlog.c
> index 831cff743803..b6540f3a9a17 100644
> --- a/drivers/platform/x86/intel/pmt/crashlog.c
> +++ b/drivers/platform/x86/intel/pmt/crashlog.c
> @@ -144,27 +144,29 @@ static int pmt_crashlog_rmw(struct crashlog_entry *crashlog, u32 bit, bool set)
>  }
>  
>  /* Read the status register and see if the specified @bit is set */
> -static bool pmt_crashlog_rc(struct crashlog_entry *crashlog, u32 bit)
> +static int pmt_crashlog_rc(struct crashlog_entry *crashlog, u32 bit, bool *state)
>  {
>  	const struct crashlog_status *status = &crashlog->info->status;
>  	u32 reg = readl(crashlog->entry.disc_table + status->offset);
>  
> -	return !!(reg & bit);
> +	*state = !!(reg & bit);
> +
> +	return 0;
>  }
>  
> -static bool pmt_crashlog_complete(struct crashlog_entry *crashlog)
> +static int pmt_crashlog_complete(struct crashlog_entry *crashlog, bool *state)
>  {
>  	/* return current value of the crashlog complete flag */
> -	return pmt_crashlog_rc(crashlog, crashlog->info->status.complete);
> +	return pmt_crashlog_rc(crashlog, crashlog->info->status.complete, state);
>  }
>  
> -static bool pmt_crashlog_disabled(struct crashlog_entry *crashlog)
> +static int pmt_crashlog_disabled(struct crashlog_entry *crashlog, bool *state)
>  {
>  	/* return current value of the crashlog disabled flag */
> -	return pmt_crashlog_rc(crashlog, crashlog->info->status.disabled);
> +	return pmt_crashlog_rc(crashlog, crashlog->info->status.disabled, state);
>  }
>  
> -static bool pmt_crashlog_supported(struct intel_pmt_entry *entry, u32 *crash_type, u32 *version)
> +static int pmt_crashlog_supported(struct intel_pmt_entry *entry, u32 *crash_type, u32 *version)
>  {
>  	u32 discovery_header = readl(entry->disc_table + CONTROL_OFFSET);
>  
> @@ -199,14 +201,14 @@ static int pmt_crashlog_set_execute(struct crashlog_entry *crashlog)
>  	return pmt_crashlog_rmw(crashlog, crashlog->info->control.manual, true);
>  }
>  
> -static bool pmt_crashlog_cleared(struct crashlog_entry *crashlog)
> +static int pmt_crashlog_cleared(struct crashlog_entry *crashlog, bool *state)
>  {
> -	return pmt_crashlog_rc(crashlog, crashlog->info->status.cleared);
> +	return pmt_crashlog_rc(crashlog, crashlog->info->status.cleared, state);
>  }
>  
> -static bool pmt_crashlog_consumed(struct crashlog_entry *crashlog)
> +static int pmt_crashlog_consumed(struct crashlog_entry *crashlog, bool *state)
>  {
> -	return pmt_crashlog_rc(crashlog, crashlog->info->status.consumed);
> +	return pmt_crashlog_rc(crashlog, crashlog->info->status.consumed, state);
>  }
>  
>  static int pmt_crashlog_set_consumed(struct crashlog_entry *crashlog)
> @@ -214,14 +216,14 @@ static int pmt_crashlog_set_consumed(struct crashlog_entry *crashlog)
>  	return pmt_crashlog_rmw(crashlog, crashlog->info->control.consume, true);
>  }
>  
> -static bool pmt_crashlog_error(struct crashlog_entry *crashlog)
> +static int pmt_crashlog_error(struct crashlog_entry *crashlog, bool *state)
>  {
> -	return pmt_crashlog_rc(crashlog, crashlog->info->status.error);
> +	return pmt_crashlog_rc(crashlog, crashlog->info->status.error, state);
>  }
>  
> -static bool pmt_crashlog_rearm(struct crashlog_entry *crashlog)
> +static int pmt_crashlog_rearm(struct crashlog_entry *crashlog, bool *state)
>  {
> -	return pmt_crashlog_rc(crashlog, crashlog->info->status.rearmed);
> +	return pmt_crashlog_rc(crashlog, crashlog->info->status.rearmed, state);
>  }
>  
>  static int pmt_crashlog_set_rearm(struct crashlog_entry *crashlog)
> @@ -236,7 +238,12 @@ static ssize_t
>  clear_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct crashlog_entry *crashlog = dev_get_drvdata(dev);
> -	bool cleared = pmt_crashlog_cleared(crashlog);
> +	bool cleared;
> +	int ret;
> +
> +	ret = pmt_crashlog_cleared(crashlog, &cleared);
> +	if (ret)
> +		return ret;
>  
>  	return sysfs_emit(buf, "%d\n", cleared);
>  }
> @@ -271,7 +278,12 @@ static ssize_t
>  consumed_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct crashlog_entry *crashlog = dev_get_drvdata(dev);
> -	bool consumed = pmt_crashlog_consumed(crashlog);
> +	bool consumed;
> +	int ret;
> +
> +	ret = pmt_crashlog_consumed(crashlog, &consumed);
> +	if (ret)
> +		return ret;
>  
>  	return sysfs_emit(buf, "%d\n", consumed);
>  }
> @@ -281,7 +293,9 @@ consumed_store(struct device *dev, struct device_attribute *attr, const char *bu
>  	       size_t count)
>  {
>  	struct crashlog_entry *crashlog;
> +	bool complete;
>  	bool consumed;
> +	bool disabled;
>  	int ret;
>  
>  	crashlog = dev_get_drvdata(dev);
> @@ -296,10 +310,16 @@ consumed_store(struct device *dev, struct device_attribute *attr, const char *bu
>  
>  	guard(mutex)(&crashlog->control_mutex);
>  
> -	if (pmt_crashlog_disabled(crashlog))
> +	ret = pmt_crashlog_disabled(crashlog, &disabled);
> +	if (ret)
> +		return ret;
> +	if (disabled)
>  		return -EBUSY;
>  
> -	if (!pmt_crashlog_complete(crashlog))
> +	ret = pmt_crashlog_complete(crashlog, &complete);
> +	if (ret)
> +		return ret;
> +	if (!complete)
>  		return -EEXIST;
>  
>  	ret = pmt_crashlog_set_consumed(crashlog);
> @@ -312,9 +332,14 @@ static ssize_t
>  enable_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct crashlog_entry *crashlog = dev_get_drvdata(dev);
> -	bool enabled = !pmt_crashlog_disabled(crashlog);
> +	bool disabled;
> +	int ret;
>  
> -	return sprintf(buf, "%d\n", enabled);
> +	ret = pmt_crashlog_disabled(crashlog, &disabled);
> +	if (ret)
> +		return ret;
> +
> +	return sysfs_emit(buf, "%d\n", !disabled);
>  }
>  
>  static ssize_t
> @@ -343,7 +368,12 @@ static ssize_t
>  error_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct crashlog_entry *crashlog = dev_get_drvdata(dev);
> -	bool error = pmt_crashlog_error(crashlog);
> +	bool error;
> +	int ret;
> +
> +	ret = pmt_crashlog_error(crashlog, &error);
> +	if (ret)
> +		return ret;
>  
>  	return sysfs_emit(buf, "%d\n", error);
>  }
> @@ -353,7 +383,12 @@ static ssize_t
>  rearm_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct crashlog_entry *crashlog = dev_get_drvdata(dev);
> -	int rearmed = pmt_crashlog_rearm(crashlog);
> +	bool rearmed;
> +	int ret;
> +
> +	ret = pmt_crashlog_rearm(crashlog, &rearmed);
> +	if (ret)
> +		return ret;
>  
>  	return sysfs_emit(buf, "%d\n", rearmed);
>  }
> @@ -389,11 +424,15 @@ trigger_show(struct device *dev, struct device_attribute *attr, char *buf)
>  {
>  	struct crashlog_entry *crashlog;
>  	bool trigger;
> +	int ret;
>  
>  	crashlog = dev_get_drvdata(dev);
> -	trigger = pmt_crashlog_complete(crashlog);
>  
> -	return sprintf(buf, "%d\n", trigger);
> +	ret = pmt_crashlog_complete(crashlog, &trigger);
> +	if (ret)
> +		return ret;
> +
> +	return sysfs_emit(buf, "%d\n", trigger);
>  }
>  
>  static ssize_t
> @@ -401,6 +440,8 @@ trigger_store(struct device *dev, struct device_attribute *attr,
>  	      const char *buf, size_t count)
>  {
>  	struct crashlog_entry *crashlog;
> +	bool complete;
> +	bool disabled;
>  	bool trigger;
>  	int ret;
>  
> @@ -413,7 +454,10 @@ trigger_store(struct device *dev, struct device_attribute *attr,
>  	guard(mutex)(&crashlog->control_mutex);
>  
>  	/* if device is currently disabled, return busy */
> -	if (pmt_crashlog_disabled(crashlog))
> +	ret = pmt_crashlog_disabled(crashlog, &disabled);
> +	if (ret)
> +		return ret;
> +	if (disabled)
>  		return -EBUSY;
>  
>  	if (!trigger) {
> @@ -422,7 +466,10 @@ trigger_store(struct device *dev, struct device_attribute *attr,
>  	}
>  
>  	/* we cannot trigger a new crash if one is still pending */
> -	if (pmt_crashlog_complete(crashlog))
> +	ret = pmt_crashlog_complete(crashlog, &complete);
> +	if (ret)
> +		return ret;
> +	if (complete)
>  		return -EEXIST;
>  
>  	ret = pmt_crashlog_set_execute(crashlog);
> -- 
> 2.43.0
> 

  reply	other threads:[~2026-09-14 16:01 UTC|newest]

Thread overview: 52+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-11 20:11 [PATCH v8 00/20] Crescent Island PMT support Michael J. Ruhl
2026-09-11 20:11 ` [PATCH v8 01/20] platform/x86/intel/pmt: complete pcidev to device update Michael J. Ruhl
2026-09-14 16:00   ` Rodrigo Vivi
2026-09-11 20:11 ` [PATCH v8 02/20] platform/x86/intel/pmt: refactor rmw with a return value Michael J. Ruhl
2026-09-14 16:01   ` Rodrigo Vivi
2026-09-11 20:11 ` [PATCH v8 03/20] platform/x86/intel/pmt: refactor rc " Michael J. Ruhl
2026-09-14 16:01   ` Rodrigo Vivi [this message]
2026-09-11 20:11 ` [PATCH v8 04/20] platform/x86/intel/pmt: Add register access callbacks Michael J. Ruhl
2026-09-14 16:03   ` Rodrigo Vivi
2026-09-14 21:05     ` Ruhl, Michael J
2026-09-11 20:11 ` [PATCH v8 05/20] platform/x86/intel/pmt: Do not remap when using callbacks Michael J. Ruhl
2026-09-11 20:26   ` sashiko-bot
2026-09-14 16:06     ` Rodrigo Vivi
2026-09-14 21:16       ` Ruhl, Michael J
2026-09-14 21:23         ` Rodrigo Vivi
2026-09-11 20:11 ` [PATCH v8 06/20] drm/xe/vsec: Do not register BMG PMT for VF Michael J. Ruhl
2026-09-14 16:07   ` Rodrigo Vivi
2026-09-14 21:04     ` Ruhl, Michael J
2026-09-14 21:15       ` Rodrigo Vivi
2026-09-14 21:35         ` Ruhl, Michael J
2026-09-11 20:11 ` [PATCH v8 07/20] drm/xe/vsec: Correct locking order Michael J. Ruhl
2026-09-14 16:07   ` Rodrigo Vivi
2026-09-14 21:33     ` Ruhl, Michael J
2026-09-16 13:10       ` Rodrigo Vivi
2026-09-11 20:11 ` [PATCH v8 08/20] drm/xe/vsec: Use correct pm state get Michael J. Ruhl
2026-09-14 16:08   ` Rodrigo Vivi
2026-09-11 20:11 ` [PATCH v8 09/20] drm/xe/vsec: Add DOC text for VSEC Michael J. Ruhl
2026-09-14 16:09   ` Rodrigo Vivi
2026-09-11 20:11 ` [PATCH v8 10/20] drm/xe/vsec: Support possible hotplug exit Michael J. Ruhl
2026-09-14 16:10   ` Rodrigo Vivi
2026-09-11 20:11 ` [PATCH v8 11/20] drm/xe/vsec: Refactor BattleMage PMT defines Michael J. Ruhl
2026-09-14 16:11   ` Rodrigo Vivi
2026-09-11 20:12 ` [PATCH v8 12/20] drm/xe/vsec: Update VSEC probe order Michael J. Ruhl
2026-09-14 16:12   ` Rodrigo Vivi
2026-09-14 21:01     ` Ruhl, Michael J
2026-09-11 20:12 ` [PATCH v8 13/20] drm/xe/vsec: Add base_offset to allow for more flexibilty Michael J. Ruhl
2026-09-14 16:12   ` Rodrigo Vivi
2026-09-11 20:12 ` [PATCH v8 14/20] drm/xe/vsec: Support Crescent Island PMT Michael J. Ruhl
2026-09-11 20:12 ` [PATCH v8 15/20] drm/xe/vsec: Crescent Island PMT decode Michael J. Ruhl
2026-09-14 16:13   ` Rodrigo Vivi
2026-09-11 20:12 ` [PATCH v8 16/20] drm/xe/vsec: Crescent Island PMT callbacks Michael J. Ruhl
2026-09-14 16:14   ` Rodrigo Vivi
2026-09-11 20:12 ` [PATCH v8 17/20] drm/xe/vsec: Support late bind fw information Michael J. Ruhl
2026-09-11 20:31   ` sashiko-bot
2026-09-14 15:58   ` Rodrigo Vivi
2026-09-14 21:15     ` Ruhl, Michael J
2026-09-15 13:14     ` Ruhl, Michael J
2026-09-11 20:12 ` [PATCH v8 18/20] drm/xe/vsec: Add PMT GUID internal access Michael J. Ruhl
2026-09-11 20:12 ` [PATCH v8 19/20] drm/xe/vsec: Update PMT " Michael J. Ruhl
2026-09-11 20:12 ` [PATCH v8 20/20] drm/xe/vsec: Refactor platform check Michael J. Ruhl
2026-09-11 20:43 ` ✗ CI.checkpatch: warning for Crescent Island PMT support (rev10) Patchwork
2026-09-11 20:44 ` ✗ CI.KUnit: failure " Patchwork

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=aqgaWFcJBxZx-M-Q@intel.com \
    --to=rodrigo.vivi@intel.com \
    --cc=airlied@gmail.com \
    --cc=anoop.c.vijay@intel.com \
    --cc=badal.nilawar@intel.com \
    --cc=david.e.box@linux.intel.com \
    --cc=hansg@kernel.org \
    --cc=ilpo.jarvinen@linux.intel.com \
    --cc=intel-xe@lists.freedesktop.org \
    --cc=james.ausmus@intel.com \
    --cc=karthik.poosa@intel.com \
    --cc=matthew.brost@intel.com \
    --cc=matthew.d.roper@intel.com \
    --cc=michael.j.ruhl@intel.com \
    --cc=platform-driver-x86@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=thomas.hellstrom@linux.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