From nobody Sun Feb 8 04:57:38 2026 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.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 361361E9B32 for ; Tue, 22 Apr 2025 10:32:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745317965; cv=none; b=Mz1wrzqBiuLcCIJNZryljbigeL211hxkcnbEwRBwILsqS5/PRH9cgfhWu+WH852lG2L+WwhVuGHiQYx8TjDAjTO7JDG9f8ugiJJvHGJGSUTMQL1I6+AG5AWLFs0YT8LExIu4+3eEDEuDIIVKMtk4tnIR8h9/eLecTJPaIF56Sf4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745317965; c=relaxed/simple; bh=CKNZ75iDINw6MC6IL4iuJlsbLi60jIt9XSgEtpjGV8A=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=WS40ukLOekj1G1NoFp83PbocRc99A48RJtLekbB3K+9I5GTdKXVQ45wYQaR84inesxZNrMQ9dWAHxEbCFHfAkwZQ/KttvSy6cP8BJMlgorFRr25ZaSJB+uGRf64Ds5HAkK2Hk6naJb5HGzxUW/KS4bDLU5z7Gyw7BNNmZmAcYpE= 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=N4xO91+i; arc=none smtp.client-ip=205.220.180.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="N4xO91+i" Received: from pps.filterd (m0279868.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 53M4OlTu006174 for ; Tue, 22 Apr 2025 10:32:42 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=mOjHDkSlrc5 FA5+7P3anTxnDru4TLkY0T08z6RqNU0s=; b=N4xO91+i3Uw0OFlVCMB3+Cynv89 r9MhX5W+loNbyPRHUUCXNZAmCUbR+IZUC7UqKFCqs/8w/oz9VeU9G/9drmDYqbVH /2HDAEdS5U5TM0O4352JAf9TSQ78dcjAs0FWIE5zAiGRk2cNrR7sDzst8xUFB21n nyln4wQrHtOKvLN+eG/vzHVOZn9lhY0KL0R3jzaHRq1tQcJ1LP52X14x/G5TOxpS GxJSkZhb/Gj1hccYiPOoJ3QN2EgTHTDadu7eAGaubDckcIt52cnl8qtJYUhO4brG URofaA3Eo0xavouDtwspIVMHWFhHSICiow6RAQ76h9MhdkC8ICowSRATEPw== 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 46435jf4rc-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 22 Apr 2025 10:32:42 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-225429696a9so66959895ad.1 for ; Tue, 22 Apr 2025 03:32:42 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745317961; x=1745922761; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mOjHDkSlrc5FA5+7P3anTxnDru4TLkY0T08z6RqNU0s=; b=HEqIkK1FNiMPhOEFLQQJqC2OBndg+4FZDa1ZNFqT8xH247yn8SbUGBNqSzrQE9uMw+ XpcYAA/EmDPQU9wFtc+eEczzwwN96hv9bPDXfd1BhJQTZ3361LZ6A0Aa8w9dHgIk/Spd z9oDh8j/BaJYAhvQ02kBceKA6Hs4BB9LBH6bBNbkDO0i86gFb7tFDkuYzubOUaZlklQH Zgd92lV/lTkSGWAEHYqYQMxQSFe1MR60+cKD8Mm1Y8tJFo7JjJlHfEx/p2kVrYklSfH/ RroAdpx8BvNmIL6meWkc1pw2JF/pqzGJkPZNZWbUl4ig2LGik30yx+VXG5i0Q455a6MG q+ew== X-Forwarded-Encrypted: i=1; AJvYcCVWRJ32DQFQfhb8iXNVattCp2KHBViPURb1sW+dC6O8zs7cxZKbT7D2ofzISi60tLh+tKAihtwMZz2dC88=@vger.kernel.org X-Gm-Message-State: AOJu0Yyiw8moH7lPbN1tffsP9yeO9NzP/1is1hn36xAbttoSLuVwKyzx H/fCY0qhRq0PP6zJFlCWZ3b4uN6SV6F2y0qU02JFS/qqzla0JTfn+bjR5/G1C6zzPDNB+OAOptM 6+xR2Cs3f/k0KrC5fx91lcfnZa/vHa/OH2IRVgCz2NyzU5ZNsOqD/Ij2BL7LYFqI= X-Gm-Gg: ASbGncsJg4ScPR584PlmmnPg+rD49Rwuv7j3ZXslOGfiH8qGkYeJp4sZ4KTgn/RL7f8 xah8l2paAy8GOLTp52diOA8NZB4yQKLr+ld58Alty8ibI+DVg4cT7r/aYFktrsUwwB7E/sdnRwO n1u+Twsvjs/7dCbcNgv5khk0g5QzuJx5rAk2LAALaK4grpM4I1Q6xwuXogILuiB9nV/IB2uU0SB CBvxmS4cFwcjohKY+VaycvxanaHlolyXBJZ2aohY51N6kkZPN7Vbfk+iUsfuZOylM+TXeiRcsyv tWQHrei/2LLaRL/QUs4zIRgNcnJg9GNo92VKbGj5 X-Received: by 2002:a17:902:ce01:b0:21f:7082:1137 with SMTP id d9443c01a7336-22c5357d158mr263473665ad.22.1745317961262; Tue, 22 Apr 2025 03:32:41 -0700 (PDT) X-Google-Smtp-Source: AGHT+IExRjxqGdz+q+89OcoW1KYSdRsZxDTYasf2vP3F6wNHhozJN1gbVwbklTo21bG14e5XCerELQ== X-Received: by 2002:a17:902:ce01:b0:21f:7082:1137 with SMTP id d9443c01a7336-22c5357d158mr263473345ad.22.1745317960918; Tue, 22 Apr 2025 03:32:40 -0700 (PDT) Received: from hu-prashk-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73dbf90dc88sm8228059b3a.83.2025.04.22.03.32.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 03:32:40 -0700 (PDT) From: Prashanth K To: Greg Kroah-Hartman , Thinh Nguyen , Kees Bakker , William McVicker , Marek Szyprowski Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Prashanth K , stable@kernel.org Subject: [PATCH v2 1/3] usb: gadget: f_ecm: Add get_status callback Date: Tue, 22 Apr 2025 16:02:29 +0530 Message-Id: <20250422103231.1954387-2-prashanth.k@oss.qualcomm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250422103231.1954387-1-prashanth.k@oss.qualcomm.com> References: <20250422103231.1954387-1-prashanth.k@oss.qualcomm.com> 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-Authority-Analysis: v=2.4 cv=EOYG00ZC c=1 sm=1 tr=0 ts=6807704a cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=XR8D0OoHHMoA:10 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=wSQy6ELrUcAAhET18-sA:9 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-GUID: IZ5TF2NtHgydRbksO3p7BbPCh6S8Yax3 X-Proofpoint-ORIG-GUID: IZ5TF2NtHgydRbksO3p7BbPCh6S8Yax3 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_05,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 mlxlogscore=999 mlxscore=0 clxscore=1015 lowpriorityscore=0 malwarescore=0 priorityscore=1501 phishscore=0 spamscore=0 adultscore=0 impostorscore=0 bulkscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504220079 Content-Type: text/plain; charset="utf-8" When host sends GET_STATUS to ECM interface, handle the request from the function driver. Since the interface is wakeup capable, set the corresponding bit, and set RW bit if the function is already armed for wakeup by the host. Cc: stable@kernel.org Fixes: 481c225c4802 ("usb: gadget: Handle function suspend feature selector= ") Signed-off-by: Prashanth K Reviewed-by: Thinh Nguyen --- drivers/usb/gadget/function/f_ecm.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/usb/gadget/function/f_ecm.c b/drivers/usb/gadget/funct= ion/f_ecm.c index 80841de845b0..027226325039 100644 --- a/drivers/usb/gadget/function/f_ecm.c +++ b/drivers/usb/gadget/function/f_ecm.c @@ -892,6 +892,12 @@ static void ecm_resume(struct usb_function *f) gether_resume(&ecm->port); } =20 +static int ecm_get_status(struct usb_function *f) +{ + return (f->func_wakeup_armed ? USB_INTRF_STAT_FUNC_RW : 0) | + USB_INTRF_STAT_FUNC_RW_CAP; +} + static void ecm_free(struct usb_function *f) { struct f_ecm *ecm; @@ -960,6 +966,7 @@ static struct usb_function *ecm_alloc(struct usb_functi= on_instance *fi) ecm->port.func.disable =3D ecm_disable; ecm->port.func.free_func =3D ecm_free; ecm->port.func.suspend =3D ecm_suspend; + ecm->port.func.get_status =3D ecm_get_status; ecm->port.func.resume =3D ecm_resume; =20 return &ecm->port.func; --=20 2.25.1 From nobody Sun Feb 8 04:57:38 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 4F1D4200BBC for ; Tue, 22 Apr 2025 10:32:46 +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=1745317967; cv=none; b=IC/8ttoJZw+pUNBlRm2FI9rAXtXJJvy+xpG/bnpG7OEXqgLktxlw4vJQxx8ckrhCKqsEll30I4mohZN7LwM8lhnY4XPqcrQaPk2KEpCe0pVx70GlU5Bs1cAnFrIsHF3LwrrC2l7B5MgD/lFJVh099x3VWuApDpEZRhv//w4rGxI= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745317967; c=relaxed/simple; bh=p27y9NFMXzVvj00e8ZA7+IGcsY4E7svOnJQzifljnL4=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=MZ9D0CGqNkb2fDWJBXKJ+/t9HpeQReeD0gdzSO+RbQsaXnvZc9HR8ysWYziPiqM+0/d7S9P/YV7Cmr1dz+IGYjnzJL4oQtb2P/QUHpVfon1t+ag6bL6fyPaN3Mnn4cfhMdxuLG/Mm5HCKLU6SeK+1ByVigc2JX+fMrwANLbraFY= 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=mpLwoBUw; 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="mpLwoBUw" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 53M4P00p011611 for ; Tue, 22 Apr 2025 10:32:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=lpT545Y/gOY A7sVvZRT5W/scaeQvyDclWBr3nb3bgNI=; b=mpLwoBUwiIBnfHKPY7/AFp8LVW3 Auu1NKKO9gBXyhDman87Bsvst2mjZbgH92mHmQuIwnaOV9gtF91SMVMfsBg8Pe5Y 3YTUQW3JP3AmwXl5t4eJC+YS2Qd9yRGbv7BtXUPUHrKzFB0yPiJQVQE8XpBeznlh hLzXqP7xzsCsMSNh10uZOBW1aHuHR82R8Uh5CFyb0QnzL4QJ2SPgKX3UD9h8CQzT d2Y1YceSY8jP1xIWslfGlohzBz+jmkTgaLjcYZfCVZmR0pRPuy1USE8NBkLDxAt5 6ainCqdpquAVU7RxLv3+F9Sc5fa+RKiff+JOY/+Zvv7qQ3OTfRI4iAXzNWA== 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 46450peyvf-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 22 Apr 2025 10:32:45 +0000 (GMT) Received: by mail-pf1-f200.google.com with SMTP id d2e1a72fcca58-739525d4d7bso3943677b3a.2 for ; Tue, 22 Apr 2025 03:32:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745317964; x=1745922764; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=lpT545Y/gOYA7sVvZRT5W/scaeQvyDclWBr3nb3bgNI=; b=I/SBZFLSuU4VPi/H/xwqh5e1nZlWTrorYB2HJqwhsaTVLitDipWY+WqOPy+GqdWl5w D2rzMO9FdsMvDRbtI/LRAqC17SNRlruxZKoXvGhupZe+VVzaZ7FK4UpMoIWybkuwSmNI Oz/a2wqZXlvTExqKF4SJ0QSss2CzRo52fOBR1NU7t3s8zF2nEVFoitGpP/Z7m972wbwJ TaBdGSB0LZLYbQX9j1SkL+ct0DuA54QGIKTaCrteWJAgvyXlqBSvAbAriGzQePQqmSuh tF6AfPIjpRa5FthvGr5ASrd69LPBDip6eEsmuLbmeyquy723NmeiOiQjQcHUXn5iZNyi OabA== X-Forwarded-Encrypted: i=1; AJvYcCXZfpAXqbDOzTdZe81aqf80ujHDtBaUXylg9do6mMJB+kKyAdWnRe8CQ7gwrUaLxYUul3wvBT+BhRNS11o=@vger.kernel.org X-Gm-Message-State: AOJu0YxxzjgasRaL3safhunz3YlJ4CvnrDxdBlpnF2M8YhcqnswMqdNK mL61gNuYUhwghTtpqWTTGcSK+4GJNpeQ8HYYHyCPXDZj0bEpciXmesOvrFKzDXNfPyhYx1CnVDy 2B1wQ/xUvYNUzixpWMLjW0jGYvK5Wu8lBkLEK3lHua4sFXwmrjklDobdxWo6ZXB8= X-Gm-Gg: ASbGncu8mcGwEgByc4p2o6b1IvXP5+MMsBbIVyZg4VJpzQajCmJmUeOM/kujPniqWnl IEFPXiuwxwZ/W+UI33Kueurkd+0AggZ/AFDRK+xJgIy/FD561NsfHw6raUOH66NEgeHsPh8I75n NBqq4mvNLvUd7JQ7lnXFkE8brTxLj06wlesgAW2deWgM9UIcHJh/oz1jo5Mrsm0YCLL+8sFLe5S hKxsgUnEOMi1s2QOAr1uQsSOMBCE78JKqLggN22TUK8yXwsYyyIO7sofjeUVaOrKw6gPBczVOt2 DHyybWdDSteaaqmDjJv+BTJRadyStNegH2dEmgd2 X-Received: by 2002:a05:6a00:14c6:b0:736:ab1e:7775 with SMTP id d2e1a72fcca58-73dc118f8e9mr19677461b3a.0.1745317964442; Tue, 22 Apr 2025 03:32:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHRWf0lx18yKey+Dgn5Q3XgsBWDvoSeOATiYIf/l2yJT5PB6Phu4kV78DU3R7y2nqx1MOLnHQ== X-Received: by 2002:a05:6a00:14c6:b0:736:ab1e:7775 with SMTP id d2e1a72fcca58-73dc118f8e9mr19677425b3a.0.1745317964048; Tue, 22 Apr 2025 03:32:44 -0700 (PDT) Received: from hu-prashk-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73dbf90dc88sm8228059b3a.83.2025.04.22.03.32.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 03:32:43 -0700 (PDT) From: Prashanth K To: Greg Kroah-Hartman , Thinh Nguyen , Kees Bakker , William McVicker , Marek Szyprowski Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Prashanth K , stable@kernel.org Subject: [PATCH v2 2/3] usb: gadget: Use get_status callback to set remote wakeup capability Date: Tue, 22 Apr 2025 16:02:30 +0530 Message-Id: <20250422103231.1954387-3-prashanth.k@oss.qualcomm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250422103231.1954387-1-prashanth.k@oss.qualcomm.com> References: <20250422103231.1954387-1-prashanth.k@oss.qualcomm.com> 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-Authority-Analysis: v=2.4 cv=Hd0UTjE8 c=1 sm=1 tr=0 ts=6807704d cx=c_pps a=mDZGXZTwRPZaeRUbqKGCBw==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=XR8D0OoHHMoA:10 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=Fe4CDuQzCUjxA5onUuAA:9 a=zc0IvFSfCIW2DFIPzwfm:22 X-Proofpoint-GUID: 2dlhgLZOj73RFf2a0sIV-MCyAtidBchx X-Proofpoint-ORIG-GUID: 2dlhgLZOj73RFf2a0sIV-MCyAtidBchx X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_05,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 priorityscore=1501 mlxscore=0 malwarescore=0 suspectscore=0 bulkscore=0 adultscore=0 mlxlogscore=999 phishscore=0 clxscore=1015 spamscore=0 impostorscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504220079 Content-Type: text/plain; charset="utf-8" Currently when the host sends GET_STATUS request for an interface, we use get_status callbacks to set/clear remote wakeup capability of that interface. And if get_status callback isn't present for that interface, then we assume its remote wakeup capability based on bmAttributes. Now consider a scenario, where we have a USB configuration with multiple interfaces (say ECM + ADB), here ECM is remote wakeup capable and as of now ADB isn't. And bmAttributes will indicate the device as wakeup capable. With the current implementation, when host sends GET_STATUS request for both interfaces, we will set FUNC_RW_CAP for both. This results in USB3 CV Chapter 9.15 (Function Remote Wakeup Test) failures as host expects remote wakeup from both interfaces. The above scenario is just an example, and the failure can be observed if we use configuration with any interface except ECM. Hence avoid configuring remote wakeup capability from composite driver based on bmAttributes, instead use get_status callbacks and let the function drivers decide this. Cc: stable@kernel.org Fixes: 481c225c4802 ("usb: gadget: Handle function suspend feature selector= ") Signed-off-by: Prashanth K Reviewed-by: Thinh Nguyen --- drivers/usb/gadget/composite.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/composite.c b/drivers/usb/gadget/composite.c index 869ad99afb48..8dbc132a505e 100644 --- a/drivers/usb/gadget/composite.c +++ b/drivers/usb/gadget/composite.c @@ -2011,15 +2011,13 @@ composite_setup(struct usb_gadget *gadget, const st= ruct usb_ctrlrequest *ctrl) =20 if (f->get_status) { status =3D f->get_status(f); + if (status < 0) break; - } else { - /* Set D0 and D1 bits based on func wakeup capability */ - if (f->config->bmAttributes & USB_CONFIG_ATT_WAKEUP) { - status |=3D USB_INTRF_STAT_FUNC_RW_CAP; - if (f->func_wakeup_armed) - status |=3D USB_INTRF_STAT_FUNC_RW; - } + + /* if D5 is not set, then device is not wakeup capable */ + if (!(f->config->bmAttributes & USB_CONFIG_ATT_WAKEUP)) + status &=3D ~(USB_INTRF_STAT_FUNC_RW_CAP | USB_INTRF_STAT_FUNC_RW); } =20 put_unaligned_le16(status & 0x0000ffff, req->buf); --=20 2.25.1 From nobody Sun Feb 8 04:57:38 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 B68EE213E76 for ; Tue, 22 Apr 2025 10:32:49 +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=1745317971; cv=none; b=qCg+ORGlR30qw2BSTC4oOUQT03ui4fvA8bvris+g4YYrXWLPdXGGvZ7nARY0dKcG+uzMWhUiFubgLS/tfK7piDF6KjkCJZbpcKKbrwgO2aQmKNDh12k4EdJXzZNx5IbzKayWWuqsVHVu8B5hXv1vndedhpyXSZvkwtJwwpSoh5I= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1745317971; c=relaxed/simple; bh=qbhS7bsOrZKDOkbN12rXpfPUFYm+boS/N917aBAvtfs=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=LHQb0YI96bU0HgeTzJS+RyZKI6iWp7LtSqPqMCSbiorNrl0LU6RDMN2W9GlgQrjrp0sJb2NvPS0hwXYualhZU6VVqiG1ZQMsDgjYLZ0QYZnj6wQ3E7vbsECiV1dj+0E2Z5rrWBMhQRxOnF+WRksjf7uMjggFXuUPWCDYHSeOkhY= 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=BqbvQItV; 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="BqbvQItV" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.2/8.18.1.2) with ESMTP id 53M4ObxY025943 for ; Tue, 22 Apr 2025 10:32:49 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:date:from:in-reply-to:message-id :mime-version:references:subject:to; s=qcppdkim1; bh=7QuJSuAaz6B LADYfrH5eY44lI3tsRy/GKAQrW+Z71q8=; b=BqbvQItV6KxsjuswZuO0srA93mb wONDHiFoVIa6DHo266Oma2jZPrPtyy9IPFim3nGg/Ak0U8BWuNqSXNYrMur95P4x RjOAjgWvnnhY39VyBoHcLFSOXg7ML3P3L8mvIP77GZJD3UaEeIhH42vIyt0P1N1N Yaoa3AFoIQmBxXMYjxAixjfJNCUd8cELa8bPm83xG8DWZy/HI80UbjRHoLycMOob XbTuVgCL4uuFabsnhpsLjAVfhirsDoyhTQ4S4AeSMpUp5T6EMlZbAye3byP5rVfx mlWhasPtUp/12r4XI59wX7YkjUpnOhe+ixNp5j4sVABlhU+BHS4vjjZ8aZA== Received: from mail-pf1-f197.google.com (mail-pf1-f197.google.com [209.85.210.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4644kjey69-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128 verify=NOT) for ; Tue, 22 Apr 2025 10:32:48 +0000 (GMT) Received: by mail-pf1-f197.google.com with SMTP id d2e1a72fcca58-739515de999so4442997b3a.1 for ; Tue, 22 Apr 2025 03:32:48 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1745317968; x=1745922768; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7QuJSuAaz6BLADYfrH5eY44lI3tsRy/GKAQrW+Z71q8=; b=D5390ZvrAWFmmfA1RozEeeo64hpcT0Vf7rS3VRwPB/MltupuYMEPlrmHu440Gx/L0Y RxFSfhlHbHgzaD6nAfD3jmBHmKdmyKqdB+gTAcO+VUFxtpHsKlb4ZqE5/MLwlvzjxfID 0ci5ewO7fE6Ep6b0MD5jNNQPhEsFWUqkOT8QA5PBRY5ls/n7S6FaMGAXqemLpjSu0KlZ 8XskE+u9HlT4czFTi/3ub4AD+rcfUu9/2MR95FzasSTnRe5l28z1IM8hgeGCjsBPHQeq DAR2KOsUuIx6n4wMB73fYeTkCiiod/vCPLBKdxRx/Qrs1XlvwdRGSNhErjX4xM8hj+/Q qS0w== X-Forwarded-Encrypted: i=1; AJvYcCVp5RlHMM+qF9cOgScZZGuz9pTdtfU0cY48hb3nYlTT0Xksg24tD5twyoqg2G4MGG4y8OKy5xr43q11Sek=@vger.kernel.org X-Gm-Message-State: AOJu0Yz2UKSRPXiHgowY4DdkA1YLXOE2h5Uv4zeLYlo1KGJb5kBU7F6N BEuaWjkZqIei/9A1Ldb/eK1+z+mSF/9bqSsXKiza5uclxCP10IkfL25aJYhWnjdVjr2txNwvmMa HH291LDJFR2e0Q7mRjhZpJD+w+jSbTKyHz5Fd7hBmRABMvGwtQwztBGEdpK3rew4= X-Gm-Gg: ASbGncuzXRWOCijpeEGXW5gZzOpLo5MrGViRbII4uf6NnrHQDQBzM4wxbyMN+EMwuH3 wrIuAQKMUJhsaTF4P8dBO27Rt9l2E5clkZ+xFQ5JTdBrwbe8/XbTwdXlhX6+ywyW9RAcvVID5s5 JhaE41ydAFkNa5CSAB5bPCJ5tcejD5isVaClAE66HxePOo9/3TSn+WJJDzlPKdFhmQQudWYIKWB gVkgOgcVav4aL54QSz4PfxGtYzSGc1fzbF+IPpKWWVWn3K+kEC+x7jLP5dGROnHjf2K26i6HKYe LuwAc/x3C6IiDovyTCXAOhVVEb0geUocqXI7WbY4 X-Received: by 2002:a05:6a00:3cc2:b0:736:5f75:4a3b with SMTP id d2e1a72fcca58-73dc14a3296mr17035196b3a.7.1745317967645; Tue, 22 Apr 2025 03:32:47 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFbq89ZKlhNrIC1F5xSOztoAMur+x71lgU4GC2F9m/6YrZPS7Y2uwXjRLzHWpnKEftkLD7DvA== X-Received: by 2002:a05:6a00:3cc2:b0:736:5f75:4a3b with SMTP id d2e1a72fcca58-73dc14a3296mr17035150b3a.7.1745317967146; Tue, 22 Apr 2025 03:32:47 -0700 (PDT) Received: from hu-prashk-hyd.qualcomm.com ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-73dbf90dc88sm8228059b3a.83.2025.04.22.03.32.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 22 Apr 2025 03:32:46 -0700 (PDT) From: Prashanth K To: Greg Kroah-Hartman , Thinh Nguyen , Kees Bakker , William McVicker , Marek Szyprowski Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, Prashanth K , stable@kernel.org Subject: [PATCH v2 3/3] usb: dwc3: gadget: Make gadget_wakeup asynchronous Date: Tue, 22 Apr 2025 16:02:31 +0530 Message-Id: <20250422103231.1954387-4-prashanth.k@oss.qualcomm.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20250422103231.1954387-1-prashanth.k@oss.qualcomm.com> References: <20250422103231.1954387-1-prashanth.k@oss.qualcomm.com> 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-GUID: GnzETeePSa0maDnSYDfBMmsTRM_-J15o X-Authority-Analysis: v=2.4 cv=f5pIBPyM c=1 sm=1 tr=0 ts=68077050 cx=c_pps a=rEQLjTOiSrHUhVqRoksmgQ==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=XR8D0OoHHMoA:10 a=VwQbUJbxAAAA:8 a=EUspDBNiAAAA:8 a=j9-q7YbHbCxKn5U3djcA:9 a=2VI0MkxyNR6bbpdq8BZq:22 X-Proofpoint-ORIG-GUID: GnzETeePSa0maDnSYDfBMmsTRM_-J15o X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1095,Hydra:6.0.680,FMLib:17.12.68.34 definitions=2025-04-22_05,2025-04-21_02,2024-11-22_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 malwarescore=0 mlxlogscore=917 mlxscore=0 impostorscore=0 adultscore=0 priorityscore=1501 clxscore=1015 suspectscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 classifier=spam authscore=0 authtc=n/a authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.19.0-2502280000 definitions=main-2504220079 Content-Type: text/plain; charset="utf-8" Currently gadget_wakeup() waits for U0 synchronously if it was called from func_wakeup(), this is because we need to send the function wakeup command soon after the link is active. And the call is made synchronous by polling DSTS continuosly for 20000 times in __dwc3_gadget_wakeup(). But it observed that sometimes the link is not active even after polling 20K times, leading to remote wakeup failures. Adding a small delay between each poll helps, but that won't guarantee resolution in future. Hence make the gadget_wakeup completely asynchronous. Since multiple interfaces can issue a function wakeup at once, add a new variable wakeup_pending_funcs which will indicate the functions that has issued func_wakup, this is represented in a bitmap format. If the link is in U3, dwc3_gadget_func_wakeup() will set the bit corresponding to interface_id and bail out. Once link comes back to U0, linksts_change irq is triggered, where the function wakeup command is sent based on bitmap. Cc: stable@kernel.org Fixes: 92c08a84b53e ("usb: dwc3: Add function suspend and function wakeup s= upport") Signed-off-by: Prashanth K Acked-by: Thinh Nguyen --- drivers/usb/dwc3/core.h | 4 +++ drivers/usb/dwc3/gadget.c | 60 +++++++++++++++------------------------ 2 files changed, 27 insertions(+), 37 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index aaa39e663f60..27eae4cf223d 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -1164,6 +1164,9 @@ struct dwc3_scratchpad_array { * @gsbuscfg0_reqinfo: store GSBUSCFG0.DATRDREQINFO, DESRDREQINFO, * DATWRREQINFO, and DESWRREQINFO value passed from * glue driver. + * @wakeup_pending_funcs: Indicates whether any interface has requested for + * function wakeup in bitmap format where bit position + * represents interface_id. */ struct dwc3 { struct work_struct drd_work; @@ -1394,6 +1397,7 @@ struct dwc3 { int num_ep_resized; struct dentry *debug_root; u32 gsbuscfg0_reqinfo; + u32 wakeup_pending_funcs; }; =20 #define INCRX_BURST_MODE 0 diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 47e73c4ed62d..69ec9cf57663 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -276,8 +276,6 @@ int dwc3_send_gadget_generic_command(struct dwc3 *dwc, = unsigned int cmd, return ret; } =20 -static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async); - /** * dwc3_send_gadget_ep_cmd - issue an endpoint command * @dep: the endpoint to which the command is going to be issued @@ -2359,10 +2357,8 @@ static int dwc3_gadget_get_frame(struct usb_gadget *= g) return __dwc3_gadget_get_frame(dwc); } =20 -static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bool async) +static int __dwc3_gadget_wakeup(struct dwc3 *dwc) { - int retries; - int ret; u32 reg; =20 @@ -2390,8 +2386,7 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc, boo= l async) return -EINVAL; } =20 - if (async) - dwc3_gadget_enable_linksts_evts(dwc, true); + dwc3_gadget_enable_linksts_evts(dwc, true); =20 ret =3D dwc3_gadget_set_link_state(dwc, DWC3_LINK_STATE_RECOV); if (ret < 0) { @@ -2410,27 +2405,8 @@ static int __dwc3_gadget_wakeup(struct dwc3 *dwc, bo= ol async) =20 /* * Since link status change events are enabled we will receive - * an U0 event when wakeup is successful. So bail out. + * an U0 event when wakeup is successful. */ - if (async) - return 0; - - /* poll until Link State changes to ON */ - retries =3D 20000; - - while (retries--) { - reg =3D dwc3_readl(dwc->regs, DWC3_DSTS); - - /* in HS, means ON */ - if (DWC3_DSTS_USBLNKST(reg) =3D=3D DWC3_LINK_STATE_U0) - break; - } - - if (DWC3_DSTS_USBLNKST(reg) !=3D DWC3_LINK_STATE_U0) { - dev_err(dwc->dev, "failed to send remote wakeup\n"); - return -EINVAL; - } - return 0; } =20 @@ -2451,7 +2427,7 @@ static int dwc3_gadget_wakeup(struct usb_gadget *g) spin_unlock_irqrestore(&dwc->lock, flags); return -EINVAL; } - ret =3D __dwc3_gadget_wakeup(dwc, true); + ret =3D __dwc3_gadget_wakeup(dwc); =20 spin_unlock_irqrestore(&dwc->lock, flags); =20 @@ -2479,14 +2455,10 @@ static int dwc3_gadget_func_wakeup(struct usb_gadge= t *g, int intf_id) */ link_state =3D dwc3_gadget_get_link_state(dwc); if (link_state =3D=3D DWC3_LINK_STATE_U3) { - ret =3D __dwc3_gadget_wakeup(dwc, false); - if (ret) { - spin_unlock_irqrestore(&dwc->lock, flags); - return -EINVAL; - } - dwc3_resume_gadget(dwc); - dwc->suspended =3D false; - dwc->link_state =3D DWC3_LINK_STATE_U0; + dwc->wakeup_pending_funcs |=3D BIT(intf_id); + ret =3D __dwc3_gadget_wakeup(dwc); + spin_unlock_irqrestore(&dwc->lock, flags); + return ret; } =20 ret =3D dwc3_send_gadget_generic_command(dwc, DWC3_DGCMD_DEV_NOTIFICATION, @@ -4353,6 +4325,8 @@ static void dwc3_gadget_linksts_change_interrupt(stru= ct dwc3 *dwc, { enum dwc3_link_state next =3D evtinfo & DWC3_LINK_STATE_MASK; unsigned int pwropt; + int ret; + int intf_id; =20 /* * WORKAROUND: DWC3 < 2.50a have an issue when configured without @@ -4428,7 +4402,7 @@ static void dwc3_gadget_linksts_change_interrupt(stru= ct dwc3 *dwc, =20 switch (next) { case DWC3_LINK_STATE_U0: - if (dwc->gadget->wakeup_armed) { + if (dwc->gadget->wakeup_armed || dwc->wakeup_pending_funcs) { dwc3_gadget_enable_linksts_evts(dwc, false); dwc3_resume_gadget(dwc); dwc->suspended =3D false; @@ -4451,6 +4425,18 @@ static void dwc3_gadget_linksts_change_interrupt(str= uct dwc3 *dwc, } =20 dwc->link_state =3D next; + + /* Proceed with func wakeup if any interfaces that has requested */ + while (dwc->wakeup_pending_funcs && (next =3D=3D DWC3_LINK_STATE_U0)) { + intf_id =3D ffs(dwc->wakeup_pending_funcs) - 1; + ret =3D dwc3_send_gadget_generic_command(dwc, DWC3_DGCMD_DEV_NOTIFICATIO= N, + DWC3_DGCMDPAR_DN_FUNC_WAKE | + DWC3_DGCMDPAR_INTF_SEL(intf_id)); + if (ret) + dev_err(dwc->dev, "Failed to send DN wake for intf %d\n", intf_id); + + dwc->wakeup_pending_funcs &=3D ~BIT(intf_id); + } } =20 static void dwc3_gadget_suspend_interrupt(struct dwc3 *dwc, --=20 2.25.1