From patchwork Wed May 29 15:28:53 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dan Scally X-Patchwork-Id: 13679114 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9DD60C25B75 for ; Wed, 29 May 2024 15:30:14 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=VN1+I59atpKlIZ1mqak9VGgWDdjkPAae6vnPiqhmKsI=; b=LeZaX29UnJ7GyJ vGVQh5zHInCZmX4wowcndHoGbTeRshyO0+ddi2Lsh4QwXvQkoBvksxa/wauDc7Rw/UYjOxrzkVHUr 0aG/q5UDzeZFp6CxVV8dT+k5zNPjfF28aMQE33wnj1WRD41Z3sGw6kXDK7kE5+xXjVEe1qA/axvCV ctzMq30ONHdvEdzXUfQERlvs4OBusPdYd2HouHhLYmNgwqj9mRPMXW0kTABdHIABKLlC9o2Ei84da yARiReqLdBleFEpOYykRBoWKsujVLRj+YiwW3TFS49mIhHYebT1Ydj34KRy36B1bLZfAZiaWjeJ9T CmcCrAgWlrM/OYPn5Xfg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCLFa-00000004hWO-2cUH; Wed, 29 May 2024 15:30:02 +0000 Received: from perceval.ideasonboard.com ([213.167.242.64]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1sCLF1-00000004h72-2Zva for linux-arm-kernel@lists.infradead.org; Wed, 29 May 2024 15:29:30 +0000 Received: from mail.ideasonboard.com (cpc141996-chfd3-2-0-cust928.12-3.cable.virginm.net [86.13.91.161]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 9573F2F79; Wed, 29 May 2024 17:29:22 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1716996563; bh=1VZKD/7iXkmlYhIgC1bcHRQA7bBFUpGOqE0+BrQtj9I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=vElfIQmjIYkFvXgK2ynoHG95MW/051It+iKrA7QK6wtQtq+8GAcKljmKHLvEFRvBq 0Ntx2QRKNe9MWPsO58ULGqUKe1HWgFSDd3EVInPFEuogPbIyp1JBrBay0p7J0+DuqH 1Q5tdWCRmb3nuS199C/6CkazSTsx/8LylaXni5aA= From: Daniel Scally To: linux-media@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org Cc: jacopo.mondi@ideasonboard.com, nayden.kanchev@arm.com, robh+dt@kernel.org, mchehab@kernel.org, krzysztof.kozlowski+dt@linaro.org, conor+dt@kernel.org, jerome.forissier@linaro.org, kieran.bingham@ideasonboard.com, laurent.pinchart@ideasonboard.com, sakari.ailus@iki.fi, dan.scally@ideasonboard.com Subject: [PATCH v5 11/16] media: platform: Fill stats buffer on ISP_START Date: Wed, 29 May 2024 16:28:53 +0100 Message-Id: <20240529152858.183799-12-dan.scally@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240529152858.183799-1-dan.scally@ideasonboard.com> References: <20240529152858.183799-1-dan.scally@ideasonboard.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240529_082928_569688_0E276B72 X-CRM114-Status: GOOD ( 14.14 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On ISP_START, fill the stats buffer by reading out the metering space in the ISP's memory. This is done for the non-active config just as the dma transfer of the registers is. To acheive that, move the checking of the current config outside of mali_c55_swap_next_config() so we can use it for both functions. Acked-by: Nayden Kanchev Co-developed-by: Jacopo Mondi Signed-off-by: Jacopo Mondi Signed-off-by: Daniel Scally --- Changes in v5: - New patch .../platform/arm/mali-c55/mali-c55-core.c | 35 ++++++++++++++----- 1 file changed, 27 insertions(+), 8 deletions(-) diff --git a/drivers/media/platform/arm/mali-c55/mali-c55-core.c b/drivers/media/platform/arm/mali-c55/mali-c55-core.c index 9ea70010876c..2cf8b1169604 100644 --- a/drivers/media/platform/arm/mali-c55/mali-c55-core.c +++ b/drivers/media/platform/arm/mali-c55/mali-c55-core.c @@ -420,15 +420,9 @@ static u32 mali_c55_check_hwcfg(struct mali_c55 *mali_c55) return version; } -static void mali_c55_swap_next_config(struct mali_c55 *mali_c55) +static void mali_c55_swap_next_config(struct mali_c55 *mali_c55, u32 next_config) { struct mali_c55_ctx *ctx = mali_c55_get_active_context(mali_c55); - u32 curr_config, next_config; - - curr_config = mali_c55_read(mali_c55, MALI_C55_REG_PING_PONG_READ, false); - curr_config = (curr_config & MALI_C55_REG_PING_PONG_READ_MASK) - >> (ffs(MALI_C55_REG_PING_PONG_READ_MASK) - 1); - next_config = curr_config ^ 1; mali_c55_update_bits(mali_c55, MALI_C55_REG_MCU_CONFIG, MALI_C55_REG_MCU_CONFIG_WRITE_MASK, next_config); @@ -440,6 +434,7 @@ static irqreturn_t mali_c55_isr(int irq, void *context) { struct device *dev = context; struct mali_c55 *mali_c55 = dev_get_drvdata(dev); + u32 curr_config, next_config; u32 interrupt_status; unsigned int i, j; @@ -465,7 +460,31 @@ static irqreturn_t mali_c55_isr(int irq, void *context) for (j = i; j < MALI_C55_NUM_CAP_DEVS; j++) mali_c55_set_next_buffer(&mali_c55->cap_devs[j]); - mali_c55_swap_next_config(mali_c55); + /* + * When the ISP starts a frame we have some work to do: + * + * 1. Copy over the config for the **next** frame + * 2. Read out the metering stats for the **last** frame + */ + + curr_config = mali_c55_read(mali_c55, + MALI_C55_REG_PING_PONG_READ, + false); + curr_config &= MALI_C55_REG_PING_PONG_READ_MASK; + curr_config >>= ffs(MALI_C55_REG_PING_PONG_READ_MASK) - 1; + next_config = curr_config ^ 1; + + /* + * The ordering of these two is currently important as + * mali_c55_stats_fill_buffer() is asynchronous whereas + * mali_c55_swap_next_config() is not. + * + * TODO: Should mali_c55_swap_next_config() be async? + */ + mali_c55_stats_fill_buffer(mali_c55, + next_config ? MALI_C55_CONFIG_PING : + MALI_C55_CONFIG_PONG); + mali_c55_swap_next_config(mali_c55, next_config); break; case MALI_C55_IRQ_ISP_DONE: