netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: <Nicolas.Ferre@microchip.com>
To: <palmer@sifive.com>, <harini.katakam@xilinx.com>
Cc: <davem@davemloft.net>, <netdev@vger.kernel.org>,
	<linux-kernel@vger.kernel.org>, <michal.simek@xilinx.com>
Subject: Re: [PATCH 1/2] net: macb: Fix compilation on systems without COMMON_CLK
Date: Mon, 24 Jun 2019 15:22:41 +0000	[thread overview]
Message-ID: <8bf8f052-cb9e-a4a6-4a7f-584cbd20582d@microchip.com> (raw)
In-Reply-To: <mhng-ac6d3a1f-07a8-40b5-a4ad-93e529ecc206@palmer-si-x1e>

On 24/06/2019 at 11:57, Palmer Dabbelt wrote:
> External E-Mail
> 
> 
> On Mon, 24 Jun 2019 02:40:21 PDT (-0700), Nicolas.Ferre@microchip.com wrote:
>> On 24/06/2019 at 08:16, Palmer Dabbelt wrote:
>>> External E-Mail
>>>
>>>
>>> The patch to add support for the FU540-C000 added a dependency on
>>> COMMON_CLK, but didn't express that via Kconfig.  This fixes the build
>>> failure by adding CONFIG_MACB_FU540, which depends on COMMON_CLK and
>>> conditionally enables the FU540-C000 support.
>>
>> Let's try to limit the use of  #ifdef's throughout the code. We are
>> using them in this driver but only for the hot paths and things that
>> have an impact on performance. I don't think it's the case here: so
>> please find another option => NACK.
> 
> OK.  Would you accept adding a Kconfig dependency of the generic MACB driver on
> COMMON_CLK, as suggested in the cover letter?

Yes: all users of this peripheral have COMMON_CLK set.
You can remove it from the PCI wrapper then.

Best regards,
   Nicolas

