Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp8525789rwi; Tue, 25 Oct 2022 07:43:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM67QotSsyr2/XRLDmKhV6p15/ZEwH0pVvSTsyHvtd3RRYdB/ajpY5vnkCIuVVf/eF21O4mJ X-Received: by 2002:aa7:df08:0:b0:461:d9a2:b247 with SMTP id c8-20020aa7df08000000b00461d9a2b247mr8595955edy.54.1666709025460; Tue, 25 Oct 2022 07:43:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666709025; cv=none; d=google.com; s=arc-20160816; b=ftx9UbC+J78OSoBJCeQFmXqlYixv8vDTAGmMgBJiVkVyrgD12uD3iU7P0d5aR5RuL9 JIOOMGTikOf0uqoUijFfRI6gUcpgdIdKdgFZfktQdWrsZ/C2YWLlSBg8B01LXCx5J9Jl I/9+bUcNsxLlTSsFFEAfvk2uoHLdOztKHkzvDDwftD7G4K3RTIWyiDc5PZlmbn4T/6He mMRBTWZ41AXlZY4O9xbIfpYUxGjDsTxlPWWUBxftWNHN6FIJ240OBX1Kzdi8GylHFkK2 NqmdpKxqkVY8XxJIAdQ/oq9ViIxCfrn+YAfSglmm6JniqFFABzqriVJyFt6iD7goImp0 RtKw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:message-id:date:from :content-transfer-encoding:mime-version:subject:dkim-signature; bh=9br0ZyOHSVRhHpxSm/lkMcBl8HPRwiAhy4oQ/5+vON0=; b=ADJWWqswfq7KzS8dUxalTu1f/hZ8N8LNSGnOyV+kqPE99vd3WiNDw1ByPFTY9CbdvN Qwq0XWzAWzGwGVvR39BbTnehJXtkaYaonhEY+PDRuwEqELY8a06VEwbeNpwaK98YjeIt vpfElQpemSAbkVxxBNpfhSH57O48RwOuj5h1n3d15XcPiRoh9psY113fsISbz0Gtn85f LH0xSAS9PL06A/lTbn5OmGEp7b64ReSKjF1/OdZ93P0UO7SQV8UV0bm9gFE9AgmADpHS 33X7kcBcePYjzccROtmhQNNl5ja2MYIN6KyKm7/tW/FrVoJlZ99MI5/JKO5ZT8uz+v6D lYOA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=NAdRz4uG; 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=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h1-20020a50cdc1000000b00457053aadeasi2772685edj.398.2022.10.25.07.43.18; Tue, 25 Oct 2022 07:43:45 -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=@chromium.org header.s=google header.b=NAdRz4uG; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232208AbiJYOfS (ORCPT + 99 others); Tue, 25 Oct 2022 10:35:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38578 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231837AbiJYOfO (ORCPT ); Tue, 25 Oct 2022 10:35:14 -0400 Received: from mail-ej1-x632.google.com (mail-ej1-x632.google.com [IPv6:2a00:1450:4864:20::632]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7EFF287F98 for ; Tue, 25 Oct 2022 07:35:12 -0700 (PDT) Received: by mail-ej1-x632.google.com with SMTP id kt23so7465713ejc.7 for ; Tue, 25 Oct 2022 07:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:message-id:date:from:content-transfer-encoding:mime-version :subject:from:to:cc:subject:date:message-id:reply-to; bh=9br0ZyOHSVRhHpxSm/lkMcBl8HPRwiAhy4oQ/5+vON0=; b=NAdRz4uGX5vaYMHtHre85T1/QAn0YaWEuk8cU9Z9GAJwiFmiRCcjFLABG34ksbMNIX 2AgLu1CU3iIh1MuYdw+Gkb3zijx+3ja7hOyY94P2ZOFzVTqcvo5bMeCF/GoTKyMY1ou9 uKcPMd06uEez4mmoxRRHqSGa5lsGaJkmzIfU8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:message-id:date:from:content-transfer-encoding:mime-version :subject:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=9br0ZyOHSVRhHpxSm/lkMcBl8HPRwiAhy4oQ/5+vON0=; b=KVyuwCVGkzPG20GDpyP/P4ZMQJiLpkt/4OHG0yBXcA64D0PmNKkciL8CuEvf33oexf V2hauIytQ6C03IQ7EbL/0/IrZAjYUkB0Xy43jtiZ2KA32xClqF37KeHzeneCoSD0JGbd 1zOW+yR2z+qzJwG+0AqXOSa+aOj4s6uLwTKKVg5Dh1Q6XTdqAVQXvvpjnmh+acwWbyuf ersoD+djEBAp64Sd0UkLJh1TaKWEqtFpSH/M9hWTApD10QHgkwfg1SIqxtSKIwt+WaF3 w0wG/kRbEruRxiRYQqnNjaQOgQp/Wf0aGvLbPkMx6A3lZSEZdfDClY0k2FMj4X1BUWL3 6YTA== X-Gm-Message-State: ACrzQf3OQBG43zfAxznNWWitk4hY5yphbfEyWoYdOQhuyN7bRAKUHJcQ fOKl7lcLZA7WfB32xpDML4qYMST1dk3SS62S X-Received: by 2002:a17:906:2a93:b0:78d:b87e:6aab with SMTP id l19-20020a1709062a9300b0078db87e6aabmr32745951eje.157.1666708511050; Tue, 25 Oct 2022 07:35:11 -0700 (PDT) Received: from alco.roam.corp.google.com ([2620:0:1059:10:e6ae:c7ac:c234:953c]) by smtp.gmail.com with ESMTPSA id e9-20020a170906314900b007acd04fcedcsm631021eje.46.2022.10.25.07.35.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 Oct 2022 07:35:10 -0700 (PDT) Subject: [PATCH v2 0/8] [RESEND] media: uvcvideo: Implement granular power management MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 8bit X-b4-tracking: H4sIAO3zV2MC/32NTQrCMBCFr1Jm7Ugyxf648h7iIm2HJtAmMmMjUnp3gwdw9fgefO/toCyBFa7VDs I5aEixAJ0qGL2LM2OYCgMZItOTQWHlOOEzvVnUZcZL39nW9jxR00LRBqeMg7g4+iLGbVlK6YO+knx+ N9mWuP9ZzBYNWqqdo8HVXd3cRi9pDdt6TjLD4ziOLwiD3s+4AAAA From: Ricardo Ribalda Date: Tue, 25 Oct 2022 16:34:21 +0200 Message-Id: <20220920-resend-powersave-v2-0-5135d1bb1c38@chromium.org> To: Mauro Carvalho Chehab Cc: Laurent Pinchart , Guenter Roeck , Max Staudt , linux-media@vger.kernel.org, Tomasz Figa , linux-kernel@vger.kernel.org, Alan Stern , Ricardo Ribalda , Hans Verkuil X-Mailer: b4 0.11.0-dev-d93f8 X-Developer-Signature: v=1; a=openpgp-sha256; l=2195; i=ribalda@chromium.org; h=from:subject:message-id; bh=gYbwqdZCjHzTHN76p6vLT9g8wCagTeQkq1M2o9SG/ig=; b=owEBbQKS/ZANAwAKAdE30T7POsSIAcsmYgBjV/Pz3t7i0pQeRgei7wYcq59IisYUZgO1FSKep7HW DevTUTeJAjMEAAEKAB0WIQREDzjr+/4oCDLSsx7RN9E+zzrEiAUCY1fz8wAKCRDRN9E+zzrEiMfpD/ wKeFHwQ7Yd35g10O6CpjuxcDxqRM+C6KRi5ku+F6MFlRcd7FAmHntUew7Ply59K8nrUlQHqfPDO3Nv H9DD2L7GP2QLcM+eRtB0ivRuLf92XQKYePJA6oIO8te6wGrk8KFX/nKvt4s6ns9OJv5SXSZzHzF6DH p6x/O1VjJ8qU700kmpWPjzLGSoLIWXwfSiijggfH7Om3M6gImpmI1WIPlPVCD0U08ohRr3KCLcubU5 zqJFJDcI/b0UAhYTZgy8Dq0apyNkyqt1rpCty8uPjkayhnJGDAYWJh4/SOzYBVWVdfTUFIGqLXnwOR dmtGMhjIYUHLjevtCacsIiah3t+bW73xERk3HEPebnBhIP6TqoMkS615h/rhGwgYXPIWLs+0Zw0M4F 84iWZQiPxDU7MhJuUEsbUDAAAdWG+uknBg0Nko27cT/BzV0RmRmYXEO3XmXmWMFH+KtIVo23fzZ/oS j6vrd/MIXEF5XTt5EWxYa2ZAykRztgjA3zQNXSknP1oIhgjrVy+j3UX6jwGmBnJDirEbxu8fMH5jk1 cEbFb1Hq5Qn7I5DO2ooX9e4TpyZcpBRXKj561lcm4RwKiaxKCYCYtYwE7//FD2GfWasHpWtGVlQuUI HfhUs0wDFVLBK93YBKf1VSsQbf5U7pg+byTniWywvsZWp0Y1nHH3UkiM0BwA== X-Developer-Key: i=ribalda@chromium.org; a=openpgp; fpr=9EC3BB66E2FC129A6F90B39556A0D81F9F782DA9 X-Spam-Status: No, score=-2.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED 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 Instead of suspending/resume the USB device at open()/close(), do it when the device is actually used. This way we can reduce the power consumption when a service is holding the video device and leaving it in an idle state. And now that all the access to the hardware, has a common entry path, use it to fix the race conditions to hardware disconnects. To: Mauro Carvalho Chehab Cc: linux-media@vger.kernel.org Cc: linux-kernel@vger.kernel.org Cc: Laurent Pinchart Cc: Tomasz Figa Cc: Alan Stern Cc: Hans Verkuil Cc: Guenter Roeck Cc: Max Staudt Signed-off-by: Ricardo Ribalda --- Changes in v2: - Make access to uvc_status contitional - Merge with Guenter race condition patchset: https://lore.kernel.org/lkml/20200917022547.198090-1-linux@roeck-us.net/ - Link to v1: https://lore.kernel.org/r/20220920-resend-powersave-v1-0-123aa2ba3836@chromium.org --- Guenter Roeck (4): media: uvcvideo: Cancel async worker earlier media: uvcvideo: Lock video streams and queues while unregistering media: uvcvideo: Release stream queue when unregistering video device media: uvcvideo: Protect uvc queue file operations against disconnect Ricardo Ribalda (4): media: uvcvideo: Only create input devs if hw supports it media: uvcvideo: Refactor streamon/streamoff media: uvcvideo: Do power management granularly media: uvcvideo: Only call status ep if hw supports it drivers/media/usb/uvc/uvc_ctrl.c | 11 +- drivers/media/usb/uvc/uvc_driver.c | 28 +++++- drivers/media/usb/uvc/uvc_queue.c | 32 +++++- drivers/media/usb/uvc/uvc_status.c | 34 ++++++- drivers/media/usb/uvc/uvc_v4l2.c | 201 ++++++++++++++++++++++++++++++------- drivers/media/usb/uvc/uvcvideo.h | 2 + 6 files changed, 262 insertions(+), 46 deletions(-) --- base-commit: 1a2dcbdde82e3a5f1db9b2f4c48aa1aeba534fb2 change-id: 20220920-resend-powersave-5981719ed267 Best regards, -- Ricardo Ribalda