From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=210.61.82.184 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796224442; b=kdY0o1W6WzvSLMPfNkmIehHanAl0ZQEOfJ9pxOm30Rx4ExqGDLTSdZkBJ2JJffxk8sl4 zulmly0ryHhWXkSYTwghIk/e1L0BTynn0qTWsMHIPVvUUJa/hjlTfhreZfCcf7cJwVKY5 maH+pWcMuoIDy0JpxbZ0SStxbBC7VbqCZOxqGp7jGayX0BNl1EFG9FRAabBsvnDaZf0Ef SrqC5wcOVEy5wDHFPGPPNlk1eCi2Ooeb+vUPuUPmHNYnuo8aKjkP1iGujP0TJH9CanjkW H9WxsEEgHO49Uy74lYGmGuwu1AL5Hu8P/Tm/dVnQm5OJ/pxREGNSfWpkAmhmm0gQKoA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796224442; h=DMARC-Filter:X-UUID:DKIM-Signature:X-CID-P-RULE:X-CID-O-INFO: X-CID-META:X-CID-BVR:X-CID-BAS:X-CID-FACTOR:X-CID-RHF:X-UUID:Received: Received:Received:From:To:CC:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding:Content-Type:X-MTK; bh=+q8N+BQkbTQuLY/z5HitG0AGSpNrmuljZM8vN5LU29g=; b=urQ8prpMnfuYQryrgfF9ZHXeYGT/349YI+ubGERF4org7bJBKeRQ5fZaGTJzTHfLia39 tRT/BbPVgEXcmuYdKU3ePjLc4M3AzsBiGUOOgdAHIFsvp75Q/qcmuqhHwQxuPb7dz9Bi3 +Gyft5XsKfP6Xy8fdo4zOfVSz6H/kjujWM8DC3wIg8bNJcndjSAnil6pSGSs4VPMuXfZR 9vg22AOE2x1HozXUJwowY839FImdLxjmv0YcwzBB36agImtOf1ca7iTpmn6R8tkZYzO7L D4FqtCYcP9vdGRrkhUplTtPdOQKeGqvU5wIBcP0Tu4PU6nLpZVqbiQfkTExehQRVLvA== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=mediatek.com; spf=pass smtp.mailfrom=mediatek.com; dkim=pass header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=T9v0lbie; arc=none smtp.remote-ip=210.61.82.184 Received: from mailgw02.mediatek.com (unknown [210.61.82.184]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9351606A68B; Wed, 2 Dec 2026 15:14:00 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A9351606A68B Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=mediatek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=mediatek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key, unprotected) header.d=mediatek.com header.i=@mediatek.com header.a=rsa-sha256 header.s=dk header.b=T9v0lbie X-UUID: fd6db3b0ee6211f1a7aecdb2598be72c-20261202 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:Message-ID:Date:Subject:CC:To:From; bh=+q8N+BQkbTQuLY/z5HitG0AGSpNrmuljZM8vN5LU29g=; b=T9v0lbieQEzl0e6OOI1s+d8pvsuiJGTAaMjyny2WlzdqwVz3b006o5bB0EsJMfujZvIkK/C7BBHMnKTuWItwEICc/roIyUQUdhUddtsySCn8TCF6qReBP8/PKBP4s4WxoWdWBZsgxaHCgOJn4mmXpRwQUF00VAQmffyiBeWuokI=; X-CID-P-RULE: Release_Ham X-CID-O-INFO: VERSION:1.3.22,REQID:9ba653ae-2ef3-4057-8a95-a8011faafa6f,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:d36851b,CLOUDID:316ea631-f289-4656-bb36-27baf4489f11,B ulkID:nil,BulkQuantity:0,SF:102|836|865|888|898,TC:-5,Content:0|15|50|99,E DM:-3,IP:nil,URL:99|1,File:130,RT:0,Bulk:nil,QS:nil,BEC:nil,COL:0,OSI:0,OS A:0,AV:0,LES:1,SPR:NO,DKR:0,DKP:0,BRR:0,BRE:0,ARC:0 X-CID-BVR: 2,SSN|SDN X-CID-BAS: 2,SSN|SDN,0,_ X-CID-FACTOR: TF_CID_SPAM_ULS,TF_CID_SPAM_SNR X-CID-RHF: D41D8CD98F00B204E9800998ECF8427E X-UUID: fd6db3b0ee6211f1a7aecdb2598be72c-20261202 Received: from mtkmbs11n2.mediatek.inc [(172.21.101.187)] by mailgw02.mediatek.com (envelope-from ) (Generic MTA with TLSv1.2 ECDHE-RSA-AES256-GCM-SHA384 256/256) with ESMTP id 649098206; Wed, 02 Dec 2026 23:13:55 +0800 Received: from mtkmbs13n1.mediatek.inc (172.21.101.193) by mtkmbs13n2.mediatek.inc (172.21.101.108) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.2562.56; Wed, 2 Dec 2026 23:13:53 +0800 Received: from mtksitap99.mediatek.inc (10.233.130.16) by mtkmbs13n1.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.2.2562.56 via Frontend Transport; Wed, 2 Dec 2026 23:13:53 +0800 From: Jason-JH Lin To: Chun-Kuang Hu , AngeloGioacchino Del Regno , Matthias Brugger , Roman Vivchar CC: Fei Shao , Jassi Brar , Jason-JH Lin , Paul-PL Chen , Zi-Hao Huang , Olivia Wen , Chen-yu Tsai , , , , , Subject: [PATCH v2] soc: mediatek: mtk-cmdq: Keep the low address in client_reg->offset Date: Wed, 2 Dec 2026 23:11:23 +0800 Message-ID: <20261202151352.1541964-1-jason-jh.lin@mediatek.com> X-Mailer: git-send-email 2.45.2 X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-MTK: N From: Jason-jh Lin The subsys ID of a GCE client stands for bits [31:16] of its register address, and the write instruction carries the low 16 bits as the offset. cmdq_dev_get_client_reg() parses both from the DT: the subsys ID, and the low 16 bits into client_reg->offset, which clients add their register offset to before they call pkt_write(). cmdq_pkt_write_pa() and cmdq_pkt_write_mask_pa() work the same way for a client without a subsys ID: pa_base replaces the subsys ID and gives bits [31:16], and offset gives the low 16 bits. But the no-subsys path of cmdq_dev_get_client_reg() leaves client_reg->offset at 0, so a client that passes client_reg->offset + reg_offset like it does with a subsys loses the low 16 bits of its base. When the base isn't 64K aligned, as the OVLSYS display components of some SoCs, the packet writes to (base & ~0xffff) + reg_offset and still runs to EOC without error. Set client_reg->offset to the low 16 bits of the base there, which is what the DT holds for a subsys, so that clients can use both paths the same way. Document pa_base and offset of the _pa helpers and of struct cmdq_client_reg accordingly. Fixes: 4bf783d8415c ("soc: mediatek: mtk-cmdq: Add pa_base parsing for hardware without subsys ID support") Cc: stable@vger.kernel.org Signed-off-by: Jason-jh Lin --- Changes in v2: - Drop the fold of pa_base + offset in cmdq_pkt_write_pa() and cmdq_pkt_write_mask_pa(), which would break callers that already pass the low 16 bits of the address in offset. Fix the cause in cmdq_dev_get_client_reg() instead, so the title changes as well. - Drop the Reviewed-by tags of v1, as the patch is different. v1: https://lore.kernel.org/all/20261201112523.643035-1-jason-jh.lin@mediatek.com/ drivers/soc/mediatek/mtk-cmdq-helper.c | 7 +++++++ include/linux/soc/mediatek/mtk-cmdq.h | 23 +++++++++++++++++++---- 2 files changed, 26 insertions(+), 4 deletions(-) diff --git a/drivers/soc/mediatek/mtk-cmdq-helper.c b/drivers/soc/mediatek/mtk-cmdq-helper.c index fb82f2a85a21..22f179b37b6b 100644 --- a/drivers/soc/mediatek/mtk-cmdq-helper.c +++ b/drivers/soc/mediatek/mtk-cmdq-helper.c @@ -9,6 +9,7 @@ #include #include #include +#include #include #define CMDQ_WRITE_ENABLE_MASK BIT(0) @@ -104,6 +105,12 @@ int cmdq_dev_get_client_reg(struct device *dev, client_reg->pkt_write = cmdq_pkt_write_pa; client_reg->pkt_write_mask = cmdq_pkt_write_mask_pa; + /* + * Keep the low 16 bits of the base, as the DT does for a + * subsys, because the base isn't always 64K aligned. + */ + client_reg->offset = lower_16_bits(res.start); + return 0; } diff --git a/include/linux/soc/mediatek/mtk-cmdq.h b/include/linux/soc/mediatek/mtk-cmdq.h index 03bb85462566..73024fd705bc 100644 --- a/include/linux/soc/mediatek/mtk-cmdq.h +++ b/include/linux/soc/mediatek/mtk-cmdq.h @@ -52,6 +52,17 @@ struct cmdq_operand { }; }; +/** + * struct cmdq_client_reg - GCE client register information from the DT + * @subsys: the CMDQ sub system code, CMDQ_SUBSYS_INVALID if there is none + * @pa_base: the physical address of the client registers, only its bits [31:16] + * are used, as the subsys ID stands for them + * @offset: the low 16 bits of @pa_base. Add the register offset to it to + * get the offset argument of @pkt_write and @pkt_write_mask + * @size: the size of the client registers + * @pkt_write: cmdq_pkt_write_subsys() or cmdq_pkt_write_pa() + * @pkt_write_mask: cmdq_pkt_write_mask_subsys() or cmdq_pkt_write_mask_pa() + */ struct cmdq_client_reg { u8 subsys; phys_addr_t pa_base; @@ -139,8 +150,10 @@ int cmdq_pkt_write(struct cmdq_pkt *pkt, u8 subsys, u16 offset, u32 value); * cmdq_pkt_write_pa() - append write command to the CMDQ packet with pa_base * @pkt: the CMDQ packet * @subsys: unused parameter - * @pa_base: the physical address base of the hardware register - * @offset: register offset from CMDQ sub system + * @pa_base: the physical address of the hardware register, only its bits + * [31:16] are used, as the subsys ID stands for them + * @offset: the low 16 bits of the register address, as for the subsys + * variant * @value: the specified target register value * * Return: 0 for success; else the error code is returned @@ -178,8 +191,10 @@ int cmdq_pkt_write_mask(struct cmdq_pkt *pkt, u8 subsys, * cmdq_pkt_write_mask_pa() - append write command with mask to the CMDQ packet with pa * @pkt: the CMDQ packet * @subsys: unused parameter - * @pa_base: the physical address base of the hardware register - * @offset: register offset from CMDQ sub system + * @pa_base: the physical address of the hardware register, only its bits + * [31:16] are used, as the subsys ID stands for them + * @offset: the low 16 bits of the register address, as for the subsys + * variant * @value: the specified target register value * @mask: the specified target register mask * -- 2.43.0