>>> I've built this with a powerpc allyesconfig (which pointed out the bug)
>>> and on RISC-V, manually checking to ensure the code was built.  I
>>> haven't even booted the resulting kernels.
>>>
>>> Fixes: c218ad559020 ("macb: Add support for SiFive FU540-C000")
>>> Signed-off-by: Palmer Dabbelt <palmer@sifive.com>
>>> ---
>>>    drivers/net/ethernet/cadence/Kconfig     | 11 +++++++++++
>>>    drivers/net/ethernet/cadence/macb_main.c | 12 ++++++++++++
>>>    2 files changed, 23 insertions(+)
>>>
>>> diff --git a/drivers/net/ethernet/cadence/Kconfig b/drivers/net/ethernet/cadence/Kconfig
>>> index 1766697c9c5a..74ee2bfd2369 100644
>>> --- a/drivers/net/ethernet/cadence/Kconfig
>>> +++ b/drivers/net/ethernet/cadence/Kconfig
>>> @@ -40,6 +40,17 @@ config MACB_USE_HWSTAMP
>>>    	---help---
>>>    	  Enable IEEE 1588 Precision Time Protocol (PTP) support for MACB.
>>>    
>>> +config MACB_FU540
>>> +	bool "Enable support for the SiFive FU540 clock controller"
>>> +	depends on MACB && COMMON_CLK
>>> +	default y
>>> +	---help---
>>> +	  Enable support for the MACB/GEM clock controller on the SiFive
>>> +	  FU540-C000.  This device is necessary for switching between 10/100
>>> +	  and gigabit modes on the FU540-C000 SoC, without which it is only
>>> +	  possible to bring up the Ethernet link in whatever mode the
>>> +	  bootloader probed.
>>> +
>>>    config MACB_PCI
>>>    	tristate "Cadence PCI MACB/GEM support"
>>>    	depends on MACB && PCI && COMMON_CLK
>>> diff --git a/drivers/net/ethernet/cadence/macb_main.c b/drivers/net/ethernet/cadence/macb_main.c
>>> index c545c5b435d8..a903dfdd4183 100644
>>> --- a/drivers/net/ethernet/cadence/macb_main.c
>>> +++ b/drivers/net/ethernet/cadence/macb_main.c
>>> @@ -41,6 +41,7 @@
>>>    #include <linux/pm_runtime.h>
>>>    #include "macb.h"
>>>    
>>> +#ifdef CONFIG_MACB_FU540
>>>    /* This structure is only used for MACB on SiFive FU540 devices */
>>>    struct sifive_fu540_macb_mgmt {
>>>    	void __iomem *reg;
>>> @@ -49,6 +50,7 @@ struct sifive_fu540_macb_mgmt {
>>>    };
>>>    
>>>    static struct sifive_fu540_macb_mgmt *mgmt;
>>> +#endif
>>>    
>>>    #define MACB_RX_BUFFER_SIZE	128
>>>    #define RX_BUFFER_MULTIPLE	64  /* bytes */
>>> @@ -3956,6 +3958,7 @@ static int at91ether_init(struct platform_device *pdev)
>>>    	return 0;
>>>    }
>>>    
>>> +#ifdef CONFIG_MACB_FU540
>>>    static unsigned long fu540_macb_tx_recalc_rate(struct clk_hw *hw,
>>>    					       unsigned long parent_rate)
>>>    {
>>> @@ -4056,7 +4059,9 @@ static int fu540_c000_init(struct platform_device *pdev)
>>>    
>>>    	return macb_init(pdev);
>>>    }
>>> +#endif
>>>    
>>> +#ifdef CONFIG_MACB_FU540
>>>    static const struct macb_config fu540_c000_config = {
>>>    	.caps = MACB_CAPS_GIGABIT_MODE_AVAILABLE | MACB_CAPS_JUMBO |
>>>    		MACB_CAPS_GEM_HAS_PTP,
>>> @@ -4065,6 +4070,7 @@ static const struct macb_config fu540_c000_config = {
>>>    	.init = fu540_c000_init,
>>>    	.jumbo_max_len = 10240,
>>>    };
>>> +#endif
>>>    
>>>    static const struct macb_config at91sam9260_config = {
>>>    	.caps = MACB_CAPS_USRIO_HAS_CLKEN | MACB_CAPS_USRIO_DEFAULT_IS_MII_GMII,
>>> @@ -4155,7 +4161,9 @@ static const struct of_device_id macb_dt_ids[] = {
>>>    	{ .compatible = "cdns,emac", .data = &emac_config },
>>>    	{ .compatible = "cdns,zynqmp-gem", .data = &zynqmp_config},
>>>    	{ .compatible = "cdns,zynq-gem", .data = &zynq_config },
>>> +#ifdef CONFIG_MACB_FU540
>>>    	{ .compatible = "sifive,fu540-macb", .data = &fu540_c000_config },
>>> +#endif
>>>    	{ /* sentinel */ }
>>>    };
>>>    MODULE_DEVICE_TABLE(of, macb_dt_ids);
>>> @@ -4363,7 +4371,9 @@ static int macb_probe(struct platform_device *pdev)
>>>    
>>>    err_disable_clocks:
>>>    	clk_disable_unprepare(tx_clk);
>>> +#ifdef CONFIG_MACB_FU540
>>>    	clk_unregister(tx_clk);
>>> +#endif
>>>    	clk_disable_unprepare(hclk);
>>>    	clk_disable_unprepare(pclk);
>>>    	clk_disable_unprepare(rx_clk);
>>> @@ -4398,7 +4408,9 @@ static int macb_remove(struct platform_device *pdev)
>>>    		pm_runtime_dont_use_autosuspend(&pdev->dev);
>>>    		if (!pm_runtime_suspended(&pdev->dev)) {
>>>    			clk_disable_unprepare(bp->tx_clk);
>>> +#ifdef CONFIG_MACB_FU540
>>>    			clk_unregister(bp->tx_clk);
>>> +#endif
>>>    			clk_disable_unprepare(bp->hclk);
>>>    			clk_disable_unprepare(bp->pclk);
>>>    			clk_disable_unprepare(bp->rx_clk);
>>>
>>
>>
>> -- 
>> Nicolas Ferre


-- 
Nicolas Ferre

  reply	other threads:[~2019-06-24 15:22 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24  6:16 net: macb: Fix compilation on systems without COMMON_CLK Palmer Dabbelt
2019-06-24  6:16 ` [PATCH 1/2] " Palmer Dabbelt
2019-06-24  9:40   ` Nicolas.Ferre
2019-06-24  9:57     ` Palmer Dabbelt
2019-06-24 15:22       ` Nicolas.Ferre [this message]
2019-06-25  5:16         ` Harini Katakam
2019-06-24  6:16 ` [PATCH 2/2] net: macb: Kconfig: Rename Atmel to Cadence Palmer Dabbelt
2019-06-24  9:49   ` Nicolas.Ferre
2019-06-24  9:57     ` Palmer Dabbelt
2019-06-24 15:42       ` Nicolas.Ferre

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=8bf8f052-cb9e-a4a6-4a7f-584cbd20582d@microchip.com \
    --to=nicolas.ferre@microchip.com \
    --cc=davem@davemloft.net \
    --cc=harini.katakam@xilinx.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.simek@xilinx.com \
    --cc=netdev@vger.kernel.org \
    --cc=palmer@sifive.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).