diff mbox series

[net-next,2/3] net: stmmac: Allow drivers to provide a default AXI configuration

Message ID 20240201-stmmac-axi-config-v1-2-822e97b2d26e@nvidia.com (mailing list archive)
State New, archived
Headers show
Series net: stmmac: Allow driver-specific AXI configuration | expand

Commit Message

Thierry Reding Feb. 1, 2024, 6:49 p.m. UTC
From: Thierry Reding <treding@nvidia.com>

In many cases the AXI configuration can be derived from the compatible
string, so there's no need to add the configuration to DT. Allow drivers
to pass in the default AXI configuration so they can be properly set up
without extra data in DT.

Signed-off-by: Thierry Reding <treding@nvidia.com>
---
 drivers/net/ethernet/stmicro/stmmac/stmmac.h       |  2 +
 .../net/ethernet/stmicro/stmmac/stmmac_platform.c  | 47 ++++++++++++++--------
 2 files changed, 33 insertions(+), 16 deletions(-)

Comments

kernel test robot Feb. 3, 2024, 11:59 a.m. UTC | #1
Hi Thierry,

kernel test robot noticed the following build warnings:

[auto build test WARNING on 51b70ff55ed88edd19b080a524063446bcc34b62]

url:    https://github.com/intel-lab-lkp/linux/commits/Thierry-Reding/net-stmmac-Pass-resources-to-DT-parsing-code/20240202-025357
base:   51b70ff55ed88edd19b080a524063446bcc34b62
patch link:    https://lore.kernel.org/r/20240201-stmmac-axi-config-v1-2-822e97b2d26e%40nvidia.com
patch subject: [PATCH net-next 2/3] net: stmmac: Allow drivers to provide a default AXI configuration
config: m68k-allyesconfig (https://download.01.org/0day-ci/archive/20240203/202402031948.IySiUm4u-lkp@intel.com/config)
compiler: m68k-linux-gcc (GCC) 13.2.0
reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20240203/202402031948.IySiUm4u-lkp@intel.com/reproduce)

If you fix the issue in a separate patch/commit (i.e. not just a new version of
the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <lkp@intel.com>
| Closes: https://lore.kernel.org/oe-kbuild-all/202402031948.IySiUm4u-lkp@intel.com/

All warnings (new ones prefixed by >>):

>> drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c:96: warning: Function parameter or struct member 'res' not described in 'stmmac_axi_setup'


vim +96 drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c

3b57de958e2aa3 Vince Bridgers     2014-07-31   86  
afea03656add70 Giuseppe Cavallaro 2016-02-29   87  /**
afea03656add70 Giuseppe Cavallaro 2016-02-29   88   * stmmac_axi_setup - parse DT parameters for programming the AXI register
afea03656add70 Giuseppe Cavallaro 2016-02-29   89   * @pdev: platform device
afea03656add70 Giuseppe Cavallaro 2016-02-29   90   * Description:
afea03656add70 Giuseppe Cavallaro 2016-02-29   91   * if required, from device-tree the AXI internal register can be tuned
afea03656add70 Giuseppe Cavallaro 2016-02-29   92   * by using platform parameters.
afea03656add70 Giuseppe Cavallaro 2016-02-29   93   */
af49f82367c1e3 Thierry Reding     2024-02-01   94  static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev,
af49f82367c1e3 Thierry Reding     2024-02-01   95  					   struct stmmac_resources *res)
afea03656add70 Giuseppe Cavallaro 2016-02-29  @96  {
afea03656add70 Giuseppe Cavallaro 2016-02-29   97  	struct device_node *np;
afea03656add70 Giuseppe Cavallaro 2016-02-29   98  	struct stmmac_axi *axi;
afea03656add70 Giuseppe Cavallaro 2016-02-29   99  
afea03656add70 Giuseppe Cavallaro 2016-02-29  100  	np = of_parse_phandle(pdev->dev.of_node, "snps,axi-config", 0);
af49f82367c1e3 Thierry Reding     2024-02-01  101  	if (!np && !res->axi)
afea03656add70 Giuseppe Cavallaro 2016-02-29  102  		return NULL;
afea03656add70 Giuseppe Cavallaro 2016-02-29  103  
64f48e593a54a8 Joao Pinto         2017-03-07  104  	axi = devm_kzalloc(&pdev->dev, sizeof(*axi), GFP_KERNEL);
4613b279bee795 Peter Chen         2016-08-01  105  	if (!axi) {
af49f82367c1e3 Thierry Reding     2024-02-01  106  		if (np)
4613b279bee795 Peter Chen         2016-08-01  107  			of_node_put(np);
af49f82367c1e3 Thierry Reding     2024-02-01  108  
afea03656add70 Giuseppe Cavallaro 2016-02-29  109  		return ERR_PTR(-ENOMEM);
4613b279bee795 Peter Chen         2016-08-01  110  	}
afea03656add70 Giuseppe Cavallaro 2016-02-29  111  
af49f82367c1e3 Thierry Reding     2024-02-01  112  	if (res->axi)
af49f82367c1e3 Thierry Reding     2024-02-01  113  		*axi = *res->axi;
af49f82367c1e3 Thierry Reding     2024-02-01  114  
af49f82367c1e3 Thierry Reding     2024-02-01  115  	if (np) {
afea03656add70 Giuseppe Cavallaro 2016-02-29  116  		axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
afea03656add70 Giuseppe Cavallaro 2016-02-29  117  		axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
61d4f140943c47 Jisheng Zhang      2022-12-03  118  		axi->axi_kbbe = of_property_read_bool(np, "snps,kbbe");
61d4f140943c47 Jisheng Zhang      2022-12-03  119  		axi->axi_fb = of_property_read_bool(np, "snps,fb");
61d4f140943c47 Jisheng Zhang      2022-12-03  120  		axi->axi_mb = of_property_read_bool(np, "snps,mb");
61d4f140943c47 Jisheng Zhang      2022-12-03  121  		axi->axi_rb =  of_property_read_bool(np, "snps,rb");
afea03656add70 Giuseppe Cavallaro 2016-02-29  122  
af49f82367c1e3 Thierry Reding     2024-02-01  123  		if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt)) {
af49f82367c1e3 Thierry Reding     2024-02-01  124  			if (!res->axi)
6b3374cb1c0bd4 Niklas Cassel      2016-12-05  125  				axi->axi_wr_osr_lmt = 1;
af49f82367c1e3 Thierry Reding     2024-02-01  126  		}
af49f82367c1e3 Thierry Reding     2024-02-01  127  
af49f82367c1e3 Thierry Reding     2024-02-01  128  		if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt)) {
af49f82367c1e3 Thierry Reding     2024-02-01  129  			if (!res->axi)
6b3374cb1c0bd4 Niklas Cassel      2016-12-05  130  				axi->axi_rd_osr_lmt = 1;
af49f82367c1e3 Thierry Reding     2024-02-01  131  		}
af49f82367c1e3 Thierry Reding     2024-02-01  132  
afea03656add70 Giuseppe Cavallaro 2016-02-29  133  		of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
af49f82367c1e3 Thierry Reding     2024-02-01  134  
4613b279bee795 Peter Chen         2016-08-01  135  		of_node_put(np);
af49f82367c1e3 Thierry Reding     2024-02-01  136  	}
afea03656add70 Giuseppe Cavallaro 2016-02-29  137  
afea03656add70 Giuseppe Cavallaro 2016-02-29  138  	return axi;
afea03656add70 Giuseppe Cavallaro 2016-02-29  139  }
afea03656add70 Giuseppe Cavallaro 2016-02-29  140
diff mbox series

