From patchwork Wed Aug 14 11:25:37 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Xu Yang X-Patchwork-Id: 13763361 Received: from DB3PR0202CU003.outbound.protection.outlook.com (mail-northeuropeazon11011008.outbound.protection.outlook.com [52.101.65.8]) (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 70E4C1AE878 for ; Wed, 14 Aug 2024 11:25:07 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=fail smtp.client-ip=52.101.65.8 ARC-Seal: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723634709; cv=fail; b=WZL+b3a/sRxhvF4r7zEeABGsNLL1EMccDEZ3GAgaSD3H296ZHtyIAYtj0vhwWRN19E6i2y+Q7fVKYfP6TS2eQzS7TsPonAg6qenZymtLV8QDvL9GspBorjd2rNe8thWfwT4LzZKntDPz74AYLsaXd/miTl6gf9ZZYB2WoHQBvHE= ARC-Message-Signature: i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1723634709; c=relaxed/simple; bh=SOoO+7X5m/QXTawtrUzRut/WY+LuA6cjN12J4r3C4ss=; h=From:To:Cc:Subject:Date:Message-Id:Content-Type:MIME-Version; b=p9Ql9iRqLwdNX9tLw9s2zq3N5ZORM68eRQMLE7opdQalQQF+GhH9mPeZTFFyOqsFqf4vlC/gq2RhnicigQzDT0eCxIcJdYBgSOvif0TCUGSRhWvZumi+B49PHwMbJsMsD4PVKr2ocWqDAxO54jY95FNIuFRetMAUFGqKrG82gFo= ARC-Authentication-Results: i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com; spf=pass smtp.mailfrom=nxp.com; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b=he8ZgWVd; arc=fail smtp.client-ip=52.101.65.8 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=nxp.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=nxp.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=nxp.com header.i=@nxp.com header.b="he8ZgWVd" ARC-Seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=jhDjLNMAKPQm7JuGoQAqf27T5yw+BxTZ/uQobsMORkrhArPBGOP7/DjJyN6INBDpC1QzHUQwsG3swwei9mH/eDVzGbRSNc2J0y7mJhx9MewSvKA0KRHMZu7tBWYuvGBg823I8BX3aDX/vYTVrugwncfk03vXF7YJnZOPeqUgzcFLX/tfx2/1SfhX9qWhjOjHGDiyPAoEbYQAv924n64+1wiW4aoF8dtwSGV/7G5JPe75lRD/oLbv4PCArThvtHb2EGUY+N2mMdC391XfUHAzJVANZy8FMamY1c3enDEhzxeNE1vg2s3KS+7AU289GE7o4J94e4PdBF4JoqpQMahHXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=zEWs4GX0bfY5H7USpplqUaN8rXVmhi54r+BJNdfdd7Q=; b=FFDuKWkRIZLmH02iGjdc2JsGvr6AruOhoNNiyB+LktpWsY5tVh5K/xG5pU9Zfz5EHP1NNcKgRk+VAj45QnVHMjuDY7XC8M0QGLtsvqrcT1pMw8GnWyY++QQROA29dzIc1+p7IZafEYECq6HWDFVwoj4YQr2y7Wp59OuOW66PIeIu/0M22y4H/CUG8+usooXOntMKIpYU+u9H6CeQUdLPJo+qDy0jvQ/fzOryzDh3QJ9Fcveg8RloosPJUwrCma8MBf4czvtsUkmwBEDQHv2E7pNKT5D6sdKS26lecy71WncFGJQ73thzhILaNqV92xfJDDpfiE1id+9+7DqUbkmdgA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=zEWs4GX0bfY5H7USpplqUaN8rXVmhi54r+BJNdfdd7Q=; b=he8ZgWVdO6ThO5Mmps+LBPr9f/K86Mvh+DDaunsW00h0N48RIaTc81lUo7VkAhm+uMnEg+Vh4VoII1/7bXph939VtS2otQWXP4lx+g4Q57nxR0G976eu3fLB1+hyco8fmgxOx+IKDIzxyI1AWP3OuNDNH9IBaTwtIa24wFuUnD9NoA4LdCNMRpUlQrc5JFqReK/0U2E7rPKFFxMZF8M1biHbebHY8SOsJooltJOnlNGC1JjO0OIduRk1RcZbOM5zx95vIwJ0AMNocvA3qD3rFPHZk9QsDIjKIcxXYMerYVy0Hu5CYfDPzJ3XcfGmEcJzXHAaYIWX514fCRPuK+9BZA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) by VI1PR04MB10052.eurprd04.prod.outlook.com (2603:10a6:800:1db::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7849.20; Wed, 14 Aug 2024 11:25:04 +0000 Received: from DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7]) by DU2PR04MB8822.eurprd04.prod.outlook.com ([fe80::4e24:c2c7:bd58:c5c7%5]) with mapi id 15.20.7849.021; Wed, 14 Aug 2024 11:25:03 +0000 From: Xu Yang To: laurent.pinchart@ideasonboard.com, dan.scally@ideasonboard.com, gregkh@linuxfoundation.org, m.grzeschik@pengutronix.de Cc: jun.li@nxp.com, imx@lists.linux.dev, linux-usb@vger.kernel.org Subject: [RESEND] usb: gadget: uvc: queue pump work in uvcg_video_enable() Date: Wed, 14 Aug 2024 19:25:37 +0800 Message-Id: <20240814112537.2608949-1-xu.yang_2@nxp.com> X-Mailer: git-send-email 2.34.1 X-ClientProxiedBy: SI2PR02CA0024.apcprd02.prod.outlook.com (2603:1096:4:195::18) To DU2PR04MB8822.eurprd04.prod.outlook.com (2603:10a6:10:2e1::11) Precedence: bulk X-Mailing-List: imx@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DU2PR04MB8822:EE_|VI1PR04MB10052:EE_ X-MS-Office365-Filtering-Correlation-Id: 26b3a33b-d603-40f8-115b-08dcbc53be10 X-LD-Processed: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635,ExtAddr X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|1800799024|376014|52116014|366016|38350700014; X-Microsoft-Antispam-Message-Info: diwEVjxvgSklZAxXkce0bsrXSJRy45SnyQ1fqeyHnCURGU4ddb8p8UKrk0wqk0OhBhZ1PCGzm2WcNQudeIwC6p1rBZh7E0wXrpNsX2zxziRYaKR6HFYZeDLYKoEcB4txVm/x1CAXgOsrnDJ3//1711Ck8NFehYgdmc1OXprCVn2d6URtUeJ3qFQyHDd5W/CPWy/xfOZLq7aeqwIvPmQHaakBQV5Bkke8nq9cnTpK2UVtfYr5awIPiRxkc4artpK8jUSNjq4EK+dgWnWEY4BHzBlRlEgXg4P0FWyad8Ec3PVf5uAuVuTr5Hl1jtcYakrKCFHUQI6Fy/vVEK7chFjaOsLdyUSC1kJFHZbvAyLQFeKgj/xvHLRAUGTDs+B2uGDPaXUhIlXrjJHPE+V0zI9pfRtJ2eg5YEqDNdMJ7/cZDgdbVt+RKQcz4j5HGuOE4qhYr2RYPtTIRMO5rU+oaV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;CAT:NONE;SFS:(13230040)(1800799024)(376014)(52116014)(366016)(38350700014);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: FdHFYWLjFkkfiGC1NFNGhCL4LS8WPZKVdPbUoowhkof+0VT4vk2iW2QRAoXdtlbZ8cmTo0Q1Rnu7FYid/42fY/Yd8stDBpFhJ04msc69d2JCjsh+QP3m841Kwp3nonDXAm//nbeASfuY3AFM7YLpAQwpSOMUpaAHUw5G6XoiVJIfsffhaWZ37eXMnMKeBJmFFGPZcc1sZKVGMiNB0D6McWKIb7F6Sm9HOBm9+l4FEIE8CbuRBupJKuuoP/Vjy45BwsFmhJRxGDSBahjjJGerSxKPUzs3gdimc+iBxaxl6Aa9FjAIpyzjkkYOaFNZNqeeW1IZNClcfNYHQditfj2uw5d4ng+IlABIZcVowa2Oidhf/x2DiK945dpcMkuX6x3sYw/r/tV/eA4xitVDWRVuJNORhQ2EmcRxPsK6du5Cgf06jWROnH1QuH0FUnP7fuF+Jz8mb7g9E9ypn2JkCuFUKqwYFi5hx6BdjYaOdDWey6X2ITjYi3QyxC32xxijEJPajr1jshBxmdgFLMx0rcvjHVk1E25f6oI4rqfRG9/QnmmwMEQdRsFC1kYO8ddTMhKxbUBGoIN7AeJAecDTk2ADNFZ6owII+JBQy/Y7T7RxHNgqGCUgJCf+mqzmGm4MktUcfaVX9SAmoMMxcwtgayEpwQkgs33j/MCdLlUd+bT/PTwTcgOfUGAClTeCO7ucdBqrKmwR+hMT+lro2HPoYwmy0By1N0cgQiq+dE25JnZvKBb3o3Objkilkn8Bivj0UhrUAGka7mpClPiW6IVGFGYtwgOPU1dbo3BgUMA7DDXwxul/Ghufb/gBqUkkhdthZ2q37bFrayzn44q7XQj0k8Upt3ovglQ7myXjCI4psav+BEAKgWB3w/CPNau6TfF4lfyR2+IenX0cMKgoh7mqcDA+TknnSeNCqj08F5YM19Of8eyGIRaXQAzFoH0e3HHI6wk743BsLYG0wpixA7BAVzLsvzN6pXJ0nP8qxd/keNvjP0xAZLQpVKsVXpzhy/oRvb0mEz6eabh4Vg2WOI7BhpeP9J7ZlNUml8ilqP4JEY8zkSAs7yXzTJVgCwixiuRsQ1QGpKwYlE6j9pT9fgEI4RGNfMg+m4EqsUBG6Q6FVTfQvcB9mpq+8OYJaF4sNicGpWehVATx03DwFt3AgTDMX9DgLdK+xTkeTnBpMAfQQJrbHKlOAeRgdJ0yL00BTMMOeRhWoZss3w9IaswGopNj6fx0T5Olby4P5US6TezWq3UNcmtJuDtIr2e9ouWYzT3CReaLzUC93orQfq/3a8eBoEOInrQOyHM57pMQeHxDAO8CQ4Qtvsmn7i5/K1Vh4+eRmu1txJoCQmiAr2qoM2OWUVFa4TxA4NdqAN17dnp+/n8stu39RH9lMLhhfSSegIBkpPE7TCkhC6xBgHZAY4dRYHcKuo1x6AeXC7S3oOKf2PdfirXBHdCc/77EZm3km/ALvtbGouLDyFr/k9HI2ONTxzenFHGsViFGg5B2fx1YceblV1TP/w6gzwf6B+IjAdq3xg49Y2h7QAxzEB0tT3EN8TIfOxQ/kUlYsGmAVALq3MiDArK3ujiMWeBQXbgoCoyzainM X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 26b3a33b-d603-40f8-115b-08dcbc53be10 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB8822.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 14 Aug 2024 11:25:03.8568 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: RaUxmXOeolo2zOW7O++26KWQEYqgd702GhVQj7D77PqEbHxcw85M9UEYYifXlbwNIelGtat375WFAcDoTYDtiA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: VI1PR04MB10052 Since commit "6acba0345b68 usb:gadget:uvc Do not use worker thread to pump isoc usb requests", pump work could only be queued in uvc_video_complete() and uvc_v4l2_qbuf(). If VIDIOC_QBUF is executed before VIDIOC_STREAMON, we can only depend on uvc_video_complete() to queue pump work. However, this requires some free requests in req_ready list. If req_ready list is empty all the time, pump work will never be queued and video datas will never be pumped to usb controller. Actually, this situation could happen when run uvc-gadget with static image: $ ./uvc-gadget -i 1080p.jpg uvc.0 When capture image from this device, the user app will always block there. The issue is uvc driver has queued video buffer before streamon, but the req_ready list is empty all the time after streamon. This will queue pump work in uvcg_video_enable() to fill some request to req_ready list so the uvc device could work properly. Fixes: 6acba0345b68 ("usb:gadget:uvc Do not use worker thread to pump isoc usb requests") Cc: stable@vger.kernel.org Signed-off-by: Xu Yang --- drivers/usb/gadget/function/uvc_video.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c index d41f5f31dadd..a9edd60fbbf7 100644 --- a/drivers/usb/gadget/function/uvc_video.c +++ b/drivers/usb/gadget/function/uvc_video.c @@ -753,6 +753,7 @@ int uvcg_video_enable(struct uvc_video *video) video->req_int_count = 0; uvc_video_ep_queue_initial_requests(video); + queue_work(video->async_wq, &video->pump); return ret; }