Received: by 2002:a89:2c3:0:b0:1ed:23cc:44d1 with SMTP id d3csp305610lqs; Tue, 5 Mar 2024 02:34:29 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWbfvKedchE4Y6SiDsTdLTBljbM7bOx252J0XWlCV7G7CxFlMvk3I/Omv2dt2g+evdddNCdXe8YEQbdJ1XqhLGV1dKrymlBCmjW80GqLQ== X-Google-Smtp-Source: AGHT+IElTCl4I/FBqa3v5juO2yl8pr3jfKJPvPy43Ri3inXG+NRJudLNXtCX4UZLYYQlvP6HDwKV X-Received: by 2002:a05:6a20:2589:b0:1a1:156f:44cb with SMTP id k9-20020a056a20258900b001a1156f44cbmr1520700pzd.30.1709634869220; Tue, 05 Mar 2024 02:34:29 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1709634869; cv=pass; d=google.com; s=arc-20160816; b=rOnioNVzhe+3z67gDxw391vpDoPjrjJWsOAzDI0GcfVAFFtBXlv0dkUjErEjvfjtxd 53vVus3JgGFsdBthXIBm9HBbnT0aaF6Od1+Ya5uS9qC/MBfjm9EJFyTb1zg14n4RXEfT 2/9x/yKF/GKUuPgaP+zIPaq+NCkf2g5iWZL6sTLun+78Ol4m1NCsXpnVONQTUAmznAu7 HfWnRysXUazzE3/iK5m8j/wWBFv94ww6+AJqpqx8h0NeFQFmswyW72rmRaM8hCxQ/oYi LRhvZxsImh7FKwYulwozctkX+oocUYmmdtNBgM7swrdLWR4QijtT4wFxRp+Vz1JZ1hQb Yzmw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:message-id:dkim-signature; bh=Uz0yh26pJyI2lgavpFBHtkwa48gqP1n9gYCBFbz4nG8=; fh=dIvolGC3JQ6R7scgSsAxk8IWjLXurdKzl9ZsSOdJcKk=; b=jThO2Zf94gj5SThzJqD4D98A7MHhKz6PpM5R8cObbJj17rXyMjDNlME1i0KYwJc0M6 hRNl1ftVOgeiUe4dzOseF8Nt3KLBvXcUYH/vJbUtcgmb7mf6iedgTw/U1Spbl7MkZ7cB BJcxk7Q5A4n0LxGafR5srYzbg44sMWAbBevrmVGGYerihPVG8mC3rMq12Py1PH/ebhI2 gywxbTsbxk9W3so/g04LGLl4iW5a6jrTlw38Na3m/PoqzajnNYFdOtcUdjtM97afycj5 MfSSDe1rNoYYKo0v3vqjeqAUytmQSQ9inSv9F0n8ET4kUNtPBFZfxqAbnWr8PKEBqh8Y ZXzg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LORY2kHf; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-92119-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92119-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id x37-20020a056a0018a500b006e621d39948si3248533pfh.192.2024.03.05.02.34.28 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 05 Mar 2024 02:34:29 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-92119-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@collabora.com header.s=mail header.b=LORY2kHf; arc=pass (i=1 spf=pass spfdomain=collabora.com dkim=pass dkdomain=collabora.com dmarc=pass fromdomain=collabora.com); spf=pass (google.com: domain of linux-kernel+bounces-92119-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-92119-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=collabora.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id D6A64282B58 for ; Tue, 5 Mar 2024 10:34:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 2CFC85BAE8; Tue, 5 Mar 2024 10:21:01 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b="LORY2kHf" Received: from madrid.collaboradmins.com (madrid.collaboradmins.com [46.235.227.194]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CCCBB5490F for ; Tue, 5 Mar 2024 10:20:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=46.235.227.194 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709634060; cv=none; b=P7PbbwFSKSOTH54Jqs+BOInohWBRUexX8e5Mhi5rXD+3WVov51M+bReYRUXQRxOiZeexhLroZMgu2EK/qe6d+3LbBmirenMkAaWgZYAMMua6dHzkRJtMb7Kwa7EKYRBNwXVdcaLcHcZQT9+MJ/3V7v8HArmgQo6B1yfBJOr7jHU= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1709634060; c=relaxed/simple; bh=BPEtYfyFZ3zIsSSumymVBNXkt5kDgI1A4gqsNs7DMws=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=JCHNuvvNisdvjlNfXzi8uMiZbOx8/XFHIiHLjBxZ+jqcTD+nltTFumIrGB3g10r03dh2ErC/FdRoJmKM7q74uPpRQG/kw5PmP0Vwj/Pwle8HXhcEq+Av0D5WeXAcqs+ns8KZP2CnpZ0gY5ZKb9U8DKyQOmuHDZK5QeYAEXRQ/sg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (2048-bit key) header.d=collabora.com header.i=@collabora.com header.b=LORY2kHf; arc=none smtp.client-ip=46.235.227.194 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=collabora.com; s=mail; t=1709634057; bh=BPEtYfyFZ3zIsSSumymVBNXkt5kDgI1A4gqsNs7DMws=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=LORY2kHfPljuF+0IEJo7vcxZLDuh04Xff+jT8HMdMATwYiBtkRza0yRd8FyyGZiFM p5gvq5ogsQXlg/lmCBt5CzgSn0fZf4xVOeDoPW0D2RLDvEMV0ZCdgr+4JK21oB3q9p Z9GXN1NnPDKMHAf+eYAvGjZebFZxH+GHa++fOEQbAli5Ru/kw3j4sulrvcW9Urhziu m+NWsTW5F6DZwTMgAXopF8zxMiOX7D42fBMAV0E+rtRNfNNMPZHMWuZ6/jYK/fB/8z YfLeRF4nFcTxgDFOqeUt8I2HDFyiXwxxfglxCt7P82RDEaKMpriqI3VxOhie906WX6 3ZZ/G8lWD827w== Received: from [100.113.186.2] (cola.collaboradmins.com [195.201.22.229]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) (Authenticated sender: kholk11) by madrid.collaboradmins.com (Postfix) with ESMTPSA id 70FC23781FEF; Tue, 5 Mar 2024 10:20:56 +0000 (UTC) Message-ID: Date: Tue, 5 Mar 2024 11:20:55 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH 5/5] mailbox: mtk-cmdq: Add support runtime get and set GCE event Content-Language: en-US To: =?UTF-8?B?SmFzb24tSkggTGluICjmnpfnnb/npaUp?= , "jassisinghbrar@gmail.com" , "matthias.bgg@gmail.com" , "chunkuang.hu@kernel.org" Cc: "linux-mediatek@lists.infradead.org" , =?UTF-8?B?U2luZ28gQ2hhbmcgKOW8teiIiOWciyk=?= , "linux-kernel@vger.kernel.org" , =?UTF-8?B?SmFzb24tY2ggQ2hlbiAo6Zmz5bu66LGqKQ==?= , =?UTF-8?B?U2hhd24gU3VuZyAo5a6L5a2d6KyZKQ==?= , =?UTF-8?B?TmFuY3kgTGluICjmnpfmrKPonqIp?= , Project_Global_Chrome_Upstream_Group , "linux-arm-kernel@lists.infradead.org" References: <20240301111126.22035-1-jason-jh.lin@mediatek.com> <20240301111126.22035-6-jason-jh.lin@mediatek.com> <298c13ff-25a7-4d9c-ab51-4c22c07c245d@collabora.com> <35b6915dd195abba009dab64dc6002362292351c.camel@mediatek.com> From: AngeloGioacchino Del Regno In-Reply-To: <35b6915dd195abba009dab64dc6002362292351c.camel@mediatek.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Il 05/03/24 04:09, Jason-JH Lin (林睿祥) ha scritto: > Hi Angelo, > > Thanks for the reviews. > > On Mon, 2024-03-04 at 11:06 +0100, AngeloGioacchino Del Regno wrote: >> Il 01/03/24 12:11, Jason-JH.Lin ha scritto: >>> ISP drivers need to get and set GCE event in their runtime contorl >>> flow. >>> So add these functions to support get and set GCE by CPU. >>> >>> Signed-off-by: Jason-JH.Lin >>> Change-Id: I494c34ebc5ec26c82213f2bc03d2033d60652523 >> >> Change-Id makes no sense upstream. Please drop. > > OK, I'll drop it. > >> >>> --- >>> drivers/mailbox/mtk-cmdq-mailbox.c | 37 >>> ++++++++++++++++++++++++ >>> include/linux/mailbox/mtk-cmdq-mailbox.h | 2 ++ >>> 2 files changed, 39 insertions(+) >>> >>> diff --git a/drivers/mailbox/mtk-cmdq-mailbox.c >>> b/drivers/mailbox/mtk-cmdq-mailbox.c >>> index ead2200f39ba..d7c08249c898 100644 >>> --- a/drivers/mailbox/mtk-cmdq-mailbox.c >>> +++ b/drivers/mailbox/mtk-cmdq-mailbox.c >>> @@ -25,7 +25,11 @@ >>> #define CMDQ_GCE_NUM_MAX (2) >>> >>> #define CMDQ_CURR_IRQ_STATUS 0x10 >>> +#define CMDQ_SYNC_TOKEN_ID 0x60 >>> +#define CMDQ_SYNC_TOKEN_VALUE 0x64 >>> +#define CMDQ_TOKEN_ID_MASK GENMASK(9, 0) >>> #define CMDQ_SYNC_TOKEN_UPDATE 0x68 >>> +#define CMDQ_TOKEN_UPDATE_VALUE BIT(16) >>> #define CMDQ_THR_SLOT_CYCLES 0x30 >>> #define CMDQ_THR_BASE 0x100 >>> #define CMDQ_THR_SIZE 0x80 >>> @@ -83,6 +87,7 @@ struct cmdq { >>> struct cmdq_thread *thread; >>> struct clk_bulk_data clocks[CMDQ_GCE_NUM_MAX]; >>> bool suspended; >>> + spinlock_t event_lock; /* lock for gce event */ >>> }; >>> >>> struct gce_plat { >>> @@ -113,6 +118,38 @@ u8 cmdq_get_shift_pa(struct mbox_chan *chan) >>> } >>> EXPORT_SYMBOL(cmdq_get_shift_pa); >>> >>> +void cmdq_set_event(void *chan, u16 event_id) >>> +{ >>> + struct cmdq *cmdq = container_of(((struct mbox_chan *)chan)- >>>> mbox, >>> + typeof(*cmdq), mbox); >> >> struct mbox_chan *mbc = chan; >> struct cmdq *cmdq = container_of(mbc->mbox, ... etc); (and this fits >> in one line) >> > OK, I'll change it. > >>> + unsigned long flags; >>> + >>> + spin_lock_irqsave(&cmdq->event_lock, flags); >> >> Why do you need irqsave/irqrestore? I think I know, but please >> explain. >> > Because ISP driver may call cmdq_get_event() first than use > cmdq_set_event() to update the event status in one > mtk_imgsys_setevent() function frequently. > > And mtk_imgsys_setevent() will be called in SW multi-thread after cmdq > callback from cmdq_irq_handler, so we use the spin_lock_irqsave to > avoid the race condition. I was imagining something like that, yes - thank you for explaining. Cheers, Angelo