Patch

diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac.h b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
index f155e4841c62..07706e7b3cfc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac.h
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac.h
@@ -35,6 +35,8 @@  struct stmmac_resources {
 	int sfty_ue_irq;
 	int rx_irq[MTL_MAX_RX_QUEUES];
 	int tx_irq[MTL_MAX_TX_QUEUES];
+
+	const struct stmmac_axi *axi;
 };
 
 enum stmmac_txbuf_type {
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
index 8ec2ac28a775..0d5f2cebd6fc 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_platform.c
@@ -91,34 +91,49 @@  static int dwmac1000_validate_ucast_entries(struct device *dev,
  * if required, from device-tree the AXI internal register can be tuned
  * by using platform parameters.
  */
-static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev)
+static struct stmmac_axi *stmmac_axi_setup(struct platform_device *pdev,
+					   struct stmmac_resources *res)
 {
 	struct device_node *np;
 	struct stmmac_axi *axi;
 
 	np = of_parse_phandle(pdev->dev.of_node, "snps,axi-config", 0);
-	if (!np)
+	if (!np && !res->axi)
 		return NULL;
 
 	axi = devm_kzalloc(&pdev->dev, sizeof(*axi), GFP_KERNEL);
 	if (!axi) {
-		of_node_put(np);
+		if (np)
+			of_node_put(np);
+
 		return ERR_PTR(-ENOMEM);
 	}
 
-	axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
-	axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
-	axi->axi_kbbe = of_property_read_bool(np, "snps,kbbe");
-	axi->axi_fb = of_property_read_bool(np, "snps,fb");
-	axi->axi_mb = of_property_read_bool(np, "snps,mb");
-	axi->axi_rb =  of_property_read_bool(np, "snps,rb");
-
-	if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt))
-		axi->axi_wr_osr_lmt = 1;
-	if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt))
-		axi->axi_rd_osr_lmt = 1;
-	of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
-	of_node_put(np);
+	if (res->axi)
+		*axi = *res->axi;
+
+	if (np) {
+		axi->axi_lpi_en = of_property_read_bool(np, "snps,lpi_en");
+		axi->axi_xit_frm = of_property_read_bool(np, "snps,xit_frm");
+		axi->axi_kbbe = of_property_read_bool(np, "snps,kbbe");
+		axi->axi_fb = of_property_read_bool(np, "snps,fb");
+		axi->axi_mb = of_property_read_bool(np, "snps,mb");
+		axi->axi_rb =  of_property_read_bool(np, "snps,rb");
+
+		if (of_property_read_u32(np, "snps,wr_osr_lmt", &axi->axi_wr_osr_lmt)) {
+			if (!res->axi)
+				axi->axi_wr_osr_lmt = 1;
+		}
+
+		if (of_property_read_u32(np, "snps,rd_osr_lmt", &axi->axi_rd_osr_lmt)) {
+			if (!res->axi)
+				axi->axi_rd_osr_lmt = 1;
+		}
+
+		of_property_read_u32_array(np, "snps,blen", axi->axi_blen, AXI_BLEN);
+
+		of_node_put(np);
+	}
 
 	return axi;
 }