Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2823634pxv; Mon, 12 Jul 2021 02:49:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyTkSvlgHisG5l/4HHpmYkUia1vnyEkbGw5RXqsuEnpJ9IPQF0hkYtvpwNOYtsZ1xYO45Ms X-Received: by 2002:a02:a1c8:: with SMTP id o8mr7506252jah.50.1626083384193; Mon, 12 Jul 2021 02:49:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626083384; cv=none; d=google.com; s=arc-20160816; b=SsUwVcWhai2Gj+MUfNpfG6R/2TwjulgxRgoI7a9LQnLTcHEQoIs+doGpQydXf3Hlar N1qYUaMXEIrfOCC9uE4i6/iFfC1cq2UQfKJE1SSGd3mJfM5QO6HDxZGj6FjIrc1M9Qpb tY4No4UUdiOqct6GBJRHnJpQ4Vuseo3eYQtSL9WGo/jF7dgjDBLwWqVZiQ0z9iA7UP8H PjvwxlDEpbTwDH+S7ZXotLo3UKzEbLU8LgFQm6EYQjb5k8EKqM2mrp/nCxAbF265ZJnu jQh6VEocdTcmyOZr489i6eXuU3dxn25kortwGyZed72yCbqzDPggoHQmq0sd/ZeJ6UmT 3mtg== 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 :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=VcVIEAVXFexdbvY78jD4enFWA45UyDj1YSjn1cL2Ji4=; b=KUFRHNib6UTWliJmvz76fYZmlSVWwN+ppyD4fJqXWA3zIontfs7Q13TES549e7gFr7 LTzlUJ+CT2QdRek08Dvr2HZW/ftQWcankrDOvLgx97FifLp9vDKgeJ8HTaaQM5w628Ia hgF1LIFQjqJHOnJPdcPkfNhQHu9ba+HY6io65Iun3XdIYTbXmCWbaguZ+IQ58wcGwpnY s4fD9ghX3UYVrsbZaAtBdAcuJSbzujlLBcd6rLRM9Q7TnnEdroLZ0uHi5Rn9Xy0kM0V5 QTkjOuxohapiPUmT3i3etoaNSry1CQchX8grur4U64DD0n5qtyX22/LBAgqg3lECfR6r 3ySQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nwJk1o+6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 12si18136240ilz.15.2021.07.12.02.49.32; Mon, 12 Jul 2021 02:49:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=nwJk1o+6; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235995AbhGLGpK (ORCPT + 99 others); Mon, 12 Jul 2021 02:45:10 -0400 Received: from mail.kernel.org ([198.145.29.99]:54744 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237885AbhGLGe4 (ORCPT ); Mon, 12 Jul 2021 02:34:56 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id B03D0601FC; Mon, 12 Jul 2021 06:32:06 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071527; bh=ciBwS34z1dq/lTAjlwP2hlPO44Gt0j7asqfs2Y6atOY=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nwJk1o+6j4x+mNeaID2VagqYNRJil43ph/qO2Vrq/mkgBHXxvAKSOj7+jsk/t8q2u 9FssWi9ajtq/zBanlZQBNTCBSHEGv4Ftle1+0VGqxm/AdMlGKdGLbdLxcG5H+rM7d3 ColunvmmATX99ighrsKGWE1jrxZyAGDOosgnYAJI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Jonathan Cameron , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.10 106/593] media: am437x: fix pm_runtime_get_sync() usage count Date: Mon, 12 Jul 2021 08:04:26 +0200 Message-Id: <20210712060854.882264452@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060843.180606720@linuxfoundation.org> References: <20210712060843.180606720@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab [ Upstream commit c41e02493334985cca1a22efd5ca962ce3abb061 ] The pm_runtime_get_sync() internally increments the dev->power.usage_count without decrementing it, even on errors. Replace it by the new pm_runtime_resume_and_get(), introduced by: commit dd8088d5a896 ("PM: runtime: Add pm_runtime_resume_and_get to deal with usage counter") in order to properly decrement the usage counter, avoiding a potential PM usage counter leak. While here, ensure that the driver will check if PM runtime resumed at vpfe_initialize_device(). Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/am437x/am437x-vpfe.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c index 0fb9f9ba1219..31cee69adbe1 100644 --- a/drivers/media/platform/am437x/am437x-vpfe.c +++ b/drivers/media/platform/am437x/am437x-vpfe.c @@ -1021,7 +1021,9 @@ static int vpfe_initialize_device(struct vpfe_device *vpfe) if (ret) return ret; - pm_runtime_get_sync(vpfe->pdev); + ret = pm_runtime_resume_and_get(vpfe->pdev); + if (ret < 0) + return ret; vpfe_config_enable(&vpfe->ccdc, 1); @@ -2443,7 +2445,11 @@ static int vpfe_probe(struct platform_device *pdev) pm_runtime_enable(&pdev->dev); /* for now just enable it here instead of waiting for the open */ - pm_runtime_get_sync(&pdev->dev); + ret = pm_runtime_resume_and_get(&pdev->dev); + if (ret < 0) { + vpfe_err(vpfe, "Unable to resume device.\n"); + goto probe_out_v4l2_unregister; + } vpfe_ccdc_config_defaults(ccdc); @@ -2530,6 +2536,11 @@ static int vpfe_suspend(struct device *dev) /* only do full suspend if streaming has started */ if (vb2_start_streaming_called(&vpfe->buffer_queue)) { + /* + * ignore RPM resume errors here, as it is already too late. + * A check like that should happen earlier, either at + * open() or just before start streaming. + */ pm_runtime_get_sync(dev); vpfe_config_enable(ccdc, 1); -- 2.30.2