From patchwork Thu Jan 20 20:19:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sam Protsenko X-Patchwork-Id: 12719032 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 64C25C433FE for ; Thu, 20 Jan 2022 20:21:45 +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: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=vfFo/cKk5iqCf/RW2vmJMAk6+1gAXjiW3URGCBt/Fvw=; b=ZpF7gm5QJfMpr7 2tKFuBK0PNgkMBQpana28WoizxYaf52NB6OQWYfSKVF7djHuNUYU/R7M69n90dl4VEs3laMoTe4Jo nTkLHeCpatkcqp/8wTLWVA7ioTfP5JFxBuLtYAzn0943irMp8ABNBOMIoQDxCUjUyzTgsK760om1t FTldD2o72ujbryWz4CHzuWVf2rhEvOGI2bpXHIFkiZ80xBXE+cFClp58JqBw0ZYmZ3D1uPbY65foz bUpRccj5pHumAO36kCGsdJSNLUk6FNuyuQGtOeJTd/syXY917ou04f8N3IAPB3DX3VyDkpFhRxohV 7y4fi5YbU+VeNv52XxiA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAduh-00D5sw-6t; Thu, 20 Jan 2022 20:20:07 +0000 Received: from mail-lf1-x129.google.com ([2a00:1450:4864:20::129]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1nAduc-00D5ry-R4 for linux-arm-kernel@lists.infradead.org; Thu, 20 Jan 2022 20:20:04 +0000 Received: by mail-lf1-x129.google.com with SMTP id b14so26072201lff.3 for ; Thu, 20 Jan 2022 12:20:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SV2+kbDgVtw0lV31uGNVO0MZ2UY0VfBryzePxW9RfDo=; b=hjq4AM/+aWwjiHOTI1IslNvdQgEv7Wbun6S6h7xb8cEm5+1TLN/d0WYqA/mc6RvKNN gQoe6LKKSpfjOZLCLTLw4Trrwoy5pXt9ZXEhM1B1luwTPNTaZHvZvecumQPBw/nPJ8Vb ENXUAiSZ2tztrL1y2h31ulq2bhNPSHGHa5MWThKCSMSusMuK0rbzEQpVlpSLdzHb6Bpk FmouJtfAYUYKVnFOUw5o0tObrSmDtyx8Zst5xGxBpe6NhnhpFeLs+PX4HmQJsf0jHfK7 yOZ9Wp7UrHJmxsXvIXLkY3xAI4Thzz/XA+rA0ufps2f8KuC/1LSFCNNgdMYPwAWozk0B 8qMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=SV2+kbDgVtw0lV31uGNVO0MZ2UY0VfBryzePxW9RfDo=; b=iZGu8MBq+dBfOToxVCP8ayx13rYK2gH2tUns+eG8roT/tbf5PNfopMU2Y7z6Zxxm9N FnREpX1rTri503IGQSLi8gst4tW3Q2P1RJzdDT0lVQO67jOuKJPn3E1bfIn4tMG8hQQ/ eyHdcxffX1dpZXDW4LRNk+JDePxdWnXL8SXAgGVCH5F3tOy4DuyGHvqy+myL2h8alF/8 0sEGlv4JobuBqmfQ7ggI8NQfpxdv5+ff4wJCUH708AUmPW1/twkBLvfzPsygCMVCtAEC LQIz3CNt4IqQHdFKMDCQxqQy9t7FUOPZVbsHC2ciGff1aj+OKK/XS6HOikudJjNc9Nsu Ynqw== X-Gm-Message-State: AOAM532NJI/Hcbr/Kq5qsMcHm5xF26zwC/HSXATFJA9aUDAk7AMqQCcx SY9IkMuwU+bNpIN4HeN4DscvMw== X-Google-Smtp-Source: ABdhPJxE6MkmquotwQB0ocKSKdWoDh5ulhRTbJKLE+X/Kg/iQUIIWJNEWpJYx5Uhrcqz6/tpYGTFTw== X-Received: by 2002:a05:651c:511:: with SMTP id o17mr559195ljp.435.1642709999939; Thu, 20 Jan 2022 12:19:59 -0800 (PST) Received: from localhost ([31.134.121.151]) by smtp.gmail.com with ESMTPSA id q17sm21155lfb.271.2022.01.20.12.19.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 20 Jan 2022 12:19:59 -0800 (PST) From: Sam Protsenko To: Joerg Roedel , Will Deacon , Krzysztof Kozlowski Cc: Sumit Semwal , Rob Herring , Catalin Marinas , Marek Szyprowski , Cho KyongHo , Hyesoo Yu , Janghyuck Kim , Jinkyu Yang , Alex , Carlos Llamas , Daniel Mentz , Erick Reyes , "J . Avila" , Jonglin Lee , Mark Salyzyn , Thierry Strudel , Will McVicker , Shawn Guo , Bjorn Andersson , linux-samsung-soc@vger.kernel.org, iommu@lists.linux-foundation.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC 0/3] iommu/samsung: Introduce Exynos sysmmu-v8 driver Date: Thu, 20 Jan 2022 22:19:55 +0200 Message-Id: <20220120201958.2649-1-semen.protsenko@linaro.org> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20220120_122002_909550_37CD98AD X-CRM114-Status: GOOD ( 22.77 ) 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 This is a draft of a new IOMMU driver used in modern Exynos SoCs (like Exynos850) and Google's GS101 SoC (used in Pixel 6 phone). Most of its code were taken from GS101 downstream kernel [1], with some extra patches on top (fixes from Exynos850 downstream kernel and some porting changes to adapt it to the mainline kernel). All development history can be found at [2]. Similarities with existing exynos-iommu.c is minimal. I did some analysis using similarity-tester tool: 8<-------------------------------------------------------------------->8 $ sim_c -peu -S exynos-iommu.c "|" samsung-* exynos-iommu.c consists for 15 % of samsung-iommu.c material exynos-iommu.c consists for 1 % of samsung-iommu-fault.c material exynos-iommu.c consists for 3 % of samsung-iommu.h material 8<-------------------------------------------------------------------->8 So the similarity is very low, most of that code is some boilerplate that shouldn't be extracted to common code (like allocating the memory and requesting clocks/interrupts in probe function). It was tested on v5.4 Android kernel on Exynos850 (E850-96 board) with DPU use-case (displaying some graphics to the screen). Also it apparently works fine on v5.10 GS101 kernel (on Pixel 6). On mainline kernel I managed to build, match and bind the driver. No real world test was done, but the changes from v5.10 (where it works fine) are minimal (see [2] for details). So I'm pretty sure the driver is functional. For this patch series I'd like to receive some high-level review for driver's design and architecture. Coding style and API issues I can fix later, when sending real (not RFC) series. Particularly I'd like to hear some opinions about: - namings: Kconfig option, file names, module name, compatible, etc - modularity: should this driver be a different platform driver (like in this series), or should it be integrated into existing exynos-iommu.c driver somehow - dt-bindings: does it look ok as it is, or some interface changes are needed - internal driver architecture: approach seems to be similar to exynos-iommu.c, but any comments are welcome - ongoing work: please let me know if you're aware of some efforts to upstream this driver by some other party (e.g. Google engineers might be working on something similar) Basically, I want to figure out what should be changed/fixed in this driver (on a high level), so it can be considered "upstreamable". [1] https://android.googlesource.com/kernel/gs/ [2] https://github.com/joe-skb7/linux/commits/iommu-exynos850-dev Sam Protsenko (3): dt-bindings: iommu: Add bindings for samsung,sysmmu-v8 iommu/samsung: Introduce Exynos sysmmu-v8 driver arm64: defconfig: Enable sysmmu-v8 IOMMU .../bindings/iommu/samsung,sysmmu-v8.txt | 31 + arch/arm64/configs/defconfig | 2 + drivers/iommu/Kconfig | 13 + drivers/iommu/Makefile | 3 + drivers/iommu/samsung-iommu-fault.c | 617 +++++++ drivers/iommu/samsung-iommu-group.c | 50 + drivers/iommu/samsung-iommu.c | 1521 +++++++++++++++++ drivers/iommu/samsung-iommu.h | 216 +++ include/dt-bindings/soc/samsung,sysmmu-v8.h | 43 + 9 files changed, 2496 insertions(+) create mode 100644 Documentation/devicetree/bindings/iommu/samsung,sysmmu-v8.txt create mode 100644 drivers/iommu/samsung-iommu-fault.c create mode 100644 drivers/iommu/samsung-iommu-group.c create mode 100644 drivers/iommu/samsung-iommu.c create mode 100644 drivers/iommu/samsung-iommu.h create mode 100644 include/dt-bindings/soc/samsung,sysmmu-v8.h