Received: by 2002:a25:f815:0:0:0:0:0 with SMTP id u21csp2230177ybd; Mon, 24 Jun 2019 02:59:12 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDJI0tkAlKkz4bm5RHpX056mjtp+Pm9Kbyr+zyKX1ayYG3ADIs1JfdmQFC/AKDD/upBCXt X-Received: by 2002:a17:90a:8a8e:: with SMTP id x14mr23101569pjn.103.1561370352087; Mon, 24 Jun 2019 02:59:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1561370352; cv=none; d=google.com; s=arc-20160816; b=Dwo7TbXNC0RMfswIpMUU511cBifwer2FN3Hlq1dng74AkmC+hbIP9dvUXl39GN+NLk JcCDPuHHgv1P0VGLB5AAnzM9SozrKeklPnLXyqBERTwsXiembcwUxjxEY9qJrn3+zltD cd4nAoWR4JNnnEbj/Wuuy9RWuISFNOs015kIWWfcfA7LPF3OTQORoDQBV8rHtSvdfbRs NxK399xULcudZ/hwNS7TnGVxCTZOtVy+oarQOTtkXMmlB3oVvWuPDNY2V3XqIhwoqjSV G8nisF61aINnYyYFK0jPisNM/etRY1qeKX1zwCuF5NViw8F0BHkWkiCJtCO0dr515+Gq +1Dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:to:from:cc:in-reply-to:subject:date; bh=9ZA8Iexrs/y5c8FvffbT362N37zmnH9csKA2fCgK9OY=; b=jgDsMWJXhjudvsa4Z97R19061Lunl7loM4rPTF3nIYbJmI+4UAh3z+JWuG6NPqr4O+ +KOrlVuISbwlfPEwLuovhLEfXmoDlXpeWFE244opfyNOiWVSnRCQb8a7PX50e9VQjwcy j+ItZdT2HwaX+w3qsnttcYanubBkBW5nZnxg+bu/PLfjIt/RZ3J0lIBp6pF/gZ2LeMYx mQ45pmNLhRU/mLbtL/HYbxCV3UqZJbA0+qmr58swdUKs+gj0YOG995D+FJ+WnVZpgHjw 8ERi48xMwNEi/wcX9XFxl9vvh23l34BjkYYl0tgeQVzGrldU3R9HFXbJpgQhmeomleAg f+EQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v20si10565237pff.26.2019.06.24.02.58.56; Mon, 24 Jun 2019 02:59:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728846AbfFXJ5Z (ORCPT + 99 others); Mon, 24 Jun 2019 05:57:25 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:44390 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727140AbfFXJ5V (ORCPT ); Mon, 24 Jun 2019 05:57:21 -0400 Received: by mail-pl1-f194.google.com with SMTP id t7so6577195plr.11 for ; Mon, 24 Jun 2019 02:57:21 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:subject:in-reply-to:cc:from:to:message-id :mime-version:content-transfer-encoding; bh=9ZA8Iexrs/y5c8FvffbT362N37zmnH9csKA2fCgK9OY=; b=KnslY9+JAO1B+j4ZfYJGH9yoakxdjVwlbxX3MW3FiXEDUF9LD5QhIO5hMRp8xPAT6W MNNUibRpbkec6mvPQk5e2hGHOlNAYRuaT9R5wEYvV5cPOIYMCuZjBEac9Zlbqke6NIIR yIr53t14OQRUkLAUnVmaxHEeu6cmAXp8Enf48lV23R9o3C7vtgFTw9ncM6KxiC4A4hPz gQxib8GF3h3+PuEy03/UkZGh9IGFnqHBGG7YuIXroa0EflgSNJUwjtLv6jAhkj9XF4xe FslWpydmlHSzFSyxKUFq5pkRhoSqfIhaljlX72uGRLR98CsFsowP/8NR5Wh2uDebdrzM 2fnA== X-Gm-Message-State: APjAAAVrr5Gf8T2QeUicyUUNT9nriwfS+8u+kBoQe1gslIIEfAD254ja pt8G43D4F7ejqzLkN7agt4YUog== X-Received: by 2002:a17:902:8509:: with SMTP id bj9mr32285512plb.79.1561370240329; Mon, 24 Jun 2019 02:57:20 -0700 (PDT) Received: from localhost (220-132-236-182.HINET-IP.hinet.net. [220.132.236.182]) by smtp.gmail.com with ESMTPSA id x7sm10010802pfm.82.2019.06.24.02.57.19 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Mon, 24 Jun 2019 02:57:19 -0700 (PDT) Date: Mon, 24 Jun 2019 02:57:19 -0700 (PDT) X-Google-Original-Date: Mon, 24 Jun 2019 02:50:25 PDT (-0700) Subject: Re: [PATCH 1/2] net: macb: Fix compilation on systems without COMMON_CLK In-Reply-To: CC: davem@davemloft.net, netdev@vger.kernel.org, linux-kernel@vger.kernel.org From: Palmer Dabbelt To: Nicolas.Ferre@microchip.com Message-ID: Mime-Version: 1.0 (MHng) Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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? > >> 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 >> --- >> 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 >> #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