From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 10BEAFCC9D4 for ; Tue, 10 Mar 2026 07:22:32 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6BDCA10E65E; Tue, 10 Mar 2026 07:22:31 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (2048-bit key; unprotected) header.d=qualcomm.com header.i=@qualcomm.com header.b="dWrtB+Yk"; dkim=pass (2048-bit key; unprotected) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="LssAIjgd"; dkim-atps=neutral Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) by gabe.freedesktop.org (Postfix) with ESMTPS id 91A2710E65E for ; Tue, 10 Mar 2026 07:22:30 +0000 (UTC) Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 62A2EBBT246495 for ; Tue, 10 Mar 2026 07:22:30 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= iImuO6SGxaLTCiAHgKuG3rSRhW0OgS17DvZFF+54V/Y=; b=dWrtB+YkkeoZVD5l dBFkknMK73pt1U9W74yJib2y3ulLziyenaDahhjvZ9t4ziBrpCDmWruMXWoHjkvA +wJ7JJFub+qHEbbjgs+a6kW/9y42jPK8PO7KHLjOm2cRsvBmb7gN7XaqgGN/TPZJ JEtkg4qNoW4BMt80YI7HtRC2+oQ0/WR7fylCDmlraX+U7JE/HY6IXXKvBkfvq+hE 83fPNy2XAtlEQfKRuK5PvtY0hYa8nI90pynbbVBLvY/KKWAhPSrTR+V37Ehaa++N ZSOTeMwl9aNU881G3Euk/MEd6o6xqIUSht/bMcjqiaEyvD8sWEt9jpcB3e/4PApe 9t2gCw== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ct88019y4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Tue, 10 Mar 2026 07:22:29 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2ae44db60c2so92051955ad.2 for ; Tue, 10 Mar 2026 00:22:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773127349; x=1773732149; darn=lists.freedesktop.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=iImuO6SGxaLTCiAHgKuG3rSRhW0OgS17DvZFF+54V/Y=; b=LssAIjgdQeG4NTL6ISo8uU5z3zbVEme8WtnBLAlVHj7HTW2cwNJQm8Eu8xm3FB4fgL xsTGzgflgXpKGQ6R2stv3QLzBype4WyNSgdNdPz5peT/j6VebjhVGvaDM9+3dCM8xZzS nQwyOpbBHOnKylkxWY9CM8bJsNxK46RTtUjPaxhTFNhn2WoIsd2C9ueQ+WRz+PlUXYIp /lWxXXSB/jfsNoQnqUAOdd8TPxBuX5hzga2VKCFvwF3eQEv3g6/OBitBQ5uguHqOGZnI 0+E0Ve46SFHwKnFrzqsZPxNPM5mxbJMgNPfFt/+g0Ujr7eesfqh/A6s6Gtj6BEZ+dqhW k38g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1773127349; x=1773732149; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=iImuO6SGxaLTCiAHgKuG3rSRhW0OgS17DvZFF+54V/Y=; b=laiBKmAL/YJuhMMqSbaT2iwFO0FaAf/smoLqa0myqbdiJi02zAdC3BhVwWMKLRwTlQ 5nNGaHnAXCOJaTmfHO16uUEO8iyeld/QhSZeotuCyHBEezm3p5QsVLC9RRNQlW01vmo7 5IJOOy7PpHCwEp6ItxctgM6UpIbyu/SrJNoYwAvnVXgEhNTk0Ue67f0olWBw4GBvkTob g+ZiSk3ftScWClVinkNiPlt86rDq5PKrfVEM4TG9Xi/e4SJVcSxe4IxWCZywuq4Vu4ru v7N+jD8mXvYN4MychT6Kr0GKiCuSrCBW7LOVkqI39ZYpd51mqobvcWt6dmMv9VQErjc2 x+BA== X-Forwarded-Encrypted: i=1; AJvYcCX6tAjt2OgUsG7jWLJokIxinmpAOc5CW0RLeOu943hnECnl9WgMhw5cHwgcNz/dUS3YD3TyMarP7s8=@lists.freedesktop.org X-Gm-Message-State: AOJu0YxGyy1srhktxAorHcIq/Rp1mjWu8zHcLe5EOAu1nataHMJxjUUv AsND61asG1OhaWM0qr3aEu415nV8Uhvb1IKRuCxzY+NXfZ0RyQ8IZvD+FqwzneHr6tAG6EH3hxn qyj2YNJlvlPm40nmeDjxd8WfYaRkLuaGslMQQ9Lcu8b2vLIVc2yisfqlH4kvhOWrMNzTI7AU= X-Gm-Gg: ATEYQzyxTRFQUUBL6auGEa8him4Lml9f2Lad6m/E/6iHFnHG+p0xU7wXFn5OppmUgQq wDaFDOSFXJ/htfLR9qKTVC3vaSd3ePzFMZ795OHkrAjxngPQc+2phsdy+Hffrqjat80Suxu8+RI 5yZEwheVS4qjAls9NIcbzaSCWpSQzGXaiMdFyC+JyFl4qdUjAbA5jwyKCnpsREqqVarVSXnYjXy raD8Pwq1OJxUbjLmP5ckERBpboA2rSE66DFiKYc526a610HNvEX8WtYaZv4OwKJCXfjHK6NfOim k9NNXg5MBxOINBDAdafm0znuahE8VcV9DGXW4mAsumyEzwpml3zJxYwWR9fygDduTkOmPS7Xzi1 6n2pyST8fJd1XIv08vvR/Yd7rg/9q8JpbaXMcepSM5/HJWjxnEQQ= X-Received: by 2002:a17:902:e790:b0:2aa:d630:cd5d with SMTP id d9443c01a7336-2ae82505f47mr138797235ad.44.1773127349320; Tue, 10 Mar 2026 00:22:29 -0700 (PDT) X-Received: by 2002:a17:902:e790:b0:2aa:d630:cd5d with SMTP id d9443c01a7336-2ae82505f47mr138796965ad.44.1773127348780; Tue, 10 Mar 2026 00:22:28 -0700 (PDT) Received: from hu-batta-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ae840b2e9dsm185200325ad.85.2026.03.10.00.22.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Mar 2026 00:22:28 -0700 (PDT) From: Kishore Batta Date: Tue, 10 Mar 2026 12:52:01 +0530 Subject: [PATCH v3 4/9] bus: mhi: Centralize firmware image table selection at probe time MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260310-sahara_protocol_new_v2-v3-4-994ea4b0d5ad@oss.qualcomm.com> References: <20260310-sahara_protocol_new_v2-v3-0-994ea4b0d5ad@oss.qualcomm.com> In-Reply-To: <20260310-sahara_protocol_new_v2-v3-0-994ea4b0d5ad@oss.qualcomm.com> To: Jonathan Corbet , Shuah Khan , Jeff Hugo , Carl Vanderlip , Oded Gabbay , Manivannan Sadhasivam 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 X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1773127328; l=3898; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=D9kJlDoQ6LGAQMXZQh6rystru1KGUPI8NHA/TRw7+VQ=; b=CTZh2FV9FQiyZwGLQPHTzXB9kJsW6bpaNzbyq0P/Z7ViUQFDLg9+WJ+aT6EaDJ4D/XXTwoGOe oXks72SrrRJAHcr4haYbVSjBADZoIijZ2z4edmqXtFNpuZGaHlJRE6T X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzEwMDA2MCBTYWx0ZWRfX8IDIN9YYJ5Me qrkdijmeVoPgL265beSkvz/fHA1h+j6wqb3NRcfKi8lgBwJdmJvTaPOtPH7nPkRzFEQjHGIIR3d Jqz1OHqHPf6RdkSFHV0v43mVw1MuB/QauRcLrDkSa9eHAFA2n1Z/365rfOpESstm3dKlHjca3HF 101erIj1Hu9lXdjp7OVqIVn137qXqPXEclN9bZUCFfzEMQwbewkaK6FntZqRWWkcHpb4sBTV9mX Ev+pi/4td32PnmiJlN030r+bnr++WuUq8ZO4JeBv0lChSwrlJOOfGf+OI+VEDxozJfUcKWRUmMJ VOuT8JqnwGkNCNvPfsSxyGpvae1dowyxvz2WToH06dw5JfEJ8G1lXIbG3JW5fKLJDGRVqbyz3bs xYinO6SRPd0y2Ov5650hGMQqR5+Zmopp/L7VP4rKjqDUZ2Syfy/+/yW3GHObMEmJdaDMAwoACfV XrgSaCerWD/s1Sugqsw== X-Proofpoint-GUID: a-brPFUFhG0cfXPSdILvvpLxDkid9olE X-Authority-Analysis: v=2.4 cv=Jtf8bc4C c=1 sm=1 tr=0 ts=69afc6b5 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=hNMuCp7LqqrRSepR2eAA:9 a=0bXxn9q0MV6snEgNplNhOjQmxlI=:19 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-ORIG-GUID: a-brPFUFhG0cfXPSdILvvpLxDkid9olE X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-10_01,2026-03-09_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 adultscore=0 malwarescore=0 priorityscore=1501 phishscore=0 impostorscore=0 bulkscore=0 clxscore=1015 spamscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603100060 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" 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 --- 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