From: Kishore Batta <kishore.batta@oss.qualcomm.com>
To: Jonathan Corbet <corbet@lwn.net>,
Shuah Khan <skhan@linuxfoundation.org>,
Jeff Hugo <jeff.hugo@oss.qualcomm.com>,
Carl Vanderlip <carl.vanderlip@oss.qualcomm.com>,
Oded Gabbay <ogabbay@kernel.org>,
Manivannan Sadhasivam <mani@kernel.org>,
andersson@kernel.org
Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org,
mhi@lists.linux.dev,
Kishore Batta <kishore.batta@oss.qualcomm.com>
Subject: [PATCH v4 4/9] bus: mhi: Centralize firmware image table selection at probe time
Date: Thu, 19 Mar 2026 12:01:44 +0530 [thread overview]
Message-ID: <20260319-sahara_protocol_new_v2-v4-4-47ad79308762@oss.qualcomm.com> (raw)
In-Reply-To: <20260319-sahara_protocol_new_v2-v4-0-47ad79308762@oss.qualcomm.com>
The Sahara driver currently selects firmware image tables using
scattered, device specific conditionals in the probe path, making the
logic harder to follow and extend.
Refactor firmware image table selection into a single, explicit probe-time
mechanism by introducing a variant table that captures device matching,
firmware image tables, firmware folder names, and streaming behavior in
one place.
This centralizes device specific decisions, simplifies the probe logic,
and avoids ad-hoc conditionals while preserving the existing behavior for
all supported AIC devices.
Signed-off-by: Kishore Batta <kishore.batta@oss.qualcomm.com>
---
drivers/bus/mhi/sahara/sahara.c | 66 ++++++++++++++++++++++++++++++++++++-----
1 file changed, 58 insertions(+), 8 deletions(-)
diff --git a/drivers/bus/mhi/sahara/sahara.c b/drivers/bus/mhi/sahara/sahara.c
index e3499977e7c6b53bc624a8eb00d0636f2ea63307..8f1c0d72066c0cf80c09d78bfc51df2e482133b9 100644
--- a/drivers/bus/mhi/sahara/sahara.c
+++ b/drivers/bus/mhi/sahara/sahara.c
@@ -180,6 +180,16 @@ struct sahara_context {
u32 read_data_length;
bool is_mem_dump_mode;
bool non_streaming;
+ const char *fw_folder;
+};
+
+struct sahara_variant {
+ const char *match;
+ bool match_is_chan;
+ const char * const *image_table;
+ size_t table_size;
+ const char *fw_folder;
+ bool non_streaming;
};
static const char * const aic100_image_table[] = {
@@ -224,11 +234,50 @@ static const char * const aic200_image_table[] = {
[78] = "qcom/aic200/pvs.bin",
};
+static const struct sahara_variant sahara_variants[] = {
+ {
+ .match = "AIC100",
+ .match_is_chan = false,
+ .image_table = aic100_image_table,
+ .table_size = ARRAY_SIZE(aic100_image_table),
+ .fw_folder = "aic100",
+ .non_streaming = true,
+ },
+ {
+ .match = "AIC200",
+ .match_is_chan = false,
+ .image_table = aic200_image_table,
+ .table_size = ARRAY_SIZE(aic200_image_table),
+ .fw_folder = "aic200",
+ .non_streaming = false,
+ }
+};
+
static bool is_streaming(struct sahara_context *context)
{
return !context->non_streaming;
}
+static const struct sahara_variant *sahara_select_variant(struct mhi_device *mhi_dev,
+ const struct mhi_device_id *id)
+{
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(sahara_variants); i++) {
+ const struct sahara_variant *v = &sahara_variants[i];
+
+ if (v->match_is_chan) {
+ if (id && id->chan && !strcmp(id->chan, v->match))
+ return v;
+ } else {
+ if (mhi_dev->mhi_cntrl && mhi_dev->mhi_cntrl->name &&
+ !strcmp(mhi_dev->mhi_cntrl->name, v->match))
+ return v;
+ }
+ }
+ return NULL;
+}
+
static int sahara_find_image(struct sahara_context *context, u32 image_id)
{
int ret;
@@ -797,6 +846,7 @@ static void sahara_read_data_processing(struct work_struct *work)
static int sahara_mhi_probe(struct mhi_device *mhi_dev, const struct mhi_device_id *id)
{
+ const struct sahara_variant *variant;
struct sahara_context *context;
int ret;
int i;
@@ -809,14 +859,14 @@ static int sahara_mhi_probe(struct mhi_device *mhi_dev, const struct mhi_device_
if (!context->rx)
return -ENOMEM;
- if (!strcmp(mhi_dev->mhi_cntrl->name, "AIC200")) {
- context->image_table = aic200_image_table;
- context->table_size = ARRAY_SIZE(aic200_image_table);
- } else {
- context->image_table = aic100_image_table;
- context->table_size = ARRAY_SIZE(aic100_image_table);
- context->non_streaming = true;
- }
+ variant = sahara_select_variant(mhi_dev, id);
+ if (!variant)
+ return -ENODEV;
+
+ context->image_table = variant->image_table;
+ context->table_size = variant->table_size;
+ context->non_streaming = variant->non_streaming;
+ context->fw_folder = variant->fw_folder;
/*
* There are two firmware implementations for READ_DATA handling.
--
2.34.1
next prev parent reply other threads:[~2026-03-19 6:32 UTC|newest]
Thread overview: 20+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-03-19 6:31 [PATCH v4 0/9] Qualcomm Sahara protocol enhancements Kishore Batta
2026-03-19 6:31 ` [PATCH v4 1/9] Add documentation for Sahara protocol Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 ` [PATCH v4 2/9] bus: mhi: Move sahara protocol driver under drivers/bus/mhi Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 ` [PATCH v4 3/9] bus: mhi: Match devices exposing the protocol on the SAHARA channel Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 ` Kishore Batta [this message]
2026-03-21 18:44 ` Claude review: bus: mhi: Centralize firmware image table selection at probe time Claude Code Review Bot
2026-03-19 6:31 ` [PATCH v4 5/9] bus: mhi: Add QDU100 variant and image_id firmware fallback Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 ` [PATCH v4 6/9] bus: mhi: Load DDR training data using per-device serial number Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 ` [PATCH v4 7/9] bus: mhi: Capture DDR training data using command mode Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 ` [PATCH v4 8/9] bus: mhi: Expose DDR training data via controller sysfs Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-19 6:31 ` [PATCH v4 9/9] Documentation: ABI: Add sysfs ABI documentation for DDR training data Kishore Batta
2026-03-21 18:44 ` Claude review: " Claude Code Review Bot
2026-03-21 18:44 ` Claude review: Qualcomm Sahara protocol enhancements Claude Code Review Bot
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=20260319-sahara_protocol_new_v2-v4-4-47ad79308762@oss.qualcomm.com \
--to=kishore.batta@oss.qualcomm.com \
--cc=andersson@kernel.org \
--cc=carl.vanderlip@oss.qualcomm.com \
--cc=corbet@lwn.net \
--cc=dri-devel@lists.freedesktop.org \
--cc=jeff.hugo@oss.qualcomm.com \
--cc=linux-arm-msm@vger.kernel.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mani@kernel.org \
--cc=mhi@lists.linux.dev \
--cc=ogabbay@kernel.org \
--cc=skhan@linuxfoundation.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