Received: by 2002:a05:6a10:a841:0:0:0:0 with SMTP id d1csp249836pxy; Thu, 22 Apr 2021 00:57:59 -0700 (PDT) X-Google-Smtp-Source: ABdhPJx38EBkGdhISGftaydJ1tsDVFl9Tx/rPWtPe7WJdQI9Ecu4e5juta4TODrDaoYNGxwFAHcS X-Received: by 2002:a17:903:10a:b029:eb:1fd1:ca0 with SMTP id y10-20020a170903010ab02900eb1fd10ca0mr2129597plc.71.1619078279772; Thu, 22 Apr 2021 00:57:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1619078279; cv=none; d=google.com; s=arc-20160816; b=S6rMmkCgApOxNwGpJ+BUGXfxs0o43lskEa8Y9BPFUiS0sX8LMFmQpTH3/zvuklThgp 9Zh+nGoJncDzUPYAwBT6fqgzm7KzQMR7maabw8ROVhxj/yHw4+vozO6DGvk1MkTy2e9x H4Tk/GOr6qmfUCWWkqhf/Ujr02oaN1WzE9jEJg9ajZLQpyDkwS2eopIl9s2NxbnLBcno dHucml+du0KBaO8Nd3BR9PRCStLgRFiYxs4TAeBwlfRrvCfRh6mURHxX8Z6ztNGAOGXL GwQVp3hibfBUXHMfLqaN48I7vS1kMx2ThLsGQcjwcMWZ7YU4LvFESfP+YztQ1UMYkK7c SnAg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:ironport-sdr:ironport-sdr; bh=eh0C9dNTJ5gNsqtJGcDHt9slPK2Hz1jbRYp6FvBAy2U=; b=E/yZynkkl+Ia6caA+dSR6N/N99g8ILVaxCITU6COs7XXKhziGWthe0KYduwm5PAO/6 POS6k7/slouAHE7dKEItj1VjPMECFVIHKJo/1UQCtVfrOpOuT7jo7ToAz+WpUxVYVsyJ ayiTGP1CX3jLbw8ly82wwdLluRKR0M0MvUJuEX1bT4BvF+OqPzqMlV9Eavua6lzt/9CX ym4v6tBsbGW0HWZfjjc8g8ouJR/QvuZOPW4uHd8dBchmlnrhmeQRXFt4RCtWIfc16rBo xc2CaeCjVLX7b/v+Bgd/TUOO66lb3aA8pcEa7TQO98a4mjojeDRVLAQmBdRCv8nes4gp LD1w== ARC-Authentication-Results: i=1; mx.google.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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q19si2234734plc.35.2021.04.22.00.57.47; Thu, 22 Apr 2021 00:57:59 -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; 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=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235191AbhDVH4V (ORCPT + 99 others); Thu, 22 Apr 2021 03:56:21 -0400 Received: from mga09.intel.com ([134.134.136.24]:8505 "EHLO mga09.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235199AbhDVH4R (ORCPT ); Thu, 22 Apr 2021 03:56:17 -0400 IronPort-SDR: IWQTsdUBrYA6/ki/gn5aJzgS3H7+R0qNn6RiAYXMQTQwlvbSHpf84zpYZR02SGnogWDfIGvqVj olI3QptfVNyw== X-IronPort-AV: E=McAfee;i="6200,9189,9961"; a="195956901" X-IronPort-AV: E=Sophos;i="5.82,241,1613462400"; d="scan'208";a="195956901" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga102.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Apr 2021 00:55:26 -0700 IronPort-SDR: 3yacpQxB6L/NSiXSXupZf+23nvxDoTzQMn3FoyJZZGun3pgzQW53tfxRS+IK+NkcG9RcrkxDH6 NYhxm/Uu61NA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,242,1613462400"; d="scan'208";a="421282393" Received: from mismail5-ilbpg0.png.intel.com ([10.88.229.82]) by fmsmga008.fm.intel.com with ESMTP; 22 Apr 2021 00:55:22 -0700 From: mohammad.athari.ismail@intel.com To: Giuseppe Cavallaro , Alexandre Torgue , Jose Abreu , "David S . Miller" , Jakub Kicinski , Maxime Coquelin , Chuah@vger.kernel.org, Kim Tatt Cc: Ong Boon Leong , Voon Weifeng , Wong Vee Khee , Tan Tee Min , netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, mohammad.athari.ismail@intel.com Subject: [PATCH net-next 1/2] net: stmmac: Add HW descriptor prefetch setting for DWMAC Core 5.20 onwards Date: Thu, 22 Apr 2021 15:55:00 +0800 Message-Id: <20210422075501.20207-2-mohammad.athari.ismail@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20210422075501.20207-1-mohammad.athari.ismail@intel.com> References: <20210422075501.20207-1-mohammad.athari.ismail@intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mohammad Athari Bin Ismail DWMAC Core 5.20 onwards supports HW descriptor prefetching. Additionally, it also depends on platform specific RTL configuration. This capability could be enabled by setting DMA_Mode bit-19 (DCHE). So, to enable this cability, platform must set plat->dma_cfg->dche = true and the DWMAC core version must be 5.20 onwards. Else, this capability wouldn`t be configured Signed-off-by: Mohammad Athari Bin Ismail --- drivers/net/ethernet/stmicro/stmmac/common.h | 1 + drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c | 10 ++++++++-- drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h | 1 + drivers/net/ethernet/stmicro/stmmac/stmmac_main.c | 5 +++++ include/linux/stmmac.h | 1 + 5 files changed, 16 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/common.h b/drivers/net/ethernet/stmicro/stmmac/common.h index c54a56b732b3..619e3c0760d6 100644 --- a/drivers/net/ethernet/stmicro/stmmac/common.h +++ b/drivers/net/ethernet/stmicro/stmmac/common.h @@ -33,6 +33,7 @@ #define DWMAC_CORE_4_10 0x41 #define DWMAC_CORE_5_00 0x50 #define DWMAC_CORE_5_10 0x51 +#define DWMAC_CORE_5_20 0x52 #define DWXGMAC_CORE_2_10 0x21 #define DWXLGMAC_CORE_2_00 0x20 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c index cb17f6c35e54..a602d16b9e53 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.c @@ -162,12 +162,18 @@ static void dwmac4_dma_init(void __iomem *ioaddr, writel(value, ioaddr + DMA_SYS_BUS_MODE); + value = readl(ioaddr + DMA_BUS_MODE); + if (dma_cfg->multi_msi_en) { - value = readl(ioaddr + DMA_BUS_MODE); value &= ~DMA_BUS_MODE_INTM_MASK; value |= (DMA_BUS_MODE_INTM_MODE1 << DMA_BUS_MODE_INTM_SHIFT); - writel(value, ioaddr + DMA_BUS_MODE); } + + if (dma_cfg->dche) + value |= DMA_BUS_MODE_DCHE; + + writel(value, ioaddr + DMA_BUS_MODE); + } static void _dwmac4_dump_dma_regs(void __iomem *ioaddr, u32 channel, diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h index 05481eb13ba6..9321879b599c 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_dma.h @@ -25,6 +25,7 @@ #define DMA_TBS_CTRL 0x00001050 /* DMA Bus Mode bitmap */ +#define DMA_BUS_MODE_DCHE BIT(19) #define DMA_BUS_MODE_INTM_MASK GENMASK(17, 16) #define DMA_BUS_MODE_INTM_SHIFT 16 #define DMA_BUS_MODE_INTM_MODE1 0x1 diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c index d1ca07c846e6..372090e8ee6f 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_main.c @@ -6849,6 +6849,11 @@ int stmmac_dvr_probe(struct device *device, if (ret) goto error_hw_init; + /* Only DWMAC core version 5.20 onwards supports HW descriptor prefetch. + */ + if (priv->synopsys_id < DWMAC_CORE_5_20) + priv->plat->dma_cfg->dche = false; + stmmac_check_ether_addr(priv); ndev->netdev_ops = &stmmac_netdev_ops; diff --git a/include/linux/stmmac.h b/include/linux/stmmac.h index 97edb31d6310..0db36360ef21 100644 --- a/include/linux/stmmac.h +++ b/include/linux/stmmac.h @@ -97,6 +97,7 @@ struct stmmac_dma_cfg { bool aal; bool eame; bool multi_msi_en; + bool dche; }; #define AXI_BLEN 7 -- 2.17.1