From patchwork Tue Oct 18 21:50:37 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Vacura X-Patchwork-Id: 4335 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3c08:b0:7f:eb39:1b51 with SMTP id e8csp3540791dys; Tue, 18 Oct 2022 14:52:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7x2Qi11eSp+0Mwds5Bm3SbTHpDhcxWhi3BCFAd1boFZQ+GvnycI1aAf8AeDOq5rudv1fYn X-Received: by 2002:a05:6402:2706:b0:45d:aaae:e74a with SMTP id y6-20020a056402270600b0045daaaee74amr4424173edd.72.1666129955193; Tue, 18 Oct 2022 14:52:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666129955; cv=none; d=google.com; s=arc-20160816; b=quavbU+ZE8s57ghUsT7JNgHn/LD75OuKqUMVz459fSPFlYDGmFwckL+RZE64kvR/D2 hroDLZIZyng95PI6mtoqMAblUeoIElFoeANXmAdf8Ylzq+fjdotPvRzQhn5qRL0PSBs1 CEx8CMmJX5YxRXyMd2r+F2m3K0vjzQhTvwexLYV+ojLwcE185l0SomWy1wVG6APrOwBM qp+yN5yLkBLi4v2XIhW4v8WBm7qDDY3CO3gWG/s718ekFaEgQPsCkzogHRHVEAttNRRS l8x4+5nibWzwfy2q8QJyUyn3p8B4z1VXOK1yDFtRYIqKJlDgCFEP/jnAvciXXLXWin9V vrUQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=3wnBijYe1mOYpew+cIYD6PmHE6UxFYuZtEBkN5jGAfo=; b=Ibir3FhFuXMk3j72IzPkm1ZaAHEyyeiPjV6xEtSkp4sLkwfWY77EMx6gPkPnpkT3r3 tdQznZeCTcNHN8pLT2scafSaNDRvg8thi/HDVfzCn03grPg9+1DJ/LVrLsi11xdnp+Fp gvNQ1rq+KC0qcL12Q/wG3hxXBsKBqYxEJnambI598ws6/rM15ZmuxyvNBLASHewAqnWw f3y+xjEMwAmD6/bSOW29rarZR2PrRHC6TLW6simxzW38rgLpaEQHFAq+LhoWjxb13SDZ btKTbEfmivB/BDGvEpzZXqLJwQU2xcvaGk9vSQGTEVXcuoKDzlFInKWmOWWvXsApArJY ZPrw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=IsisYXdp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id dp14-20020a170906c14e00b007800ee1b748si12109171ejc.953.2022.10.18.14.52.10; Tue, 18 Oct 2022 14:52:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=IsisYXdp; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229919AbiJRVv3 (ORCPT + 99 others); Tue, 18 Oct 2022 17:51:29 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229526AbiJRVvZ (ORCPT ); Tue, 18 Oct 2022 17:51:25 -0400 Received: from mail1.bemta35.messagelabs.com (mail1.bemta35.messagelabs.com [67.219.250.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CAF0BE2F5; Tue, 18 Oct 2022 14:51:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; s=Selector; t=1666129881; i=@motorola.com; bh=3wnBijYe1mOYpew+cIYD6PmHE6UxFYuZtEBkN5jGAfo=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=IsisYXdpthplP9kffU1By4DZtdES3sfO6IjrNbb/naAKo/g1RvHuegGkuUumxnCY/ trUJRQ0tPGkq/NpZwL02zkWpX+RO5i3iR8aqGKso1+y0lg0+q8pl3jUnxId/23arDw VCL1uS1MPLxOHx1P+X/IQBZMWR/Y5fRbA/OFWrX4tv/ob/Z0zFeFNequH3nk2bJsNO B4yy/lReFVt+se1waxuqB5FJ10F3tkk/bcNkjNh/egoRnaArTIOS0x5jm0xgnyJiiu mFDC2Q87AWTXOhG2sYbIiRGrRN6TKVjJY2W8qAG7e4jbfY+kuPYqvMEmPYCVbROsVj EUu1tOqIzv/Vw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrEIsWRWlGSWpSXmKPExsWS8eKJhO4Nef9 kg7lnuS2OtT1ht3hyoJ3RonfZHjaL5sXr2Sw6Jy5ht1jYtoTF4vKuOWwWi5a1MltsabvCZPHj Tx+zxYKNjxgtVi04wO7A4zG7Yyarx6ZVnWwe++euYfdY3DeZ1aP/r4HHlv2fGT0+b5ILYI9iz cxLyq9IYM2Yt2oRa8FVjorVG18yNjCuZ+9i5OQQEpjOJLF5sm8XIxeQvY5J4u61zywgCTYBNY kFr1cxg9giArISh6/8BrOZBRpYJDZfC+5i5OAQFvCVOHVVEiTMIqAq8W3xbxaQMK+ApcS0W3w gYQkBeYn9B8+CdXIKWEl0PWxjgVhrKfG49QoriM0rIChxcuYTFojp8hLNW2czT2DknYUkNQtJ agEj0ypGs+LUorLUIl1DM72kosz0jJLcxMwcvcQq3US90mLd8tTiEl0jvcTyYr3U4mK94src5 JwUvbzUkk2MwOBPKUop38F4ZdkfvUOMkhxMSqK8c775JQvxJeWnVGYkFmfEF5XmpBYfYpTh4F CS4OWU8k8WEixKTU+tSMvMAUYiTFqCg0dJhDdNBijNW1yQmFucmQ6ROsWoy9G5v+sAsxBLXn5 eqpQ4L7csUJEASFFGaR7cCFhSuMQoKyXMy8jAwCDEU5BalJtZgir/ilGcg1FJmPcAyCqezLwS uE2vgI5gAjrCdIsfyBEliQgpqQam3UZ5Wi8NAlts2Hmrnk71+/X+aEuKs0qg4p+oTV+O7HmeY t8j4dIep7o3bvb2LsVGzXiBgEwxBl0t7hNXZP/LzmgO3/ykOP6C1fzOCPMbS+yizzJGHXe90G eoteZEbsjWgo2bY75Offz81Jv/M2TOXQ8M23nw98VyFaO4ggu78xfufeU/8+cCW6bkLAeG6oW BbotL1vxQPS317JbJNjPmxe2i/4Vnt6lwRrmKp8WqMEQomE75/3xCTkJVX8KjRXOOrO+b+ju7 7kXunRdJYia2c+enev2auV9lQZcOxz8vnfXWS572rS48a2inWWQp+e1F/SvxY8+6RPVDZk5dU vkywO/9mdK1nfsfxW74XK6ixFKckWioxVxUnAgA9UiGKYUDAAA= X-Env-Sender: w36195@motorola.com X-Msg-Ref: server-18.tower-636.messagelabs.com!1666129879!642371!1 X-Originating-IP: [104.232.228.24] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.87.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 29871 invoked from network); 18 Oct 2022 21:51:20 -0000 Received: from unknown (HELO va32lpfpp04.lenovo.com) (104.232.228.24) by server-18.tower-636.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Oct 2022 21:51:20 -0000 Received: from va32lmmrp02.lenovo.com (va32lmmrp02.mot.com [10.62.176.191]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by va32lpfpp04.lenovo.com (Postfix) with ESMTPS id 4MsSHC1SMgzgK7f; Tue, 18 Oct 2022 21:51:19 +0000 (UTC) Received: from p1g3.mot.com (unknown [100.64.172.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: w36195) by va32lmmrp02.lenovo.com (Postfix) with ESMTPSA id 4MsSHB6Z49zf6WS; Tue, 18 Oct 2022 21:51:18 +0000 (UTC) From: Dan Vacura To: linux-usb@vger.kernel.org Cc: Daniel Scally , Thinh Nguyen , Jeff Vanhoof , Dan Vacura , stable@vger.kernel.org, Greg Kroah-Hartman , Jonathan Corbet , Laurent Pinchart , Felipe Balbi , Michael Grzeschik , Paul Elder , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v4 1/6] usb: gadget: uvc: fix dropped frame after missed isoc Date: Tue, 18 Oct 2022 16:50:37 -0500 Message-Id: <20221018215044.765044-2-w36195@motorola.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018215044.765044-1-w36195@motorola.com> References: <20221018215044.765044-1-w36195@motorola.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747063883829581153?= X-GMAIL-MSGID: =?utf-8?q?1747063883829581153?= With the re-use of the previous completion status in 0d1c407b1a749 ("usb: dwc3: gadget: Return proper request status") it could be possible that the next frame would also get dropped if the current frame has a missed isoc error. Ensure that an interrupt is requested for the start of a new frame. Fixes: fc78941d8169 ("usb: gadget: uvc: decrease the interrupt load to a quarter") Cc: Signed-off-by: Dan Vacura --- V1 -> V3: - no change, new patch in series V3 -> V4: - no change drivers/usb/gadget/function/uvc_video.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index bb037fcc90e6..323977716f5a 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -431,7 +431,8 @@ static void uvcg_video_pump(struct work_struct *work) /* Endpoint now owns the request */ req = NULL; - video->req_int_count++; + if (buf->state != UVC_BUF_STATE_DONE) + video->req_int_count++; } if (!req) From patchwork Tue Oct 18 21:50:38 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Vacura X-Patchwork-Id: 4336 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3c08:b0:7f:eb39:1b51 with SMTP id e8csp3540923dys; Tue, 18 Oct 2022 14:52:52 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4sEqJa0Tgpi3VHTE9eETK/ke9PmVNSkpo3fPLxogKp+jhIe7AY/84f5w34WYyPhQ95Ra5k X-Received: by 2002:aa7:ce02:0:b0:459:4833:380a with SMTP id d2-20020aa7ce02000000b004594833380amr4466057edv.359.1666129972510; Tue, 18 Oct 2022 14:52:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666129972; cv=none; d=google.com; s=arc-20160816; b=dx83HkSxScOq/sySUGN1w6pDPyIu8jc0Psi/0WTWZq9/hb6M/2xSAwGpNMDX5DpdIm 2bWsmTRpGVx8vKQedeePtq8N1OJPxUJnm4SWuZJxcuIwHbI77WOcxVpeO1ztkBc5+W80 Aeeg8tWt1xkFmMRQZ7Cgl8Q621BCjXx9O2v6pOKOtnH5i8oHnxZ7pzrsmlQfvGaep6LM 179KPBB8Kq0FUarrYB5ElTwK+W6rThUvZcDkU4N1hz0uJzxTg6RuXqWTVVeSzvT6G4m4 FLQ7QQE5ldSgc2TjnnR3sUPCxgeaDSW/tXKFbwZVntaBjabFlvCju5sJjAyKTD/kDX9W 2xqg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=bO+t7UqaqxmwmRshsqfK3GUaZZgmxlkHrl4GFIHl+m0=; b=FNr53IOgnThmV9kxfQTvLdri3EDZ/c4ie3XEaRiq6KkixFTA5IWvVEx0qT0uOu32d0 o7lUVxXkQU2NAeQ1gHFI3RCRZv2hzu47GRheYAcsz4kHr2IpX6DmMD0hYanKDxrCdmko UZUSrNAGvMICWPu6Bz9UfOxSYL6TivFte4w0uGybmylnXmkd9qFNA5FYv97OWyVWvvXx Tyqd5UaJQNabnY+9PAS79ljNZy//DS2VeKeRIQR8gnfmCyodF/mmQt31KzaJ3SsMhI6g MApbB3GtvuhOpnVir15vu7nYnwAv52IBLqh2ASUjngZbDQYwS+ve2bxUjYmsMkdUcWKi mhkg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=E8KVIrfs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hd40-20020a17090796a800b0078d3ab37efasi13883903ejc.84.2022.10.18.14.52.27; Tue, 18 Oct 2022 14:52:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=E8KVIrfs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230010AbiJRVvc (ORCPT + 99 others); Tue, 18 Oct 2022 17:51:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35158 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229606AbiJRVvZ (ORCPT ); Tue, 18 Oct 2022 17:51:25 -0400 Received: from mail1.bemta33.messagelabs.com (mail1.bemta33.messagelabs.com [67.219.247.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12A79C787A; Tue, 18 Oct 2022 14:51:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; s=Selector; t=1666129883; i=@motorola.com; bh=bO+t7UqaqxmwmRshsqfK3GUaZZgmxlkHrl4GFIHl+m0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=E8KVIrfs2WLt4NdbBdlWMqX90JZZU7oUlBjrgFQSaJPPRGmRD16ML/7FbiUJFMmwd ZJogW+YuK0VFl+MJh6y+Els9dy00fjPR6TdfwsW0U/3HCrdt/WlQk6h8bawRLhpswi 78Lf+JHx8JUISKqGegWxwo38+kaL+maNWYrE+xfMEQEw0ZcS8ZdSgOn0prPWpfJmeU q+a9Usrm6e6ovviezHraZNCUsvGxvkUHFxIOemue8kr4SS7zxmih6YxQ9IDbRBAYlX NQPD4hNSixqSCANBMtGD3APFHCkzKqNcgWq8vxE6MJMtYr01jsTfJXCC/6SEBrEFtD Hk/yPQ6v6G0lw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFmpjleJIrShJLcpLzFFi42LJePFEXPemvH+ ywetNxhbH2p6wWzw50M5o0btsD5tF8+L1bBadE5ewWyxsW8JicXnXHDaLRctamS22tF1hsvjx p4/ZYsHGR4wWqxYcYHfg8ZjdMZPVY9OqTjaP/XPXsHss7pvM6tH/18Bjy/7PjB6fN8kFsEexZ uYl5VcksGY8PptY0C9TcbnlEnsD42KJLkYuDiGBGUwSLRv2sEM465gk7m7+yNLFyMnBJqAmse D1KmYQW0RAVuLwld/MIEXMAg0sEpd7rgMVcXAIC8RLbNkkAFLDIqAqceZPDyuIzStgKdHyYDs jiC0hIC+x/+BZsDmcAlYSXQ/bwOYLAdU8br0CVS8ocXLmE7A4M1B989bZzBMYeWchSc1CklrA yLSK0aw4tagstUjXyEAvqSgzPaMkNzEzRy+xSjdRr7RYNzWxuETXSC+xvFgvtbhYr7gyNzknR S8vtWQTIzACUoocLHcwTlz2R+8QoyQHk5Io75xvfslCfEn5KZUZicUZ8UWlOanFhxhlODiUJH g5pfyThQSLUtNTK9Iyc4DRCJOW4OBREuFNkwFK8xYXJOYWZ6ZDpE4x2nOc37l/LzPH1Nn/9jN zLAeTM7+2HWAWYsnLz0uVEufllgVqEwBpyyjNgxsKSx6XGGWlhHkZGRgYhHgKUotyM0tQ5V8x inMwKgnzHgBZzpOZVwK3+xXQWUxAZ5lu8QM5qyQRISXVwNS/50VyWLZ1Ut+HADHvkIMtEYoTn 73Zu+/9sbQgsczi5a+5Oyd6628x6wndtlyhOKg9sZbP/a05y4I9tUJSpzkuOxaftZF7n6OzNT Zmbl2ofbtSWUMDU0roYoWTjFv2HE8+JMym/S10wp038RJzONbwXnq7/XmJUaHTt6dHv8ziYUz 49eZf04uWG+LvX4qIXdq5NnzlCbGJC9gtn1fsOLht6zKFbudbLF3tLPNPWb1rWbr3PnPYx7rO L5WGBpevynqoHQlfZr/mXPfUuN0M3Cu/zJ2c555jzB2zV0Fe4cMJ3eeJepsC9ut63F2kUHl+x 6TXDQ/dy/LOrDV5JeJ5b9Kpe1vV8xQsk/U2s2xb9kSJpTgj0VCLuag4EQCoZ8qWmQMAAA== X-Env-Sender: w36195@motorola.com X-Msg-Ref: server-12.tower-715.messagelabs.com!1666129881!57521!1 X-Originating-IP: [104.232.228.23] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.100.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 19892 invoked from network); 18 Oct 2022 21:51:21 -0000 Received: from unknown (HELO va32lpfpp03.lenovo.com) (104.232.228.23) by server-12.tower-715.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Oct 2022 21:51:21 -0000 Received: from va32lmmrp02.lenovo.com (va32lmmrp02.mot.com [10.62.176.191]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by va32lpfpp03.lenovo.com (Postfix) with ESMTPS id 4MsSHF30MPz50WfM; Tue, 18 Oct 2022 21:51:21 +0000 (UTC) Received: from p1g3.mot.com (unknown [100.64.172.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: w36195) by va32lmmrp02.lenovo.com (Postfix) with ESMTPSA id 4MsSHF12rwzf6WS; Tue, 18 Oct 2022 21:51:21 +0000 (UTC) From: Dan Vacura To: linux-usb@vger.kernel.org Cc: Daniel Scally , Thinh Nguyen , Jeff Vanhoof , stable@vger.kernel.org, Dan Vacura , Greg Kroah-Hartman , Jonathan Corbet , Laurent Pinchart , Felipe Balbi , Paul Elder , Michael Grzeschik , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v4 2/6] usb: dwc3: gadget: cancel requests instead of release after missed isoc Date: Tue, 18 Oct 2022 16:50:38 -0500 Message-Id: <20221018215044.765044-3-w36195@motorola.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018215044.765044-1-w36195@motorola.com> References: <20221018215044.765044-1-w36195@motorola.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747063902107591188?= X-GMAIL-MSGID: =?utf-8?q?1747063902107591188?= From: Jeff Vanhoof arm-smmu related crashes seen after a Missed ISOC interrupt when no_interrupt=1 is used. This can happen if the hardware is still using the data associated with a TRB after the usb_request's ->complete call has been made. Instead of immediately releasing a request when a Missed ISOC interrupt has occurred, this change will add logic to cancel the request instead where it will eventually be released when the END_TRANSFER command has completed. This logic is similar to some of the cleanup done in dwc3_gadget_ep_dequeue. Fixes: 6d8a019614f3 ("usb: dwc3: gadget: check for Missed Isoc from event status") Cc: Signed-off-by: Jeff Vanhoof Co-developed-by: Dan Vacura Signed-off-by: Dan Vacura --- V1 -> V3: - no change, new patch in series V3 -> V4: - no change drivers/usb/dwc3/core.h | 1 + drivers/usb/dwc3/gadget.c | 38 ++++++++++++++++++++++++++------------ 2 files changed, 27 insertions(+), 12 deletions(-) diff --git a/drivers/usb/dwc3/core.h b/drivers/usb/dwc3/core.h index 8f9959ba9fd4..9b005d912241 100644 --- a/drivers/usb/dwc3/core.h +++ b/drivers/usb/dwc3/core.h @@ -943,6 +943,7 @@ struct dwc3_request { #define DWC3_REQUEST_STATUS_DEQUEUED 3 #define DWC3_REQUEST_STATUS_STALLED 4 #define DWC3_REQUEST_STATUS_COMPLETED 5 +#define DWC3_REQUEST_STATUS_MISSED_ISOC 6 #define DWC3_REQUEST_STATUS_UNKNOWN -1 u8 epnum; diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 079cd333632e..411532c5c378 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -2021,6 +2021,9 @@ static void dwc3_gadget_ep_cleanup_cancelled_requests(struct dwc3_ep *dep) case DWC3_REQUEST_STATUS_STALLED: dwc3_gadget_giveback(dep, req, -EPIPE); break; + case DWC3_REQUEST_STATUS_MISSED_ISOC: + dwc3_gadget_giveback(dep, req, -EXDEV); + break; default: dev_err(dwc->dev, "request cancelled with wrong reason:%d\n", req->status); dwc3_gadget_giveback(dep, req, -ECONNRESET); @@ -3402,21 +3405,32 @@ static bool dwc3_gadget_endpoint_trbs_complete(struct dwc3_ep *dep, struct dwc3 *dwc = dep->dwc; bool no_started_trb = true; - dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); + if (status == -EXDEV) { + struct dwc3_request *tmp; + struct dwc3_request *req; - if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) - goto out; + if (!(dep->flags & DWC3_EP_END_TRANSFER_PENDING)) + dwc3_stop_active_transfer(dep, true, true); - if (!dep->endpoint.desc) - return no_started_trb; + list_for_each_entry_safe(req, tmp, &dep->started_list, list) + dwc3_gadget_move_cancelled_request(req, + DWC3_REQUEST_STATUS_MISSED_ISOC); + } else { + dwc3_gadget_ep_cleanup_completed_requests(dep, event, status); - if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && - list_empty(&dep->started_list) && - (list_empty(&dep->pending_list) || status == -EXDEV)) - dwc3_stop_active_transfer(dep, true, true); - else if (dwc3_gadget_ep_should_continue(dep)) - if (__dwc3_gadget_kick_transfer(dep) == 0) - no_started_trb = false; + if (dep->flags & DWC3_EP_END_TRANSFER_PENDING) + goto out; + + if (!dep->endpoint.desc) + return no_started_trb; + + if (usb_endpoint_xfer_isoc(dep->endpoint.desc) && + list_empty(&dep->started_list) && list_empty(&dep->pending_list)) + dwc3_stop_active_transfer(dep, true, true); + else if (dwc3_gadget_ep_should_continue(dep)) + if (__dwc3_gadget_kick_transfer(dep) == 0) + no_started_trb = false; + } out: /* From patchwork Tue Oct 18 21:50:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Vacura X-Patchwork-Id: 4337 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3c08:b0:7f:eb39:1b51 with SMTP id e8csp3541553dys; Tue, 18 Oct 2022 14:54:16 -0700 (PDT) X-Google-Smtp-Source: AMsMyM52Yxpi3vi3wnbfqDgJ6wIsbRHCB/GhaBHiNjPNcef4/ubmMNlQSziSz5ygGVgeboWRzdVd X-Received: by 2002:a05:6402:2793:b0:45c:d273:8c18 with SMTP id b19-20020a056402279300b0045cd2738c18mr4644229ede.337.1666130056221; Tue, 18 Oct 2022 14:54:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666130056; cv=none; d=google.com; s=arc-20160816; b=WFtrRY90pAoipfHTP8brA2dJh+Bw+5VdXGfo0UoxpfZE4StK84jTXy5LkTWLcf/5nY MHT8HajGSFwsS/2k5sDa+vsijUBD850iGaM+PBcqwp4+Ri8wkPtFS7E8T0OsnjSxRHcI huj0PZXjBXJMEpEpSL8kbKUu8pKdXioHNRhlfF5GYKCg8rwGWzTKfItMbAMQcrxFhbls fxPQIinJ4Yz1hm8iylA4mS3b+dJOHoa226tNTW+Ra7mEaB0OWiL+SfGPYuSX7HONG3MO ndSQtGDMzGDSybEIEqxNSIrJwtatPflFQ+Md2Xm3noii4zbmH/pkVUoM55sCiTUrXdVw MJow== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sfQAryD/xBgH6Xtqc/fcYqWHp7Ikn2PFWWAT/anYcbM=; b=eozhuLQdruncmEmbI25GKkDmtsC/Dtmb65iTUneIVJaOAC+Juny+00EEfZK6Woy3DS /TXbRFI1yLSwckN6lIiLxoa0SNOefPyxzVjbHYXCxSYw+czIBAaop3LxiKl45alm3ZNm Vz6PMIUbmm5qvOonlo5FMWVqFRcXHW+3rIojGqtN1Md9eNUCJQtgzX1/xB/LCyxFBFV2 RTGwBoqri0LUvdlSbcS340iNkvxm+GXlVM4X/zC3oVrFdMOhigwnW7qHreduCp3YmiGM 1nCEM5xVcCXGu3Exks216XzV94WjIiYmAxHV2GdgYtCDnbCHkDwZGcipg9vbCLP7oOzA 2GUw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=aXiY4dEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ce12-20020a170906b24c00b007819684b56fsi10865988ejb.225.2022.10.18.14.53.51; Tue, 18 Oct 2022 14:54:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=aXiY4dEG; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230034AbiJRVvg (ORCPT + 99 others); Tue, 18 Oct 2022 17:51:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35186 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229861AbiJRVv1 (ORCPT ); Tue, 18 Oct 2022 17:51:27 -0400 Received: from mail1.bemta35.messagelabs.com (mail1.bemta35.messagelabs.com [67.219.250.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7AFC9BE2FA; Tue, 18 Oct 2022 14:51:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; s=Selector; t=1666129886; i=@motorola.com; bh=sfQAryD/xBgH6Xtqc/fcYqWHp7Ikn2PFWWAT/anYcbM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=aXiY4dEGkp/dNiF7l4HrWCrfgbEP/IqiSPH15ayVN/gcz93V3SIUcFSvjI52RRP70 vGC1S2ysDOyy/JEv884apnHB2b0RsTTqNV6cqnkX70cNAG239aLyBRhsu+tMTsNoF2 2NjUunMi9W0McB89Nnea5ofCuzXRouspWTA8R9O4hDTUwRAQ90cncQfCGOZ6RZwQJj bZ8atdeRvhyoj1qu9/KOSMDPXtFW2hHGw8VXZA6GrhCvnuAmPXCdUqsTvnrDH58+k4 G92VIchE73JE8M6ORTrTVmvi5u4ya3nQudpiAx8NlOriEwGCOig4woQrmIWH8IYQzd ZmSOiXe5rxFcw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRWlGSWpSXmKPExsWS8eKJhO4def9 kgyePDCyOtT1ht3hyoJ3RonfZHjaL5sXr2Sw6Jy5ht1jYtoTF4vKuOWwWi5a1MltsabvCZPHj Tx+zxYKNjxgtVi04wO7A4zG7Yyarx6ZVnWwe++euYfdY3DeZ1aP/r4HHlv2fGT0+b5ILYI9iz cxLyq9IYM3Y9/IgY8E7pYqGi29YGxgvynYxcnEICUxnkjjwqYkFwlnHJDHx0Q0gh5ODTUBNYs HrVcwgtoiArMThK7/BbGaBBhaJzdeCQWxhAXeJS70Tgeo5OFgEVCV2dRqAhHkFLCWWvWllBbE lBOQl9h88C9bKKWAl0fWwDWy8EFDN49YrrBD1ghInZz5hgRgvL9G8dTbzBEbeWUhSs5CkFjAy rWI0LU4tKkst0jXSSyrKTM8oyU3MzNFLrNJN1Cst1i1PLS4ByiSWF+ulFhfrFVfmJuek6OWll mxiBIZ/SlHC/B2MU5f+0TvEKMnBpCTKO+ebX7IQX1J+SmVGYnFGfFFpTmrxIUYZDg4lCV5OKf 9kIcGi1PTUirTMHGAswqQlOHiURHjTZIDSvMUFibnFmekQqVOMuhyd+7sOMAux5OXnpUqJ83L LAhUJgBRllObBjYClhUuMslLCvIwMDAxCPAWpRbmZJajyrxjFORiVhHkPgKziycwrgdv0CugI JqAjTLf4gRxRkoiQkmpg6uJmX9uk/uOQ4am/sUsuH3GukV14R0X+/Zut387cZUo6dnNmHFPVX x9/ia9nk85VSHBoMR3bdks/7XO0RflbTc/u8vkSu092pEyZKm6eK8Ia9KNUdkbhSoH1n01FbB fe0mV//NJf+rhqvEySb9j51M07OubHsT01mDxjoafJWd6WAkPuM8cLuBu4X51eFb2nZ/XRbZL 2O0+UbKh+Ly/LdIQ5YuuW3Qz8lewibaVbXevyIszk/2xc51l+zu3ERYFPeT3lMZZXrzi8F5Od /uSyio/llG+OlZ8WBnXdfDbTZemDQm/JK5mtl3/cZuesLWZgkd+zkqFLb5ptl9jMyXXPmNmMA xmmbN04yftfvVK8EktxRqKhFnNRcSIATuoq6oYDAAA= X-Env-Sender: w36195@motorola.com X-Msg-Ref: server-18.tower-636.messagelabs.com!1666129883!642373!1 X-Originating-IP: [104.232.228.24] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.87.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30411 invoked from network); 18 Oct 2022 21:51:24 -0000 Received: from unknown (HELO va32lpfpp04.lenovo.com) (104.232.228.24) by server-18.tower-636.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Oct 2022 21:51:24 -0000 Received: from va32lmmrp02.lenovo.com (va32lmmrp02.mot.com [10.62.176.191]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by va32lpfpp04.lenovo.com (Postfix) with ESMTPS id 4MsSHH5HK9zgK7f; Tue, 18 Oct 2022 21:51:23 +0000 (UTC) Received: from p1g3.mot.com (unknown [100.64.172.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: w36195) by va32lmmrp02.lenovo.com (Postfix) with ESMTPSA id 4MsSHH3S9Jzf6WS; Tue, 18 Oct 2022 21:51:23 +0000 (UTC) From: Dan Vacura To: linux-usb@vger.kernel.org Cc: Daniel Scally , Thinh Nguyen , Jeff Vanhoof , Dan Vacura , stable@vger.kernel.org, Greg Kroah-Hartman , Jonathan Corbet , Laurent Pinchart , Felipe Balbi , Michael Grzeschik , Paul Elder , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v4 3/6] usb: gadget: uvc: fix sg handling in error case Date: Tue, 18 Oct 2022 16:50:39 -0500 Message-Id: <20221018215044.765044-4-w36195@motorola.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018215044.765044-1-w36195@motorola.com> References: <20221018215044.765044-1-w36195@motorola.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747063990276019353?= X-GMAIL-MSGID: =?utf-8?q?1747063990276019353?= If there is a transmission error the buffer will be returned too early, causing a memory fault as subsequent requests for that buffer are still queued up to be sent. Refactor the error handling to wait for the final request to come in before reporting back the buffer to userspace for all transfer types (bulk/isoc/isoc_sg). This ensures userspace knows if the frame was successfully sent. Fixes: e81e7f9a0eb9 ("usb: gadget: uvc: add scatter gather support") Cc: Signed-off-by: Dan Vacura --- V1 -> V2: - undo error rename - change uvcg_info to uvcg_dbg V2 -> V3: - no changes V3 -> V4: - drop extra cc stable cherry-picks, as a request was made to stable drivers/usb/gadget/function/uvc_queue.c | 8 +++++--- drivers/usb/gadget/function/uvc_video.c | 18 ++++++++++++++---- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c index ec500ee499ee..0aa3d7e1f3cc 100644 --- a/drivers/usb/gadget/function/uvc_queue.c +++ b/drivers/usb/gadget/function/uvc_queue.c @@ -304,6 +304,7 @@ int uvcg_queue_enable(struct uvc_video_queue *queue, int enable) queue->sequence = 0; queue->buf_used = 0; + queue->flags &= ~UVC_QUEUE_DROP_INCOMPLETE; } else { ret = vb2_streamoff(&queue->queue, queue->queue.type); if (ret < 0) @@ -329,10 +330,11 @@ int uvcg_queue_enable(struct uvc_video_queue *queue, int enable) void uvcg_complete_buffer(struct uvc_video_queue *queue, struct uvc_buffer *buf) { - if ((queue->flags & UVC_QUEUE_DROP_INCOMPLETE) && - buf->length != buf->bytesused) { - buf->state = UVC_BUF_STATE_QUEUED; + if (queue->flags & UVC_QUEUE_DROP_INCOMPLETE) { + queue->flags &= ~UVC_QUEUE_DROP_INCOMPLETE; + buf->state = UVC_BUF_STATE_ERROR; vb2_set_plane_payload(&buf->buf.vb2_buf, 0, 0); + vb2_buffer_done(&buf->buf.vb2_buf, VB2_BUF_STATE_ERROR); return; } diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index 323977716f5a..5993e083819c 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -88,6 +88,7 @@ uvc_video_encode_bulk(struct usb_request *req, struct uvc_video *video, struct uvc_buffer *buf) { void *mem = req->buf; + struct uvc_request *ureq = req->context; int len = video->req_size; int ret; @@ -113,13 +114,14 @@ uvc_video_encode_bulk(struct usb_request *req, struct uvc_video *video, video->queue.buf_used = 0; buf->state = UVC_BUF_STATE_DONE; list_del(&buf->queue); - uvcg_complete_buffer(&video->queue, buf); video->fid ^= UVC_STREAM_FID; + ureq->last_buf = buf; video->payload_size = 0; } if (video->payload_size == video->max_payload_size || + video->queue.flags & UVC_QUEUE_DROP_INCOMPLETE || buf->bytesused == video->queue.buf_used) video->payload_size = 0; } @@ -180,7 +182,8 @@ uvc_video_encode_isoc_sg(struct usb_request *req, struct uvc_video *video, req->length -= len; video->queue.buf_used += req->length - header_len; - if (buf->bytesused == video->queue.buf_used || !buf->sg) { + if (buf->bytesused == video->queue.buf_used || !buf->sg || + video->queue.flags & UVC_QUEUE_DROP_INCOMPLETE) { video->queue.buf_used = 0; buf->state = UVC_BUF_STATE_DONE; buf->offset = 0; @@ -195,6 +198,7 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video, struct uvc_buffer *buf) { void *mem = req->buf; + struct uvc_request *ureq = req->context; int len = video->req_size; int ret; @@ -209,12 +213,13 @@ uvc_video_encode_isoc(struct usb_request *req, struct uvc_video *video, req->length = video->req_size - len; - if (buf->bytesused == video->queue.buf_used) { + if (buf->bytesused == video->queue.buf_used || + video->queue.flags & UVC_QUEUE_DROP_INCOMPLETE) { video->queue.buf_used = 0; buf->state = UVC_BUF_STATE_DONE; list_del(&buf->queue); - uvcg_complete_buffer(&video->queue, buf); video->fid ^= UVC_STREAM_FID; + ureq->last_buf = buf; } } @@ -255,6 +260,11 @@ uvc_video_complete(struct usb_ep *ep, struct usb_request *req) case 0: break; + case -EXDEV: + uvcg_dbg(&video->uvc->func, "VS request missed xfer.\n"); + queue->flags |= UVC_QUEUE_DROP_INCOMPLETE; + break; + case -ESHUTDOWN: /* disconnect from host. */ uvcg_dbg(&video->uvc->func, "VS request cancelled.\n"); uvcg_queue_cancel(queue, 1); From patchwork Tue Oct 18 21:50:40 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Vacura X-Patchwork-Id: 4338 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3c08:b0:7f:eb39:1b51 with SMTP id e8csp3542369dys; Tue, 18 Oct 2022 14:56:06 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GujXcT8/hxI1L16lD4BQbrmoBrL3KtcASDPOwdPL3KUEsY02pRbNXWfiZMRhGZIWvNnVp X-Received: by 2002:a17:906:eeca:b0:730:6880:c397 with SMTP id wu10-20020a170906eeca00b007306880c397mr4124202ejb.593.1666130166146; Tue, 18 Oct 2022 14:56:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666130166; cv=none; d=google.com; s=arc-20160816; b=SlAuYlyo4Q3ZFtu+nLXmfrYI3jsDPTIzur1Fch+Hktfds1SorLd8j3EEefHd0e2NrR Y7sn8r4thuRwTIgJOymIDZ+ZOwcaBYdGJuEZ50obhfG4xNKd6GZ8+6V5KRzQb/89Dv6u X8pQiWfahVY4UqwFyzUtY14KQxmFBeXi4gYp0PL6azyP/S06bVy83aMKsuKj7jhzFM09 BXMpZwYA/8bSUeFmIoNNNhJPxliwV/iZdG2Oba33sZzIJm0Z+iGjmi4+oiqPU+0Oey7L /Cr3nOA4tDjNMgxELu2/fVjtLSI432Rxz0zWzR1Zo+hrotu1NiOmmkbGHCqdevEJFFwZ T2iQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=sRQxZis6uCJYVoJAnHknw5dTcE1MWsQ1xSYk7VRSQkM=; b=o4NVs067mo6/EwUzH3IfDFHd7Xepr+QUOrVaElGVAcqSCr93iNha0GHgbyvwVC3RFx Td2W2kUvCe6NdMVZk+vAUp32/OcgOsIINhtUTFoDCWA7ANd3V8T+occHhoK0imtEQrCv wxOoUrcTfPjez2w1Aiw/JQvaeBHJERBQ8wbS16joigcnEtPuYiUJ/BrHWQsZh0atxweX UzioJG0vKufzblY0T+V6Z5jOQ929/cnwHCubLpi7vo/hkuKZrFy42NObgjgSGCOhZuhm Si+FbjLO+4aMk4sppFFFAMoRMajNpjlk/6g1NQmx1XbzGCsG91jvrMh38W0UqAvGEqFt Dj2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=J8RVRD+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hq38-20020a1709073f2600b0078bb4d5db86si11875916ejc.77.2022.10.18.14.55.36; Tue, 18 Oct 2022 14:56:06 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=J8RVRD+t; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230046AbiJRVvj (ORCPT + 99 others); Tue, 18 Oct 2022 17:51:39 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229917AbiJRVv2 (ORCPT ); Tue, 18 Oct 2022 17:51:28 -0400 Received: from mail1.bemta35.messagelabs.com (mail1.bemta35.messagelabs.com [67.219.250.2]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2363BBE2F5; Tue, 18 Oct 2022 14:51:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; s=Selector; t=1666129887; i=@motorola.com; bh=sRQxZis6uCJYVoJAnHknw5dTcE1MWsQ1xSYk7VRSQkM=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=J8RVRD+t/ZOLfV4xw6PbYaduZsKrrq6d01ANwX8eMn19amTViOxmsz4fMm0HIge/x wjpnv+snKMgESPP1fdjBzbpbCtDMyoYVloGtHOTk1xk5Yja7H3p1s1C9oFLzQ7YY+g OKuOgk+E7fzpbvxNmdk/xFgA7nSy54NUnOu83IulPLP273QHOjm674l5IB9mNHMKwZ I3FfC7F9O9MezRlvKkaX+Iy+AS/74/a2I9SezbevTFZc1Xksf/FcYjZkmRON9VvX2b 6TAiPwzvR/de4yAxYMFxJzejSJbJSOSEmE+Alz+JqKacx3ezkcu1NSUMdKOt6+vMOx 5jeQNOH5A2rlQ== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrMIsWRWlGSWpSXmKPExsUyYU+Ds+49ef9 kg461ZhbH2p6wWzw50M5o0btsD5tF8+L1bBadE5ewWyxsW8JicXnXHDaLRctamS22tF1hsvjx p4/ZYsHGR4wWqxYcYHfg8ZjdMZPVY9OqTjaP/XPXsHss7pvM6tH/18Bjy/7PjB6fN8kFsEexZ uYl5VcksGbsaj7PUvCVq2JZ2y7mBsZNnF2MXBxCAtOYJDbP/MjexcgJ5Kxjkph7wRrEZhNQk1 jwehUziC0iICtx+MpvZpAGZoEGFonLPddZuhg5OIQFfCWmTzECMVkEVCUmL00GKecVsJS4cmE 1E4gtISAvsf/gWbAxnAJWEl0P21ggVllKPG69wgpRLyhxcuYTsDgzUH3z1tnMExh5ZyFJzUKS WsDItIrRrDi1qCy1SNfQQi+pKDM9oyQ3MTNHL7FKN1GvtFi3PLW4RNdIL7G8WC+1uFivuDI3O SdFLy+1ZBMjMPxTihJ6djBuX/ZH7xCjJAeTkijvnG9+yUJ8SfkplRmJxRnxRaU5qcWHGGU4OJ QkeDml/JOFBItS01Mr0jJzgLEIk5bg4FES4U2TAUrzFhck5hZnpkOkTjHqcnTu7zrALMSSl5+ XKiXOyy0LVCQAUpRRmgc3ApYWLjHKSgnzMjIwMAjxFKQW5WaWoMq/YhTnYFQS5j0AsoonM68E btMroCOYgI4w3eIHckRJIkJKqoHJ9u+xvb/2ZVtfvXRGgPP2nrRnzxiNjkWqGQaHuoQ7l3Qy3 VSfo8zU2KTExjmBRye09onuzceJStJ/nq650nz/FcdT/tq9Te8Kvc5lrFcs8K/3e5y8onCC4K 41TSdre65WPvt5nNcj9sSfyncXf1pN8y/5kth05UjAq8sTt88xkr4t1P9a5+a0lpXZTC7c1mW aHO+slxqKrE1iq3lfPHXjQdv800s/COkqWU7NcT67q3Qqw7fPNxre317C/8VParHoGs55Jw+J HFPNPb/s0yatGVYTTs87ZMqdVu+o4Xd9o/7dHVrOscqLv+72fSLK9C7w62/pqo0vLG1+N5itf 2u8huWkmlfY+lqnlwknVnuoK7EUZyQaajEXFScCABQo1EOGAwAA X-Env-Sender: w36195@motorola.com X-Msg-Ref: server-19.tower-655.messagelabs.com!1666129886!235534!1 X-Originating-IP: [144.188.128.67] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.87.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 25603 invoked from network); 18 Oct 2022 21:51:26 -0000 Received: from unknown (HELO ilclpfpp01.lenovo.com) (144.188.128.67) by server-19.tower-655.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Oct 2022 21:51:26 -0000 Received: from va32lmmrp02.lenovo.com (va32lmmrp02.mot.com [10.62.176.191]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ilclpfpp01.lenovo.com (Postfix) with ESMTPS id 4MsSHL0mqwzfBZq; Tue, 18 Oct 2022 21:51:26 +0000 (UTC) Received: from p1g3.mot.com (unknown [100.64.172.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: w36195) by va32lmmrp02.lenovo.com (Postfix) with ESMTPSA id 4MsSHK56klzf6WS; Tue, 18 Oct 2022 21:51:25 +0000 (UTC) From: Dan Vacura To: linux-usb@vger.kernel.org Cc: Daniel Scally , Thinh Nguyen , Jeff Vanhoof , stable@vger.kernel.org, Dan Vacura , Greg Kroah-Hartman , Jonathan Corbet , Laurent Pinchart , Felipe Balbi , Paul Elder , Michael Grzeschik , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v4 4/6] usb: gadget: uvc: fix sg handling during video encode Date: Tue, 18 Oct 2022 16:50:40 -0500 Message-Id: <20221018215044.765044-5-w36195@motorola.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018215044.765044-1-w36195@motorola.com> References: <20221018215044.765044-1-w36195@motorola.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747064104745329020?= X-GMAIL-MSGID: =?utf-8?q?1747064104745329020?= From: Jeff Vanhoof In uvc_video_encode_isoc_sg, the uvc_request's sg list is incorrectly being populated leading to corrupt video being received by the remote end. When building the sg list the usage of buf->sg's 'dma_length' field is not correct and instead its 'length' field should be used. Fixes: e81e7f9a0eb9 ("usb: gadget: uvc: add scatter gather support") Cc: Signed-off-by: Jeff Vanhoof Signed-off-by: Dan Vacura --- V1 -> V3: - no change, new patch in series V3 -> V4: - no change drivers/usb/gadget/function/uvc_video.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index 5993e083819c..dd1c6b2ca7c6 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -157,10 +157,10 @@ uvc_video_encode_isoc_sg(struct usb_request *req, struct uvc_video *video, sg = sg_next(sg); for_each_sg(sg, iter, ureq->sgt.nents - 1, i) { - if (!len || !buf->sg || !sg_dma_len(buf->sg)) + if (!len || !buf->sg || !buf->sg->length) break; - sg_left = sg_dma_len(buf->sg) - buf->offset; + sg_left = buf->sg->length - buf->offset; part = min_t(unsigned int, len, sg_left); sg_set_page(iter, sg_page(buf->sg), part, buf->offset); From patchwork Tue Oct 18 21:50:41 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Vacura X-Patchwork-Id: 4339 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3c08:b0:7f:eb39:1b51 with SMTP id e8csp3542410dys; Tue, 18 Oct 2022 14:56:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4xhcHLHXMDEU6gHNbncdVJGr4g77RkUbw8znQihemupXdiPZM532LSqeMiUAaAfb/ILQP2 X-Received: by 2002:a17:906:8a4b:b0:78d:d475:ff74 with SMTP id gx11-20020a1709068a4b00b0078dd475ff74mr3979914ejc.131.1666130172081; Tue, 18 Oct 2022 14:56:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666130172; cv=none; d=google.com; s=arc-20160816; b=Y9EeWNdnv6G2A6pxbbsUrmB6dDvAnjhWkMDK8gU3wVYE23jTjkXkwtMev3Bvu9CZtv 9Q2GAlzMlkw8Snpg50+w9xpf4/NlSMNi+7yIKFLqZJ3YgtzG+PdLDWgeyWuJmqGhmxZF KQfKZxIhAZoF4J6MwWJYlhuyeVOYOIbhRiwR7cKmHGDKNyue9OKEqkuzKc/PLTrpwiBo gLHMJOqO84vL9VqmqeSevv3sEZvhQ6zroj01swUbyJ9desa43sTpj0oRMTYMmTkrO124 JmlyvQUNt9O579BT3XBLq2fgrtxz/TAUdueIeb+W0rKAvBNypQPPy7NSGJ49hd0pZ1bQ 48fA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=8C4mpLzfAGmUvqoBtRBj2oPSMTlDzsJxu1HgUPQnxFc=; b=HexpYit/C3HyMdd8cMQXIjxFrAN/7tIqd7cET0U1nIiX1PZaevVUAzZBsrpQL/mph4 1pe+lJU5ccO9ZTcH3qdZs78Zl+IgAKdzED42Abgebvq5alrWQ1xe0r+fMf1/72a9+oCr 5OUHD+TvH0neT31OgxyEIEQ5qYCorexyWhPv/H9BH8b2NSIfZEmiSvSjA7qpKW5j2HUE KNDmUr5pP43ZGTSqgUqAZcNaGrWxunkzlCXQMfPx76GTkjOjboJsySUjgKdhSOzdgQhm VH+fahyB18wbCMPhPI/0AD5+6Q+yfxPazmhas5i8rfaQ8vqYCJbK8pkP81R0WMMrCN0a 8Ctw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=qX84A6D9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id bv24-20020a170906b1d800b0078dc3be6508si11771457ejb.192.2022.10.18.14.55.46; Tue, 18 Oct 2022 14:56:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=qX84A6D9; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230076AbiJRVvr (ORCPT + 99 others); Tue, 18 Oct 2022 17:51:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35344 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230009AbiJRVvc (ORCPT ); Tue, 18 Oct 2022 17:51:32 -0400 Received: from mail1.bemta33.messagelabs.com (mail1.bemta33.messagelabs.com [67.219.247.6]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7B47CAE55; Tue, 18 Oct 2022 14:51:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; s=Selector; t=1666129889; i=@motorola.com; bh=8C4mpLzfAGmUvqoBtRBj2oPSMTlDzsJxu1HgUPQnxFc=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=qX84A6D9CB5ogQPXoUAJL4ECeD6qUMTDh7ABwIrIdel4AhXNiJaqt8/O/tpWT/EfJ 7acGYcMF1G6FRTzLvR2BTZQf2Rar6sy4vBtmiCBkhbA4ZuNU5CTzMeGguDGLQ3yBJZ SbdL5cx3FDq0yNMOquGW8O7aht9QB1oUfWR9BEhg0uWBvKfV290Eg55wzCrSRe/Qxz xljd5T4nzlYnVKPwwc+xGYQsvBW96btMR80Q+Yy875EI9wpX8OckkfvxqjCuFQYnD3 hlu2nBBOS98xc2F1p67PG/QPgzDywcf/qzfKoWmcK8iIjYcZ4jWPmtADkmxbZ9yytj kR/iDfrGizpkw== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrIIsWRWlGSWpSXmKPExsWS8eKJuO4Def9 kg7cPhC2OtT1ht3hyoJ3RonfZHjaL5sXr2Sw6Jy5ht1jYtoTF4vKuOWwWi5a1MltsabvCZPHj Tx+zxaoFB9gduD1md8xk9di0qpPNY//cNewei/sms3r0/zXw2LL/M6PH501yAexRrJl5SfkVC awZDQdfsRTcNaiY/PgWcwPjN80uRi4OIYEZTBLT1z5ghHDWMUlMfXiQvYuRk4NNQE1iwetVzC C2iICsxOErv5lBipgFnjNLHP60DiwhLBAgcebTazYQm0VAVeLXoueMIDavgKXE1d13wQZJCMh L7D94FqyeU8BKouthGwuILQRU87j1CitEvaDEyZlPwOLMQPXNW2czT2DknYUkNQtJagEj0ypG s+LUorLUIl1DS72kosz0jJLcxMwcvcQq3US90mLd1MTiEl0jvcTyYr3U4mK94src5JwUvbzUk k2MwNBPKXL/uYNx/rI/eocYJTmYlER553zzSxbiS8pPqcxILM6ILyrNSS0+xCjDwaEkwcsp5Z 8sJFiUmp5akZaZA4xDmLQEB4+SCG+aDFCat7ggMbc4Mx0idYpRl6Nzf9cBZiGWvPy8VClxXm5 ZoCIBkKKM0jy4EbCUcIlRVkqYl5GBgUGIpyC1KDezBFX+FaM4B6OSMO8BkFU8mXklcJteAR3B BHSE6RY/kCNKEhFSUg1MM3iy9x158saluiVWxXOZZNvmLT/ffZrqeNBn4WWTun1fvRuuVefMu zajbtWLv+sb3lqKb5DaJvfnbuyvlVHl82S1s5e/zd9Y5uj1T0RFbIHc0133l7FULp7hP+fp4S 81U7SuXpupP5XlyNbZWtpyRT+slzJc8Bb/sk5Y8MA11U1v4jOic3eZ7FzELn+TxfDGhuaz6i/ 8T8keOjrPmeXJ96Rt/lfOW3b0SqoW5zyaKdp4XXOxTs6Vpv+qqTPi9sfL5P8Tr5z84fi81lfc wWapNh6n9r65KtXH7Vdqca8iXUlL7Z0X6+k6n8yXIhMZ7/P3eFyYdq/JhEO91z703fd7bV+Ek zbPli0LeK4rM5FhjRJLcUaioRZzUXEiAIYJe2KEAwAA X-Env-Sender: w36195@motorola.com X-Msg-Ref: server-12.tower-715.messagelabs.com!1666129888!57532!1 X-Originating-IP: [104.232.228.23] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.100.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 20118 invoked from network); 18 Oct 2022 21:51:28 -0000 Received: from unknown (HELO va32lpfpp03.lenovo.com) (104.232.228.23) by server-12.tower-715.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Oct 2022 21:51:28 -0000 Received: from va32lmmrp02.lenovo.com (va32lmmrp02.mot.com [10.62.176.191]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by va32lpfpp03.lenovo.com (Postfix) with ESMTPS id 4MsSHM6xjrz50WfM; Tue, 18 Oct 2022 21:51:27 +0000 (UTC) Received: from p1g3.mot.com (unknown [100.64.172.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: w36195) by va32lmmrp02.lenovo.com (Postfix) with ESMTPSA id 4MsSHM5G9Mzf6WS; Tue, 18 Oct 2022 21:51:27 +0000 (UTC) From: Dan Vacura To: linux-usb@vger.kernel.org Cc: Daniel Scally , Thinh Nguyen , Jeff Vanhoof , Dan Vacura , Greg Kroah-Hartman , Jonathan Corbet , Laurent Pinchart , Felipe Balbi , Paul Elder , Michael Grzeschik , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v4 5/6] usb: gadget: uvc: make interrupt skip logic configurable Date: Tue, 18 Oct 2022 16:50:41 -0500 Message-Id: <20221018215044.765044-6-w36195@motorola.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018215044.765044-1-w36195@motorola.com> References: <20221018215044.765044-1-w36195@motorola.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747064111422275164?= X-GMAIL-MSGID: =?utf-8?q?1747064111422275164?= Some UDC hw may not support skipping interrupts, but still support the request. Allow the interrupt frequency to be configurable to the user. Signed-off-by: Dan Vacura --- V1 -> V2: - no change, new patch in series V2 -> V3: - default to baseline value of 4, fix storing the initial value V3 -> V4: - no change Documentation/ABI/testing/configfs-usb-gadget-uvc | 1 + Documentation/usb/gadget-testing.rst | 2 ++ drivers/usb/gadget/function/f_uvc.c | 3 +++ drivers/usb/gadget/function/u_uvc.h | 1 + drivers/usb/gadget/function/uvc.h | 2 ++ drivers/usb/gadget/function/uvc_configfs.c | 2 ++ drivers/usb/gadget/function/uvc_queue.c | 6 ++++++ drivers/usb/gadget/function/uvc_video.c | 3 ++- 8 files changed, 19 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/configfs-usb-gadget-uvc b/Documentation/ABI/testing/configfs-usb-gadget-uvc index 611b23e6488d..5dfaa3f7f6a4 100644 --- a/Documentation/ABI/testing/configfs-usb-gadget-uvc +++ b/Documentation/ABI/testing/configfs-usb-gadget-uvc @@ -8,6 +8,7 @@ Description: UVC function directory streaming_maxpacket 1..1023 (fs), 1..3072 (hs/ss) streaming_interval 1..16 function_name string [32] + req_int_skip_div unsigned int =================== ============================= What: /config/usb-gadget/gadget/functions/uvc.name/control diff --git a/Documentation/usb/gadget-testing.rst b/Documentation/usb/gadget-testing.rst index 2278c9ffb74a..f9b5a09be1f4 100644 --- a/Documentation/usb/gadget-testing.rst +++ b/Documentation/usb/gadget-testing.rst @@ -794,6 +794,8 @@ The uvc function provides these attributes in its function directory: sending or receiving when this configuration is selected function_name name of the interface + req_int_skip_div divisor of total requests to aid in calculating + interrupt frequency, 0 indicates all interrupt =================== ================================================ There are also "control" and "streaming" subdirectories, each of which contain diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index 6e196e06181e..e40ca26b9c55 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -655,6 +655,8 @@ uvc_function_bind(struct usb_configuration *c, struct usb_function *f) cpu_to_le16(max_packet_size * max_packet_mult * (opts->streaming_maxburst + 1)); + uvc->config_skip_int_div = opts->req_int_skip_div; + /* Allocate endpoints. */ ep = usb_ep_autoconfig(cdev->gadget, &uvc_control_ep); if (!ep) { @@ -872,6 +874,7 @@ static struct usb_function_instance *uvc_alloc_inst(void) opts->streaming_interval = 1; opts->streaming_maxpacket = 1024; + opts->req_int_skip_div = 4; snprintf(opts->function_name, sizeof(opts->function_name), "UVC Camera"); ret = uvcg_attach_configfs(opts); diff --git a/drivers/usb/gadget/function/u_uvc.h b/drivers/usb/gadget/function/u_uvc.h index 24b8681b0d6f..6f73bd5638ed 100644 --- a/drivers/usb/gadget/function/u_uvc.h +++ b/drivers/usb/gadget/function/u_uvc.h @@ -24,6 +24,7 @@ struct f_uvc_opts { unsigned int streaming_interval; unsigned int streaming_maxpacket; unsigned int streaming_maxburst; + unsigned int req_int_skip_div; unsigned int control_interface; unsigned int streaming_interface; diff --git a/drivers/usb/gadget/function/uvc.h b/drivers/usb/gadget/function/uvc.h index 40226b1f7e14..29f9477c92cc 100644 --- a/drivers/usb/gadget/function/uvc.h +++ b/drivers/usb/gadget/function/uvc.h @@ -107,6 +107,7 @@ struct uvc_video { spinlock_t req_lock; unsigned int req_int_count; + unsigned int req_int_skip_div; void (*encode) (struct usb_request *req, struct uvc_video *video, struct uvc_buffer *buf); @@ -155,6 +156,7 @@ struct uvc_device { /* Events */ unsigned int event_length; unsigned int event_setup_out : 1; + unsigned int config_skip_int_div; }; static inline struct uvc_device *to_uvc(struct usb_function *f) diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index 4303a3283ba0..419e926ab57e 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c @@ -2350,6 +2350,7 @@ UVC_ATTR(f_uvc_opts_, cname, cname) UVCG_OPTS_ATTR(streaming_interval, streaming_interval, 16); UVCG_OPTS_ATTR(streaming_maxpacket, streaming_maxpacket, 3072); UVCG_OPTS_ATTR(streaming_maxburst, streaming_maxburst, 15); +UVCG_OPTS_ATTR(req_int_skip_div, req_int_skip_div, UINT_MAX); #undef UVCG_OPTS_ATTR @@ -2399,6 +2400,7 @@ static struct configfs_attribute *uvc_attrs[] = { &f_uvc_opts_attr_streaming_interval, &f_uvc_opts_attr_streaming_maxpacket, &f_uvc_opts_attr_streaming_maxburst, + &f_uvc_opts_attr_req_int_skip_div, &f_uvc_opts_string_attr_function_name, NULL, }; diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c index 0aa3d7e1f3cc..02559906a55a 100644 --- a/drivers/usb/gadget/function/uvc_queue.c +++ b/drivers/usb/gadget/function/uvc_queue.c @@ -63,6 +63,12 @@ static int uvc_queue_setup(struct vb2_queue *vq, */ nreq = DIV_ROUND_UP(DIV_ROUND_UP(sizes[0], 2), req_size); nreq = clamp(nreq, 4U, 64U); + if (0 == video->uvc->config_skip_int_div) { + video->req_int_skip_div = nreq; + } else { + video->req_int_skip_div = min_t(unsigned int, nreq, + video->uvc->config_skip_int_div); + } video->uvc_num_requests = nreq; return 0; diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index dd1c6b2ca7c6..c1a80c5d1f63 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -423,7 +423,8 @@ static void uvcg_video_pump(struct work_struct *work) if (list_empty(&video->req_free) || buf->state == UVC_BUF_STATE_DONE || !(video->req_int_count % - DIV_ROUND_UP(video->uvc_num_requests, 4))) { + DIV_ROUND_UP(video->uvc_num_requests, + video->req_int_skip_div))) { video->req_int_count = 0; req->no_interrupt = 0; } else { From patchwork Tue Oct 18 21:50:42 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Vacura X-Patchwork-Id: 4340 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:3c08:b0:7f:eb39:1b51 with SMTP id e8csp3542786dys; Tue, 18 Oct 2022 14:57:09 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7939aMN1+Q3xSMD+eussyDalTQraGpEGntmcPlWOZRIPSab7We9VZQdvYpOwPn+2rjJ83q X-Received: by 2002:a17:907:7b94:b0:731:1b11:c241 with SMTP id ne20-20020a1709077b9400b007311b11c241mr4244351ejc.676.1666130229406; Tue, 18 Oct 2022 14:57:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666130229; cv=none; d=google.com; s=arc-20160816; b=Q8isAW0pJ9116sMn96Oy/+v3ARfYwZ8buqtju8lxgN805Ww0UdLxTKqcOPrWgHuQU2 lSkwANR9nmZk4Sx1UXaRLr1P7bw3+lJ292ABWChuwCwUVsNkBerI22aB9LOlty5wrKZt p3FaTANz3pNDNZu2/rEKtEgfzQcRKYDuNFgFTSvZwmaLcgqbYZ0O8TvBQ98EZFUV2nIv Cbtv1adZa0QJ1S5RCA7SohkGF/WC7Y6a9Wt3hWHMpFo11dvXSTXg2f7p8FCaTD7aOIXC zMyL7/VU3N8kMpvomHN2FiD/aIjFeLKqAloJg/RzVfpjKrRuws1/QWM6W/ZB8XVUHH1f 2AvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=uujB7YfI4RYuL9Qe9Qd8cFtPSbJRkCOtgIQ1f9GJcPA=; b=nlcTacifORW+S1gjQyyurAVnEHjIgiSTbx2aG1GuUMQazNLQhzJVq2qSck2bW8bLPT ePBNf16IbpC5454hOkxm+Oyloz7cJdlayfpjxldPK2uGteRcbbJHbzVjwlCfMJdVVVJ+ dcX3OZ5Pc1XL2ReTW80AxDNsPewth4vYjdkhFRViydUmTs+0i4lbuJ2b3ZBaHpilYGMd 1AzQ8kMpNp2/KzQXOTJQWhISIMJ6UPLOmSIs2Wo4s4WE1lI/JHhFhhLDIMzvMxMj6h0M JzW3AegQbcQN1FPlLppcLY8vxIM9WviBa9OgVCy6N/PY/RhrSxca/kAO8lzSbdQrv9BN NWlA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=D5pWJRyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y11-20020aa7ce8b000000b0045ce176e5eesi10568189edv.543.2022.10.18.14.56.43; Tue, 18 Oct 2022 14:57:09 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@motorola.com header.s=Selector header.b=D5pWJRyh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=motorola.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230172AbiJRVvw (ORCPT + 99 others); Tue, 18 Oct 2022 17:51:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35636 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230060AbiJRVvm (ORCPT ); Tue, 18 Oct 2022 17:51:42 -0400 Received: from mail1.bemta35.messagelabs.com (mail1.bemta35.messagelabs.com [67.219.250.114]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7FD01CE98A; Tue, 18 Oct 2022 14:51:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=motorola.com; s=Selector; t=1666129892; i=@motorola.com; bh=uujB7YfI4RYuL9Qe9Qd8cFtPSbJRkCOtgIQ1f9GJcPA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version:Content-Transfer-Encoding; b=D5pWJRyhX93G1EAaFkYYRwFywAV0cK+R1QDJfIVeCu1jjGHtVnciMFGgUVQLqLnay lP83LIOWDM5Cws1N2eAD5x52UDjEsyi5oDbMYVOiy+GFVFcl04HBHcgHX54DE0TVvU NaJsNWGPVpf6T6NGTIa5zUkUlgcoq+qVuq6c7kusGWxk/nwe91YmGt5ItEgic1aPnl lFIU2ObwFltRFfKGP8mMHDGy/FYQesDoHamfTWAXTzIHUr7HDsHAzFB6ZMJ1Er8XOu pTIW0DqO4Y+7bN475GnozDK+aLxitDvHwd0x7FnN21f0rKkLJHQK7WbS5qHtO1C8RD b/20zHZbQkk4Q== X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrGIsWRWlGSWpSXmKPExsWS8eKJmO4jef9 kg3n9NhbH2p6wWzw50M5o0btsD5tF8+L1bBadE5ewWyxsW8JicXnXHDaLRctamS22tF1hsvjx p4/ZYtWCA+wO3B6zO2ayemxa1cnmsX/uGnaPxX2TWT36/xp4bNn/mdHj8ya5APYo1sy8pPyKB NaM5xN3Mhbc0q7YeOMvcwPjbdUuRi4OIYEZTBJXev6yQjjrmCRObH3M2MXIycEmoCax4PUqZh BbREBW4vCV38wgRcwCz5klpu28xdTFyMEhLOAj0bDUAKSGRUBVYsbLnWwgNq+ApcT3pd/BeiU E5CX2HzwLZnMKWEl0PWxjAbGFgGoet15hhagXlDg58wlYnBmovnnrbOYJjLyzkKRmIUktYGRa xWhWnFpUllqka2Sol1SUmZ5RkpuYmaOXWKWbqFdarFueWlyia6SXWF6sl1pcrFdcmZuck6KXl 1qyiREY+ClF6c92MLYs+6N3iFGSg0lJlHfON79kIb6k/JTKjMTijPii0pzU4kOMMhwcShK8nF L+yUKCRanpqRVpmTnAKIRJS3DwKInwpskApXmLCxJzizPTIVKnGI05ps7+t5+Zo3N/1wFmIZa 8/LxUKXFeblmgUgGQ0ozSPLhBsORwiVFWSpiXkYGBQYinILUoN7MEVf4VozgHo5Iw7wGQhTyZ eSVw+14BncIEdIrpFj+QU0oSEVJSDUzq23p+i+96uXHxirBdLrX3Ba9bHJ1YfHjJtoZ9E4M1U uqiEhQ4yxZ6Vf0uvFhXkJLQ8McssX7DQpGWNT1LlW8f3FG77vVJ64YzGwyOVUrp/GZMqOJQ+u I4O31arzhvx4X8Qn8LLqFFEU+tvl4wTp84m+u2x0R3jTWcLO9K8tLv75PyOuqm8vYfr3F34a4 77o9vTv+pu+TtR899vk/Un86brXyNy2H32cXnDynUr3tyrNT4+EklpkyzpKYItrJlX4/4uemI Oe/ivXDn4rxaRdd7T9WT1Fu+Wp8tulbxNnbJzP+rd5RlL1aax/cuyIp/Cid7UGNt+eTSp8YMb vXiZY+LLv6cvrft2+M1x6LPWy5TYinOSDTUYi4qTgQANw1zN4kDAAA= X-Env-Sender: w36195@motorola.com X-Msg-Ref: server-12.tower-655.messagelabs.com!1666129890!235854!1 X-Originating-IP: [104.232.228.22] X-SYMC-ESS-Client-Auth: outbound-route-from=pass X-StarScan-Received: X-StarScan-Version: 9.87.3; banners=-,-,- X-VirusChecked: Checked Received: (qmail 30631 invoked from network); 18 Oct 2022 21:51:30 -0000 Received: from unknown (HELO va32lpfpp02.lenovo.com) (104.232.228.22) by server-12.tower-655.messagelabs.com with ECDHE-RSA-AES256-GCM-SHA384 encrypted SMTP; 18 Oct 2022 21:51:30 -0000 Received: from va32lmmrp02.lenovo.com (va32lmmrp02.mot.com [10.62.176.191]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by va32lpfpp02.lenovo.com (Postfix) with ESMTPS id 4MsSHP6bHKz50GH2; Tue, 18 Oct 2022 21:51:29 +0000 (UTC) Received: from p1g3.mot.com (unknown [100.64.172.121]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: w36195) by va32lmmrp02.lenovo.com (Postfix) with ESMTPSA id 4MsSHP4sQlzf6WS; Tue, 18 Oct 2022 21:51:29 +0000 (UTC) From: Dan Vacura To: linux-usb@vger.kernel.org Cc: Daniel Scally , Thinh Nguyen , Jeff Vanhoof , Dan Vacura , Greg Kroah-Hartman , Jonathan Corbet , Laurent Pinchart , Felipe Balbi , Michael Grzeschik , Paul Elder , linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org Subject: [PATCH v4 6/6] usb: gadget: uvc: add configfs option for sg support Date: Tue, 18 Oct 2022 16:50:42 -0500 Message-Id: <20221018215044.765044-7-w36195@motorola.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20221018215044.765044-1-w36195@motorola.com> References: <20221018215044.765044-1-w36195@motorola.com> MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747064171693851674?= X-GMAIL-MSGID: =?utf-8?q?1747064171693851674?= The scatter gather support doesn't appear to work well with some UDC hw. Add the ability to turn off the feature depending on the controller in use or other platform quirks. The default is for the uvc gadget to support sg as long as the UDC hw supports it. The specific failure was with the dwc3 controller, but fixes and improvements are pending for those failures. This capability is now more intended for future unexpected failures or poor sg support on a given platform. Signed-off-by: Dan Vacura --- V1 -> V2: - no change, new patch in series V2 -> V3: - default on, same as baseline V3 -> V4: - update comment and documentation, refactor use of opts->sg_supported directly in uvc_queue Documentation/ABI/testing/configfs-usb-gadget-uvc | 1 + Documentation/usb/gadget-testing.rst | 4 ++++ drivers/usb/gadget/function/f_uvc.c | 1 + drivers/usb/gadget/function/u_uvc.h | 1 + drivers/usb/gadget/function/uvc_configfs.c | 2 ++ drivers/usb/gadget/function/uvc_queue.c | 4 +++- 6 files changed, 12 insertions(+), 1 deletion(-) diff --git a/Documentation/ABI/testing/configfs-usb-gadget-uvc b/Documentation/ABI/testing/configfs-usb-gadget-uvc index 5dfaa3f7f6a4..839a75fc28ee 100644 --- a/Documentation/ABI/testing/configfs-usb-gadget-uvc +++ b/Documentation/ABI/testing/configfs-usb-gadget-uvc @@ -9,6 +9,7 @@ Description: UVC function directory streaming_interval 1..16 function_name string [32] req_int_skip_div unsigned int + sg_supported 0..1 =================== ============================= What: /config/usb-gadget/gadget/functions/uvc.name/control diff --git a/Documentation/usb/gadget-testing.rst b/Documentation/usb/gadget-testing.rst index f9b5a09be1f4..be72577a03e9 100644 --- a/Documentation/usb/gadget-testing.rst +++ b/Documentation/usb/gadget-testing.rst @@ -796,6 +796,10 @@ The uvc function provides these attributes in its function directory: function_name name of the interface req_int_skip_div divisor of total requests to aid in calculating interrupt frequency, 0 indicates all interrupt + sg_supported allow for scatter gather to be used if the UDC + hw supports it, this is default on and only + intended to be temporally turned off if a given + platform doesn't work well with scatter gather =================== ================================================ There are also "control" and "streaming" subdirectories, each of which contain diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index e40ca26b9c55..83d96e81c05f 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -875,6 +875,7 @@ static struct usb_function_instance *uvc_alloc_inst(void) opts->streaming_interval = 1; opts->streaming_maxpacket = 1024; opts->req_int_skip_div = 4; + opts->sg_supported = 1; snprintf(opts->function_name, sizeof(opts->function_name), "UVC Camera"); ret = uvcg_attach_configfs(opts); diff --git a/drivers/usb/gadget/function/u_uvc.h b/drivers/usb/gadget/function/u_uvc.h index 6f73bd5638ed..5ccced629925 100644 --- a/drivers/usb/gadget/function/u_uvc.h +++ b/drivers/usb/gadget/function/u_uvc.h @@ -25,6 +25,7 @@ struct f_uvc_opts { unsigned int streaming_maxpacket; unsigned int streaming_maxburst; unsigned int req_int_skip_div; + unsigned int sg_supported; unsigned int control_interface; unsigned int streaming_interface; diff --git a/drivers/usb/gadget/function/uvc_configfs.c b/drivers/usb/gadget/function/uvc_configfs.c index 419e926ab57e..3784c0e02d01 100644 --- a/drivers/usb/gadget/function/uvc_configfs.c +++ b/drivers/usb/gadget/function/uvc_configfs.c @@ -2351,6 +2351,7 @@ UVCG_OPTS_ATTR(streaming_interval, streaming_interval, 16); UVCG_OPTS_ATTR(streaming_maxpacket, streaming_maxpacket, 3072); UVCG_OPTS_ATTR(streaming_maxburst, streaming_maxburst, 15); UVCG_OPTS_ATTR(req_int_skip_div, req_int_skip_div, UINT_MAX); +UVCG_OPTS_ATTR(sg_supported, sg_supported, 1); #undef UVCG_OPTS_ATTR @@ -2401,6 +2402,7 @@ static struct configfs_attribute *uvc_attrs[] = { &f_uvc_opts_attr_streaming_maxpacket, &f_uvc_opts_attr_streaming_maxburst, &f_uvc_opts_attr_req_int_skip_div, + &f_uvc_opts_attr_sg_supported, &f_uvc_opts_string_attr_function_name, NULL, }; diff --git a/drivers/usb/gadget/function/uvc_queue.c b/drivers/usb/gadget/function/uvc_queue.c index 02559906a55a..aee405663d6e 100644 --- a/drivers/usb/gadget/function/uvc_queue.c +++ b/drivers/usb/gadget/function/uvc_queue.c @@ -21,6 +21,7 @@ #include #include "uvc.h" +#include "u_uvc.h" /* ------------------------------------------------------------------------ * Video buffers queue management. @@ -141,6 +142,7 @@ int uvcg_queue_init(struct uvc_video_queue *queue, struct device *dev, enum v4l2 { struct uvc_video *video = container_of(queue, struct uvc_video, queue); struct usb_composite_dev *cdev = video->uvc->func.config->cdev; + struct f_uvc_opts *opts = fi_to_f_uvc_opts(video->uvc->func.fi); int ret; queue->queue.type = type; @@ -149,7 +151,7 @@ int uvcg_queue_init(struct uvc_video_queue *queue, struct device *dev, enum v4l2 queue->queue.buf_struct_size = sizeof(struct uvc_buffer); queue->queue.ops = &uvc_queue_qops; queue->queue.lock = lock; - if (cdev->gadget->sg_supported) { + if (opts->sg_supported && cdev->gadget->sg_supported) { queue->queue.mem_ops = &vb2_dma_sg_memops; queue->use_sg = 1; } else {