From patchwork Tue Oct 25 08:17:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chang, Junxiao" X-Patchwork-Id: 10589 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp879731wru; Tue, 25 Oct 2022 01:33:23 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6QF0jwFQQF9r+Y0MQ0D//AKpPe+ETN9b0G5+EHoA3ejzhiD4JzNuPR3HxEh+0NVVfxXBt9 X-Received: by 2002:a17:90a:ad08:b0:212:d5f1:e0c6 with SMTP id r8-20020a17090aad0800b00212d5f1e0c6mr22279172pjq.228.1666686803280; Tue, 25 Oct 2022 01:33:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666686803; cv=none; d=google.com; s=arc-20160816; b=CGO5ceX/b3GRyNrhylGgpneNtWDRNqxXTXT4P2yyrpxeCuEHqdBffYjoZ55sduTZ3n EHGfiYW66izMYaHqB3p/st6jtNLtWfaMdjgmTdLIY1zuZRFxsPLQEV3YPmOJqk+BanTB 0LfhDcVPXbK4YdpgsUMMJ8VeuG4YyqxZB/OEeGy8sWUb9SCzJEf9rW/Lj28wpiDHhiZq 0ZROatMEdTG5qFhjOJiN7VnfkNG90EbUCsNeCy+wr02/i0PpRJJChuz1sSJtu9H58K8R jiBR3HUjzBpMkg2wQCZRt2VPntIfMhGOJTf5W5x7JhcAnovtE1YnlS6b4CSGAJMqPQzl AM5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=zJxlRLccqST63+cUbXalOb4XhkLqBfaWkBst/1yAIMA=; b=OfJRXlIS8bfIG8vsMrjJkLZjt732zGT8fN/0d8gKvPoYm3Wplc/XrSR1EXFqruIZlR HGgsf40BCZV2JTLAmh6xeqCdMiaxqBhVSwBJ04mE/vINMlWt23E20n7taaklkOYckf/D PlYTo2TTq+Q21h74F+gPwDhTP10GAOQtRcoklmHLPCj+D9qV8FsHG0E1QukUpxDL16Bw y+w3z+BFRGP7IZkdcddnbmHdajzuV/L8RGPGvMgDWVUAQw6O/8wr/iiZzCf0aJt91oLb VneeOppCkwVJkvr5CrkaXrLYACj5m9v+SUxOP64K4HzQTI0quPpXq7ZHDTcnOIm58UDc GIUQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QWUFLDuN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g3-20020a636b03000000b00439e6a52bb4si2240928pgc.620.2022.10.25.01.33.10; Tue, 25 Oct 2022 01:33:23 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=QWUFLDuN; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232240AbiJYI1F (ORCPT + 99 others); Tue, 25 Oct 2022 04:27:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231955AbiJYI1D (ORCPT ); Tue, 25 Oct 2022 04:27:03 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 941DE65FC; Tue, 25 Oct 2022 01:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1666686422; x=1698222422; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=/8wa08b9rvNl5cMcmZVDXdij/gFrnDmrwVc10g0xUnw=; b=QWUFLDuNTW8yN8mZX56u9C94dw4wOn3lzRuiYLAe2ApA8B+L95zCZTAl E2ASSzwh6k0gc+T8AtYZbLflLqtWHHauikpepbt1DZyQl4R67xNGQ2DFB jD7TYSZVn3sfjZl6j8OtPYaZ9ollXr3lXYdOQs5gLXN8HqLxMY1n/zFmJ INAE5jI7oGwYkSvZQ7tP3KwMj3EUdsQCMiC0YETzFGJBQCMUo6YfX0Mae UlhA9iYp5UYgJljd+N9cc8kw6F6tWAwJrFBMgZe9O7R/KneH2+RzEwo3y ibM23yKA4sRX8BtomSnycxIRpKUqRupWBg4X0VE591O/6ZN1vqU+aaT9W w==; X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="307614741" X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="307614741" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2022 01:26:59 -0700 X-IronPort-AV: E=McAfee;i="6500,9779,10510"; a="582697282" X-IronPort-AV: E=Sophos;i="5.95,211,1661842800"; d="scan'208";a="582697282" Received: from junxiaochang.bj.intel.com ([10.238.135.52]) by orsmga003-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Oct 2022 01:26:55 -0700 From: Junxiao Chang To: peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, mcoquelin.stm32@gmail.com, Joao.Pinto@synopsys.com, netdev@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Cc: junxiao.chang@intel.com, veekhee@gmail.com Subject: [PATCH net-next,v2] net: stmmac: remove duplicate dma queue channel macros Date: Tue, 25 Oct 2022 16:17:47 +0800 Message-Id: <20221025081747.1884926-1-junxiao.chang@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_NONE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747638361603807803?= X-GMAIL-MSGID: =?utf-8?q?1747647781199381375?= It doesn't need extra macros for queue 0 & 4. Same macro could be used for all 8 queues. Related queue/channel functions could be combined together. Original macro which has two same parameters is unsafe macro and might have potential side effects. Each MTL RxQ DMA channel mask is 4 bits, so using (0xf << chan) instead of GENMASK(x + 3, x) to avoid unsafe macro. Signed-off-by: Junxiao Chang --- v2: combined "if (queue < 4)" and "else" according to Vee Khee's suggestion. v1: https://lore.kernel.org/r/20221025053555.1883731-1-junxiao.chang@intel.com --- drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 4 +--- .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 21 ++++++------------- 2 files changed, 7 insertions(+), 18 deletions(-) diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h index 71dad409f78b0..ccd49346d3b30 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h @@ -331,9 +331,7 @@ enum power_event { #define MTL_RXQ_DMA_MAP0 0x00000c30 /* queue 0 to 3 */ #define MTL_RXQ_DMA_MAP1 0x00000c34 /* queue 4 to 7 */ -#define MTL_RXQ_DMA_Q04MDMACH_MASK GENMASK(3, 0) -#define MTL_RXQ_DMA_Q04MDMACH(x) ((x) << 0) -#define MTL_RXQ_DMA_QXMDMACH_MASK(x) GENMASK(11 + (8 * ((x) - 1)), 8 * (x)) +#define MTL_RXQ_DMA_QXMDMACH_MASK(x) (0xf << 8 * (x)) #define MTL_RXQ_DMA_QXMDMACH(chan, q) ((chan) << (8 * (q))) #define MTL_CHAN_BASE_ADDR 0x00000d00 diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c index c25bfecb4a2df..513f6ea335a82 100644 --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4_core.c @@ -214,26 +214,17 @@ static void dwmac4_map_mtl_dma(struct mac_device_info *hw, u32 queue, u32 chan) void __iomem *ioaddr = hw->pcsr; u32 value; - if (queue < 4) + if (queue < 4) { value = readl(ioaddr + MTL_RXQ_DMA_MAP0); - else - value = readl(ioaddr + MTL_RXQ_DMA_MAP1); - - if (queue == 0 || queue == 4) { - value &= ~MTL_RXQ_DMA_Q04MDMACH_MASK; - value |= MTL_RXQ_DMA_Q04MDMACH(chan); - } else if (queue > 4) { - value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4); - value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4); - } else { value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue); value |= MTL_RXQ_DMA_QXMDMACH(chan, queue); - } - - if (queue < 4) writel(value, ioaddr + MTL_RXQ_DMA_MAP0); - else + } else { + value = readl(ioaddr + MTL_RXQ_DMA_MAP1); + value &= ~MTL_RXQ_DMA_QXMDMACH_MASK(queue - 4); + value |= MTL_RXQ_DMA_QXMDMACH(chan, queue - 4); writel(value, ioaddr + MTL_RXQ_DMA_MAP1); + } } static void dwmac4_config_cbs(struct mac_device_info *hw,