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 gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (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 307FCC77B72 for ; Tue, 18 Apr 2023 01:24:00 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 370F010E106; Tue, 18 Apr 2023 01:23:59 +0000 (UTC) Received: from twspam01.aspeedtech.com (twspam01.aspeedtech.com [211.20.114.71]) by gabe.freedesktop.org (Postfix) with ESMTPS id D7E4310E106 for ; Tue, 18 Apr 2023 01:23:56 +0000 (UTC) Received: from mail.aspeedtech.com ([192.168.0.24]) by twspam01.aspeedtech.com with ESMTP id 33I17Ulr052113; Tue, 18 Apr 2023 09:07:30 +0800 (GMT-8) (envelope-from jammy_huang@aspeedtech.com) Received: from [192.168.2.115] (192.168.2.115) by TWMBX02.aspeed.com (192.168.0.24) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 18 Apr 2023 09:23:45 +0800 Content-Type: multipart/alternative; boundary="------------EV2pfdDpumQngY98BIgbpEql" Message-ID: Date: Tue, 18 Apr 2023 09:23:46 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH] drm/ast: Fix ARM compatibility To: Thomas Zimmermann , , , References: <20230302021905.2777-1-jammy_huang@aspeedtech.com> <24987cff-02e4-aa4a-449f-fd48accf7365@suse.de> Content-Language: en-US From: Jammy Huang In-Reply-To: <24987cff-02e4-aa4a-449f-fd48accf7365@suse.de> X-Originating-IP: [192.168.2.115] X-ClientProxiedBy: TWMBX02.aspeed.com (192.168.0.24) To TWMBX02.aspeed.com (192.168.0.24) X-DNSRBL: X-MAIL: twspam01.aspeedtech.com 33I17Ulr052113 X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: giantl@nvidia.com, linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" --------------EV2pfdDpumQngY98BIgbpEql Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 8bit Hi Thomas, The Intel(x86) CPUs have a separate address space for "IO", but the ARM architecture only has "memory", so all IO devices are accessed as if they were memory. Which means ARM does not support isolated IO. Here is a related discussion on ARM's forum. https://community.arm.com/support-forums/f/architectures-and-processors-forum/52046/how-to-read-write-an-i-o-port-in-aarch64 Thus, we want to adapt MMIO only after this patch. On 2023/4/17 下午 07:51, Thomas Zimmermann wrote: > Hi > > Am 07.04.23 um 04:09 schrieb Jammy Huang: >> Hi Thomas, >> >> Could you help review this patch?? >> >> We met some problem on nvidia's ARM platfrom and need this patch to >> fix it. >> >> On 2023/3/2 上午 10:19, Jammy Huang wrote: >>> ARM architecture only has 'memory', so all devices are accessed by >>> MMIO. >>> >>> Signed-off-by: Jammy Huang >>> --- >>>   drivers/gpu/drm/ast/ast_main.c | 17 +---------------- >>>   1 file changed, 1 insertion(+), 16 deletions(-) >>> >>> diff --git a/drivers/gpu/drm/ast/ast_main.c >>> b/drivers/gpu/drm/ast/ast_main.c >>> index 794ffd4a29c5..f86d01e9f024 100644 >>> --- a/drivers/gpu/drm/ast/ast_main.c >>> +++ b/drivers/gpu/drm/ast/ast_main.c >>> @@ -424,22 +424,7 @@ struct ast_device *ast_device_create(const >>> struct drm_driver *drv, >>>       if (!ast->regs) >>>           return ERR_PTR(-EIO); >>> -    /* >>> -     * If we don't have IO space at all, use MMIO now and >>> -     * assume the chip has MMIO enabled by default (rev 0x20 >>> -     * and higher). >>> -     */ >>> -    if (!(pci_resource_flags(pdev, 2) & IORESOURCE_IO)) { >>> -        drm_info(dev, "platform has no IO space, trying MMIO\n"); >>> -        ast->ioregs = ast->regs + AST_IO_MM_OFFSET; >>> -    } >>> - >>> -    /* "map" IO regs if the above hasn't done so already */ >>> -    if (!ast->ioregs) { >>> -        ast->ioregs = pcim_iomap(pdev, 2, 0); > > What happens on systems that use this branch? > > Best regards > Thomas > >>> -        if (!ast->ioregs) >>> -            return ERR_PTR(-EIO); >>> -    } >>> +    ast->ioregs = ast->regs + AST_IO_MM_OFFSET; >>>       ast_detect_chip(dev, &need_post); >>> >>> base-commit: 254986e324add8a30d0019c6da59f81adc8b565f >> > -- Best Regards Jammy --------------EV2pfdDpumQngY98BIgbpEql Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: 8bit

Hi Thomas,

The Intel(x86) CPUs have a separate address space for "IO", but the ARM architecture only has "memory", so all IO devices are accessed as if they were memory. Which means ARM does not support isolated IO. Here is a related discussion on ARM's forum.

 https://community.arm.com/support-forums/f/architectures-and-processors-forum/52046/how-to-read-write-an-i-o-port-in-aarch64

Thus, we want to adapt MMIO only after this patch.

On 2023/4/17 下午 07:51, Thomas Zimmermann wrote:
Hi

Am 07.04.23 um 04:09 schrieb Jammy Huang:
Hi Thomas,

Could you help review this patch??

We met some problem on nvidia's ARM platfrom and need this patch to fix it.

On 2023/3/2 上午 10:19, Jammy Huang wrote:
ARM architecture only has 'memory', so all devices are accessed by MMIO.

Signed-off-by: Jammy Huang <jammy_huang@aspeedtech.com>
---
  drivers/gpu/drm/ast/ast_main.c | 17 +----------------
  1 file changed, 1 insertion(+), 16 deletions(-)

diff --git a/drivers/gpu/drm/ast/ast_main.c b/drivers/gpu/drm/ast/ast_main.c
index 794ffd4a29c5..f86d01e9f024 100644
--- a/drivers/gpu/drm/ast/ast_main.c
+++ b/drivers/gpu/drm/ast/ast_main.c
@@ -424,22 +424,7 @@ struct ast_device *ast_device_create(const struct drm_driver *drv,
      if (!ast->regs)
          return ERR_PTR(-EIO);
-    /*
-     * If we don't have IO space at all, use MMIO now and
-     * assume the chip has MMIO enabled by default (rev 0x20
-     * and higher).
-     */
-    if (!(pci_resource_flags(pdev, 2) & IORESOURCE_IO)) {
-        drm_info(dev, "platform has no IO space, trying MMIO\n");
-        ast->ioregs = ast->regs + AST_IO_MM_OFFSET;
-    }
-
-    /* "map" IO regs if the above hasn't done so already */
-    if (!ast->ioregs) {
-        ast->ioregs = pcim_iomap(pdev, 2, 0);

What happens on systems that use this branch?

Best regards
Thomas

-        if (!ast->ioregs)
-            return ERR_PTR(-EIO);
-    }
+    ast->ioregs = ast->regs + AST_IO_MM_OFFSET;
      ast_detect_chip(dev, &need_post);

base-commit: 254986e324add8a30d0019c6da59f81adc8b565f


-- 
Best Regards
Jammy
--------------EV2pfdDpumQngY98BIgbpEql--