Received: by 2002:a05:6a10:f3d0:0:0:0:0 with SMTP id a16csp2834053pxv; Mon, 12 Jul 2021 03:05:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy/8tDMyZcGTKb8/cMrCT5qs4B0oZbOJKx8Ho5qMlHlfg1R3/FL1mfRuTN+WL9jKp4QOUb9 X-Received: by 2002:a92:2911:: with SMTP id l17mr3015290ilg.263.1626084351334; Mon, 12 Jul 2021 03:05:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626084351; cv=none; d=google.com; s=arc-20160816; b=1DMtreVd67aInJMgO0b3cWGijTGBZl7IweK7PY2XAymBOAuMXH53QNhRKCNS0/bqYm i2aZGSvjHHBcoECWDWANJKB9hUOiszG4NlHpxPt0wGBRdLPmLVR2XtjzvyZnadHdWAOt +VMQUeEhocATFSQnNzOcE62pzOXN/INGCVojVPOFDBrcSOhFxO19MdMeqAyp9DXsL850 vKWdD0j12GijbEjhWhPIziP3FZE48U2KNWC1k4kgnB2TlgfPJ+qbpLvtiWv8+Tkfm5D7 JlviKNEnP+BuCTVc98wXyJva4EcZHNE6I99ehzugt0T9/xSsFGLadzn9nkLm5d99wW/E LfIw== 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=wVm4Fx4xO7IWM8OPsG6yEFJYYXRb41zoRmGLWLwB/Z0=; b=WbSxwOyj/nfaG2k27PZKLuZ+E9BnRvlvAI3g9ld5i5Hqxo8BHKIqJsSP1jFB3pbrKJ FiMjxbDa1TGoNIZaQ0MV1YGzelzBac9slZ4mG8O1fL2ncijiPMJWtV4CrW0uJPMJ8XW0 Yz/mUoD3jiYfOMhOe4XjoUzLWFWAti2rNBYf0u3tJlU7FBN42g2bKNqw5V+vlJ8x0njI W6LGtfJPNnsZo67WPqjiTiIp/gkWcEcO8k7jBXRcfQlQlvFitm0DEWHgFRgQBXQtVtIP XiUoGbZpO0I0F5MMEpEUFw4Kt5RjatL3aRiHpLXV+08aLnuQxOoONJ1TDB3aqri1CU4r Jp9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=oF0uG2W4; 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 r17si18860451iov.104.2021.07.12.03.05.39; Mon, 12 Jul 2021 03:05:51 -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=oF0uG2W4; 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 S1345108AbhGLHgH (ORCPT + 99 others); Mon, 12 Jul 2021 03:36:07 -0400 Received: from mail.kernel.org ([198.145.29.99]:43022 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S241832AbhGLHHd (ORCPT ); Mon, 12 Jul 2021 03:07:33 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 9601260FE7; Mon, 12 Jul 2021 07:04:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626073477; bh=KdCEJK8exetM24aIuhXoADNfokLieJ29Z173kFeZDko=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oF0uG2W4oWEIUotff82taez2yFIrPjGLQVEmqGE8b7PULgOFDD05biejuchZaylZn Fa6ZYPjlkog8ZzLv7bWrZiF0kpOZOkFSN2zkG6NEnJ6ycMwgYof1Q3AFTsClx1fLDY Aee1LPBuhy360BUiSwolReIdKB0fDdw1GU4CzwHw= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Ezequiel Garcia , Mauro Carvalho Chehab , Sasha Levin Subject: [PATCH 5.12 253/700] media: hantro: do a PM resume earlier Date: Mon, 12 Jul 2021 08:05:36 +0200 Message-Id: <20210712061002.806139065@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060924.797321836@linuxfoundation.org> References: <20210712060924.797321836@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 892bb6ecead9b834ba7ad1d07513e9eba1baa3a4 ] The device_run() first enables the clock and then tries to resume PM runtime, checking for errors. Well, if for some reason the pm_runtime can not resume, it would be better to detect it beforehand. So, change the order inside device_run(). Reviewed-by: Ezequiel Garcia Fixes: 775fec69008d ("media: add Rockchip VPU JPEG encoder driver") Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Sasha Levin --- drivers/staging/media/hantro/hantro_drv.c | 33 +++++++++++++++-------- 1 file changed, 22 insertions(+), 11 deletions(-) diff --git a/drivers/staging/media/hantro/hantro_drv.c b/drivers/staging/media/hantro/hantro_drv.c index e5f200e64993..2d6e0056be62 100644 --- a/drivers/staging/media/hantro/hantro_drv.c +++ b/drivers/staging/media/hantro/hantro_drv.c @@ -56,16 +56,12 @@ dma_addr_t hantro_get_ref(struct hantro_ctx *ctx, u64 ts) return hantro_get_dec_buf_addr(ctx, buf); } -static void hantro_job_finish(struct hantro_dev *vpu, - struct hantro_ctx *ctx, - enum vb2_buffer_state result) +static void hantro_job_finish_no_pm(struct hantro_dev *vpu, + struct hantro_ctx *ctx, + enum vb2_buffer_state result) { struct vb2_v4l2_buffer *src, *dst; - pm_runtime_mark_last_busy(vpu->dev); - pm_runtime_put_autosuspend(vpu->dev); - clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks); - src = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); dst = v4l2_m2m_next_dst_buf(ctx->fh.m2m_ctx); @@ -81,6 +77,18 @@ static void hantro_job_finish(struct hantro_dev *vpu, result); } +static void hantro_job_finish(struct hantro_dev *vpu, + struct hantro_ctx *ctx, + enum vb2_buffer_state result) +{ + pm_runtime_mark_last_busy(vpu->dev); + pm_runtime_put_autosuspend(vpu->dev); + + clk_bulk_disable(vpu->variant->num_clocks, vpu->clocks); + + hantro_job_finish_no_pm(vpu, ctx, result); +} + void hantro_irq_done(struct hantro_dev *vpu, enum vb2_buffer_state result) { @@ -152,12 +160,15 @@ static void device_run(void *priv) src = hantro_get_src_buf(ctx); dst = hantro_get_dst_buf(ctx); + ret = pm_runtime_get_sync(ctx->dev->dev); + if (ret < 0) { + pm_runtime_put_noidle(ctx->dev->dev); + goto err_cancel_job; + } + ret = clk_bulk_enable(ctx->dev->variant->num_clocks, ctx->dev->clocks); if (ret) goto err_cancel_job; - ret = pm_runtime_get_sync(ctx->dev->dev); - if (ret < 0) - goto err_cancel_job; v4l2_m2m_buf_copy_metadata(src, dst, true); @@ -165,7 +176,7 @@ static void device_run(void *priv) return; err_cancel_job: - hantro_job_finish(ctx->dev, ctx, VB2_BUF_STATE_ERROR); + hantro_job_finish_no_pm(ctx->dev, ctx, VB2_BUF_STATE_ERROR); } static struct v4l2_m2m_ops vpu_m2m_ops = { -- 2.30.2