From patchwork Thu Feb 23 08:13:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SXJ1aSBXYW5nICjnjovnkZ4p?= X-Patchwork-Id: 60825 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp196004wrd; Thu, 23 Feb 2023 00:14:02 -0800 (PST) X-Google-Smtp-Source: AK7set/F56g85cmW9zNiQk2ns8pPvhqFOFfTruP8QlUSEbjF+ihDjHn5Nytms/Y+HXiv7JOWWIxH X-Received: by 2002:a17:90a:fb84:b0:237:47b0:30d3 with SMTP id cp4-20020a17090afb8400b0023747b030d3mr3700033pjb.4.1677140042456; Thu, 23 Feb 2023 00:14:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677140042; cv=none; d=google.com; s=arc-20160816; b=lKWb7J51wyN8LI2xXFziEi339ap2E5GCQbbI6aHDts+idff1Sii3/SehRvpCcXv4aW 8QXw8X7OdeKXozs/8RugUtb+bOfYYZ8ccfHHn05KwU9iaSoa/5Om8/cYyEHyRYsw8UiM 91y4786NoMwOPw8ksc1CsM+bfpAZHeZ/cJZjT5m8jObMxpe9gLn/Ah4R7hyv4LyXq779 r2kWElTXJX2ON1IOGVEPKB5gCLHM+DMmED//5zyvj7gFI2LT3vxpWuxSo+WjgXVOYlZd +D3PCpm3m2wdVeYkEZ4Bhhqe32OoF6dPgijFa3IOx/aGa7UYvcoXMayZKOC2H777VrLT 81Fg== 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=zKQNhHm6N//epT/kKKmOBAV+Pxos4Bzj8k8OKQmEryU=; b=uWYDQGgow8+M8XCnjItb8CVakoZwmJcqxGiUFRLNeLEne16j44pSpoAK+T29JbbRwY sc7iUSKilPJf3bMd+3UqpJVJGnFu8XaratLB5bT7r2YgPC9wB9rzjmBBDXhEurVXMgUw wajqGSeAGB/T9cmQVbqwgy3B3kREgtbdQ+X7NuJuwuSd+c3SAZ+c47mhAASmsC0Fk7tR WEensdOGi+SHqPwPI149o+xfG079u/9OKEtbHtZS8VFnccUht/XLgBuFSXO4R8MwwmXv Jp17Jo9yWXNERRvy3YlAT7ecfZrX37ZOTFODle6TnhfUc/a/4KUe3C1ZhAdaop4MIv0q i0Lg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=CEH9PjTO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l11-20020a17090a72cb00b0023408c25bd7si15272690pjk.65.2023.02.23.00.13.49; Thu, 23 Feb 2023 00:14:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=CEH9PjTO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233400AbjBWINg (ORCPT + 99 others); Thu, 23 Feb 2023 03:13:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232802AbjBWIN1 (ORCPT ); Thu, 23 Feb 2023 03:13:27 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8F71A498AF; Thu, 23 Feb 2023 00:13:25 -0800 (PST) X-UUID: ed6a18aab35111ed945fc101203acc17-20230223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=zKQNhHm6N//epT/kKKmOBAV+Pxos4Bzj8k8OKQmEryU=; b=CEH9PjTOQFSD3jfIGhhqVn4KGLVzN9YcXdGhq/CrSJ1Ct6wIcZE+zWVk9cJEEaEuT1/TAScDPXP8ck88tsIZaFBQvlPocXAabHZbhJwcJkf9vJFceXIPGtLKphcHZLnQPdqFF/rsLhxPmbVXHUyP+n+nKHWKkzqrzwa2GLMoGN8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:922cd7d1-aded-4d41-afef-441fb634c8ea,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.20,REQID:922cd7d1-aded-4d41-afef-441fb634c8ea,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:25b5999,CLOUDID:0c87e6f3-ddba-41c3-91d9-10eeade8eac7,B ulkID:230223161319I53H5PP3,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0 X-UUID: ed6a18aab35111ed945fc101203acc17-20230223 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 699362284; Thu, 23 Feb 2023 16:13:17 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 23 Feb 2023 16:13:16 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 23 Feb 2023 16:13:15 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , , , kyrie wu CC: , , , , , Tomasz Figa , , , Yunfei Dong , Irui Wang Subject: [V1,1/7] media: mtk-jpeg: Fixes jpeghw multi-core judgement Date: Thu, 23 Feb 2023 16:13:06 +0800 Message-ID: <20230223081312.29296-2-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223081312.29296-1-irui.wang@mediatek.com> References: <20230223081312.29296-1-irui.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758608796986568507?= X-GMAIL-MSGID: =?utf-8?q?1758608796986568507?= From: kyrie wu some chips have multi-hw, but others have only one, modify the condition of multi-hw judgement Fixes: 934e8bccac95 ("mtk-jpegenc: support jpegenc multi-hardware") Signed-off-by: kyrie wu Signed-off-by: irui wang Reviewed-by: AngeloGioacchino Del Regno --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 5 ++++- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h | 2 ++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 969516a940ba..6d052747a15e 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1692,7 +1692,7 @@ static int mtk_jpeg_probe(struct platform_device *pdev) return -EINVAL; } - if (list_empty(&pdev->dev.devres_head)) { + if (!jpeg->variant->multi_core) { INIT_DELAYED_WORK(&jpeg->job_timeout_work, mtk_jpeg_job_timeout_work); @@ -1874,6 +1874,7 @@ static const struct mtk_jpeg_variant mtk_jpeg_drvdata = { .ioctl_ops = &mtk_jpeg_enc_ioctl_ops, .out_q_default_fourcc = V4L2_PIX_FMT_YUYV, .cap_q_default_fourcc = V4L2_PIX_FMT_JPEG, + .multi_core = false, }; static struct mtk_jpeg_variant mtk8195_jpegenc_drvdata = { @@ -1885,6 +1886,7 @@ static struct mtk_jpeg_variant mtk8195_jpegenc_drvdata = { .ioctl_ops = &mtk_jpeg_enc_ioctl_ops, .out_q_default_fourcc = V4L2_PIX_FMT_YUYV, .cap_q_default_fourcc = V4L2_PIX_FMT_JPEG, + .multi_core = true, }; static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = { @@ -1896,6 +1898,7 @@ static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = { .ioctl_ops = &mtk_jpeg_dec_ioctl_ops, .out_q_default_fourcc = V4L2_PIX_FMT_JPEG, .cap_q_default_fourcc = V4L2_PIX_FMT_YUV420M, + .multi_core = true, }; #if defined(CONFIG_OF) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index b9126476be8f..f87358cc9f47 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h @@ -60,6 +60,7 @@ enum mtk_jpeg_ctx_state { * @ioctl_ops: the callback of jpeg v4l2_ioctl_ops * @out_q_default_fourcc: output queue default fourcc * @cap_q_default_fourcc: capture queue default fourcc + * @multi_core: mark jpeg hw is multi_core or not */ struct mtk_jpeg_variant { struct clk_bulk_data *clks; @@ -74,6 +75,7 @@ struct mtk_jpeg_variant { const struct v4l2_ioctl_ops *ioctl_ops; u32 out_q_default_fourcc; u32 cap_q_default_fourcc; + bool multi_core; }; struct mtk_jpeg_src_buf { From patchwork Thu Feb 23 08:13:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SXJ1aSBXYW5nICjnjovnkZ4p?= X-Patchwork-Id: 60824 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp195967wrd; Thu, 23 Feb 2023 00:13:54 -0800 (PST) X-Google-Smtp-Source: AK7set/EYtnjSqLbiu3pfZIbNnqKynXMvEEC7hmP9oEh0b/vDzvE5vYaUedH8ZbEf6DP9AFes5OL X-Received: by 2002:a17:90a:bf08:b0:230:a082:b085 with SMTP id c8-20020a17090abf0800b00230a082b085mr10313052pjs.0.1677140034128; Thu, 23 Feb 2023 00:13:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677140034; cv=none; d=google.com; s=arc-20160816; b=R9fRl5eKC2rGPM/dzTwr/aJB8URiU1OeWQ1lSGS/EevD34OkaBQ8DiTCHLkwkfzAk9 jEoY5Nc56IviO9FYhlrHUe+xK7SgZSU+yE0mpdbr1nm1MzEgjvELeNQNdTEOF9xG8l9O bXNIR/2KgoIXuREvDeoAl+sbPxQxmOvx0mybwWNJZ2A1KcdNNdqLVtcPvQ0Yw1ZhywuC OPdRw9xa50rKlbiyTB0TftbCHJka15M1MnJNnLe3Z/pqLo48q6YMXNyv3fciscAz3zwG fr+FOU/A5JkKTERbQwHYGJ/iO2EwoGBTNgzWe/bO+tXia8h3pRsNOZACd6MBLKKTfJG0 sJOQ== 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=sJQQkamtHAcgkCGJ0h3Tqt0rl885miX0Xvw7NZPq2Hg=; b=Z5n8A/EnXEGCVBYayBBuDB068N88+MkuwTUGQjsRTyS8XtahmU7jxnFMl0jb2uQkBf OpwRfT7ZfsQfRRo21d8cGfGZ9KHfzIqZ4Aw1sO6Uned/ySm/vFmn6ww9HYvZLRcSjh6N pKu/F6t2eXhJdTi8nO4QKxaztcyp6kf+BxiQS8Ob5CRC96Ect4i3ceH0Ie4F0bQ3a61S pDxyiOUCVS37ZI0Q8oA2oIYy6fyMiBKP+Wtd51UCa2rJdYF3DuEdXMP2P4glFeKsx66T Coz4f/onIbWKWrFDMz98m6DswWibFS60mpgoku/eac6knb9VhNV0rsWVGWOzMq1YtnT8 aPzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=c0jNQ6Hn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id ix9-20020a170902f80900b0019911e762c1si11115320plb.212.2023.02.23.00.13.40; Thu, 23 Feb 2023 00:13:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=c0jNQ6Hn; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233352AbjBWINb (ORCPT + 99 others); Thu, 23 Feb 2023 03:13:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231493AbjBWIN1 (ORCPT ); Thu, 23 Feb 2023 03:13:27 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 826BE498A8; Thu, 23 Feb 2023 00:13:22 -0800 (PST) X-UUID: edf0e470b35111eda06fc9ecc4dadd91-20230223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=sJQQkamtHAcgkCGJ0h3Tqt0rl885miX0Xvw7NZPq2Hg=; b=c0jNQ6Hn1y4i4MqIktQi+ubrWV/iawkX/a7Ao8fXpy6Nc06od2bvr6QJi3CS57TYFP8o5SXP7BhlhR/ffFIeJWV9j0JNDnnyWbyFxbWT8L3bWFhH+OBCcjyO56EDJiZAPT8ZlbGInP4DuTrsAx1I8rfOvDUmA7ZVdu82fD09BpI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:fc54e0ea-316c-44f4-97db-276262671a50,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION :release,TS:-5 X-CID-META: VersionHash:25b5999,CLOUDID:2b0159b1-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: edf0e470b35111eda06fc9ecc4dadd91-20230223 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1057414654; Thu, 23 Feb 2023 16:13:18 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Thu, 23 Feb 2023 16:13:17 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 23 Feb 2023 16:13:16 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , , , kyrie wu CC: , , , , , Tomasz Figa , , , Yunfei Dong , "Irui Wang" Subject: [V1,2/7] media: mtk-jpeg: add jpeg single core initial function Date: Thu, 23 Feb 2023 16:13:07 +0800 Message-ID: <20230223081312.29296-3-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223081312.29296-1-irui.wang@mediatek.com> References: <20230223081312.29296-1-irui.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758608788476664367?= X-GMAIL-MSGID: =?utf-8?q?1758608788476664367?= From: kyrie wu add single core initial function to init reg_base, irq and clk. Signed-off-by: kyrie wu Signed-off-by: irui wang --- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 74 +++++++++++-------- 1 file changed, 44 insertions(+), 30 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index 6d052747a15e..daa4a6448311 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1671,10 +1671,50 @@ static void mtk_jpeg_job_timeout_work(struct work_struct *work) v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); } +static int mtk_jpeg_single_core_init(struct platform_device *pdev, + struct mtk_jpeg_dev *jpeg_dev) +{ + struct mtk_jpeg_dev *jpeg = jpeg_dev; + int jpeg_irq, ret; + + INIT_DELAYED_WORK(&jpeg->job_timeout_work, + mtk_jpeg_job_timeout_work); + + jpeg->reg_base = devm_platform_ioremap_resource(pdev, 0); + if (IS_ERR(jpeg->reg_base)) { + ret = PTR_ERR(jpeg->reg_base); + return ret; + } + + jpeg_irq = platform_get_irq(pdev, 0); + if (jpeg_irq < 0) + return jpeg_irq; + + ret = devm_request_irq(&pdev->dev, + jpeg_irq, + jpeg->variant->irq_handler, + 0, + pdev->name, jpeg); + if (ret) { + dev_err(&pdev->dev, "Failed to request jpeg_irq %d (%d)\n", + jpeg_irq, ret); + return ret; + } + + ret = devm_clk_bulk_get(jpeg->dev, + jpeg->variant->num_clks, + jpeg->variant->clks); + if (ret) { + dev_err(&pdev->dev, "Failed to init clk\n"); + return ret; + } + + return 0; +} + static int mtk_jpeg_probe(struct platform_device *pdev) { struct mtk_jpeg_dev *jpeg; - int jpeg_irq; int ret; jpeg = devm_kzalloc(&pdev->dev, sizeof(*jpeg), GFP_KERNEL); @@ -1693,36 +1733,10 @@ static int mtk_jpeg_probe(struct platform_device *pdev) } if (!jpeg->variant->multi_core) { - INIT_DELAYED_WORK(&jpeg->job_timeout_work, - mtk_jpeg_job_timeout_work); - - jpeg->reg_base = devm_platform_ioremap_resource(pdev, 0); - if (IS_ERR(jpeg->reg_base)) { - ret = PTR_ERR(jpeg->reg_base); - return ret; - } - - jpeg_irq = platform_get_irq(pdev, 0); - if (jpeg_irq < 0) - return jpeg_irq; - - ret = devm_request_irq(&pdev->dev, - jpeg_irq, - jpeg->variant->irq_handler, - 0, - pdev->name, jpeg); - if (ret) { - dev_err(&pdev->dev, "Failed to request jpeg_irq %d (%d)\n", - jpeg_irq, ret); - return ret; - } - - ret = devm_clk_bulk_get(jpeg->dev, - jpeg->variant->num_clks, - jpeg->variant->clks); + ret = mtk_jpeg_single_core_init(pdev, jpeg); if (ret) { - dev_err(&pdev->dev, "Failed to init clk\n"); - return ret; + v4l2_err(&jpeg->v4l2_dev, "mtk_jpeg_single_core_init failed."); + return -EINVAL; } } From patchwork Thu Feb 23 08:13:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SXJ1aSBXYW5nICjnjovnkZ4p?= X-Patchwork-Id: 60826 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp196336wrd; Thu, 23 Feb 2023 00:15:10 -0800 (PST) X-Google-Smtp-Source: AK7set/+Ko6s0r++W8KMKJ5z8UnRkMq6vw5Ca/klMJZugzmDiU0G+Nsl0U8fBWJuTM8tzKFnYzLO X-Received: by 2002:a17:90b:30b:b0:234:b170:1f27 with SMTP id ay11-20020a17090b030b00b00234b1701f27mr10769715pjb.0.1677140110138; Thu, 23 Feb 2023 00:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677140110; cv=none; d=google.com; s=arc-20160816; b=DHF2wGpcyaOJPn6LMj5SAZ2KRRHO4AvVb2Vm4121+XLv4gTv7nsk4qJcG9PSOb2c/m qLIzP+niJ5CSsRkNboUXTBmNPxIitS5JR8z0zJEz8rLhTxGH1kMivcoppLKhpnMY1STa XBwNSex5VgKA5/UiFiNAXsPczHlJD4a2VPJFANpwqLuAVijdWaghHY2MMEcllScSSy8l 6vpgz3z7fZLf8343kIQ5w4pzxXMnA+jwKct1r8HKolOfDtkWCQuaeItQjM3lvV0bdh5y chA5fdgwN+GsqDoLVx9TGI4JhDqPJiV3Rr+30t3FAGoqPBbmcTyanipjZt7aI6HUJt41 GdlA== 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=9r+WM7v+v+aqqXYNQiSrE5n+ZdQz4RMsB1qmBc64lKc=; b=DL2WozmfmAWxqSdqLV1TtbMjHJWImazL4WHszES92wM4ae6TIDFoPDkkD2T9vdiVEe r5ZBXOimXxjHtbqjEb64IKvnbZgKukBeZiw40VVQLXu4XWFY3Du6so3TRqDJX3sOdOc+ TvhLLNeeWZxGq4wZWhd99RB6KPJZmZSbPtBbCiiaqEEPl9RlF97DzLd4J1Ncb8czXpfy bdPIOgD0ybjuxWEW5SKuq91ZM2WP2OsjF8xQRoiUIn6uuYZv2LlW8IICVVTrOdtcALSY LAZAKt5Mi1b60IqcNYjVaHjspVxHhkGQbJX+zdcbLnlbJYZJv2P+8i/sqe+0ZQeHrhSU TsWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ChraeNE4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m7-20020a17090a414700b002352eb7b6ecsi13608253pjg.80.2023.02.23.00.14.57; Thu, 23 Feb 2023 00:15:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=ChraeNE4; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbjBWINm (ORCPT + 99 others); Thu, 23 Feb 2023 03:13:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38722 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232954AbjBWIN2 (ORCPT ); Thu, 23 Feb 2023 03:13:28 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9CD4D498B0; Thu, 23 Feb 2023 00:13:25 -0800 (PST) X-UUID: ee7e07d8b35111eda06fc9ecc4dadd91-20230223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=9r+WM7v+v+aqqXYNQiSrE5n+ZdQz4RMsB1qmBc64lKc=; b=ChraeNE4TzN/puh2uv+/XmMBZN2w/EBZrV5r4s0hZ5qAuSxWbsrhJjkgCeC6NMp4i7igoBRNcZNYI1a0KZuz+DtdJzVQV5/kLhEg0xnffH1AJ9kld4gVb4owEb7KHfqExYnt8fYH5+AmeALYoBfeVD4guwT7mAp6X3Z2uCjHEKo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:4d03de18-5c64-4e89-a81e-003b5a1be404,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:-25 X-CID-META: VersionHash:25b5999,CLOUDID:a30159b1-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: ee7e07d8b35111eda06fc9ecc4dadd91-20230223 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 393979555; Thu, 23 Feb 2023 16:13:19 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs13n1.mediatek.inc (172.21.101.193) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 23 Feb 2023 16:13:17 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 23 Feb 2023 16:13:17 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , , , kyrie wu CC: , , , , , Tomasz Figa , , , Yunfei Dong , Irui Wang Subject: [V1,3/7] media: mtk-jpeg: Fixes jpeg enc&dec worker sw flow Date: Thu, 23 Feb 2023 16:13:08 +0800 Message-ID: <20230223081312.29296-4-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223081312.29296-1-irui.wang@mediatek.com> References: <20230223081312.29296-1-irui.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758608867959725250?= X-GMAIL-MSGID: =?utf-8?q?1758608867959725250?= From: kyrie wu 1. Move removing buffer after sw setting and before hw setting in enc&dec worker to prevents the operation of removing the buffer twice if the sw setting fails. 2. Remove the redundant operation of queue work in the jpegenc irq handler because the jpegenc worker has called v4l2_m2m_job_finish to do it. Fixes: 5fb1c2361e56 ("mtk-jpegenc: add jpeg encode worker interface") Fixes: dedc21500334 ("media: mtk-jpegdec: add jpeg decode worker interface") Signed-off-by: kyrie wu Signed-off-by: irui wang --- .../media/platform/mediatek/jpeg/mtk_jpeg_core.c | 14 +++++++------- .../media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c | 4 ---- 2 files changed, 7 insertions(+), 11 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index daa4a6448311..d940dc5ede74 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1025,9 +1025,6 @@ static void mtk_jpegenc_worker(struct work_struct *work) if (!dst_buf) goto getbuf_fail; - v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); - v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); - v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, true); mtk_jpegenc_set_hw_param(ctx, hw_id, src_buf, dst_buf); @@ -1045,6 +1042,9 @@ static void mtk_jpegenc_worker(struct work_struct *work) goto enc_end; } + v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); + v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + schedule_delayed_work(&comp_jpeg[hw_id]->job_timeout_work, msecs_to_jiffies(MTK_JPEG_HW_TIMEOUT_MSEC)); @@ -1220,9 +1220,6 @@ static void mtk_jpegdec_worker(struct work_struct *work) if (!dst_buf) goto getbuf_fail; - v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); - v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); - v4l2_m2m_buf_copy_metadata(src_buf, dst_buf, true); jpeg_src_buf = mtk_jpeg_vb2_to_srcbuf(&src_buf->vb2_buf); jpeg_dst_buf = mtk_jpeg_vb2_to_srcbuf(&dst_buf->vb2_buf); @@ -1231,7 +1228,7 @@ static void mtk_jpegdec_worker(struct work_struct *work) &jpeg_src_buf->dec_param)) { mtk_jpeg_queue_src_chg_event(ctx); ctx->state = MTK_JPEG_SOURCE_CHANGE; - goto dec_end; + goto getbuf_fail; } jpeg_src_buf->curr_ctx = ctx; @@ -1254,6 +1251,9 @@ static void mtk_jpegdec_worker(struct work_struct *work) goto clk_end; } + v4l2_m2m_src_buf_remove(ctx->fh.m2m_ctx); + v4l2_m2m_dst_buf_remove(ctx->fh.m2m_ctx); + schedule_delayed_work(&comp_jpeg[hw_id]->job_timeout_work, msecs_to_jiffies(MTK_JPEG_HW_TIMEOUT_MSEC)); diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c index 1bbb712d78d0..867f4c1a09fa 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c @@ -286,10 +286,6 @@ static irqreturn_t mtk_jpegenc_hw_irq_handler(int irq, void *priv) mtk_jpegenc_put_buf(jpeg); pm_runtime_put(ctx->jpeg->dev); clk_disable_unprepare(jpeg->venc_clk.clks->clk); - if (!list_empty(&ctx->fh.m2m_ctx->out_q_ctx.rdy_queue) || - !list_empty(&ctx->fh.m2m_ctx->cap_q_ctx.rdy_queue)) { - queue_work(master_jpeg->workqueue, &ctx->jpeg_work); - } jpeg->hw_state = MTK_JPEG_HW_IDLE; wake_up(&master_jpeg->enc_hw_wq); From patchwork Thu Feb 23 08:13:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SXJ1aSBXYW5nICjnjovnkZ4p?= X-Patchwork-Id: 60827 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp196337wrd; Thu, 23 Feb 2023 00:15:10 -0800 (PST) X-Google-Smtp-Source: AK7set+LNHLttNXdCZzDiEOSb+YOob+lIARWrSUAWPwHGcn6Qr5DdZi2rsrGzXhnBFqhF/8Sv/iW X-Received: by 2002:a17:902:d4c8:b0:19a:7217:32af with SMTP id o8-20020a170902d4c800b0019a721732afmr11901894plg.5.1677140110207; Thu, 23 Feb 2023 00:15:10 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677140110; cv=none; d=google.com; s=arc-20160816; b=ye7LzeJxQ3DRi+kWyUZVRjISuLaR65CD0GrjTF9Byb3nudx0YekhEJ7oE3Bx6/pgaO t5vI8PvLbv8WPCn4eKNfszdT09hSvHhuJ2yGKrZD+5fMevDmlShnf/h20FF9Rj446tS2 F2FVQy6hQ0OK1xagLOcXzcXt+jkYwEDwrafFYOhxBRHJdBiO9RESruoZHw2HPl3JDGWt QvM96HDmrK4X3XGfVvh5nW0wfIvjIA5Va/Z5b1090WmLCr21MyHnarrFwub7QuiDELot n5Q9On5xLa4cFSjKBgGHJNrGYUmuOu+XicfsZgNPiz9dEMlUqtDDcmiJeRrwYxNchxaf q7nA== 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=E32PwqnhE80CiZUxZ6uWYUqazqWNe/vh/gd6x779/5A=; b=qgtPcsFjLnG/muOrbR99pv27jFq6VK+PUI1+cH7oAFkzPSAQLP6GIQ3Ok01C8EK4ut J9e6LVPK/uWiqKaX/cNwAnE9k1cjgbFALbVfh6CrZmgRaVEu+akXKx7l/b04X7275Rnl P4NDXbjSf1HxYC8nMZvbLc/47C0luNMPcgx+bQUhGDlBL1Cui1wl7gDc7/mrANX36RBq WbFrzDUh2OuSkXNgC/RfImHJKWUEUYW0+9x1wpGXcpHr/VxlyZnaFRPIsEpb7CWt8NS0 2mPkUvEHNHn8kYczqnv2Ibhi+zyW0CtU4ytJIOl1T5jwla+jcEtT9p4A32z73f6RFNP0 +ZiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=WZxmcdhY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n6-20020a170902e54600b00186b3cb9b80si20314211plf.354.2023.02.23.00.14.57; Thu, 23 Feb 2023 00:15:10 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=WZxmcdhY; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232802AbjBWINj (ORCPT + 99 others); Thu, 23 Feb 2023 03:13:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232115AbjBWIN1 (ORCPT ); Thu, 23 Feb 2023 03:13:27 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 83EAC498AD; Thu, 23 Feb 2023 00:13:24 -0800 (PST) X-UUID: ef0b0e26b35111eda06fc9ecc4dadd91-20230223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=E32PwqnhE80CiZUxZ6uWYUqazqWNe/vh/gd6x779/5A=; b=WZxmcdhYvxlb9EJR2nA45nzY7bEJA5/W/rLvwMf7Sf4MIvkX7U40iHpHofNKLoWJW58Yxy1RiYDHutKUYNuIdCssBO8J9FgMaHguZQb27RnLtaxDtaOAM5Z6wqjgCVk54HE5R6jQiD+1aZ80cSFS2yxoFKkqwSWfhnjnYyCU/VM=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:e2d54818-7d78-4db6-9c43-b5180de4401d,IP:0,U RL:0,TC:0,Content:0,EDM:0,RT:0,SF:0,FILE:0,BULK:0,RULE:Release_Ham,ACTION: release,TS:0 X-CID-META: VersionHash:25b5999,CLOUDID:5887e6f3-ddba-41c3-91d9-10eeade8eac7,B ulkID:nil,BulkQuantity:0,Recheck:0,SF:102,TC:nil,Content:0,EDM:-3,IP:nil,U RL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: ef0b0e26b35111eda06fc9ecc4dadd91-20230223 Received: from mtkmbs10n2.mediatek.inc [(172.21.101.183)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 963153462; Thu, 23 Feb 2023 16:13:20 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs11n1.mediatek.inc (172.21.101.185) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 23 Feb 2023 16:13:18 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 23 Feb 2023 16:13:18 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , , , kyrie wu CC: , , , , , Tomasz Figa , , , Yunfei Dong , Irui Wang Subject: [V1,4/7] media: mtk-jpeg: reconstructs the initialization mode of worker Date: Thu, 23 Feb 2023 16:13:09 +0800 Message-ID: <20230223081312.29296-5-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223081312.29296-1-irui.wang@mediatek.com> References: <20230223081312.29296-1-irui.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758608868266651872?= X-GMAIL-MSGID: =?utf-8?q?1758608868266651872?= From: kyrie wu exclude is_jpgenc_multihw or is_jpgdec_multihw for judgment, and re-initialize jpeg worker. Signed-off-by: kyrie wu Signed-off-by: irui wang --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 9 +++------ drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h | 2 ++ 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index d940dc5ede74..e89195f1989c 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1575,12 +1575,7 @@ static int mtk_jpeg_open(struct file *file) goto free; } - if (jpeg->is_jpgenc_multihw) - INIT_WORK(&ctx->jpeg_work, mtk_jpegenc_worker); - - if (jpeg->is_jpgdec_multihw) - INIT_WORK(&ctx->jpeg_work, mtk_jpegdec_worker); - + INIT_WORK(&ctx->jpeg_work, jpeg->variant->jpeg_worker); INIT_LIST_HEAD(&ctx->dst_done_queue); spin_lock_init(&ctx->done_queue_lock); v4l2_fh_init(&ctx->fh, vfd); @@ -1901,6 +1896,7 @@ static struct mtk_jpeg_variant mtk8195_jpegenc_drvdata = { .out_q_default_fourcc = V4L2_PIX_FMT_YUYV, .cap_q_default_fourcc = V4L2_PIX_FMT_JPEG, .multi_core = true, + .jpeg_worker = mtk_jpegenc_worker, }; static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = { @@ -1913,6 +1909,7 @@ static const struct mtk_jpeg_variant mtk8195_jpegdec_drvdata = { .out_q_default_fourcc = V4L2_PIX_FMT_JPEG, .cap_q_default_fourcc = V4L2_PIX_FMT_YUV420M, .multi_core = true, + .jpeg_worker = mtk_jpegdec_worker, }; #if defined(CONFIG_OF) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index f87358cc9f47..e118a0175f75 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h @@ -61,6 +61,7 @@ enum mtk_jpeg_ctx_state { * @out_q_default_fourcc: output queue default fourcc * @cap_q_default_fourcc: capture queue default fourcc * @multi_core: mark jpeg hw is multi_core or not + * @jpeg_worker: jpeg dec or enc worker */ struct mtk_jpeg_variant { struct clk_bulk_data *clks; @@ -76,6 +77,7 @@ struct mtk_jpeg_variant { u32 out_q_default_fourcc; u32 cap_q_default_fourcc; bool multi_core; + void (*jpeg_worker)(struct work_struct *work); }; struct mtk_jpeg_src_buf { From patchwork Thu Feb 23 08:13:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SXJ1aSBXYW5nICjnjovnkZ4p?= X-Patchwork-Id: 60829 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp196646wrd; Thu, 23 Feb 2023 00:16:02 -0800 (PST) X-Google-Smtp-Source: AK7set9/fiIce8T+tTmq77KV4mZZLy/lTCUcSh2k/8a6tmaWiv8G6zO1k/jTMlPnsTzW7DDfvUtA X-Received: by 2002:a05:6a20:699f:b0:c7:6088:9bc4 with SMTP id t31-20020a056a20699f00b000c760889bc4mr13045019pzk.5.1677140162384; Thu, 23 Feb 2023 00:16:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677140162; cv=none; d=google.com; s=arc-20160816; b=uPC61lJ+GzXIWdBIpRlMVJJv9Pmhhma/kiU1wvRIuPtOCxrUL09x8NOj6IfVnuy2t6 0ntxicjz1/0tWrip6BiH9paCAQIGw78a+d8iRLfinCZzZ1tOYzYDHhn11V4yN7vOWOTT PSuiykEzrGRT6NMgKDa3LvCbiUcnTTlPHDUDlIGBSYzVU+SFCIiCbqrRo+qNhNhKpdQy wjT9RpltgZml4sxZ+eBKIXXF+8iXaM6Syx9RXI82wepqYO9pe4RMX0uGYS/gRqo5LiL4 MMaQhX4whpqGYEuw0p2n+LbaU2wXZiLxHuv/KkvvcWyisKo3zXd3LLnQb4NCYyQQ4QES xQ0g== 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=QsyCwrGwGh6nf4heZThET+LTLXoG42t7GpLMsbNCMTs=; b=kGCG0JamFzmfNFXlwshC9ffTwK3JPDutpiF+/had8obbOg0hrMp7T2FqWm3j3RvZl+ tc2ubta+U71cwemoPoKLozg2koy161pA1U/lfcy9aQzwWlHutRn3Vkir3I8+EDlV6BBn jKxLmUWUzGst1QI3cpAoJk/H/dKhx/VaJY3Pi/z4352pO8FbQMqRD1iI+s9YFjOgmI5d OZkk73N7aw2OndRxwRONdu1AScXmxT7TeVFnlCjAw9zoolAX77B5uTG9WM+zDC/nruNF lLbcb9uGgFz3c4/O5wGuefjW1JciBC+Jxjq0mCcY1AIY7ZG2viVfeneYktTbQx0d1ezQ o4EA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=EQhUWMEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id cn15-20020a056a00340f00b005a911b0a4e0si10504661pfb.240.2023.02.23.00.15.49; Thu, 23 Feb 2023 00:16:02 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=EQhUWMEh; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233538AbjBWINs (ORCPT + 99 others); Thu, 23 Feb 2023 03:13:48 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38740 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233295AbjBWIN3 (ORCPT ); Thu, 23 Feb 2023 03:13:29 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 97093498B4; Thu, 23 Feb 2023 00:13:27 -0800 (PST) X-UUID: ef8ecdbab35111ed945fc101203acc17-20230223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=QsyCwrGwGh6nf4heZThET+LTLXoG42t7GpLMsbNCMTs=; b=EQhUWMEhiLzo52BoAhc3eABLKbhW/C/kAk/DV+8M4V59q8DnMckVNZ4aKojfAAN3a0AWoKtzhZevyQgVncFmB4KQDNcSwfINnWxsff9S2U5HNrDKYw4lDq8ZP87nP9R0FTYL5zzSRvySv47zcToX6GsUkZIUArXtI81Lz4af+nY=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:d4e45d69-c2f2-441d-ada6-d244e96eef0a,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.20,REQID:d4e45d69-c2f2-441d-ada6-d244e96eef0a,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:25b5999,CLOUDID:10607826-564d-42d9-9875-7c868ee415ec,B ulkID:230223161322DDLYE2TR,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: ef8ecdbab35111ed945fc101203acc17-20230223 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1281582550; Thu, 23 Feb 2023 16:13:21 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Thu, 23 Feb 2023 16:13:19 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 23 Feb 2023 16:13:19 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , , , kyrie wu CC: , , , , , Tomasz Figa , , , Yunfei Dong , "Irui Wang" Subject: [V1,5/7] media: mtk-jpeg: Remove some unnecessary variables Date: Thu, 23 Feb 2023 16:13:10 +0800 Message-ID: <20230223081312.29296-6-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223081312.29296-1-irui.wang@mediatek.com> References: <20230223081312.29296-1-irui.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758608922739690641?= X-GMAIL-MSGID: =?utf-8?q?1758608922739690641?= From: kyrie wu remove is_jpgenc_multihw, is_jpgdec_multihw, and unnecessary initialization. Signed-off-by: kyrie wu Signed-off-by: irui wang --- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 4 --- .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 29 ++++++++----------- .../platform/mediatek/jpeg/mtk_jpeg_enc_hw.c | 18 ++++-------- 3 files changed, 18 insertions(+), 33 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index e118a0175f75..83cf35a12b7a 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h @@ -204,12 +204,10 @@ struct mtk_jpegdec_comp_dev { * @variant: driver variant to be used * @reg_encbase: jpg encode register base addr * @enc_hw_dev: jpg encode hardware device - * @is_jpgenc_multihw: the flag of multi-hw core * @enc_hw_wq: jpg encode wait queue * @enchw_rdy: jpg encode hw ready flag * @reg_decbase: jpg decode register base addr * @dec_hw_dev: jpg decode hardware device - * @is_jpgdec_multihw: the flag of dec multi-hw core * @dec_hw_wq: jpg decode wait queue * @dec_workqueue: jpg decode work queue * @dechw_rdy: jpg decode hw ready flag @@ -229,13 +227,11 @@ struct mtk_jpeg_dev { void __iomem *reg_encbase[MTK_JPEGENC_HW_MAX]; struct mtk_jpegenc_comp_dev *enc_hw_dev[MTK_JPEGENC_HW_MAX]; - bool is_jpgenc_multihw; wait_queue_head_t enc_hw_wq; atomic_t enchw_rdy; void __iomem *reg_decbase[MTK_JPEGDEC_HW_MAX]; struct mtk_jpegdec_comp_dev *dec_hw_dev[MTK_JPEGDEC_HW_MAX]; - bool is_jpgdec_multihw; wait_queue_head_t dec_hw_wq; struct workqueue_struct *dec_workqueue; atomic_t dechw_rdy; diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c index 8c07fa02fd9a..5b47bd83c5ce 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c @@ -608,23 +608,18 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev) dev->plat_dev = pdev; dev->dev = &pdev->dev; - if (!master_dev->is_jpgdec_multihw) { - master_dev->is_jpgdec_multihw = true; - for (i = 0; i < MTK_JPEGDEC_HW_MAX; i++) - master_dev->dec_hw_dev[i] = NULL; - - init_waitqueue_head(&master_dev->dec_hw_wq); - master_dev->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, - WQ_MEM_RECLAIM - | WQ_FREEZABLE); - if (!master_dev->workqueue) - return -EINVAL; - - ret = devm_add_action_or_reset(&pdev->dev, mtk_jpegdec_destroy_workqueue, - master_dev->workqueue); - if (ret) - return ret; - } + init_waitqueue_head(&master_dev->dec_hw_wq); + master_dev->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, + WQ_MEM_RECLAIM + | WQ_FREEZABLE); + if (!master_dev->workqueue) + return -EINVAL; + + ret = devm_add_action_or_reset(&pdev->dev, + mtk_jpegdec_destroy_workqueue, + master_dev->workqueue); + if (ret) + return ret; atomic_set(&master_dev->dechw_rdy, MTK_JPEGDEC_HW_MAX); spin_lock_init(&dev->hw_lock); diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c index 867f4c1a09fa..c2bc0b531b32 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c @@ -340,18 +340,12 @@ static int mtk_jpegenc_hw_probe(struct platform_device *pdev) dev->plat_dev = pdev; dev->dev = &pdev->dev; - if (!master_dev->is_jpgenc_multihw) { - master_dev->is_jpgenc_multihw = true; - for (i = 0; i < MTK_JPEGENC_HW_MAX; i++) - master_dev->enc_hw_dev[i] = NULL; - - init_waitqueue_head(&master_dev->enc_hw_wq); - master_dev->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, - WQ_MEM_RECLAIM - | WQ_FREEZABLE); - if (!master_dev->workqueue) - return -EINVAL; - } + init_waitqueue_head(&master_dev->enc_hw_wq); + master_dev->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, + WQ_MEM_RECLAIM + | WQ_FREEZABLE); + if (!master_dev->workqueue) + return -EINVAL; atomic_set(&master_dev->enchw_rdy, MTK_JPEGENC_HW_MAX); spin_lock_init(&dev->hw_lock); From patchwork Thu Feb 23 08:13:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SXJ1aSBXYW5nICjnjovnkZ4p?= X-Patchwork-Id: 60830 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp200326wrd; Thu, 23 Feb 2023 00:28:47 -0800 (PST) X-Google-Smtp-Source: AK7set/6kC91EkSu3By64cLW9q/MlSFPCkcTlsoJisNH9aP+v6PWldghYd1JG4iT7ySJnW7uUzTE X-Received: by 2002:a05:6a20:548a:b0:c6:d235:ac8c with SMTP id i10-20020a056a20548a00b000c6d235ac8cmr13264277pzk.4.1677140927493; Thu, 23 Feb 2023 00:28:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677140927; cv=none; d=google.com; s=arc-20160816; b=OnXXvSLUkoNC/RLh7dn6Ihkc6nb9tXqlKrB2sZjX69nnYRQnXFwqixhThI4JpltstY V8A0gu7pES8dAxj3IoH9COiV6lpC43IxIY+ZEqTMfjtLsv+o/BtAJTW88R0Qx9+kgn88 vfx41Nl7VOcgjYJVQ9YU1+p9hHhkUIxMbp2H5YqGSnDg/r7zHjccoOamJoa2OkRGEZtn TUcdVnwREKazTXRV/t9h3NJFcauyRoKUwCxKu+G+fC2n6FwJgaNMivPGZK/C/zcCnnlS JPOsP3PuzXnyyqMAEW3XmEdmcGQ0RStZAW3jemUjG/yHeTXSnERd7ZQ4d9ylLUKy8u6X JN2w== 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=Gn2kibkOu2BpBaNvPK5fRP0sBK77AQfIg4Roa4SkH2Q=; b=Gl4bF5ajzgrudDfuLIYkUICivmQRKC0qP+QzVAdt9LEocxQS2PABLiac5RZi2Bdy8v XZYkQKhvCoxFkKX+XiH7M0H8xqVpyzk5tcScrRKsgkKQSn10sahfDG3DYjgvlpY8y9gK Q1tHaOOfj3P4/nLc0nHlDYXk8HaEP32q/jcTdSgvFNED1oVkxk/G5ts9q6Ir2oQznBl/ VrUa1cZE5d5ifguJZ4S+OgtrFlDk6SxPJt6IOmjM4sPRFiKEPecWcJX9Psv/tgpgc3Ll Vxp7aEvKVMvdSASdRinO/XjrQ5Eh+1yAFUxolHWgL6P41ICoVFK8/TAyxG2gG3E1jaIs XLcw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=e+D7LlVM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id a64-20020a639043000000b0049b37046fbcsi4146762pge.391.2023.02.23.00.28.34; Thu, 23 Feb 2023 00:28:47 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b=e+D7LlVM; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233556AbjBWINu (ORCPT + 99 others); Thu, 23 Feb 2023 03:13:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233338AbjBWINb (ORCPT ); Thu, 23 Feb 2023 03:13:31 -0500 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A7CFF498A7; Thu, 23 Feb 2023 00:13:28 -0800 (PST) X-UUID: ef9117e6b35111ed945fc101203acc17-20230223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=Gn2kibkOu2BpBaNvPK5fRP0sBK77AQfIg4Roa4SkH2Q=; b=e+D7LlVMEpRcYj30QUVcRp1Z21pNGyrr4Exxpd/1ZIq8ykn6fLYGRXkYTUisLz3yVsZ3Q78EYa2F75++Gk7IFNtfFVy1j7anaGykUtOWzgkCl1dQghWgaSV8MLUxX4C3sHEf0bOyuuN+EaU5A+WOzli8WSDznrphXU1JlvODRQ8=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:c5b493c1-79ee-49ad-9967-7170850c1d84,IP:0,U RL:0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTI ON:release,TS:70 X-CID-INFO: VERSION:1.1.20,REQID:c5b493c1-79ee-49ad-9967-7170850c1d84,IP:0,URL :0,TC:0,Content:-25,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTI ON:quarantine,TS:70 X-CID-META: VersionHash:25b5999,CLOUDID:b20159b1-beed-4dfc-bd9c-e1b22fa6ccc4,B ulkID:230223161322DDLYE2TR,BulkQuantity:1,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:43,QS:nil,BEC:nil,COL :0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: ef9117e6b35111ed945fc101203acc17-20230223 Received: from mtkmbs10n1.mediatek.inc [(172.21.101.34)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1897907847; Thu, 23 Feb 2023 16:13:21 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n2.mediatek.inc (172.21.101.183) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.3; Thu, 23 Feb 2023 16:13:20 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 23 Feb 2023 16:13:19 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , , , kyrie wu CC: , , , , , Tomasz Figa , , , Yunfei Dong , "Irui Wang" Subject: [V1,6/7] media: mtk-jpeg: refactor some variables Date: Thu, 23 Feb 2023 16:13:11 +0800 Message-ID: <20230223081312.29296-7-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223081312.29296-1-irui.wang@mediatek.com> References: <20230223081312.29296-1-irui.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758609725112609683?= X-GMAIL-MSGID: =?utf-8?q?1758609725112609683?= From: kyrie wu Refactor some variables to reduce redundancy and optimize the initialization process. Signed-off-by: kyrie wu Signed-off-by: irui wang --- .../platform/mediatek/jpeg/mtk_jpeg_core.c | 31 ++++++++++++++----- .../platform/mediatek/jpeg/mtk_jpeg_core.h | 18 ++++------- .../platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 16 +++------- .../platform/mediatek/jpeg/mtk_jpeg_enc_hw.c | 16 +++------- 4 files changed, 37 insertions(+), 44 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index e89195f1989c..ab06c1ee80d4 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1004,8 +1004,8 @@ static void mtk_jpegenc_worker(struct work_struct *work) retry_select: hw_id = mtk_jpegenc_get_hw(ctx); if (hw_id < 0) { - ret = wait_event_interruptible(jpeg->enc_hw_wq, - atomic_read(&jpeg->enchw_rdy) > 0); + ret = wait_event_interruptible(jpeg->hw_wq, + atomic_read(&jpeg->hw_rdy) > 0); if (ret != 0 || (i++ > MTK_JPEG_MAX_RETRY_TIME)) { dev_err(jpeg->dev, "%s : %d, all HW are busy\n", __func__, __LINE__); @@ -1016,7 +1016,7 @@ static void mtk_jpegenc_worker(struct work_struct *work) goto retry_select; } - atomic_dec(&jpeg->enchw_rdy); + atomic_dec(&jpeg->hw_rdy); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); if (!src_buf) goto getbuf_fail; @@ -1073,7 +1073,7 @@ static void mtk_jpegenc_worker(struct work_struct *work) v4l2_m2m_buf_done(src_buf, buf_state); v4l2_m2m_buf_done(dst_buf, buf_state); getbuf_fail: - atomic_inc(&jpeg->enchw_rdy); + atomic_inc(&jpeg->hw_rdy); mtk_jpegenc_put_hw(jpeg, hw_id); v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); } @@ -1198,8 +1198,8 @@ static void mtk_jpegdec_worker(struct work_struct *work) retry_select: hw_id = mtk_jpegdec_get_hw(ctx); if (hw_id < 0) { - ret = wait_event_interruptible_timeout(jpeg->dec_hw_wq, - atomic_read(&jpeg->dechw_rdy) > 0, + ret = wait_event_interruptible_timeout(jpeg->hw_wq, + atomic_read(&jpeg->hw_rdy) > 0, MTK_JPEG_HW_TIMEOUT_MSEC); if (ret != 0 || (i++ > MTK_JPEG_MAX_RETRY_TIME)) { dev_err(jpeg->dev, "%s : %d, all HW are busy\n", @@ -1211,7 +1211,7 @@ static void mtk_jpegdec_worker(struct work_struct *work) goto retry_select; } - atomic_dec(&jpeg->dechw_rdy); + atomic_dec(&jpeg->hw_rdy); src_buf = v4l2_m2m_next_src_buf(ctx->fh.m2m_ctx); if (!src_buf) goto getbuf_fail; @@ -1290,7 +1290,7 @@ static void mtk_jpegdec_worker(struct work_struct *work) v4l2_m2m_buf_done(src_buf, buf_state); v4l2_m2m_buf_done(dst_buf, buf_state); getbuf_fail: - atomic_inc(&jpeg->dechw_rdy); + atomic_inc(&jpeg->hw_rdy); mtk_jpegdec_put_hw(jpeg, hw_id); v4l2_m2m_job_finish(jpeg->m2m_dev, ctx->fh.m2m_ctx); } @@ -1710,6 +1710,8 @@ static int mtk_jpeg_single_core_init(struct platform_device *pdev, static int mtk_jpeg_probe(struct platform_device *pdev) { struct mtk_jpeg_dev *jpeg; + struct device_node *child; + int num_child = 0; int ret; jpeg = devm_kzalloc(&pdev->dev, sizeof(*jpeg), GFP_KERNEL); @@ -1733,6 +1735,19 @@ static int mtk_jpeg_probe(struct platform_device *pdev) v4l2_err(&jpeg->v4l2_dev, "mtk_jpeg_single_core_init failed."); return -EINVAL; } + } else { + init_waitqueue_head(&jpeg->hw_wq); + + for_each_child_of_node(pdev->dev.of_node, child) + num_child++; + + atomic_set(&jpeg->hw_rdy, num_child); + + jpeg->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, + WQ_MEM_RECLAIM + | WQ_FREEZABLE); + if (!jpeg->workqueue) + return -EINVAL; } ret = v4l2_device_register(&pdev->dev, &jpeg->v4l2_dev); diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index 83cf35a12b7a..89242e407dc9 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h @@ -203,14 +203,11 @@ struct mtk_jpegdec_comp_dev { * @job_timeout_work: IRQ timeout structure * @variant: driver variant to be used * @reg_encbase: jpg encode register base addr - * @enc_hw_dev: jpg encode hardware device - * @enc_hw_wq: jpg encode wait queue - * @enchw_rdy: jpg encode hw ready flag + * @enc_hw_dev: jpg encode hardware device + * @hw_wq: jpg wait queue + * @hw_rdy: jpg hw ready flag * @reg_decbase: jpg decode register base addr - * @dec_hw_dev: jpg decode hardware device - * @dec_hw_wq: jpg decode wait queue - * @dec_workqueue: jpg decode work queue - * @dechw_rdy: jpg decode hw ready flag + * @dec_hw_dev: jpg decode hardware device */ struct mtk_jpeg_dev { struct mutex lock; @@ -227,14 +224,11 @@ struct mtk_jpeg_dev { void __iomem *reg_encbase[MTK_JPEGENC_HW_MAX]; struct mtk_jpegenc_comp_dev *enc_hw_dev[MTK_JPEGENC_HW_MAX]; - wait_queue_head_t enc_hw_wq; - atomic_t enchw_rdy; + wait_queue_head_t hw_wq; + atomic_t hw_rdy; void __iomem *reg_decbase[MTK_JPEGDEC_HW_MAX]; struct mtk_jpegdec_comp_dev *dec_hw_dev[MTK_JPEGDEC_HW_MAX]; - wait_queue_head_t dec_hw_wq; - struct workqueue_struct *dec_workqueue; - atomic_t dechw_rdy; }; /** diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c index 5b47bd83c5ce..b7c2de2489b0 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c @@ -503,8 +503,8 @@ static void mtk_jpegdec_timeout_work(struct work_struct *work) clk_disable_unprepare(cjpeg->jdec_clk.clks->clk); pm_runtime_put(cjpeg->dev); cjpeg->hw_state = MTK_JPEG_HW_IDLE; - atomic_inc(&master_jpeg->dechw_rdy); - wake_up(&master_jpeg->dec_hw_wq); + atomic_inc(&master_jpeg->hw_rdy); + wake_up(&master_jpeg->hw_wq); v4l2_m2m_buf_done(src_buf, buf_state); mtk_jpegdec_put_buf(cjpeg); } @@ -551,8 +551,8 @@ static irqreturn_t mtk_jpegdec_hw_irq_handler(int irq, void *priv) clk_disable_unprepare(jpeg->jdec_clk.clks->clk); jpeg->hw_state = MTK_JPEG_HW_IDLE; - wake_up(&master_jpeg->dec_hw_wq); - atomic_inc(&master_jpeg->dechw_rdy); + wake_up(&master_jpeg->hw_wq); + atomic_inc(&master_jpeg->hw_rdy); return IRQ_HANDLED; } @@ -608,20 +608,12 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev) dev->plat_dev = pdev; dev->dev = &pdev->dev; - init_waitqueue_head(&master_dev->dec_hw_wq); - master_dev->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, - WQ_MEM_RECLAIM - | WQ_FREEZABLE); - if (!master_dev->workqueue) - return -EINVAL; - ret = devm_add_action_or_reset(&pdev->dev, mtk_jpegdec_destroy_workqueue, master_dev->workqueue); if (ret) return ret; - atomic_set(&master_dev->dechw_rdy, MTK_JPEGDEC_HW_MAX); spin_lock_init(&dev->hw_lock); dev->hw_state = MTK_JPEG_HW_IDLE; diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c index c2bc0b531b32..e35ee1bdce3d 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c @@ -248,8 +248,8 @@ static void mtk_jpegenc_timeout_work(struct work_struct *work) clk_disable_unprepare(cjpeg->venc_clk.clks->clk); pm_runtime_put(cjpeg->dev); cjpeg->hw_state = MTK_JPEG_HW_IDLE; - atomic_inc(&master_jpeg->enchw_rdy); - wake_up(&master_jpeg->enc_hw_wq); + atomic_inc(&master_jpeg->hw_rdy); + wake_up(&master_jpeg->hw_wq); v4l2_m2m_buf_done(src_buf, buf_state); mtk_jpegenc_put_buf(cjpeg); } @@ -288,8 +288,8 @@ static irqreturn_t mtk_jpegenc_hw_irq_handler(int irq, void *priv) clk_disable_unprepare(jpeg->venc_clk.clks->clk); jpeg->hw_state = MTK_JPEG_HW_IDLE; - wake_up(&master_jpeg->enc_hw_wq); - atomic_inc(&master_jpeg->enchw_rdy); + wake_up(&master_jpeg->hw_wq); + atomic_inc(&master_jpeg->hw_rdy); return IRQ_HANDLED; } @@ -340,14 +340,6 @@ static int mtk_jpegenc_hw_probe(struct platform_device *pdev) dev->plat_dev = pdev; dev->dev = &pdev->dev; - init_waitqueue_head(&master_dev->enc_hw_wq); - master_dev->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, - WQ_MEM_RECLAIM - | WQ_FREEZABLE); - if (!master_dev->workqueue) - return -EINVAL; - - atomic_set(&master_dev->enchw_rdy, MTK_JPEGENC_HW_MAX); spin_lock_init(&dev->hw_lock); dev->hw_state = MTK_JPEG_HW_IDLE; From patchwork Thu Feb 23 08:13:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?SXJ1aSBXYW5nICjnjovnkZ4p?= X-Patchwork-Id: 60828 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp196635wrd; Thu, 23 Feb 2023 00:16:01 -0800 (PST) X-Google-Smtp-Source: AK7set+Nt1+wHEi/N1WkPhvz1S9CqzDvkmFMyLy/5gxaCDzXkRad5qjOMUBIVHJO7oi6IAem+h9r X-Received: by 2002:a05:6a20:6918:b0:cb:7cc4:3ddb with SMTP id q24-20020a056a20691800b000cb7cc43ddbmr10398113pzj.3.1677140161240; Thu, 23 Feb 2023 00:16:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1677140161; cv=none; d=google.com; s=arc-20160816; b=0lC+2l2RRKh+xdorbVMYfCFZUiXRNjfe64C9F+IbRipqlDbNgXafIgk44ilaUN/DrU 7W73a9ADrfCHNhTtRucKtX5QsK64VZ4FKljJ307zO0sdne57gQUzqDIkN60QnWBl0wB3 COGpiXwzLwPCkooHZqo6BymBTRmzECCmP5a7uV7QUmIhwaKxI39X0icCFf9/II+4FLKx /vP/Dc1y/tR1+V3cwhpq7RhWb2iJB4LXXcSaoG+oE3McjDtUVnMCWMLi3SAtt4/s0UUX kW2d9iMa6cuyjzsN5NLtBSZw7Zn6RYhea6WCUc7gUhAwksC0J4QfvW4dcmKen+HQ2Sq2 l4ig== 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=rnHDPaF+R8FF8PJd9FlWmcGdhDJGTaMa9mgP/cJusow=; b=LuXqWG0lazIgN9JqQ+PoAFs9yqZLgcRHRJUQtGTgf4rtOSAiia3lAcpytly82M/mEz iBH+agFsqczr39aO8/cmy0jdejjtm3NkPB2MO7p4ePy7GpvSlQOEREIfgutl4FLg3zbI 7U3LyftHxS0P7za5DttCYnHOpRh1+FUCr8QLLFtttspKHwf8oweVKQXpaCxRLPTz5W+I 4ZDtJQRIgDKixVNFpXPSkiq6C6hfY178c59X0G08prmvddJqwzPDSuFjiNalz/D8HOHR COnpqf+ttJP3vEG34lnMxoJx2MRsPZCHqAZUjlxOFzr05T7WDuG09eRFW0kFo6hIV/yI ygwQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="iyvZhzs/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id r3-20020a6560c3000000b004fba448b8bdsi1230612pgv.49.2023.02.23.00.15.48; Thu, 23 Feb 2023 00:16:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@mediatek.com header.s=dk header.b="iyvZhzs/"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=mediatek.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233525AbjBWINp (ORCPT + 99 others); Thu, 23 Feb 2023 03:13:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38730 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233272AbjBWIN3 (ORCPT ); Thu, 23 Feb 2023 03:13:29 -0500 Received: from mailgw01.mediatek.com (unknown [60.244.123.138]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94AD0498B1; Thu, 23 Feb 2023 00:13:27 -0800 (PST) X-UUID: f0adf95ab35111eda06fc9ecc4dadd91-20230223 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=mediatek.com; s=dk; h=Content-Type:Content-Transfer-Encoding:MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:CC:To:From; bh=rnHDPaF+R8FF8PJd9FlWmcGdhDJGTaMa9mgP/cJusow=; b=iyvZhzs/d+X6uWsDwkbwMsoSy8H+T4dCVr3oJ3NWVZcpgOczFwdH+AfbVcMDxdugTsIof8mhtuDUKe5XLZYFSg4IhzufZlgrtpBRoRi5LLvmzLoGL0l1ShKCZVG21Wc1tZsVTA6JS+zTz249d2DsQjbQqlVajpk36w+eFLsZPZo=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.1.20,REQID:fa71ef87-f3c7-40c4-9acd-59da380a80c5,IP:0,U RL:0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Release_Ham,ACTIO N:release,TS:90 X-CID-INFO: VERSION:1.1.20,REQID:fa71ef87-f3c7-40c4-9acd-59da380a80c5,IP:0,URL :0,TC:0,Content:-5,EDM:0,RT:0,SF:95,FILE:0,BULK:0,RULE:Spam_GS981B3D,ACTIO N:quarantine,TS:90 X-CID-META: VersionHash:25b5999,CLOUDID:85607826-564d-42d9-9875-7c868ee415ec,B ulkID:230223161325QJPJ32VM,BulkQuantity:0,Recheck:0,SF:38|29|28|17|19|48,T C:nil,Content:0,EDM:-3,IP:nil,URL:11|1,File:nil,Bulk:nil,QS:nil,BEC:nil,CO L:0,OSI:0,OSA:0,AV:0 X-CID-BVR: 0,NGT X-UUID: f0adf95ab35111eda06fc9ecc4dadd91-20230223 Received: from mtkmbs13n1.mediatek.inc [(172.21.101.193)] by mailgw01.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 1498509786; Thu, 23 Feb 2023 16:13:22 +0800 Received: from mtkmbs11n2.mediatek.inc (172.21.101.187) by mtkmbs10n1.mediatek.inc (172.21.101.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.792.15; Thu, 23 Feb 2023 16:13:21 +0800 Received: from mhfsdcap04.gcn.mediatek.inc (10.17.3.154) by mtkmbs11n2.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.792.15 via Frontend Transport; Thu, 23 Feb 2023 16:13:20 +0800 From: Irui Wang To: Hans Verkuil , Mauro Carvalho Chehab , Matthias Brugger , , , kyrie wu CC: , , , , , Tomasz Figa , , , Yunfei Dong , "Irui Wang" Subject: [V1,7/7] media: mtk-jpeg: refactor hw dev initializaiton Date: Thu, 23 Feb 2023 16:13:12 +0800 Message-ID: <20230223081312.29296-8-irui.wang@mediatek.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230223081312.29296-1-irui.wang@mediatek.com> References: <20230223081312.29296-1-irui.wang@mediatek.com> MIME-Version: 1.0 X-MTK: N X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_PASS, SPF_PASS,UNPARSEABLE_RELAY autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1758608921688230148?= X-GMAIL-MSGID: =?utf-8?q?1758608921688230148?= From: kyrie wu Add a atomic_t variable for initialization of hw dev. Signed-off-by: kyrie wu Signed-off-by: irui wang --- drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c | 1 + drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h | 2 ++ .../media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c | 12 ++++-------- .../media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c | 12 ++++-------- 4 files changed, 11 insertions(+), 16 deletions(-) diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c index ab06c1ee80d4..1dd03938df7e 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.c @@ -1742,6 +1742,7 @@ static int mtk_jpeg_probe(struct platform_device *pdev) num_child++; atomic_set(&jpeg->hw_rdy, num_child); + atomic_set(&jpeg->hw_index, 0); jpeg->workqueue = alloc_ordered_workqueue(MTK_JPEG_NAME, WQ_MEM_RECLAIM diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h index 89242e407dc9..8ba6e757e11a 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_core.h @@ -208,6 +208,7 @@ struct mtk_jpegdec_comp_dev { * @hw_rdy: jpg hw ready flag * @reg_decbase: jpg decode register base addr * @dec_hw_dev: jpg decode hardware device + * @hw_index: jpg hw index */ struct mtk_jpeg_dev { struct mutex lock; @@ -229,6 +230,7 @@ struct mtk_jpeg_dev { void __iomem *reg_decbase[MTK_JPEGDEC_HW_MAX]; struct mtk_jpegdec_comp_dev *dec_hw_dev[MTK_JPEGDEC_HW_MAX]; + atomic_t hw_index; }; /** diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c index b7c2de2489b0..869068fac5e2 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_dec_hw.c @@ -638,14 +638,10 @@ static int mtk_jpegdec_hw_probe(struct platform_device *pdev) return dev_err_probe(&pdev->dev, ret, "Failed to register JPEGDEC irq handler.\n"); - for (i = 0; i < MTK_JPEGDEC_HW_MAX; i++) { - if (master_dev->dec_hw_dev[i]) - continue; - - master_dev->dec_hw_dev[i] = dev; - master_dev->reg_decbase[i] = dev->reg_base; - dev->master_dev = master_dev; - } + i = atomic_add_return(1, &master_dev->hw_index) - 1; + master_dev->dec_hw_dev[i] = dev; + master_dev->reg_decbase[i] = dev->reg_base; + dev->master_dev = master_dev; platform_set_drvdata(pdev, dev); pm_runtime_enable(&pdev->dev); diff --git a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c index e35ee1bdce3d..71e85b4bbf12 100644 --- a/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c +++ b/drivers/media/platform/mediatek/jpeg/mtk_jpeg_enc_hw.c @@ -362,14 +362,10 @@ static int mtk_jpegenc_hw_probe(struct platform_device *pdev) if (ret) return ret; - for (i = 0; i < MTK_JPEGENC_HW_MAX; i++) { - if (master_dev->enc_hw_dev[i]) - continue; - - master_dev->enc_hw_dev[i] = dev; - master_dev->reg_encbase[i] = dev->reg_base; - dev->master_dev = master_dev; - } + i = atomic_add_return(1, &master_dev->hw_index) - 1; + master_dev->enc_hw_dev[i] = dev; + master_dev->reg_encbase[i] = dev->reg_base; + dev->master_dev = master_dev; platform_set_drvdata(pdev, dev); pm_runtime_enable(&pdev->dev);