Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3344323pxv; Sun, 4 Jul 2021 16:07:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwUKOJZm6LKBX4q3Ob+Zw4p4h5BVvJScvn6Pub5zhgBM3DbaULGUYgiqfs8vqumIfvVOVAJ X-Received: by 2002:a02:a310:: with SMTP id q16mr9896246jai.8.1625440026940; Sun, 04 Jul 2021 16:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440026; cv=none; d=google.com; s=arc-20160816; b=BwCO+PX8/qJGT9KgHq5iAnGJh1xev95yjNs0Sm3orNivpOYjuE38sLO6nXlwUjpe28 8aIuuRyB2sxUkGPqyEc7Pv3aQSSBoJwyR+o2BEM8w3OSQoq30SNakVEkjiyL3nuB4s1j 0NWM3usSlWrN0PYMr+tNk0ZZdLD9HUE5u2t9SZLShfT42huFIwvXnlEHpHaxhWhlOlU0 1/pg9QbmyTwrruI0Hl0F6IGg74wUf1xwjHZ5O86YvS97qar0oiZeLL2VelLnnfgMAnUO zJVlGHTqGOo8JD3tCvOdWHwWgLRcBbyJ2MnZwPI6dZAVyt5pae1svXXE0c3RMvPzBK45 5NOw== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=0OcdAVHa7SfJTGLAy83yDITaYwHVWeltLqDp1LQ/uBA=; b=iGCUMeUcB1W+tkJ4vJdbp7MF/ugXl6zbeC+PgKh5V+0gSzGvjlhz8vYmmWcQyKZaaB QA2dfr/Zk/+LrUSX20c3FnqQ7Q/JIJvIyAx/V9rBpqMt0MYFU/8+Ey6YyGk5V9WN/PJH tFJeSEwLiwWKvEfRJEEv7vAA2ESIPi5FAjWmOvXiKeQ1Ec+EJKrhlXZyLpceHz1+ssNn YsdQ3bHFN5xj3omf8D0cqI6iHsSIdd8k/LSEe3arTkxGzt/Tj0VOXxwCi9Fk+XQ6SnUg tMCxJPgqSpgLM+UAdqSxWZkQVy8htMSbP1nX6M6bF7irK4ny/zIqwNENIPism8ia+eE7 slgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="bxG34i/J"; 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=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c12si12314743iol.103.2021.07.04.16.06.55; Sun, 04 Jul 2021 16:07:06 -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=@kernel.org header.s=k20201202 header.b="bxG34i/J"; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230032AbhGDXHQ (ORCPT + 99 others); Sun, 4 Jul 2021 19:07:16 -0400 Received: from mail.kernel.org ([198.145.29.99]:45152 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbhGDXHK (ORCPT ); Sun, 4 Jul 2021 19:07:10 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id E0F956135D; Sun, 4 Jul 2021 23:04:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439874; bh=c5RGKMO/Iij/OF/EMGrK9bgD+2TCuXmHaKdi0NSsXx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bxG34i/Jo+kUzeTkn7Wy9b6Elk+wejxTW5L3VampBPAzFiw1bhWHl3mi+BWTNuLYE 8M2d4ifn8Zn3fezwXmTDVh5FtogygoAnHkcyr5oOQ3QozCOQ2R0zXc2ew2KwxNlY+H sSKPEhfEO67lXxH7iPHDHI5466ai/z6kW/aaOt3vP9gq+MGNIKox1FslX7dpmmTydI Zo8PzOPXaadWgu/biOG5/ha+73z0FzAq5HPJFDYhSk1aIYys4TtA5i0xulivm3kNec CfE5PhJEtPS5NA+Kn9H2jHoJewibf7u8cTz+uE1NfCDQGkxYO+Hb4rntGPSD1703FM UlO5irO8bk3mw== From: Sasha Levin To: linux-kernel@vger.kernel.org, stable@vger.kernel.org Cc: Mauro Carvalho Chehab , Jonathan Cameron , Sasha Levin , linux-media@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: [PATCH AUTOSEL 5.13 10/85] media: mtk-vcodec: fix PM runtime get logic Date: Sun, 4 Jul 2021 19:03:05 -0400 Message-Id: <20210704230420.1488358-10-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230420.1488358-1-sashal@kernel.org> References: <20210704230420.1488358-1-sashal@kernel.org> MIME-Version: 1.0 X-stable: review X-Patchwork-Hint: Ignore Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mauro Carvalho Chehab [ Upstream commit 908711f542c17fe61e5d653da1beb8e5ab5c7b50 ] Currently, the driver just assumes that PM runtime logic succeded resuming the device. That may not be the case, as pm_runtime_get_sync() can fail (but keeping the usage count incremented). Replace the code to use pm_runtime_resume_and_get(), and letting it return the error code. This way, if mtk_vcodec_dec_pw_on() fails, the logic under fops_vcodec_open() will do the right thing and return an error, instead of just assuming that the device is ready to be used. Reviewed-by: Jonathan Cameron Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c | 4 +++- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c | 8 +++++--- drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h | 2 +- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c index 147dfef1638d..f87dc47d9e63 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_drv.c @@ -126,7 +126,9 @@ static int fops_vcodec_open(struct file *file) mtk_vcodec_dec_set_default_params(ctx); if (v4l2_fh_is_singular(&ctx->fh)) { - mtk_vcodec_dec_pw_on(&dev->pm); + ret = mtk_vcodec_dec_pw_on(&dev->pm); + if (ret < 0) + goto err_load_fw; /* * Does nothing if firmware was already loaded. */ diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c index ddee7046ce42..6038db96f71c 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.c @@ -88,13 +88,15 @@ void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev) put_device(dev->pm.larbvdec); } -void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm) +int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm) { int ret; - ret = pm_runtime_get_sync(pm->dev); + ret = pm_runtime_resume_and_get(pm->dev); if (ret) - mtk_v4l2_err("pm_runtime_get_sync fail %d", ret); + mtk_v4l2_err("pm_runtime_resume_and_get fail %d", ret); + + return ret; } void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm) diff --git a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h index 872d8bf8cfaf..280aeaefdb65 100644 --- a/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h +++ b/drivers/media/platform/mtk-vcodec/mtk_vcodec_dec_pm.h @@ -12,7 +12,7 @@ int mtk_vcodec_init_dec_pm(struct mtk_vcodec_dev *dev); void mtk_vcodec_release_dec_pm(struct mtk_vcodec_dev *dev); -void mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm); +int mtk_vcodec_dec_pw_on(struct mtk_vcodec_pm *pm); void mtk_vcodec_dec_pw_off(struct mtk_vcodec_pm *pm); void mtk_vcodec_dec_clock_on(struct mtk_vcodec_pm *pm); void mtk_vcodec_dec_clock_off(struct mtk_vcodec_pm *pm); -- 2.30.2