Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp1511839ybk; Thu, 21 May 2020 08:35:08 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeFy6etNkl2b9xlArVPMS+uWz0v8fsx+5aVAdUJV8RlnqpQtGQ4IauWqEi8WcypfBxEpwG X-Received: by 2002:a17:906:3652:: with SMTP id r18mr3966338ejb.526.1590075308678; Thu, 21 May 2020 08:35:08 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590075308; cv=none; d=google.com; s=arc-20160816; b=KqmLMqF5UgXb8ISrIoaoJGo1HQHUmA5we1+m3gt5lWkHXBYIJNGDJekjNWtlnDOIO8 TD+AAVmxB1uf4m89/4P2RoU6TMvmo20H6azO4DrYwyYyUAK1/JSyoF1j8n4RlDLBmNiY YTtRC1MrXeoda36He+jO02utFjRgWBVF39INKuTt+IknKZlMQmVYoHvCpI/40VAUcjau YQjQBBuPXzKq/7afTLC20ukpySkMVDkKeqvdBZKfPTxXoKOE7mOebLuK0i5rxDv0W7jl vxGboW9j60lOj1VN1ect34X0OehRFRRtlsEhHZY8gE409eXAk0rnofhGcccimoOISANc PNDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=a+XGEo7RdRLWXaBT5I1D5SW4Aa/jygWE9YUzvCS9gvI=; b=IMlC+W38Ganeo5e2cQ+mhpZJ/OyDV5vcvC/4wj8PODrS9hzM5PwPYVkKcJE1bUg7fX +fCB348rWhOJ1nbOPLRKG+mfYgy1efIL/BbwgIoLLBMnXK8kLUxIiyArUuOnVME12Bwu ePjxmEV6hCSStQ080lbvnYWx8DMg7Xrj6+Ogc0XStZsA9kbbA2kge8bwl1luw/1uGuom NRwd8r0eCxL2R79uRMGDdp0LPZ6WDqU97dG1s5JHkIVmsXr/LrK1234JheLBvOKrA+a9 4lzuNH57eBCvVV217aDzjzEB+6XEcrgFk9W9lVI7R46Ta5SCizg8R46AQbwH2InyLfm9 juLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=C6Qnseph; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id do10si4685996ejc.671.2020.05.21.08.34.42; Thu, 21 May 2020 08:35:08 -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=@chromium.org header.s=google header.b=C6Qnseph; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728269AbgEUPdC (ORCPT + 99 others); Thu, 21 May 2020 11:33:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36662 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726938AbgEUPdB (ORCPT ); Thu, 21 May 2020 11:33:01 -0400 Received: from mail-wm1-x341.google.com (mail-wm1-x341.google.com [IPv6:2a00:1450:4864:20::341]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 48F22C061A0F for ; Thu, 21 May 2020 08:33:01 -0700 (PDT) Received: by mail-wm1-x341.google.com with SMTP id n5so6801927wmd.0 for ; Thu, 21 May 2020 08:33:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=a+XGEo7RdRLWXaBT5I1D5SW4Aa/jygWE9YUzvCS9gvI=; b=C6QnsephZ4AXYbZbM1y/Cghfe4u+luUWsgG6OhW+RMXWdsfoZHD3nxlNwa1hYOht3T WTfDVrMB9YUP/UOKUCF8OVzgeCtW2v5g8iWYm18a9M2nlHg/NnB8Ir6MPtJ5w+UhTuNZ xvN1sB6mgklbOCg7LJog22flxrih0eY9gDBhU= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=a+XGEo7RdRLWXaBT5I1D5SW4Aa/jygWE9YUzvCS9gvI=; b=chTxzlrUXiL1H6C3IJaXmkdEt4Dfqyez2pzrKGyh25eRa9qF2V65drbAaXMnkx8izo JOQ80DN7osV7jWggWcOS8iu1wN26LmEYggXsSHJ+Tuw0/3GrOaoZIWtMgMelaEAelaxH NpxsLPk2z8INQR3BaUW5TMwbRlCeOD00+4uDz1WO8e7SvSIcDhcVvXGZUz8ITiUP9xz/ cIxfC9VrGHYclrLfzSuVDU/sXjUHvhI9eQoBzZR/I88KyO0V7aHX6neUpc0AHhmx8Vp7 aRLOf0+IUtcZFWu3E9Oc118gI2qrHRz5xNpv7xq6xvMqPSimnKF+jbd83BQQA9MKCtwX gzxw== X-Gm-Message-State: AOAM532qQirveFEt6/kATez8kRn1MkXoWzQFvXrMI31+Gb04H9o+OxsN F+Jjjn4jTDae8dW19fo2G1nlKA== X-Received: by 2002:a7b:c4cc:: with SMTP id g12mr9202139wmk.168.1590075179928; Thu, 21 May 2020 08:32:59 -0700 (PDT) Received: from chromium.org (205.215.190.35.bc.googleusercontent.com. [35.190.215.205]) by smtp.gmail.com with ESMTPSA id i11sm7245926wrc.35.2020.05.21.08.32.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 21 May 2020 08:32:59 -0700 (PDT) Date: Thu, 21 May 2020 15:32:57 +0000 From: Tomasz Figa To: Xia Jiang Cc: Hans Verkuil , Mauro Carvalho Chehab , Rob Herring , Matthias Brugger , Rick Chang , linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, Marek Szyprowski , srv_heupstream@mediatek.com, senozhatsky@chromium.org, mojahsu@chromium.org, drinkcat@chromium.org, maoguang.meng@mediatek.com, sj.huang@mediatek.com Subject: Re: [PATCH v8 06/14] media: platform: Improve the implementation of the system PM ops Message-ID: <20200521153257.GF209565@chromium.org> References: <20200403094033.8288-1-xia.jiang@mediatek.com> <20200403094033.8288-7-xia.jiang@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200403094033.8288-7-xia.jiang@mediatek.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Xia, On Fri, Apr 03, 2020 at 05:40:25PM +0800, Xia Jiang wrote: > Cancel reset hw operation in suspend and resume function because this > will be done in device_run(). This and... > Add spin_lock and unlock operation in irq and resume function to make > sure that the current frame is processed completely before suspend. ...this are two separate changes. Please split. > > Signed-off-by: Xia Jiang > --- > drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c | 11 +++++++++-- > 1 file changed, 9 insertions(+), 2 deletions(-) > > diff --git a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c > index dd5cadd101ef..2fa3711fdc9b 100644 > --- a/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c > +++ b/drivers/media/platform/mtk-jpeg/mtk_jpeg_core.c > @@ -911,6 +911,8 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) > u32 dec_ret; > int i; > > + spin_lock(&jpeg->hw_lock); > + nit: For consistency, it is recommended to always use the same, i.e. the strongest, spin_(un)lock_ primitives when operating on the same spinlock. In this case it would be the irqsave(restore) variants. > dec_ret = mtk_jpeg_dec_get_int_status(jpeg->dec_reg_base); > dec_irq_ret = mtk_jpeg_dec_enum_result(dec_ret); > ctx = v4l2_m2m_get_curr_priv(jpeg->m2m_dev); > @@ -941,6 +943,7 @@ static irqreturn_t mtk_jpeg_dec_irq(int irq, void *priv) > v4l2_m2m_buf_done(src_buf, buf_state); > v4l2_m2m_buf_done(dst_buf, buf_state); > v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); > + spin_unlock(&jpeg->hw_lock); > pm_runtime_put_sync(ctx->jpeg->dev); > return IRQ_HANDLED; > } > @@ -1191,7 +1194,6 @@ static __maybe_unused int mtk_jpeg_pm_suspend(struct device *dev) > { > struct mtk_jpeg_dev *jpeg = dev_get_drvdata(dev); > > - mtk_jpeg_dec_reset(jpeg->dec_reg_base); > mtk_jpeg_clk_off(jpeg); > > return 0; > @@ -1202,19 +1204,24 @@ static __maybe_unused int mtk_jpeg_pm_resume(struct device *dev) > struct mtk_jpeg_dev *jpeg = dev_get_drvdata(dev); > > mtk_jpeg_clk_on(jpeg); > - mtk_jpeg_dec_reset(jpeg->dec_reg_base); > > return 0; > } > > static __maybe_unused int mtk_jpeg_suspend(struct device *dev) > { > + struct mtk_jpeg_dev *jpeg = dev_get_drvdata(dev); > + unsigned long flags; > int ret; > > if (pm_runtime_suspended(dev)) > return 0; > > + spin_lock_irqsave(&jpeg->hw_lock, flags); What does this spinlock protect us from? I can see that it would prevent the interrupt handler from being called, but is it okay to suspend the system without handling the interrupt? > + > ret = mtk_jpeg_pm_suspend(dev); > + Looking at the implementation of mtk_jpeg_pm_suspend(), all it does is disabling the clock. How do we make sure that there is no frame currently being processed by the hardware? Best regards, Tomasz