From patchwork Wed Apr 18 03:18:16 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paul Elder X-Patchwork-Id: 10347337 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 5081F60365 for ; Wed, 18 Apr 2018 03:20:28 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4D4C427F7F for ; Wed, 18 Apr 2018 03:20:28 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41F0228469; Wed, 18 Apr 2018 03:20:28 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9D7F27F7F for ; Wed, 18 Apr 2018 03:20:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753725AbeDRDTu (ORCPT ); Tue, 17 Apr 2018 23:19:50 -0400 Received: from mail-cys01nam02on0089.outbound.protection.outlook.com ([104.47.37.89]:52281 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753654AbeDRDTm (ORCPT ); Tue, 17 Apr 2018 23:19:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pitt.onmicrosoft.com; s=selector1-pitt-edu; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=gqFLWngF15Nty9zjqxxSC86vxYpQumRSiHns8VgnElk=; b=pBD+dFwWu5MBibxcQYRvYcaG3AcDzgiHZMp6IGFDaBWAOGWq5y156nX4CjRZE9gsPpgqGjF0TYrNxsM7ggx5CQH0EkJmyADCHiX/9NbD+1Awegz910PSb/pyqHjUEcTOI7Y+nNJ0O0eLNN3SkYelvukhTXfrzaftMfGYYtkd4y8= Authentication-Results: vger.kernel.org; dkim=none (message not signed) header.d=none; vger.kernel.org; dmarc=none action=none header.from=pitt.edu; Received: from garnet.hsd1.pa.comcast.net (2601:547:500:1222::543d) by CY1PR04MB1926.namprd04.prod.outlook.com (2a01:111:e400:50f1::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.675.9; Wed, 18 Apr 2018 03:19:40 +0000 From: Paul Elder To: linux-usb@vger.kernel.org Cc: Paul Elder , laurent.pinchart@ideasonboard.com Subject: [PATCH 4/4] usb: gadget: uvc: disable stream when disconnected Date: Tue, 17 Apr 2018 23:18:16 -0400 Message-Id: X-Mailer: git-send-email 2.17.0 In-Reply-To: References: MIME-Version: 1.0 X-Originating-IP: [2601:547:500:1222::543d] X-ClientProxiedBy: BN3PR03CA0105.namprd03.prod.outlook.com (2603:10b6:400:4::23) To CY1PR04MB1926.namprd04.prod.outlook.com (2a01:111:e400:50f1::22) X-MS-PublicTrafficType: Email X-Microsoft-Antispam: UriScan:(55037057525728); BCL:0; PCL:0; RULEID:(7020095)(4652020)(8989080)(5600026)(4534165)(4627221)(201703031133081)(201702281549075)(8990040)(2017052603328)(7153060)(7193020); SRVR:CY1PR04MB1926; X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1926; 3:XTOhB0BpDoYCaU4EF4RnFykXnQ8MzXYHcQe7uCOu2VxbqnhI76JO/GbPF5N3C/F/cW1dI3Ra5gMPvu8aIM3ese2Cpd9z4uv4C16tVIhObQ3JY5+Y0N0XiAyLUgXzwkRU+JruG0RUSMJROm1Ea+A9RGI+Ha3L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LDMD3WGeMPKp/JiqAKH7wU7tQdt6kicXjQA+UXJrc/Aj0WCPN+fKppnf21c0ZJaJzut0LckNVJMcRtU+l2s3az3CdXPN74NNleUR6boKboZqjPjr1mFj6q/wU8UfWO1r8vSj+PHYzYDcQp5BxErRTMy2+XzQR6Tympqt65NL2OKqZ90I2eG5TFJvukt4KNnA3ilgRZkZRevjbHKv9LxaHfAnv5uxEvX62j3yco0IbYWN7UtC; 4:dttwcZwYQ8zeolz2DO8bFEkVH+UDQySg3d06cmFHKiBqGfiun1mME5/vyMXQUqV6c3wPSXT4U22FLnHsEh7NFAZunxrxYIFxPmWQ85Di9ZiTAbvZNwgllu6OG5Jv2/NYhlv/7Lx4155Niu7cYVJVFY0R+FsnJEorNZUGDc5uBVorrbnVMaylef24+EG07S4JPIGbXvf/ZERIZXXdPDwn/iHKRfI+Ouhj8EhIgrphcPoXxtUM+NI3D8+thI/KFE03i+Q4UPG3y3oauvRbMjOqgNbs8mNCur6+H50KqszNKyxnf3dyNzDYg88GAl0rvHAs X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(55037057525728); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3002001)(93006095)(93001095)(3231232)(944501327)(52105095)(10201501046)(6041310)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123562045)(20161123560045)(20161123564045)(20161123558120)(6072148)(201708071742011); SRVR:CY1PR04MB1926; BCL:0; PCL:0; RULEID:; SRVR:CY1PR04MB1926; X-Forefront-PRVS: 06469BCC91 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(376002)(39380400002)(396003)(366004)(346002)(39860400002)(52396003)(16586007)(7736002)(6486002)(476003)(75432002)(786003)(52116002)(2361001)(316002)(6116002)(6506007)(46003)(2616005)(305945005)(478600001)(446003)(11346002)(186003)(16526019)(86362001)(76176011)(25786009)(2906002)(88552002)(48376002)(50226002)(118296001)(4326008)(8676002)(8936002)(50466002)(81166006)(5660300001)(44832011)(36756003)(6916009)(2351001)(6512007)(6666003); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR04MB1926; H:garnet.hsd1.pa.comcast.net; FPR:; SPF:None; LANG:en; MLV:sfv; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR04MB1926; 23:7+N7E/b+bJup+Mgnen/oO3GeQfvVZR37QshAMcSaE?= =?us-ascii?Q?6Xfp74FnIVsEPSx4IQB55MVyD8rtNQYp+ErwsvBQnoD5mnUZx1oEuwKMb511?= =?us-ascii?Q?D3vsHuayUuiHbbTIlxx3tYzT6ng1s1ORHSLMqXPrhA0rlCyO+tbxlOW9lulA?= =?us-ascii?Q?nTuBFi8YmI0rzHqltLFMUefLHCgnkOb+VKwEmUP4U28T8e7gdGW1YNbu+psT?= =?us-ascii?Q?ApoqrsgnQmUIYN/zs8Pug8ht6XyM5Yc5cnA31ygduAjAbb1t7EfrNlFxl7k0?= =?us-ascii?Q?sNHU3LRRVmoB3jaTUET3YrlJWva3ogf3NjX/vD9e5x7LeO4Ero6z5jqf+U2G?= =?us-ascii?Q?uFWL2wWV0QQW9oUEofbyZJ25E+K7i8NaLRpoW9tZc3J5NPQ6aTzfN8AFMboX?= =?us-ascii?Q?drSYvE+cLTmdfWrpvJax9B56GzcpiBrfzcYNzg0WGTNN+X/gjZlDwYTYs47z?= =?us-ascii?Q?D4s6ki5Q2VOmwmyOvSWu8BeYGe+O0+LYHKDbeyO1DN+FvLqxVClyUvRo5AKV?= =?us-ascii?Q?N4P3TvS8eVKsScBLYQV5sJOe6faDt/0j+Mi0yV4UXlb8E762yVXD4sq69lSX?= =?us-ascii?Q?h5kWMNOW26AmgOG/or+6NrXvWOAGwGBeaRMZv7FhNaANLpUoS5T3M/gtdj/w?= =?us-ascii?Q?wZwgczDf90gdUwwDdgj/vt1714efMsoGhyvgEeB57f6pGGezVYklHkKrivB8?= =?us-ascii?Q?LzdeF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sWjSRPXlYFZwQrEg0SXIdcjmV8JhxvNEAT5J1dFQRixEnxD7JQUpLiwNW8xjan3VcJoa46yewDX+xIqfl73sCq4X0w0UyBDg==; 5:JrxAnvD8NIuUIpdl/2iiTLtR7ABnSHa8qP+N2eh2hRMVqKKXJ2r/QDe46WubVVYDnQAgSgwBRFzZHF+ZFu8/3EOJGhivNJrEFZXwuHQnJ5zBkCZ2TF6gw2gy4Hw01u631C9eKzKOWaNw4P1ozD7i19bd9l/9zjuwfk3j0WEwWPU=; 24:FM2LPGW+WbXqa0gQBMy6FW4vAaS+cdQdO7pS/c0Ml3PEwabh1R2JT76fGa4/DX6jH0hMhlqO/mmsr5eLqpmPDFGyTKqlRJb7B9zowAqoel4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR04MB1926; 7:90JOUX9AD3F5fkQ6NzQEg8hHeYZs7KgfkMht/HsdItL91KIQwvgM+Lx5tkdGS6vYaisUfYt7Qxn6H31kcZcukhiP/o5NWlu7sx6vgxY1Bt8Uwb3y0eh4qYpVS+qTNQjbSZoEdjcwr6k5H/PVbniK8p1h6uDOOBL4T9meZ0fus7E/cen6MJ9pRRiBMcfkj/pWXTVBVhGC4bdUOhBSvTvRpYTbU3OsGKF2uMXQI6IT5jSIBNe9PfKFgmz3owgzRXmY X-MS-Office365-Filtering-Correlation-Id: 4fc75216-c683-40e7-4f7c-08d5a4db3993 X-OriginatorOrg: pitt.edu X-MS-Exchange-CrossTenant-OriginalArrivalTime: 18 Apr 2018 03:19:40.9635 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 4fc75216-c683-40e7-4f7c-08d5a4db3993 X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 9ef9f489-e0a0-4eeb-87cc-3a526112fd0d X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR04MB1926 Sender: linux-usb-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-usb@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Down the call stack from the ioctl handler for VIDIOC_STREAMON, uvc_video_alloc_requests contains a BUG_ON, which in the high level, triggers when VIDIOC_STREAMON ioctl is issued without VIDIOC_STREAMOFF being issued previously. This can also be triggered by starting the stream and then physically disconnecting usb. To fix this, do the streamoff procedures on usb disconnect. Signed-off-by: Paul Elder --- drivers/usb/gadget/function/f_uvc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/drivers/usb/gadget/function/f_uvc.c b/drivers/usb/gadget/function/f_uvc.c index 3324d36e809c..e67f42ee2342 100644 --- a/drivers/usb/gadget/function/f_uvc.c +++ b/drivers/usb/gadget/function/f_uvc.c @@ -384,9 +384,12 @@ uvc_function_disable(struct usb_function *f) { struct uvc_device *uvc = to_uvc(f); struct v4l2_event v4l2_event; + struct uvc_video *video = &uvc->video; INFO(f->config->cdev, "uvc_function_disable\n"); + uvcg_video_enable(video, 0); + memset(&v4l2_event, 0, sizeof(v4l2_event)); v4l2_event.type = UVC_EVENT_DISCONNECT; v4l2_event_queue(&uvc->vdev, &v4l2_event);