From patchwork Thu Oct 31 20:47:20 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michal Wilczynski X-Patchwork-Id: 13858352 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 AFB81E67484 for ; Thu, 31 Oct 2024 20:47:53 +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:References:MIME-Version: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:In-Reply-To: List-Owner; bh=1g3miTQh7BBXzteJnAjgyljoCKhLlaKZmwRRJ2mLMZI=; b=SLrO0AOul+EHwz yxUjdNwa2bD+NE4pLdadL63+3Wtbba0qOhuiyQNqKJdWE46XwI6hNoJT1A0PPP5NMiGb4nGsnS8oL 6r9E2ipqW8p3ceDN7qkG3ji97NTEbUjqLWSBBfMHcFOzytPX85iJQDEK23GRj3UaC8fA0ArVG+m6a 5MLFOOjAy+mMznYyB+eg4v8hCsj8gz37ioZQju1Kupuq1Zl/RZ09CQ30yjsQLGAXIWYE2WYBhfDNh OrhPtKUZwWej1UoWEjz2/Pyd1UdJ3kAlLzwg2g6SafvhMyd21Ef+jj0AiyjjBZoSNfj2XF0c93yOG 5ZqyGjFrKhSa0M1jsbZg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1t6c53-00000004odw-3DZP; Thu, 31 Oct 2024 20:47:45 +0000 Received: from mailout2.w1.samsung.com ([210.118.77.12]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1t6c4y-00000004oa7-1w5T for linux-riscv@lists.infradead.org; Thu, 31 Oct 2024 20:47:43 +0000 Received: from eucas1p2.samsung.com (unknown [182.198.249.207]) by mailout2.w1.samsung.com (KnoxPortal) with ESMTP id 20241031204735euoutp02200850aeb63ea679068b5a17cf5dbd7c~DpJgpyX6K2195921959euoutp02f for ; Thu, 31 Oct 2024 20:47:35 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 mailout2.w1.samsung.com 20241031204735euoutp02200850aeb63ea679068b5a17cf5dbd7c~DpJgpyX6K2195921959euoutp02f DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=samsung.com; s=mail20170921; t=1730407655; bh=s6DGAxUHb2q0xPQ2y2B8ZAw2ghixwQVQZDTwr523jNs=; h=From:To:Cc:Subject:Date:References:From; b=PCSAuJNZ+NAbFTqo63200lRTk6h5pTUnNfFw5E4xHK2/zOQD8C/ntOg6ihR2MGRwM pt2QWAS8tRBJjNMhOZSYzTu0kDnz3QdmpI3l783szv6IsA2g/tKVZfKsC2g/DIWZSO 507G8Q6HDBFmb1Mn058RV57ZQu3np/moa1G+Mavc= Received: from eusmges1new.samsung.com (unknown [203.254.199.242]) by eucas1p2.samsung.com (KnoxPortal) with ESMTP id 20241031204734eucas1p2bbdcbc237d9116eefa8aa796fceed66d~DpJfpT9gU1026810268eucas1p2O; Thu, 31 Oct 2024 20:47:34 +0000 (GMT) Received: from eucas1p1.samsung.com ( [182.198.249.206]) by eusmges1new.samsung.com (EUCPMTA) with SMTP id 52.15.20821.5ECE3276; Thu, 31 Oct 2024 20:47:34 +0000 (GMT) Received: from eusmtrp1.samsung.com (unknown [182.198.249.138]) by eucas1p2.samsung.com (KnoxPortal) with ESMTPA id 20241031204733eucas1p223f2ad621130055e20e81b7633054f26~DpJfMXC1B0030200302eucas1p2T; Thu, 31 Oct 2024 20:47:33 +0000 (GMT) Received: from eusmgms2.samsung.com (unknown [182.198.249.180]) by eusmtrp1.samsung.com (KnoxPortal) with ESMTP id 20241031204733eusmtrp1b33538262d60038dd58e7d1cd60e4d1b~DpJfLqsOF2727327273eusmtrp1z; Thu, 31 Oct 2024 20:47:33 +0000 (GMT) X-AuditID: cbfec7f2-b09c370000005155-ee-6723ece5f573 Received: from eusmtip1.samsung.com ( [203.254.199.221]) by eusmgms2.samsung.com (EUCPMTA) with SMTP id 0D.20.19654.5ECE3276; Thu, 31 Oct 2024 20:47:33 +0000 (GMT) Received: from AMDC4942.home (unknown [106.210.136.40]) by eusmtip1.samsung.com (KnoxPortal) with ESMTPA id 20241031204732eusmtip140e0fa6c8476517761ca8e5e11e13e5d~DpJeEmhKz1679316793eusmtip1J; Thu, 31 Oct 2024 20:47:32 +0000 (GMT) From: Michal Wilczynski To: drew@pdp7.com, guoren@kernel.org, wefu@redhat.com, jassisinghbrar@gmail.com, robh@kernel.org, krzk+dt@kernel.org, conor+dt@kernel.org, paul.walmsley@sifive.com, palmer@dabbelt.com, aou@eecs.berkeley.edu, m.szyprowski@samsung.com, samuel.holland@sifive.com, emil.renner.berthing@canonical.com Cc: linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Michal Wilczynski Subject: [PATCH v5 0/3] Introduce support for T-head TH1520 Mailbox Date: Thu, 31 Oct 2024 21:47:20 +0100 Message-Id: <20241031204723.1149912-1-m.wilczynski@samsung.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFrrPKsWRmVeSWpSXmKPExsWy7djPc7rP3iinG9y5yGSx9fcsdos1e88x Wcw/co7V4t6lLUwWlzpXMFq82NvIYnFtxVx2i5ez7rFZXN41h81i2+cWNou1R+6yW6z/Op/J 4uXlHmaLtln8Fv/37GC3WH3uCotFy/4pLA6C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KLMUZiYZazEXFiQDyuy5VXwMAAA== X-CMS-MailID: 20241031204733eucas1p223f2ad621130055e20e81b7633054f26 X-Msg-Generator: CA X-RootMTR: 20241031204733eucas1p223f2ad621130055e20e81b7633054f26 X-EPHeader: CA CMS-TYPE: 201P X-CMS-RootMailID: 20241031204733eucas1p223f2ad621130055e20e81b7633054f26 References: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241031_134741_097265_FC192857 X-CRM114-Status: GOOD ( 27.62 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The T-head TH1520 SoC supports a hardware mailbox that enables two cores within the SoC to communicate and coordinate [1]. One example of such coordination would be cooperation with the T-Head E902 core, which is responsible for power, clock, and resource management. For example, in the specific case of the BXM-4-64 GPU, it needs to be powered on by the E902 core, and the kernel running on the E910 needs to 'ask' the firmware running on the E902 core to enable power to the GPU island. Given recent advancements in work on the upstream GPU driver [2], there is an emerging need to get this code in the mainline kernel. Link: https://openbeagle.org/beaglev-ahead/beaglev-ahead/-/blob/main/docs/TH1520%20System%20User%20Manual.pdf [1] Link: https://gitlab.freedesktop.org/imagination/linux-firmware/-/issues/1 [2] Thanks everyone for taking the time to review this series ! To test this, I've prepared a diff that includes the missing drivers utilizing the mailbox and enabled the GPU node in the device tree to use the drm/imagination driver. I’ve created two branches. Both contain the same code, including this patch series and some extra commits with mailbox consumers. The only difference is that one branch has an additional commit that switches ON calls to OFF calls (and vice versa) to observe the behavior when the GPU is turned off via the mailbox. To reproduce, simply clone the repository, add the following extra options in the config: CONFIG_THEAD_TH1520_MBOX=y #(this series) CONFIG_DRM_POWERVR=y CONFIG_LIGHT_AON=y CONFIG_LIGHT_AON_PD=y Then build and deploy on the target. In case [1], the output should be: [ 2.478394] light_aon_probe: virtual_log_mem=0x000000005faf564a, phy base=0x33600000, size:2097152 [ 2.488589] succeed to create power domain debugfs direntry [ 2.494987] powervr ffef400000.gpu: Before reading BVNC At this point, the system will hang because the driver is trying to read memory-mapped registers while the GPU isn’t powered on. In case [2], the GPU powers on correctly, and the BVNC can be read without issues. If the specific firmware file isn’t available, the output would look like this: root@revyos-lpi4a:~# dmesg | grep gpu [ 2.408207] powervr ffef400000.gpu: Before reading BVNC [ 2.413533] powervr ffef400000.gpu: After reading BVNC [ 2.418930] powervr ffef400000.gpu: Direct firmware load for powervr/rogue_36.52.104.182_v1.fw failed with error -2 [ 2.429568] powervr ffef400000.gpu: [drm] *ERROR* failed to load firmware powervr/rogue_36.52.104.182_v1.fw (err=-2) [ 2.440403] powervr ffef400000.gpu: probe with driver powervr failed with error -2 Here are the links: [1] - https://github.com/mwilczy/linux/tree/31_october_demonstrate_mailbox_not_working [2] - https://github.com/mwilczy/linux/tree/31_october_demonstrate_mailbox_working Note: U-Boot must load the AON firmware at startup to the address mapped for AON for this to work properly. v5: - removed 'type' mbox-cell, which isn't really necessary for the use-cases of the series, but desribes SW protocol instead of the HW, adjust driver code logic to account for this, simplifying it - change the register mappings in the device tree node to reflect the manual - adjust the driver code to compensate for irregularities in the mappings, do this by modifying th1520_map_mmio() with extra argument 'offset' - add support for enabling/disabling MBOX clocks in the driver - add clocks in the dt-binding/device tree node - rebase and retest v4: - fixed warning of unused variable - added Reviewed-by from Krzysztof - fixed minor cosmetic issues in dt-binding v3: - added a comment about mixing devm_ and non-devm resources in the context of shared interrupts and explained why it's safe to do so in this particular case - changed the order of resource freeing in the .shutdown callback - used a wrapper function for register mapping - since the only conceivable use case for this mailbox driver is communication with cores not managed by the kernel, I’ve hard-coded this by removing the thead,icu-cpu-id property and adjusted the mailbox driver code accordingly. - added a more detailed description for mbox-cells. - made some cosmetic changes. - retested by applying the patch with non-yet-upstreamed patches, confirming that the drm/imagination driver can read the registers correctly. v2: - fixed thead,th1520-mbox.yaml binding file by dropping redundant descriptions, renaming reg-names, removing unnecessary clocks, providing constraints and defining ICU's - fixed the mailbox driver code to work well with updated binding-file, removed clocks support, as it's not necessary for mailbox to work - adjusted the device tree node instance of mbox_910t so it will work with updated bindings file Michal Wilczynski (3): mailbox: Introduce support for T-head TH1520 Mailbox driver dt-bindings: mailbox: Add thead,th1520-mailbox bindings riscv: dts: thead: Add mailbox node .../bindings/mailbox/thead,th1520-mbox.yaml | 89 +++ MAINTAINERS | 2 + arch/riscv/boot/dts/thead/th1520.dtsi | 16 + drivers/mailbox/Kconfig | 10 + drivers/mailbox/Makefile | 2 + drivers/mailbox/mailbox-th1520.c | 592 ++++++++++++++++++ 6 files changed, 711 insertions(+) create mode 100644 Documentation/devicetree/bindings/mailbox/thead,th1520-mbox.yaml create mode 100644 drivers/mailbox/mailbox-th1520.c