From: Rodrigo Vivi <rodrigo.vivi@intel.com>
To: Karthik Poosa <karthik.poosa@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <anshuman.gupta@intel.com>,
<badal.nilawar@intel.com>, <raag.jadav@intel.com>,
<riana.tauro@intel.com>, <sk.anirban@intel.com>,
<mallesh.koujalagi@intel.com>, <soham.purkait@intel.com>,
<ravi.kishore.koppuravuri@intel.com>
Subject: Re: [PATCH v4 03/10] drm/xe/pcode: Add ordered write batch helper
Date: Wed, 25 Nov 2026 13:29:27 -0500 [thread overview]
Message-ID: <awcpB6s_32zyhNBi@intel.com> (raw)
In-Reply-To: <20261124054811.798763-4-karthik.poosa@intel.com>
On Tue, Nov 24, 2026 at 11:18:04AM +0530, Karthik Poosa wrote:
> Add a pcode helper that issues an ordered sequence of mailbox writes
> while holding the pcode lock, so no other mailbox command can be
> interleaved.
>
> This will be used to write fan tables atomically with respect to other
> pcode users.
The question here is: why do you need this?
What are the odds of this starving and causing timeouts on other critical paths?
The code below itself is right and I'd give my rv-b, but I'm concern
about the overall impact and risks, so we need a very clear and sound 'why'.
Thanks,
Rodrigo.
>
> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com>
> ---
>
> v2:
> - Document partial-failure semantics and lock hold time in kernel-doc.
> - Reword commit message.
> - Return -EINVAL for an empty batch. (Soham)
> - Log the failing batch index, mailbox, data and error. (Soham)
> - Add kernel-doc for struct xe_pcode_write.
>
> drivers/gpu/drm/xe/xe_pcode.c | 39 +++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/xe/xe_pcode.h | 12 +++++++++++
> 2 files changed, 51 insertions(+)
>
> diff --git a/drivers/gpu/drm/xe/xe_pcode.c b/drivers/gpu/drm/xe/xe_pcode.c
> index 266deecbb100..ab796218e737 100644
> --- a/drivers/gpu/drm/xe/xe_pcode.c
> +++ b/drivers/gpu/drm/xe/xe_pcode.c
> @@ -124,6 +124,45 @@ int xe_pcode_write_timeout(struct xe_tile *tile, u32 mbox, u32 data, int timeout
> return err;
> }
>
> +/**
> + * xe_pcode_write_batch - issue pcode writes in order under the mailbox lock
> + * @tile: tile
> + * @writes: mailbox/data pairs to write
> + * @count: number of entries in @writes
> + *
> + * Holds the pcode lock across all writes so no other mailbox command can be
> + * interleaved; the lock may be held for up to @count * PCODE_DEFAULT_TIMEOUT_MS.
> + * Stops at the first failure; earlier writes are not reverted.
> + *
> + * Return: 0 on success, negative error code otherwise.
> + */
> +int xe_pcode_write_batch(struct xe_tile *tile, const struct xe_pcode_write *writes,
> + unsigned int count)
> +{
> + unsigned int i;
> + int err = 0;
> +
> + if (!count)
> + return -EINVAL;
> +
> + mutex_lock(&tile->pcode.lock);
> + for (i = 0; i < count; i++) {
> + u32 data = writes[i].data;
> +
> + err = pcode_mailbox_rw(tile, writes[i].mbox, &data, NULL, PCODE_DEFAULT_TIMEOUT_MS,
> + false, false);
> + if (err) {
> + xe_err(tile_to_xe(tile),
> + "pcode batch write %u/%u failed: mbox 0x%08x data 0x%08x, ret %pe\n",
> + i + 1, count, writes[i].mbox, writes[i].data, ERR_PTR(err));
> + break;
> + }
> + }
> + mutex_unlock(&tile->pcode.lock);
> +
> + return err;
> +}
> +
> int xe_pcode_write64_timeout(struct xe_tile *tile, u32 mbox, u32 data0, u32 data1, int timeout)
> {
> int err;
> diff --git a/drivers/gpu/drm/xe/xe_pcode.h b/drivers/gpu/drm/xe/xe_pcode.h
> index 7e43792b0037..c601a12baba6 100644
> --- a/drivers/gpu/drm/xe/xe_pcode.h
> +++ b/drivers/gpu/drm/xe/xe_pcode.h
> @@ -18,6 +18,16 @@ struct xe_pcode_version {
> u32 engg;
> };
>
> +/**
> + * struct xe_pcode_write - single pcode mailbox write
> + * @mbox: mailbox command
> + * @data: value written to PCODE_DATA0
> + */
> +struct xe_pcode_write {
> + u32 mbox;
> + u32 data;
> +};
> +
> #define PCODE_DEFAULT_TIMEOUT_MS 10
>
> int xe_pcode_init_early(struct xe_tile *tile);
> @@ -28,6 +38,8 @@ int xe_pcode_init_min_freq_table(struct xe_tile *tile, u32 min_gt_freq,
> int xe_pcode_read(struct xe_tile *tile, u32 mbox, u32 *val0, u32 *val1);
> int xe_pcode_write_timeout(struct xe_tile *tile, u32 mbox, u32 val,
> int timeout_ms);
> +int xe_pcode_write_batch(struct xe_tile *tile, const struct xe_pcode_write *writes,
> + unsigned int count);
> int xe_pcode_write64_timeout(struct xe_tile *tile, u32 mbox, u32 data0,
> u32 data1, int timeout);
> int xe_get_pcode_version(struct xe_device *xe, struct xe_pcode_version *version);
> --
> 2.34.1
>
next prev parent reply other threads:[~2026-11-25 19:31 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-24 5:48 [PATCH v4 00/10] drm/xe/hwmon: Add fan control support Karthik Poosa
2026-11-24 5:48 ` [PATCH v4 01/10] drm/xe/hwmon: Initialize fan-control backend and table cache Karthik Poosa
2026-11-24 5:48 ` [PATCH v4 02/10] drm/xe/hwmon: Expose fanN_max Karthik Poosa
2026-11-25 18:26 ` Rodrigo Vivi
2026-11-24 5:48 ` [PATCH v4 03/10] drm/xe/pcode: Add ordered write batch helper Karthik Poosa
2026-11-25 18:29 ` Rodrigo Vivi [this message]
2026-11-26 13:48 ` Poosa, Karthik
2026-11-24 5:48 ` [PATCH v4 04/10] drm/xe/hwmon: Expose pwm[1-3] Karthik Poosa
2026-11-24 5:48 ` [PATCH v4 05/10] drm/xe/hwmon: Expose pwm[1-3]_enable Karthik Poosa
2026-11-24 6:01 ` sashiko-bot
2026-11-25 13:26 ` Poosa, Karthik
2026-11-24 5:48 ` [PATCH v4 06/10] drm/xe/hwmon: Enable fan curve control support Karthik Poosa
2026-11-24 6:02 ` sashiko-bot
2026-11-24 5:48 ` [PATCH v4 07/10] drm/xe/hwmon: Add kernel-doc for fan control Karthik Poosa
2026-11-24 5:53 ` sashiko-bot
2026-11-26 12:33 ` Poosa, Karthik
2026-11-24 5:48 ` [PATCH v4 08/10] drm/xe/hwmon: Preserve fan user table across suspend resume Karthik Poosa
2026-11-24 6:07 ` sashiko-bot
2026-11-26 13:35 ` Poosa, Karthik
2026-11-24 5:48 ` [PATCH v4 09/10] drm/xe/hwmon: Update fan info after late binding Karthik Poosa
2026-11-24 6:11 ` sashiko-bot
2026-11-24 5:48 ` [PATCH v4 10/10] drm/xe/hwmon: Enable fan support for CRI Karthik Poosa
2026-11-25 18:30 ` Rodrigo Vivi
2026-11-24 5:56 ` ✗ CI.KUnit: failure for drm/xe/hwmon: Add fan control support 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=awcpB6s_32zyhNBi@intel.com \
--to=rodrigo.vivi@intel.com \
--cc=anshuman.gupta@intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=raag.jadav@intel.com \
--cc=ravi.kishore.koppuravuri@intel.com \
--cc=riana.tauro@intel.com \
--cc=sk.anirban@intel.com \
--cc=soham.purkait@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