Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp1349510ybz; Wed, 29 Apr 2020 20:27:17 -0700 (PDT) X-Google-Smtp-Source: APiQypJ2JX68nGcPX5ljguizR/KLrCi073ruudK+UHz93Uw3N1cRzfvv6oHeDOgewdH1WULOH3+Q X-Received: by 2002:a17:906:300a:: with SMTP id 10mr804057ejz.139.1588217236944; Wed, 29 Apr 2020 20:27:16 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1588217236; cv=pass; d=google.com; s=arc-20160816; b=zLcP2suLKAgqNSaTNiauJ4WTzuHfG0mO6OlBxFXtWunwAF/QLAKOrBXKVvudbNjC39 YzMqrItoB+OvU3HzuthAKtddEJcgpqwDhL8RcyQqpL5Oh21rtFyFxDaPiXilwlLnHM9+ X+evmqr0Bsa8MzGw/yZacsCk1ZVeLuyc5+fhQp06+L4NJMyYSKQA9JT7SmFfKpV6hH4y uZ4DothvoVJ/GRqbAguYgO+UY18zFRDX0MXyqY2S/KnaQcDI2ZdFhr5dh4Ttdfk4OcRx AI9hDwgb1YSPl26kMXDpwiu3q0W/Fd4+7ofBQtIKO0UgV0yUFMCZ6Sq+a4NF/N+fXd+r 6RQg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:references:in-reply-to:reply-to:user-agent:subject:cc:to :from:date:dkim-signature; bh=eLjXJXbz1KqXBB+PX8paWXxS+pm36WZwqQB5RB0gzc4=; b=LfPwRFhGDLaP5+QS5WmYtxOaealMVK2FjZtSUHg4npuXqW0uFHBik2CXIUT5shO2/Q 7wngR5N9gP99iap5fmgQZAvGjCm4lCMOK00VSHsoi0HE4JRCJ7N3Yy2BLiLP3mPWGcys 4sKdRu1Osy37xaGlOncsf1RHiP2YUs3CQMegBjM/maOVCfsjoFBYVjjXLCGayANhtGx7 gLOUGxPCjvYQIVTznpbzrrAHeMi19xGn8srKixEnqLme3mvgXCmo5o+9IOGaL1lduQAM 9tcMMmR4MJcxWK/AULRlWCHIWZ44CSaethxD6T7d5d4M+M04c/1ZRWHzXDr4I1Bz3bTH 8D1g== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=NlihTNgy; arc=pass (i=1 spf=pass spfdomain=flygoat.com dkim=pass dkdomain=flygoat.com dmarc=pass fromdomain=flygoat.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lu44si4933005ejb.394.2020.04.29.20.26.53; Wed, 29 Apr 2020 20:27:16 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=mail header.b=NlihTNgy; arc=pass (i=1 spf=pass spfdomain=flygoat.com dkim=pass dkdomain=flygoat.com dmarc=pass fromdomain=flygoat.com>); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726590AbgD3DYT (ORCPT + 99 others); Wed, 29 Apr 2020 23:24:19 -0400 Received: from sender3-op-o12.zoho.com.cn ([124.251.121.243]:17787 "EHLO sender3-op-o12.zoho.com.cn" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726431AbgD3DYT (ORCPT ); Wed, 29 Apr 2020 23:24:19 -0400 ARC-Seal: i=1; a=rsa-sha256; t=1588217013; cv=none; d=zoho.com.cn; s=zohoarc; b=GIo2wREN+iNYh7ww3JMjajB8fxE2ua7+9eAs2AL5CT7kU1kY9mZDvCKr6NgwxprjtHBiWDPTiQU771eFHpC+DpbEuxNXXS+sP75I2jBMdaSp1LltXrRti87iOZN8BJPS5cWGdUiVVLaeJe7FrDCQos0NGBLxxGg23EJvizq7dYM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com.cn; s=zohoarc; t=1588217013; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:Reply-To:References:Subject:To; bh=eLjXJXbz1KqXBB+PX8paWXxS+pm36WZwqQB5RB0gzc4=; b=kU35dfu1ZfVQUBXZZYa/xnUZyK7EXz20woVjX7+YcIbjQLoSpDdwOvBT9+u6lOMjaYaFA1JZCY/PN60O5Fx7NF0jzGgYPzOrvgVcHa5lEYXcwpGhSTtjzuele+/aawHieY6gLrYbllkD46vSC+Z+EMXu176E8c1rJ4D3TIhFwAM= ARC-Authentication-Results: i=1; mx.zoho.com.cn; dkim=pass header.i=flygoat.com; spf=pass smtp.mailfrom=jiaxun.yang@flygoat.com; dmarc=pass header.from= header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1588217013; s=mail; d=flygoat.com; i=jiaxun.yang@flygoat.com; h=Date:From:To:CC:Subject:Reply-to:In-Reply-To:References:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding; bh=eLjXJXbz1KqXBB+PX8paWXxS+pm36WZwqQB5RB0gzc4=; b=NlihTNgyqLczwA1v+v1MFrPx1/vo9MoD705bQsciEhRGnl7foAbLiH/TLwUNZ9Hk P6egaA6nD1FXiwLWLiHztFWMKVQ5DAes5SX0myXg/8RZLNg4F4yqmHhWeMhUb5JnSWj rkj8EjijCQzYuML/KpfT/MhrqgaJhl1rM9QZ8cKE= Received: from [127.0.0.1] (115.205.241.207 [115.205.241.207]) by mx.zoho.com.cn with SMTPS id 1588217010321100.41453220362018; Thu, 30 Apr 2020 11:23:30 +0800 (CST) Date: Thu, 30 Apr 2020 11:23:25 +0800 From: Jiaxun Yang To: Tiezhu Yang , Thomas Bogendoerfer , Christoph Hellwig , Huacai Chen CC: linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org, Xuefeng Li Subject: Re: [PATCH v6] MIPS: Loongson: Add DMA support for LS7A User-Agent: K-9 Mail for Android Reply-to: jiaxun.yang@flygoat.com In-Reply-To: <1588213867-32274-1-git-send-email-yangtiezhu@loongson.cn> References: <1588213867-32274-1-git-send-email-yangtiezhu@loongson.cn> Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-ZohoCNMailClient: External Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =E4=BA=8E 2020=E5=B9=B44=E6=9C=8830=E6=97=A5 GMT+08:00 =E4=B8=8A=E5=8D=881= 0:31:07, Tiezhu Yang =E5=86=99=E5=88=B0: >In the current market, the most used bridge chip on the Loongson >platform are RS780E and LS7A, the RS780E bridge chip is already >supported by the mainline kernel=2E > >In order to use the default implementation of __phys_to_dma() and >__dma_to_phys() in dma-direct=2Eh, remove CONFIG_ARCH_HAS_PHYS_TO_DMA >and then set the bus's DMA limit to 36 bit for RS780E to maintain >downward compatibility=2E > >Signed-off-by: Tiezhu Yang >--- > >Hi Christoph and Jiaxun, > >Thank you very much for your suggestions=2E I'm probably going to refine this before we implement full devicetree boot= , but that's in far future=2E LGTM to me for now=2E Thanks=2E Reviewed-by: Jiaxun Yang > >v5: > - use the default implementation of __phys_to_dma() > and __dma_to_phys() in dma-direct=2Eh > >v6: > - make loongson_dma_config() static > - put ls7a things before rs780 things > > arch/mips/Kconfig | 1 - > arch/mips/include/asm/mach-loongson64/boot_param=2Eh | 5 +++++ > arch/mips/loongson64/dma=2Ec | 22 +++++++++++---= -------- > arch/mips/loongson64/env=2Ec | 2 ++ > 4 files changed, 18 insertions(+), 12 deletions(-) > >diff --git a/arch/mips/Kconfig b/arch/mips/Kconfig >index 9f15539=2E=2E12b6bdb 100644 >--- a/arch/mips/Kconfig >+++ b/arch/mips/Kconfig >@@ -1454,7 +1454,6 @@ choice > config CPU_LOONGSON64 > bool "Loongson 64-bit CPU" > depends on SYS_HAS_CPU_LOONGSON64 >- select ARCH_HAS_PHYS_TO_DMA > select CPU_MIPSR2 > select CPU_HAS_PREFETCH > select CPU_SUPPORTS_64BIT_KERNEL >diff --git a/arch/mips/include/asm/mach-loongson64/boot_param=2Eh b/arch/= mips/include/asm/mach-loongson64/boot_param=2Eh >index f082d87=2E=2E0c07a96 100644 >--- a/arch/mips/include/asm/mach-loongson64/boot_param=2Eh >+++ b/arch/mips/include/asm/mach-loongson64/boot_param=2Eh >@@ -197,6 +197,7 @@ enum loongson_bridge_type { > RS780E =3D 2 > }; >=20 >+struct pci_dev; > struct loongson_system_configuration { > u32 nr_cpus; > u32 nr_nodes; >@@ -221,9 +222,13 @@ struct loongson_system_configuration { > u32 nr_sensors; > struct sensor_device sensors[MAX_SENSORS]; > u64 workarounds; >+ void (*dma_config)(struct pci_dev *pdev); > }; >=20 > extern struct efi_memory_map_loongson *loongson_memmap; > extern struct loongson_system_configuration loongson_sysconf; >=20 >+extern void ls7a_dma_config(struct pci_dev *pdev); >+extern void rs780e_dma_config(struct pci_dev *pdev); >+ > #endif >diff --git a/arch/mips/loongson64/dma=2Ec b/arch/mips/loongson64/dma=2Ec >index 5e86635=2E=2Eef40b0d 100644 >--- a/arch/mips/loongson64/dma=2Ec >+++ b/arch/mips/loongson64/dma=2Ec >@@ -1,24 +1,24 @@ > // SPDX-License-Identifier: GPL-2=2E0 >-#include >+#include > #include > #include >=20 >-dma_addr_t __phys_to_dma(struct device *dev, phys_addr_t paddr) >+void ls7a_dma_config(struct pci_dev *pdev) > { >- /* We extract 2bit node id (bit 44~47, only bit 44~45 used now) from >- * Loongson-3's 48bit address space and embed it into 40bit */ >- long nid =3D (paddr >> 44) & 0x3; >- return ((nid << 44) ^ paddr) | (nid << 37); > } >=20 >-phys_addr_t __dma_to_phys(struct device *dev, dma_addr_t daddr) >+void rs780e_dma_config(struct pci_dev *pdev) > { >- /* We extract 2bit node id (bit 44~47, only bit 44~45 used now) from >- * Loongson-3's 48bit address space and embed it into 40bit */ >- long nid =3D (daddr >> 37) & 0x3; >- return ((nid << 37) ^ daddr) | (nid << 44); >+ pdev->dev=2Ebus_dma_limit =3D DMA_BIT_MASK(36); > } >=20 >+static void loongson_dma_config(struct pci_dev *pdev) >+{ >+ loongson_sysconf=2Edma_config(pdev); >+} >+ >+DECLARE_PCI_FIXUP_EARLY(PCI_ANY_ID, PCI_ANY_ID, loongson_dma_config); >+ > void __init plat_swiotlb_setup(void) > { > swiotlb_init(1); >diff --git a/arch/mips/loongson64/env=2Ec b/arch/mips/loongson64/env=2Ec >index 71f4aaf=2E=2E496f401 100644 >--- a/arch/mips/loongson64/env=2Ec >+++ b/arch/mips/loongson64/env=2Ec >@@ -192,8 +192,10 @@ void __init prom_init_env(void) > if (vendor =3D=3D PCI_VENDOR_ID_LOONGSON && device =3D=3D 0x7a00) { > pr_info("The bridge chip is LS7A\n"); > loongson_sysconf=2Ebridgetype =3D LS7A; >+ loongson_sysconf=2Edma_config =3D ls7a_dma_config; > } else { > pr_info("The bridge chip is RS780E or SR5690\n"); > loongson_sysconf=2Ebridgetype =3D RS780E; >+ loongson_sysconf=2Edma_config =3D rs780e_dma_config; > } > } --=20 Jiaxun Yang