From patchwork Thu Aug 19 15:13:36 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandre Bailon X-Patchwork-Id: 12447383 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.5 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A10F3C4338F for ; Thu, 19 Aug 2021 15:14:43 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 6CB0560E76 for ; Thu, 19 Aug 2021 15:14:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 6CB0560E76 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=baylibre.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.org 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: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:References: List-Owner; bh=G8imnPFFhgSkxWgxBeazqpQCo3XvVeG5DJR4f3JJRqM=; b=nf0XS1R/wlIm+e 2KZgPwLwHqNBD/JusKrb9J+gDNYFrAwNE/aRYa3Pvtz9oFSLuQkVPv5QFGrzXHlsQi3KNRXY8jUto gisfCsN7AwEYX5+L7fk+KmimEk06BUFIH9/JsCGM3eWhB92sN/16oa6Cqjgy0YDFKXtmBmaHDZpG1 9iAZn4eOfqBVSaGAZmBB3rH1uhhxFWdLdSSJnADQDtDMj/qCeHPE2jLZCzv1oAKbFcOfDFAoc0K7f Lb3tomjZfhzAcoi2i8SgX9OS4qtMEFo2klqQi8JUBVQ6xwblL4g3UefpXFc7DepulGARKk3pUeMlD DddNlPl2NJjWAs9LaxAg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGjiO-008kHz-9e; Thu, 19 Aug 2021 15:12:20 +0000 Received: from mail-wr1-x42c.google.com ([2a00:1450:4864:20::42c]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mGji9-008kCE-7k for linux-arm-kernel@lists.infradead.org; Thu, 19 Aug 2021 15:12:07 +0000 Received: by mail-wr1-x42c.google.com with SMTP id x10so9629696wrt.8 for ; Thu, 19 Aug 2021 08:12:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5fuKx796Elw77gjwAl8zSUCyFS8ubJYZz/EESfgpkks=; b=yJO+jMFUHCHJyCh9Zu40TaUlUDaMmBDwvj6GBQ5q50P79oWOYEdyNpawb3tXW2vj/z DNDwKA1kERRV4sFALw7q4B+eIHB9W0uAUI4UQT4nKyHTJ4HxggF05nBG32WgnRHI4hHz GSZuIy1M61HsgU1IZwAkH78cpaMLJEcjOAm02QVu+HScUOkVgDIhfMfJdeDHeyzFtpth 8uWrVpmv004XMwHmWy0zyJOVKGSK3WXMx3a8wgsP0avywV5rNzXDAaT0O3yM3+sakDNb ifH07P/3cHXavrfVgGWJ4pH4oYS8NlWeypmvN4syL1o0U6/c1x9c3jItYf3jTMQWNAyv FBqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=5fuKx796Elw77gjwAl8zSUCyFS8ubJYZz/EESfgpkks=; b=q37QCfc2S11p3urZ4LNGzwJ6hb3tv+ECdmTB3NpRbe+Kl3s2LYPu4nL2zc88DfTihF pKC+HgWcIT0sCRWfkwzcev/SbjTMBXeIgeLPL81KXuhJ0X6iff47P0v/lHxv9vViEaRb WViPzSEHURHHikOlOtXJ4YdxBUHuDT9QB0L+TnV3f3tg/Agj/fN/M2c9lC956Wrvvy9t Dh7iniaBaC1HgkQ02PmTnjLnIgezYlcwkQikghZpSuWaZ32H9hCD77qU44+rCDQ4rTpr R8cZfH9fy0uh+Viqn6fXgKEhU8tM7U/C/Qn4GUjO7D8fN/EzUAEAVWs5w7Ojaz6c0Xdg OyVw== X-Gm-Message-State: AOAM530tq8QGinXUinh22QiO2+KCN+SlhnBy7GuERCXqFG9/TVwkQQZ2 hBH6V+87yhaLR4PvKqpRkPSrcQ== X-Google-Smtp-Source: ABdhPJz4GjMnmtkXigDTLZBtL+MRkj19w1VdlfTSBix8abrDJ1TrXre8hr9XFACVNZy95wL68RZRmA== X-Received: by 2002:adf:d085:: with SMTP id y5mr4549112wrh.209.1629385922579; Thu, 19 Aug 2021 08:12:02 -0700 (PDT) Received: from alex-xps13.baylibre.local (laubervilliers-658-1-213-31.w90-63.abo.wanadoo.fr. [90.63.244.31]) by smtp.gmail.com with ESMTPSA id j37sm1556962wms.39.2021.08.19.08.12.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 08:12:01 -0700 (PDT) From: Alexandre Bailon To: ohad@wizery.com, bjorn.andersson@linaro.org, mathieu.poirier@linaro.org, robh+dt@kernel.org Cc: matthias.bgg@gmail.com, linux-remoteproc@vger.kernel.org, devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, linux-kernel@vger.kernel.org, stephane.leprovost@mediatek.com, gpain@baylibre.com, khilman@baylibre.com, Alexandre Bailon Subject: [PATCH v3 0/4] Add support of mt8183 APU Date: Thu, 19 Aug 2021 17:13:36 +0200 Message-Id: <20210819151340.741565-1-abailon@baylibre.com> X-Mailer: git-send-email 2.31.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210819_081205_380883_17C6DDAA X-CRM114-Status: GOOD ( 20.08 ) 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 Some Mediatek's SoC have an Accelerated Processing Unit. This adds support of the one available in the mt8183 (aswell some derivative SoC). This v3 attempt to handle memory differently. In the v2, the memory was reserved in dts and all dma allocation made by remoteproc was using it. Since we may load many firmwares with different size, this could lead to a memory waste or out of memory issues. In addition, the APU itself expect the memory to mapped at a specific address. The firmware, because of many hardware / software limitations use hardcoded address. To simplify memory management of userspace application, kernel and firmware, and to rmeove a couple of hacks, we changed the way to manage the memory. With the v3, only the virtio memory (that won't never change) is reserved in the dts. The firmware declare resource similar to the CARVOUT_RSC that used by this driver to allocate and map the memory using the IOMMU. I am not sure that the best solution but the simplest one I found so far. Changes in v3: - Remove IOMMU hack. Instead, manage the IOMMU directly from the driver - Update the device tree bindings: only use reserved memory for virtio. All the other memory allocation will be done using DMA API. This sould simplify the memory management. - Add more comments Changes in v2: - Drop the workarounds needed to load bad firmwares - There are many name for the APU (most common one is VPU). Rename many functions and dts nodes to be more consistent. - Use the bulk clock API, and enable / disable clock at a better place - add few comments explaining how to start the APU - update the way to use pinctl for JTAG - fix some minors issues - fix device tree bindings Alexandre Bailon (4): dt bindings: remoteproc: Add bindings for MT8183 APU remoteproc: Add a remoteproc driver for the MT8183's APU remoteproc: mtk_vpu_rproc: Add support of JTAG ARM64: mt8183: Add support of APU to mt8183 .../bindings/remoteproc/mtk,apu.yaml | 118 ++++ .../boot/dts/mediatek/mt8183-pumpkin.dts | 48 ++ arch/arm64/boot/dts/mediatek/mt8183.dtsi | 40 ++ drivers/remoteproc/Kconfig | 19 + drivers/remoteproc/Makefile | 1 + drivers/remoteproc/mtk_apu.c | 590 ++++++++++++++++++ 6 files changed, 816 insertions(+) create mode 100644 Documentation/devicetree/bindings/remoteproc/mtk,apu.yaml create mode 100644 drivers/remoteproc/mtk_apu.c