Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp3345962pxv; Sun, 4 Jul 2021 16:10:11 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwsjYmr36O66tpa0fthJFcz7WafbrwHToyMOnw3hf6kTJ1bxxL+Fj3O15Jqbm2UKfhXqDas X-Received: by 2002:a17:907:6297:: with SMTP id nd23mr10068931ejc.62.1625440211268; Sun, 04 Jul 2021 16:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1625440211; cv=none; d=google.com; s=arc-20160816; b=riBOH89M+jZibVQoFsDjeqa8LnV/SMmpD8HhyZWflkCmjDi3sHcdtjXKmcp7BM/vy8 BNvnERjewciGqY9LIjI59XTQ7hXQzQU4e6rnes6rypEUOj7pn0Ch9nEmfkRp28do+Kgy D9gCzrRM58z4Kh2iL918EvGW7iS/lrHabV3o+EOUKbSeKSRH1XmPTz7wSkWqRwTDV/Uc RLdvhtnh0JAsEY8yXOsX/x7t3NZjF+kzgbYHsffYekNB6Cip1Ass9scSVhfD+oUdeTH4 qO4UbQGkODZf00lvSzrKLlD6jUtS7ZLErlCPfx+4zaELo2JhRe0UrXVHSL6KSZ3q9Du2 a8eQ== 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=C3oeury7tzDrLgKfxqOEpxStgOgMJljHAsuxhssm8XKlzLyurJkYEYkYsdmPYzpaOC H/+e7FlR7j33IyC5FjnDGBIJFj5SB2egiLnsuZjvunwEAeXNvbdGiY4FAbMGngf3K7G2 W83YFVBfGsq4BbYZHNOjywDerAGtHs55uZmWi5J1Y5BDLVgNO8FXuewOxEyx8+nl/1W3 pjjZbIM5u42u2Ys/1A2Ur0GnF7RqBgt8C1DyAYtVRViqlLooobl/KXQ5RMjCygSQdg/M 0ht1q6aFT4c/Tk/j60XRgYCGEQhS30qtwhHrhGHVSOs7mmo+U4Sa2b1b5uOU98D9DOGg vBjA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b="a5E/5soj"; 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 t7si9746547edq.209.2021.07.04.16.09.47; Sun, 04 Jul 2021 16:10:11 -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="a5E/5soj"; 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 S232539AbhGDXKr (ORCPT + 99 others); Sun, 4 Jul 2021 19:10:47 -0400 Received: from mail.kernel.org ([198.145.29.99]:46816 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231768AbhGDXJG (ORCPT ); Sun, 4 Jul 2021 19:09:06 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30BF6611ED; Sun, 4 Jul 2021 23:06:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1625439990; bh=c5RGKMO/Iij/OF/EMGrK9bgD+2TCuXmHaKdi0NSsXx4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=a5E/5sojpdRZPuxteqBfJ6FRfBy+hYZZz+D0CBiEiPICeN+Vlyxr9X2UEMqMueCAM iaC7kZ6PI2RnrkHdoggCoOF/6V9gBBWPGRThn0PErA0x0cHrLVTtelc/CJcZG0e4pm 0B4pk4BiK88dEqFE+NvKh61gRFXQazRNtD+gxCJjRvoLUs4YM7aHEuITEWKglsDVwb lM3ztyW+djVUtot+8NIHr56Z4JwGFpIBCRj2pM3aj+oNowPxVQOR3uzMn5FUtcuZ5/ Oa3BpVNrEMf6rXH3EEfkNCJLvoUz4ZCA+RAKH3k9b1Zpd7G/DLCUijAt5x9hOGlJNm wCQfy6Mc2c62g== 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.12 10/80] media: mtk-vcodec: fix PM runtime get logic Date: Sun, 4 Jul 2021 19:05:06 -0400 Message-Id: <20210704230616.1489200-10-sashal@kernel.org> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210704230616.1489200-1-sashal@kernel.org> References: <20210704230616.1489200-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