Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp1149623rwl; Fri, 7 Apr 2023 10:39:14 -0700 (PDT) X-Google-Smtp-Source: AKy350Y7ERIEn1vMThHTTDnHAm9w6oEovtfWb4KaNR+CX/zmHU6RyeKpl5ke715Z2AGla/Yj7nBa X-Received: by 2002:a17:902:fb44:b0:1a1:b440:377d with SMTP id lf4-20020a170902fb4400b001a1b440377dmr2911700plb.2.1680889153821; Fri, 07 Apr 2023 10:39:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1680889153; cv=none; d=google.com; s=arc-20160816; b=bg4/ZKkjFpti0apnKM+woWwvilpT70hKOVQ+YQgdQp0MfgwxC45V2hMOpLvSmmfK84 f2eLFAwgrYXXQ7yIHZfQHN9fjOXrSXLtoS4Ap5B/JQGk+jF+4a/HEpCPkQHjF2lRebRx zD8DZWjGjrGCMxBHmAIdd0DsKIoJOr3QyasWN9Z8IwFjPfRo+fH6FQPd08zYbO8XvLtl RIapNxdaFuvZEcoiefFFqEYIF1mQXK40Fzaps0T7Ihv9uxkJ+vkYsGB2CNaLWJRZ5yJX QWxXHWjxpEmdgWmNUhMvlLssT+gfnJS/Vfw63QYNqkxs1VZJ/dTbRuCzAdH9MzHjSX9M TzHQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=girDT/3e1iBfq8YfqylLYXxjOSDey8dBT/Mp5wOCRPk=; b=KBTD9XAuv354kEqpdjphcxuZIWwIYIhW5+6TZkzMC1qdXhId2FDMIELhIAdovGYVrm 14i1/03l4Kgi82IO8ulLYnrtoc0/Xwi444NDPXwFJdeCkZ0/lCzalgLofRTlZ4I/NDAn JrvMctvkPnp/aLX3DGQEqSB/Mu9DcvHCY6eB+k4Af3/gtDn+efijujRXo9B4hiDiD0Lb zbWeyQW17PEShDw3JpVzgP+eAE2eu4HqiNR8Ztz3faJLN8pfCBwFlHfBVVM4pbR5YcVu g/fTt15er6FubjL9U9VOp5L+TBrLQb+SrMFQCCrsMS/ZQ8KnwKCLYFh5hkk0MMKuAz45 komQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b="UviER/VA"; 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=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l70-20020a638849000000b00507766aea63si4033215pgd.864.2023.04.07.10.39.00; Fri, 07 Apr 2023 10:39:13 -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=@redhat.com header.s=mimecast20190719 header.b="UviER/VA"; 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=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229814AbjDGRg6 (ORCPT + 99 others); Fri, 7 Apr 2023 13:36:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229826AbjDGRg4 (ORCPT ); Fri, 7 Apr 2023 13:36:56 -0400 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6BF3B752 for ; Fri, 7 Apr 2023 10:36:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1680888969; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=girDT/3e1iBfq8YfqylLYXxjOSDey8dBT/Mp5wOCRPk=; b=UviER/VAxClIrkOFWwi9D7NCrDBJUvSROYGQ1n1GlbcD3eYK1ZOU55gCuQNHuZQd7oCPBA JznFj4COT3R6x9pfeprrM/aulUQ+gm53e1u/jv5P/gz7RMZPP0GyNwyvZmHMypdEjhAkeZ /gUD83rvSyfJu+sX1GkRajd71gGS5+s= Received: from mail-ot1-f70.google.com (mail-ot1-f70.google.com [209.85.210.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-623-G1ISPKNXMzyhUhaLRVQkNA-1; Fri, 07 Apr 2023 13:36:08 -0400 X-MC-Unique: G1ISPKNXMzyhUhaLRVQkNA-1 Received: by mail-ot1-f70.google.com with SMTP id f23-20020a056830205700b006a1d2e5b085so8623720otp.14 for ; Fri, 07 Apr 2023 10:36:07 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1680888967; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=girDT/3e1iBfq8YfqylLYXxjOSDey8dBT/Mp5wOCRPk=; b=JY46bEha/4hJKckiuDjWrI2VvsjroOV9bY3S76rXuyGmlmEd4ZfhNUqV+uYnlSHMHX ObJqq+eGLRB7s9NIEodkWnE/enQeW7i+m+NA1aCt6Kj5EhzDoT8rh7O/IyShN6KyIFLh pFLxqyrFu3F1zPMVB4xfPxif/OB0X7CTtyOUwT7ajGImhqqtLFMFdwCAgOJAWt3jS9zg dL46zP4veb9reVCM+WS9a4nHOR00W4QG3V+ZGGKZt8hfEMOK3iafjESQ7nWdw861aAvj PZf2yvmWUrtcHXuFIUkIfNp9bhAyVJWKhchebpsgfOqV0uZJm9O7BmG2/PMT16cx3nZq 4jTw== X-Gm-Message-State: AAQBX9ea4eQwe9bD8DuUT0KLfZzn1DyAUuZLHtf6Ca7RwTej19fXUiP8 oBwo0rbGaiOdN85R/8c8onoycEJK5nWFZPFdTLUHs5Sq0e4Su16qlNX/G3+8Q7Gc5pN7HgiUUG5 J5GP6LlLRO7HSdtmOQiKkHFsB X-Received: by 2002:a05:6870:b690:b0:17f:8da0:ce51 with SMTP id cy16-20020a056870b69000b0017f8da0ce51mr1898777oab.13.1680888967272; Fri, 07 Apr 2023 10:36:07 -0700 (PDT) X-Received: by 2002:a05:6870:b690:b0:17f:8da0:ce51 with SMTP id cy16-20020a056870b69000b0017f8da0ce51mr1898768oab.13.1680888966976; Fri, 07 Apr 2023 10:36:06 -0700 (PDT) Received: from halaney-x13s (104-53-165-62.lightspeed.stlsmo.sbcglobal.net. [104.53.165.62]) by smtp.gmail.com with ESMTPSA id an19-20020a056871b19300b00183fbbe8cdfsm1294396oac.31.2023.04.07.10.36.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 07 Apr 2023 10:36:06 -0700 (PDT) Date: Fri, 7 Apr 2023 12:36:03 -0500 From: Andrew Halaney To: Simon Horman Cc: linux-kernel@vger.kernel.org, agross@kernel.org, andersson@kernel.org, konrad.dybcio@linaro.org, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, vkoul@kernel.org, bhupesh.sharma@linaro.org, wens@csie.org, jernej.skrabec@gmail.com, samuel@sholland.org, mturquette@baylibre.com, peppe.cavallaro@st.com, alexandre.torgue@foss.st.com, joabreu@synopsys.com, mcoquelin.stm32@gmail.com, richardcochran@gmail.com, linux@armlinux.org.uk, veekhee@apple.com, tee.min.tan@linux.intel.com, mohammad.athari.ismail@intel.com, jonathanh@nvidia.com, ruppala@nvidia.com, bmasney@redhat.com, andrey.konovalov@linaro.org, linux-arm-msm@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, ncai@quicinc.com, jsuraj@qti.qualcomm.com, hisunil@quicinc.com, echanude@redhat.com Subject: Re: [PATCH net-next v3 09/12] net: stmmac: dwmac4: Allow platforms to specify some DMA/MTL offsets Message-ID: <20230407173603.lyj5fjox23uhn2gb@halaney-x13s> References: <20230331214549.756660-1-ahalaney@redhat.com> <20230331214549.756660-10-ahalaney@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-0.2 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_NONE autolearn=unavailable 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 On Sat, Apr 01, 2023 at 04:58:59PM +0200, Simon Horman wrote: > On Fri, Mar 31, 2023 at 04:45:46PM -0500, Andrew Halaney wrote: > > Some platforms have dwmac4 implementations that have a different > > address space layout than the default, resulting in the need to define > > their own DMA/MTL offsets. > > > > Extend the functions to allow a platform driver to indicate what its > > addresses are, overriding the defaults. > > > > Signed-off-by: Andrew Halaney > > --- > > > > This patch (and the prior patch) are replacements for > > https://lore.kernel.org/netdev/20230320204153.21736840@kernel.org/ > > as was requested. Hopefully I was understanding the intent correctly :) > > > > I'm pretty sure further refinement will be requested for this one, but > > it is the best I could come up with myself! Specifically some of the > > naming, dealing with spacing in some older spots of dwmac4, > > where the addresses should live in the structure hierarchy, etc are > > things I would not be surprised to have to rework if this is still > > preferred over the wrapper approach. > > > > Changes since v2: > > * New, replacing old wrapper approach > > > > drivers/net/ethernet/stmicro/stmmac/dwmac4.h | 91 ++++++++-- > > .../net/ethernet/stmicro/stmmac/dwmac4_core.c | 36 ++-- > > .../net/ethernet/stmicro/stmmac/dwmac4_dma.c | 157 ++++++++++-------- > > .../net/ethernet/stmicro/stmmac/dwmac4_dma.h | 51 +++--- > > .../net/ethernet/stmicro/stmmac/dwmac4_lib.c | 67 +++++--- > > include/linux/stmmac.h | 19 +++ > > 6 files changed, 279 insertions(+), 142 deletions(-) > > > > diff --git a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h > > index ccd49346d3b3..a0c0ee1dc13f 100644 > > --- a/drivers/net/ethernet/stmicro/stmmac/dwmac4.h > > +++ b/drivers/net/ethernet/stmicro/stmmac/dwmac4.h > > @@ -336,14 +336,23 @@ enum power_event { > > > > #define MTL_CHAN_BASE_ADDR 0x00000d00 > > #define MTL_CHAN_BASE_OFFSET 0x40 > > -#define MTL_CHANX_BASE_ADDR(x) (MTL_CHAN_BASE_ADDR + \ > > - (x * MTL_CHAN_BASE_OFFSET)) > > - > > -#define MTL_CHAN_TX_OP_MODE(x) MTL_CHANX_BASE_ADDR(x) > > -#define MTL_CHAN_TX_DEBUG(x) (MTL_CHANX_BASE_ADDR(x) + 0x8) > > -#define MTL_CHAN_INT_CTRL(x) (MTL_CHANX_BASE_ADDR(x) + 0x2c) > > -#define MTL_CHAN_RX_OP_MODE(x) (MTL_CHANX_BASE_ADDR(x) + 0x30) > > -#define MTL_CHAN_RX_DEBUG(x) (MTL_CHANX_BASE_ADDR(x) + 0x38) > > +#define MTL_CHANX_BASE_ADDR(addrs, x) \ > > +({ \ > > + const struct dwmac4_addrs *__addrs = addrs; \ > > + const u32 __x = x; \ > > + u32 __addr; \ > > + if (__addrs) \ > > + __addr = __addrs->mtl_chan + (__x * __addrs->mtl_chan_offset); \ > > + else \ > > + __addr = MTL_CHAN_BASE_ADDR + (__x * MTL_CHAN_BASE_OFFSET); \ > > + __addr; \ > > +}) > > Could this and similar macros added by this patch be functions? > From my pov a benefit would be slightly more type safety. > And as a bonus there wouldn't be any need to handle aliasing of input. > Sure, to be honest I'll be much more comfortable coding that up anyways. I don't do a ton of macro programming and had to refamiliarize myself of the pitfalls that comes with it when doing this. Thanks, Andrew