From patchwork Tue Apr 2 16:45:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikhail Rudenko X-Patchwork-Id: 13614412 Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 2874615B119; Tue, 2 Apr 2024 16:46:27 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.46 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712076388; cv=none; b=YK5+pHeq+avq/yOU6ZzvxN9GDJUTTqSMYjAQak6CcQNniSrHYdw/iZ1+0vnOi86Cxo3yLgf09q9CnD0KrNX5bKQh0XQYVxCZmLp4gOPgBhmiFjQ8R6n3v3ufIR91l3ds4vezvCwVFwLKlVurhILW+RECIX+sYU5Uot0/EXyAZrU= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712076388; c=relaxed/simple; bh=H0ma8eY/8/S2N+welQc2fVRYTdGUfB4oLn55S6JvmDA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=gxkoDWaKEje48hEWtH54b9JnYPtYNMsnVSVmXQWdbktLDwHRkjF6jkxUfHJw1iLyr5LiM/4Y5GLrc0OiqNuYS4tQT3g0/4qlZpRB7CI2Ie3vQsJ78bzm5Aq5XPsVimSAlNW6xXyBgwTxdxUkdDSwHyfDvAOXfp3upti6U7iwbXQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=BXpgWmNf; arc=none smtp.client-ip=209.85.167.46 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BXpgWmNf" Received: by mail-lf1-f46.google.com with SMTP id 2adb3069b0e04-515c3eeea5dso6338544e87.1; Tue, 02 Apr 2024 09:46:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1712076385; x=1712681185; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Zvp9vfG0Jk7g28an8SJ7vQketSIg/VKljXWkv56ib7E=; b=BXpgWmNf6NSF3KtTrY/rWU5tJS8wZ5IGNScMCA07dhS636FyUmmBSS4wq5sBXnmOOZ wt1HGYhW5Psmgc5bF9Rh0MWSaYvnmxJ1/zc25JO074GbHxnCsX06KlGB+P9pCTm5TO6C l2xAGp8+FdDb/CWPtXJKkuZ6mC54hS/nONXoQp7XdKThoKXXfALpkZ4mCEkw09/GQV5J +BpAEtNUAUUpntFE1SKnodnf9//O17z/wZkoVzCwD8UihhslrIOIYxJFxYhO+RTx3Gz2 2F217SIBnAAU9hJkNpAIB2iBvxdVq4uq5JzfwoTu0uk4KLlaGwv/UzIP/BWFS5C/1D80 R4+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712076385; x=1712681185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Zvp9vfG0Jk7g28an8SJ7vQketSIg/VKljXWkv56ib7E=; b=DLeEbBXrHcgJNL8IDBBtGp2h7G0LlaBC12B0CepNZ9492XsRhDTm6lHrqjpqoyybme rqqryhjWaEoXhyL8uWT3zi0qqF8oqWC2Mcik0uIbv1gX79DkmqCu14bivFYEJ8wdZy5L XgHk1nEUv+3LwkW8fEuAz5BbqRJv6GDKgvhXZfuF0yPXKQfqKgfojFhRcDnuGlYti3f+ dvqpVfyvQlf7THhlPgva0j3F5y7ltR5zvbcI/JFQlwVIUWjg8l/0NfA2qmJlUKdHFYES kZP/1wzHoI/fCPne0JQIu+8nRQXct5g9TlIhefE/ZENxcu6SMtzbvxHoN1ZqaoVWfW0T 7MEQ== X-Forwarded-Encrypted: i=1; AJvYcCULSObrNvN5dtl8+JLjyzxaNQQaZx4GTZqQINtGH0mFmK4cPOitcIU+Cu1H8ODh54nDGEtz3j4JQBzcKd7OWaOiVmmvqF5XyMlUsz7H X-Gm-Message-State: AOJu0YyLWMoKEJffvcsQoH0QxLDiQaljsrBBUA7zs45m3hxmDUFXMDXh b/keoKfrefgq2loeTCBB4ZKl2PhsX7QHIpKzZKKaMDwBg6CoCdIcbOxWnQHTTHkTaA== X-Google-Smtp-Source: AGHT+IEReO8ZOKL4HY4Vm9cDttgAjqCtyW+FlGR/Twe2yq6ADB3Ot4ZsoFYgpQyRa54LPEmWoieyLA== X-Received: by 2002:a05:6512:200d:b0:513:4a0c:b83d with SMTP id a13-20020a056512200d00b005134a0cb83dmr7938266lfb.46.1712076384509; Tue, 02 Apr 2024 09:46:24 -0700 (PDT) Received: from localhost ([77.91.78.25]) by smtp.gmail.com with ESMTPSA id g1-20020ac24d81000000b00515c102c826sm1779374lfe.270.2024.04.02.09.46.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 02 Apr 2024 09:46:24 -0700 (PDT) From: Mikhail Rudenko To: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Sakari Ailus , Laurent Pinchart , Jacopo Mondi , Tommaso Merciai , Christophe JAILLET , Dave Stevenson , Mauro Carvalho Chehab , Mikhail Rudenko Subject: [PATCH v4 09/20] media: i2c: ov4689: Use runtime PM autosuspend Date: Tue, 2 Apr 2024 19:45:40 +0300 Message-ID: <20240402164552.19171-10-mike.rudenko@gmail.com> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240402164552.19171-1-mike.rudenko@gmail.com> References: <20240402164552.19171-1-mike.rudenko@gmail.com> Precedence: bulk X-Mailing-List: linux-media@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Use runtime PM autosuspend to avoid powering off the sensor during fast stop-reconfigure-restart cycles. Signed-off-by: Mikhail Rudenko Reviewed-by: Laurent Pinchart --- drivers/media/i2c/ov4689.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/media/i2c/ov4689.c b/drivers/media/i2c/ov4689.c index 0e0e694510aa..2354397ab34c 100644 --- a/drivers/media/i2c/ov4689.c +++ b/drivers/media/i2c/ov4689.c @@ -426,7 +426,8 @@ static int ov4689_s_stream(struct v4l2_subdev *sd, int on) } else { cci_write(ov4689->regmap, OV4689_REG_CTRL_MODE, OV4689_MODE_SW_STANDBY, NULL); - pm_runtime_put(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); } unlock_and_return: @@ -606,7 +607,8 @@ static int ov4689_set_ctrl(struct v4l2_ctrl *ctrl) break; } - pm_runtime_put(dev); + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); return ret; } @@ -876,8 +878,10 @@ static int ov4689_probe(struct i2c_client *client) } pm_runtime_set_active(dev); + pm_runtime_get_noresume(dev); pm_runtime_enable(dev); - pm_runtime_idle(dev); + pm_runtime_set_autosuspend_delay(dev, 1000); + pm_runtime_use_autosuspend(dev); ret = v4l2_async_register_subdev_sensor(sd); if (ret) { @@ -885,11 +889,14 @@ static int ov4689_probe(struct i2c_client *client) goto err_clean_subdev_pm; } + pm_runtime_mark_last_busy(dev); + pm_runtime_put_autosuspend(dev); + return 0; err_clean_subdev_pm: pm_runtime_disable(dev); - pm_runtime_set_suspended(dev); + pm_runtime_put_noidle(dev); v4l2_subdev_cleanup(sd); err_clean_entity: media_entity_cleanup(&sd->entity);