From nobody Thu Apr 9 16:25:47 2026 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 831A03563E9 for ; Sat, 7 Mar 2026 11:42:16 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883738; cv=none; b=F5U0Y0SnmiuYPsw7ZjiZXRsw5Ez1VuQkdw5mgVlNhN0SN1HTAOtJougSVocNfA8jcHA1tSB2DtuggzjxP8PGRudo4DDpNsQy1DsXAqDXalqPogHGkxkse2kw4zMNEVG0oLK3eTfOkml1dlCRM88gEhlqEuHs7CHAC6Lc0W5Ib/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883738; c=relaxed/simple; bh=D9kJlDoQ6LGAQMXZQh6rystru1KGUPI8NHA/TRw7+VQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oBReYetM6O+57reZiYyUT5gOfAzhkDtn0pKeW5Dm4I0zw34TcutTtIGQ8oS0wk7LTVMD4kBl25Z4DGuToIhLCttdoaTOarOT7cHI6wLshmtKFO8uLxdNPLcJV/W1awX8Cj3/68B8q8UGvQb+hC9vEbIOGZ4OM/S7z8XtlxECtXs= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=WekjT8zM; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=a8sWamLc; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="WekjT8zM"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="a8sWamLc" 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 6276rAw0277700 for ; Sat, 7 Mar 2026 11:42:16 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=WekjT8zMSpAi5+2F NOC5OFX4Hs7Lvw67uEwHoXkTlsSG9brO0irqbmk5NV+pK6evVNNk31KGWrOem33d lwy8sOLdr6VKl7gUlygdv/+fsJXXiNHrea0cqIOeMe9ZzIiGtE14uJZP1sYtBDTk a9yK+cr+GE9TsHDNzE49XRpZMM0FUU1R8C182+F4yLpw243CUPdPb+cUYR+XykkS fKObjn1Fvl1V9jWgXOrBWiv7XAactbecX84059nCJ+6ebDoAcvltOSyolj7Ya3pG YL9wGJO33LUEyBQdHuEPqFIXJttvP+lG68vka83+W9yZA/YHMG0sfnFf7tdSQXJB foSrtQ== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4crcse0m6x-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:15 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2ae3badc00dso81045895ad.3 for ; Sat, 07 Mar 2026 03:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883735; x=1773488535; darn=vger.kernel.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=a8sWamLc4lNN9E3rG9JDnNZrVVGG6IWCMK5aUg3zTn1maRT9m/nlUBDjsminqEoS7E vKmtCf56Y6R0EW5qSoGTLDVKxe9yURIItaCxUwn12FOAM2NqyiyDUPNKjD+ZNYca5gZe VrJvqRBKRnYkuLcCUOJ+uva/TE3QJMXxNP3u/4u4JLSu9EZhno7QRMLQ0xFZVkJmyOXi 7r5pZ/ui4PdexAVvhjFS9oh2TsyZA8EO2s904MratS2ueG1ZZq6vMhPX1qc/I1TMSnDS nR0xZHV/ggruJTgF02gk2FI2PsAkgcrSJ6vwfGU3y71ZufM255RgnSXh7v1Nh8myXhOi AcHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883735; x=1773488535; 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=eVy52E1JcD3y4hBDA1fl4vlyTsw+0fd47SrX4d3EinoHMPTYzmHGrT/UeTHd03gukP CcF28lqd8dutXxljLxHT1w/LkTpuI6ilJpKOhCn/oMw4XwpjFMsZFQC0Hag7yeYyc17a bn9eDaCIwHRhf9njfBhvr7B7X8jeuVHZ/et/kqF2ZGrtJ6Kach5kV7YKR5bWIr+U5vvc kOsFCUOUFZ66Z8PnGrbrx/nWsL9UzkdM/WX0BdTx7Cwfq6KX78+MwsEv8j6EG94rWUZA vQoct/9VHBbSqFTHQMHmEB4aDwEtI2erxlBN+0qgp37sLaFv4WI7uFH4qhyCK29dwQkC +V+Q== X-Forwarded-Encrypted: i=1; AJvYcCVbWuGVnHhnbnDuTR3iQpEMF1JdJdOZuk6GbusGDHkr+MxtnKheej0rzzA+n2guAtm1x0PckLZbhUdNbdQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyB/qRrZI+NMS9K66y6FZ8dZn14OP34MGx53WzU9FmX4UJoXlBc fSwCOQQFEVl0HmVbFsobQ7Ew3aEz/64uGo53H2wEhJ1O7ef2kRd+BAv244jAm6KemrupQbWCSr0 gCR+q8QinLum+oZf3Y++ROkwK7+++sHt8p9et6OOPxsuhvuxargGiJb7ASJ8aChLPBq8= X-Gm-Gg: ATEYQzw4XifpsVck5awMkaffttnl+cmhrULKeSM5iOmjfXRiupl1yE2yG4YuNpuBtbn xURKLYjEFebVlk9mT71k8LGeE6Y8h9ULZxomnDaOLijdv2iuNI3s1QZ/Fk0NnVOrrdJ42DF61M6 dtwD4ycRZ/5Awo+zxyiU7LpaZOKmr2gTWkUR8M5KiGnWil1STfMrFXG87v8aixO6VLvuJlJijrL Dgsx9gt7G2Qr64sVsxql8r6obazIu0lQH3tLdOAkEwRDXtfu9y+h5lE5l9VtBxYq7lT+8TZeLM3 PNxNa0FyAAJdmTrSGstRae7UQGM0uBDFC/9vHB387W6UqqWy5My8HMxhR6mL3CjioF3dZyk11Co FS3/yWE70oFQfFSobvKvzLzL7X1mf5cSiHXhM/XdzNhAGtlv7qfc= X-Received: by 2002:a17:902:ef46:b0:2ae:3b36:23e7 with SMTP id d9443c01a7336-2ae82398d80mr52195395ad.16.1772883735200; Sat, 07 Mar 2026 03:42:15 -0800 (PST) X-Received: by 2002:a17:902:ef46:b0:2ae:3b36:23e7 with SMTP id d9443c01a7336-2ae82398d80mr52195255ad.16.1772883734674; Sat, 07 Mar 2026 03:42:14 -0800 (PST) Received: from hu-batta-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ae83f8c713sm47996145ad.66.2026.03.07.03.42.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:14 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:25 +0530 Subject: [PATCH v2 4/9] bus: mhi: Centralize firmware image table selection at probe time Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Message-Id: <20260307-sahara_protocol_new_v2-v2-4-29dc748b5e9c@oss.qualcomm.com> References: <20260307-sahara_protocol_new_v2-v2-0-29dc748b5e9c@oss.qualcomm.com> In-Reply-To: <20260307-sahara_protocol_new_v2-v2-0-29dc748b5e9c@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=1772883713; l=3898; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=D9kJlDoQ6LGAQMXZQh6rystru1KGUPI8NHA/TRw7+VQ=; b=AaVGqgpWF7eVrREnt5Y5EO03kCIUBYl4kZdPLgZDVTiiCm1Kho2b7UaZcoD4cMrp/CaoDgmiD nVWAvjGkYNWD1NS4wgwp5xWhVrRF461rQtmOaVvcy6WrppQya1xF2rq X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Authority-Analysis: v=2.4 cv=IdqKmGqa c=1 sm=1 tr=0 ts=69ac0f17 cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==: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=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-GUID: yOuKoSem-gK9XoNWdesP8tGcBIuFtslv X-Proofpoint-ORIG-GUID: yOuKoSem-gK9XoNWdesP8tGcBIuFtslv X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOCBTYWx0ZWRfX6karpATHGHVg q0BPt6WI7bmlZ8mskElF5mjhmluulKhho7IpYCltKIpHRB7yq7UKekuFoo6HD9vwH2sS2hPspLU FNJgErzTwY0+nymCzNiDxwChgfEfZF8RQs5xloxbMtEitaCWU9lHjCPt8QW7bP4ciwdomYIRmP+ dI1m/m9csnGRJ2xbxXugWp+4Bx2C30pVDdAhrGLjhe2nzRoFQy+BeB+wJ0+/OjirHMztpvC5NqV gR4CluOcq2c8eeVN0T4tBV+P8qaaUNSWYyLaz12U7w8aXoXE9K+7lnpd2+NvwvHl8PguW1wdJdA BCj5MZPAIBRujMuKp4J22LKC1Tn1677XJvxlPdrL1Z6JuE7UQhvHA2cSEPZOKejyFoXYSgOTGm7 fOXcOWx0BTpPuHu32ZJynNNY2pFnPpGsbX4P9Y7YGJZvqc+K7eTvTmuChYXsLvLIJkiNAiJLp89 IG6GvSupKtVKDU9F4Dg== 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-07_04,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 adultscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070108 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/sahar= a.c index e3499977e7c6b53bc624a8eb00d0636f2ea63307..8f1c0d72066c0cf80c09d78bfc5= 1df2e482133b9 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; }; =20 static const char * const aic100_image_table[] =3D { @@ -224,11 +234,50 @@ static const char * const aic200_image_table[] =3D { [78] =3D "qcom/aic200/pvs.bin", }; =20 +static const struct sahara_variant sahara_variants[] =3D { + { + .match =3D "AIC100", + .match_is_chan =3D false, + .image_table =3D aic100_image_table, + .table_size =3D ARRAY_SIZE(aic100_image_table), + .fw_folder =3D "aic100", + .non_streaming =3D true, + }, + { + .match =3D "AIC200", + .match_is_chan =3D false, + .image_table =3D aic200_image_table, + .table_size =3D ARRAY_SIZE(aic200_image_table), + .fw_folder =3D "aic200", + .non_streaming =3D false, + } +}; + static bool is_streaming(struct sahara_context *context) { return !context->non_streaming; } =20 +static const struct sahara_variant *sahara_select_variant(struct mhi_devic= e *mhi_dev, + const struct mhi_device_id *id) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(sahara_variants); i++) { + const struct sahara_variant *v =3D &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_str= uct *work) =20 static int sahara_mhi_probe(struct mhi_device *mhi_dev, const struct mhi_d= evice_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_de= v, const struct mhi_device_ if (!context->rx) return -ENOMEM; =20 - if (!strcmp(mhi_dev->mhi_cntrl->name, "AIC200")) { - context->image_table =3D aic200_image_table; - context->table_size =3D ARRAY_SIZE(aic200_image_table); - } else { - context->image_table =3D aic100_image_table; - context->table_size =3D ARRAY_SIZE(aic100_image_table); - context->non_streaming =3D true; - } + variant =3D sahara_select_variant(mhi_dev, id); + if (!variant) + return -ENODEV; + + context->image_table =3D variant->image_table; + context->table_size =3D variant->table_size; + context->non_streaming =3D variant->non_streaming; + context->fw_folder =3D variant->fw_folder; =20 /* * There are two firmware implementations for READ_DATA handling. --=20 2.34.1