linux-cxl.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Richard Cheng" <icheng@nvidia.com>
Cc: linux-cxl@vger.kernel.org
Subject: Re: [PATCH v2] cxl/region: Add cxl_decoder_is_passthrough() helper
Date: Wed, 05 Aug 2026 07:15:37 +0000	[thread overview]
Message-ID: <20260805071538.546561F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260805065935.27837-1-icheng@nvidia.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Medium] `cxl_decoder_is_passthrough()` incorrectly identifies single-target root decoders as passthrough decoders, contradicting the commit message.
--

--- Patch [1]: [PATCH v2] cxl/region: Add cxl_decoder_is_passthrough() helper ---
commit 9b921fd6e2f183466d76ed78181b72b15a45105b
Author: Richard Cheng <icheng@nvidia.com>
cxl/region: Add cxl_decoder_is_passthrough() helper

This commit abstracts the passthrough decoder check into a standalone
helper function. The commit message explicitly notes this is necessary
because checking only for a NULL ->commit() would incorrectly identify
root decoders and DVSEC-emulated endpoint decoders as passthrough.

Link: https://lore.kernel.org/linux-cxl/20260727103743.63343-1-icheng@nvidia.com/

> diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c
> --- a/drivers/cxl/core/region.c
> +++ b/drivers/cxl/core/region.c
[ ... ]
> +/*
> + * A single-dport host-bridge need not publish an HDM decoder capability
> + * when passthrough decode can be assumed. The resulting decoder is a
> + * software-only construct with no registers to program, so it carries no
> + * ->commit() operation, see devm_cxl_add_passthrough_decoder().
> + *
> + * A NULL ->commit() alone does not identify one, it is also NULL for
> + * DVSEC-emulated endpoint decoders. Test the decoder type and target
> + * count as well.
> + */
> +static bool cxl_decoder_is_passthrough(struct cxl_decoder *cxld)
> +{
> +	if (cxld->commit)
> +		return false;
> +
> +	if (!is_switch_decoder(&cxld->dev))
> +		return false;
> +
> +	return to_cxl_switch_decoder(&cxld->dev)->nr_targets <= 1;

[Severity: Medium]
Does this helper correctly exclude root decoders as intended?

The commit message states that root decoders leave ->commit() NULL and
that a future caller testing ->commit() alone would silently include them.
However, looking at is_switch_decoder() in drivers/cxl/core/port.c, it
returns true for root decoders:

bool is_switch_decoder(struct device *dev)
{
        return is_root_decoder(dev) || dev->type == &cxl_decoder_switch_type;
}

Since is_switch_decoder() evaluates to true for root decoders, won't this
function incorrectly return true for single-target root decoders? This
appears to create a misleading abstraction that contradicts the commit
message's claim about ruling out root decoders.

> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260805065935.27837-1-icheng@nvidia.com?part=1

  reply	other threads:[~2026-08-05  7:15 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-08-05  6:59 [PATCH v2] cxl/region: Add cxl_decoder_is_passthrough() helper Richard Cheng
2026-08-05  7:15 ` sashiko-bot [this message]
2026-08-13 13:53 ` Robert Richter

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=20260805071538.546561F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=icheng@nvidia.com \
    --cc=linux-cxl@vger.kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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).