From nobody Sun Feb 8 19:24:50 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 8D44A1EB5E1 for ; Sat, 27 Dec 2025 14:52:34 +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=1766847156; cv=none; b=O/URF4Rtc6jmt/CNRnISV23cT6er+Y9/f1/TwaTE6hFt1XuVR7KmFgMbkqbx57MGu30P8K9ICarbAtZQL9Qk4SBEvzLJiKMPSirlTp+Zvx+W3p3OuOBNMI2eX5QR95zZmPLhGyI9R0CjeIUSUqXIFPwZVi1P2h35TNu6TiHnHt0= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1766847156; c=relaxed/simple; bh=QVwu/cly5PIg5l9ixNViMh4+cYAoXOja3oSlSRthxkI=; h=From:To:Cc:Subject:Date:Message-Id:MIME-Version; b=ZTvQBA0S0lZGAV3Jy8tJ6Af6mwhyGFeEZ4YrsMq+UWaCYFbb4BxULSLY0gm85AsxATOvNoKiyRYgIsGDy8TRaNJo7lMyImrHFaHkZgLqxDRuczc6Xxio5HVRRiOsogzk5/uUmyxhHw0/XpdjMBm5WTAfWFgn91J3xRroZrMmoy8= 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=NdbMrXp6; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=BmBTEieX; 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="NdbMrXp6"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="BmBTEieX" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 5BRBlETU3833592 for ; Sat, 27 Dec 2025 14:52:33 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:message-id:mime-version :subject:to; s=qcppdkim1; bh=AEWtHZcWLawGiNRhaHiYMPStvPGArMGlYGW jUW6JiB0=; b=NdbMrXp6on+oFdvplw2M0LMlsScb3nStqj8C8GYlh18B/Or+2Eh EiTuUct1sCeLfvD3XeNkwlVDC+F9OJo8Lkmc+iGu8IvF4xq6WIjeezrVwiwiCKKI 31VUWP0HZ2eVRrw4d7ZLAMa12rV4bWsnnLvurOROMjJn+TPxJCN8Grobxcf+4kTt SSKqa0uZ/Z05eGQobb1IAHTyX08h4NzgDb2GJPUbPmW7oR8c1IjsNXse9iYmzTXL hmVWkVutMQ6n0ScdaPqVcxykZa1RZrqtr2/d83Yqsd66dqp0f6ndmirt9n8nRNM4 cS8M3fJXCtBqx38HdQ+Jjn6XGwKPpD9lORQ== Received: from mail-pf1-f200.google.com (mail-pf1-f200.google.com [209.85.210.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ba7p1rpvh-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 27 Dec 2025 14:52:33 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-7ba9c366057so20074846b3a.1 for ; Sat, 27 Dec 2025 06:52:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1766847153; x=1767451953; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=AEWtHZcWLawGiNRhaHiYMPStvPGArMGlYGWjUW6JiB0=; b=BmBTEieX3DR0HDoevRqdw/yyVhL9w3Hwq5rX3bEHS+oZUzjlFFS2bpRmQyjxi/jUCI FpO5y71Rj/gWvZg65N0KzTRtGMnJiVAsd2PLO3PL+jneUAHBeinKbrFGn7QehLEgN/X3 h/6YT3nBW8cMaKvze/bypD0GGJUjaZreVoL7FL4lM0AnvpoXDdXFkLl8IG6NN4WMSOA6 FaXCsqmXk2rh6RnmI95fsPXCUTpZ3/7RcrvJChhWW4HWpIBPjhqHEBP7WVQy+4ToUAjM uFedqwqB81lnlFS1Fa8RCh9ArT5kdXZoryuUJVZ+wRXG/8/nS5mZKGhKsqNNSm9UNtrg R+VQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1766847153; x=1767451953; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=AEWtHZcWLawGiNRhaHiYMPStvPGArMGlYGWjUW6JiB0=; b=shNpV5yWbDYL/9TGf8kfItiPkQNwuD5dtsVPUJIQttccwu41NIX5bqdLM4vrRhgCLl XcPckxS6i2lqfcBbz9qobir30kdbE7gQw7JbKaMEu2ADwME2gNJvdxBWdfldWY1rYypl GzuRnA/HJKj6ErodLdzwtwCUnkQOMAokVQ44ZX+DuMz8ZvrJbKkDhbGBo6KUaCDmqCkL 7kZNuFIo610aUzgK2OKViBlxSsczS/uPFWHfJ4dc1PeI19+2G8WOjCdM56WdDiepJeTP EL6/tYcz73MHG95jJJSUSfpDKdSSBl3eTXms8jxy/+T80k7wc2MkBuj8nQKJmq+km0HM Nczg== X-Forwarded-Encrypted: i=1; AJvYcCX11tGCSsZpe5uH1FEeaEZgdSY3+h8tle7qxZjx+uLEg+d9s0oRbOCZkMKCoRCbCENr3wy+LbOsCfjbRgY=@vger.kernel.org X-Gm-Message-State: AOJu0YxdwmZemyiciP7yJJ24ryf1RVgmhWqK+Lc/Ul3s3i02t5wTECo+ hex/ZCRYlQqkrzNKVbHMxD65TMNrE/vkDHCaEJ0haf74UlpWUFw+l0qC4KeJ+hgCbOtIf900o4c fLRFiek4aWf9Mwx27AWzHpwIdZyk6jqgWP6mFgouTJmtKKZ0sx1b93QSQpcZwUSxRlQ3WNavGuQ M= X-Gm-Gg: AY/fxX5d6s5GEOPMtx2bDknpefnmbieeflPgDM6rWK72x2QQFjmVan4V8OzVmrgC5zr J1EULapcidPkZxKvJRCoJWDW2o0FPeo363LPcGObYxlvM5lZYKP3BankBKboHci7DAWH8YEg/mm jmv+j7mKvMoZXzfp1n2kw7vOk7/i0zadxtFvLb/g3EHUAmjbftjPYF8e6XvvqF5C+itc8suP8T2 40XWBXE98Bj7Nqkw25zkMdPxF/gIxTQsFRUZDD+1W+QueYzE3AtpwrcvkZAuzwfNNzxU+XJ/3yC nAXJ9yQ/LspvEvQmpG1hsMgk3PIGiHkiAlsf649MicrUbv3VFb9Kiag2GFHzYKFJI852ET5DqrN pyN/4/WSBxEMTvcpVkzX29h9ytLrwZi37WZBDIpD0KnyoZj8= X-Received: by 2002:a05:6a00:4006:b0:7e8:450c:6196 with SMTP id d2e1a72fcca58-7ff66480856mr25050470b3a.45.1766847152786; Sat, 27 Dec 2025 06:52:32 -0800 (PST) X-Google-Smtp-Source: AGHT+IHSfMKtxceN14N4MPlrZYOzEaI7Q7GksOqhJKTSN+nRa2lD1z1LjfzKg/21jcBUycRzSgSeUg== X-Received: by 2002:a05:6a00:4006:b0:7e8:450c:6196 with SMTP id d2e1a72fcca58-7ff66480856mr25050455b3a.45.1766847152354; Sat, 27 Dec 2025 06:52:32 -0800 (PST) Received: from hu-kriskura-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-7ff7e0a1a2asm24706340b3a.41.2025.12.27.06.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Dec 2025 06:52:31 -0800 (PST) From: Krishna Kurapati To: Greg Kroah-Hartman , Jonathan Corbet Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Krishna Kurapati Subject: [PATCH] usb: gadget: f_sourcesink: Support maxburst configurability for bulk endpoints Date: Sat, 27 Dec 2025 20:22:24 +0530 Message-Id: <20251227145224.2091397-1-krishna.kurapati@oss.qualcomm.com> X-Mailer: git-send-email 2.34.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-Proofpoint-ORIG-GUID: HFbMD7oI-LGkyT6arhZkAvyhOTYJOQCB X-Proofpoint-Spam-Details-Enc: AW1haW4tMjUxMjI3MDE0MCBTYWx0ZWRfX92jvU7sRPx7o Dwbo+afks+HVH12NHqKg2IZ39tslDwXy++EMFhI2PEZaUfKwBfFOnbjywNarHgbg58VAS/K+0V0 Oe79w3OfLeQtLYmGISshq0d1XlXOQ9pLDUGxvn7bpWOXXT4SeyDpNHQfV4nhRqQv3tcw9btsDco qFFqz7KOT7+3qBOVRDAadzHe6LOSu3E7oPchEOVoIzVoAqy1wXWcL5D/UcXKzo1n2WK0yUn9veT rCcwVv3SxeTEnu9AkOBnyKjpg8eeanBGkRhyZ0ZyO7VCTyaaVmzy6fF5eKoKWNI19znlHDroOvh UcpHm/t8JY9kIkYLojzLaZd2gphILvZuQLEO//KE2LI9BSc0L5euXBVkIFYj/NcUKJq7UnQ8n+s z69tR79D+rvKvhJmwU1bM3nXBsZIxBVpx/ZXg92guElhn04BaKVba63eKUpTGpSmQRb4axKAkZV s9lhCllp+y65T04bZvw== X-Proofpoint-GUID: HFbMD7oI-LGkyT6arhZkAvyhOTYJOQCB X-Authority-Analysis: v=2.4 cv=PKMCOPqC c=1 sm=1 tr=0 ts=694ff2b1 cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=wP3pNCr1ah4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=UBjmvLYHQkscieVNT2UA:9 a=zc0IvFSfCIW2DFIPzwfm:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.9,FMLib:17.12.100.49 definitions=2025-12-27_03,2025-12-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 bulkscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 priorityscore=1501 adultscore=0 suspectscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2512120000 definitions=main-2512270140 Content-Type: text/plain; charset="utf-8" Add support to configure maxburst via configfs for bulk endpoints. Update gadget documentation describing the new configfs property. Signed-off-by: Krishna Kurapati --- Note: - Verified by checking bulk ep descriptors on host after changing values via configfs. - Ignored two checkpatch errors complaining usage of "unsigned" instead of "unsinged int". This was done to maintain consistency in declaration of variables in structures. Documentation/usb/gadget-testing.rst | 1 + drivers/usb/gadget/function/f_sourcesink.c | 52 ++++++++++++++++++++++ drivers/usb/gadget/function/g_zero.h | 1 + 3 files changed, 54 insertions(+) diff --git a/Documentation/usb/gadget-testing.rst b/Documentation/usb/gadge= t-testing.rst index 5f90af1fb573..e32c5ad29e2d 100644 --- a/Documentation/usb/gadget-testing.rst +++ b/Documentation/usb/gadget-testing.rst @@ -686,6 +686,7 @@ The SOURCESINK function provides these attributes in it= s function directory: isoc_mult 0..2 (hs/ss only) isoc_maxburst 0..15 (ss only) bulk_buflen buffer length + bulk_maxburst 0..15 (ss only) bulk_qlen depth of queue for bulk iso_qlen depth of queue for iso =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D diff --git a/drivers/usb/gadget/function/f_sourcesink.c b/drivers/usb/gadge= t/function/f_sourcesink.c index ec5fd25020fd..ca80b26e4fc9 100644 --- a/drivers/usb/gadget/function/f_sourcesink.c +++ b/drivers/usb/gadget/function/f_sourcesink.c @@ -46,6 +46,7 @@ struct f_sourcesink { unsigned isoc_mult; unsigned isoc_maxburst; unsigned buflen; + unsigned bulk_maxburst; unsigned bulk_qlen; unsigned iso_qlen; }; @@ -328,6 +329,12 @@ sourcesink_bind(struct usb_configuration *c, struct us= b_function *f) source_sink_intf_alt0.bInterfaceNumber =3D id; source_sink_intf_alt1.bInterfaceNumber =3D id; =20 + if (ss->bulk_maxburst > 15) + ss->bulk_maxburst =3D 15; + + ss_source_comp_desc.bMaxBurst =3D ss->bulk_maxburst; + ss_sink_comp_desc.bMaxBurst =3D ss->bulk_maxburst; + /* allocate bulk endpoints */ ss->in_ep =3D usb_ep_autoconfig(cdev->gadget, &fs_source_desc); if (!ss->in_ep) { @@ -853,6 +860,7 @@ static struct usb_function *source_sink_alloc_func( ss->isoc_mult =3D ss_opts->isoc_mult; ss->isoc_maxburst =3D ss_opts->isoc_maxburst; ss->buflen =3D ss_opts->bulk_buflen; + ss->bulk_maxburst =3D ss_opts->bulk_maxburst; ss->bulk_qlen =3D ss_opts->bulk_qlen; ss->iso_qlen =3D ss_opts->iso_qlen; =20 @@ -1101,6 +1109,49 @@ static ssize_t f_ss_opts_isoc_maxburst_store(struct = config_item *item, =20 CONFIGFS_ATTR(f_ss_opts_, isoc_maxburst); =20 +static ssize_t f_ss_opts_bulk_maxburst_show(struct config_item *item, char= *page) +{ + struct f_ss_opts *opts =3D to_f_ss_opts(item); + int result; + + mutex_lock(&opts->lock); + result =3D sysfs_emit(page, "%u\n", opts->bulk_maxburst); + mutex_unlock(&opts->lock); + + return result; +} + +static ssize_t f_ss_opts_bulk_maxburst_store(struct config_item *item, + const char *page, size_t len) +{ + struct f_ss_opts *opts =3D to_f_ss_opts(item); + int ret; + u8 num; + + mutex_lock(&opts->lock); + if (opts->refcnt) { + ret =3D -EBUSY; + goto end; + } + + ret =3D kstrtou8(page, 0, &num); + if (ret) + goto end; + + if (num > 15) { + ret =3D -EINVAL; + goto end; + } + + opts->bulk_maxburst =3D num; + ret =3D len; +end: + mutex_unlock(&opts->lock); + return ret; +} + +CONFIGFS_ATTR(f_ss_opts_, bulk_maxburst); + static ssize_t f_ss_opts_bulk_buflen_show(struct config_item *item, char *= page) { struct f_ss_opts *opts =3D to_f_ss_opts(item); @@ -1222,6 +1273,7 @@ static struct configfs_attribute *ss_attrs[] =3D { &f_ss_opts_attr_isoc_mult, &f_ss_opts_attr_isoc_maxburst, &f_ss_opts_attr_bulk_buflen, + &f_ss_opts_attr_bulk_maxburst, &f_ss_opts_attr_bulk_qlen, &f_ss_opts_attr_iso_qlen, NULL, diff --git a/drivers/usb/gadget/function/g_zero.h b/drivers/usb/gadget/func= tion/g_zero.h index 98b8462ad538..7bd66004821f 100644 --- a/drivers/usb/gadget/function/g_zero.h +++ b/drivers/usb/gadget/function/g_zero.h @@ -34,6 +34,7 @@ struct f_ss_opts { unsigned isoc_mult; unsigned isoc_maxburst; unsigned bulk_buflen; + unsigned bulk_maxburst; unsigned bulk_qlen; unsigned iso_qlen; =20 --=20 2.34.1