From patchwork Sat Nov 19 23:09:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexander Lobakin X-Patchwork-Id: 23352 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:adf:f944:0:0:0:0:0 with SMTP id q4csp898942wrr; Sat, 19 Nov 2022 15:11:37 -0800 (PST) X-Google-Smtp-Source: AA0mqf4sPMmvDXUP7xK2laDe6aw0lCkGXKcKSiAGSZ0vCt5+MKS3WLpfLky0zGpgSkZ/16wpcqxm X-Received: by 2002:a17:903:300a:b0:186:5de3:8f10 with SMTP id o10-20020a170903300a00b001865de38f10mr5411694pla.92.1668899497477; Sat, 19 Nov 2022 15:11:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1668899497; cv=none; d=google.com; s=arc-20160816; b=QYBYRLWQ496ET0W5jLec5S3xT+d04xjoov3T0yprz3kOHiqKTtmqhUgBgbJsYF0yqj zJtR2anjuirkinobqN6C5TAi9wm6DiTIdE3gVTTymswisFdmSy3deUKOlxFgiAh4D60K AGNIczv8Hxt0JL3AxN4Q7x9Xg6zzNcmSmQkcZQAA2mdwRXfdy/V0YQs+q9HI6uRy8PBp lFhZIiRRrF32nsd2f+sFITxgBEJRA/24xC9fzqC4tX6we2vbSDCWmEpVGHm0osFJfVwX JoshNHLiGkBzHZCDRYMnErkAbJLPA1wztPNi9WRuM0Sg7PhNTglTKSB26A9Dr2zcTCf3 H+lg== 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 :feedback-id:references:in-reply-to:message-id:subject:cc:from:to :dkim-signature:date; bh=wNP0UQpU7yrDZr4V2xlMMmH7hWXhkAKdC5HFrg14b2U=; b=wmLjC9kUeSBX1+nH0Yc0cD9S2TFguN/T65TQnOr64+gvs//nfjJEomPhdXDSFQ8g1v PoN1D4ihMwGSZfh5EWXn3txq4mtyZYxJHd94NE/Nvagg8YxsEaiKMcDaz9wndT1t6kNo fBhsMQM7GZ6ReYruCK5j4trKB5lc0RtYU9sOIyA3RTPGVqSB4N2LgSC7qUpuxYo1CLSD pggDxxWznFnxPElCzyJn9CTuOrv7gB581DaScU1jyp0Cy0nT9Dc7P9SbNZCBUFlMGoar aerO33kOwNYt6SohoSndO2RAr1mDoK4wTVDNRLzcreZiE7t5nACOD8xGXtr9tp50s3iz UMKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@pm.me header.s=protonmail3 header.b=TdhooLtY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170902ccc900b00178386d88c6si7527482ple.186.2022.11.19.15.11.24; Sat, 19 Nov 2022 15:11:37 -0800 (PST) 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=@pm.me header.s=protonmail3 header.b=TdhooLtY; 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=QUARANTINE sp=QUARANTINE dis=NONE) header.from=pm.me Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235305AbiKSXKO (ORCPT + 99 others); Sat, 19 Nov 2022 18:10:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33800 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235377AbiKSXJ6 (ORCPT ); Sat, 19 Nov 2022 18:09:58 -0500 Received: from mail-40134.protonmail.ch (mail-40134.protonmail.ch [185.70.40.134]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 47528101FC; Sat, 19 Nov 2022 15:09:57 -0800 (PST) Date: Sat, 19 Nov 2022 23:09:51 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pm.me; s=protonmail3; t=1668899395; x=1669158595; bh=wNP0UQpU7yrDZr4V2xlMMmH7hWXhkAKdC5HFrg14b2U=; h=Date:To:From:Cc:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector; b=TdhooLtYMTOiXSgX6a8vur7U8YSfc54R+aNkyLrZOxGhW9ZmtfU2kNxaQOmVntH5M RaFWicXh4WLlwJG9nmjBzB2F0cFaqn8BIIKyCUGv/leCqern8weFAm0prQk5TEMji/ qpwLjthLgEeDPTus9GXPDGf+Mz2eE4Q32y5S6KxXvsSHmjn2i34UjgegVmBRo5B7mu V9IvBd9WD/RDTR7XV8B121h4KfQI/Zqlx1h6izDtKhhhgoO6NH6aEgbxDLUQt0kEOB 7fuYsxpgTk8poLjQMJnSY0wit5xC1Lc+taQrCH6InXHhoJocSMB4GKTeMAbUZSAozo jTSk3B04DZlXg== To: linux-kbuild@vger.kernel.org From: Alexander Lobakin Cc: Alexander Lobakin , Masahiro Yamada , Nicolas Schier , Jens Axboe , Boris Brezillon , Borislav Petkov , Tony Luck , Miquel Raynal , Vladimir Oltean , Alexandre Belloni , Derek Chickles , Ioana Ciornei , Salil Mehta , Sunil Goutham , Grygorii Strashko , Daniel Scally , Hans de Goede , Mark Brown , Andy Shevchenko , NXP Linux Team , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 15/18] net: dpaa2: fix mixed module-builtin object Message-ID: <20221119225650.1044591-16-alobakin@pm.me> In-Reply-To: <20221119225650.1044591-1-alobakin@pm.me> References: <20221119225650.1044591-1-alobakin@pm.me> Feedback-ID: 22809121:user:proton MIME-Version: 1.0 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_PASS,SPF_PASS 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 X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1749967958964456547?= X-GMAIL-MSGID: =?utf-8?q?1749967958964456547?= With CONFIG_FSL_DPAA2_ETH=m and CONFIG_FSL_DPAA2_SWITCH=y (or vice versa), dpaa2-mac.o and dpmac.o are linked to a module and also to vmlinux even though the expected CFLAGS are different between builtins and modules. This is the same situation as fixed by commit 637a642f5ca5 ("zstd: Fixing mixed module-builtin objects"). There's also no need to duplicate relatively big piece of object code into two modules. Introduce the new module, fsl-dpaa2-mac, to provide the common functions to both fsl-dpaa2-eth and fsl-dpaa2-switch. Misc: constify and shrink @dpaa2_mac_ethtool_stats while at it. Fixes: 84cba72956fd ("dpaa2-switch: integrate the MAC endpoint support") Suggested-by: Masahiro Yamada Signed-off-by: Alexander Lobakin Reviewed-by: Masahiro Yamada --- drivers/net/ethernet/freescale/dpaa2/Kconfig | 6 ++++++ drivers/net/ethernet/freescale/dpaa2/Makefile | 6 ++++-- drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 2 ++ drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c | 15 ++++++++++++++- .../net/ethernet/freescale/dpaa2/dpaa2-switch.c | 2 ++ 5 files changed, 28 insertions(+), 3 deletions(-) -- 2.38.1 diff --git a/drivers/net/ethernet/freescale/dpaa2/Kconfig b/drivers/net/ethernet/freescale/dpaa2/Kconfig index d029b69c3f18..54c388f25c43 100644 --- a/drivers/net/ethernet/freescale/dpaa2/Kconfig +++ b/drivers/net/ethernet/freescale/dpaa2/Kconfig @@ -1,7 +1,12 @@ # SPDX-License-Identifier: GPL-2.0-only + +config FSL_DPAA2_MAC + tristate + config FSL_DPAA2_ETH tristate "Freescale DPAA2 Ethernet" depends on FSL_MC_BUS && FSL_MC_DPIO + select FSL_DPAA2_MAC select PHYLINK select PCS_LYNX select FSL_XGMAC_MDIO @@ -34,6 +39,7 @@ config FSL_DPAA2_SWITCH tristate "Freescale DPAA2 Ethernet Switch" depends on BRIDGE || BRIDGE=n depends on NET_SWITCHDEV + select FSL_DPAA2_MAC help Driver for Freescale DPAA2 Ethernet Switch. This driver manages switch objects discovered on the Freeescale MC bus. diff --git a/drivers/net/ethernet/freescale/dpaa2/Makefile b/drivers/net/ethernet/freescale/dpaa2/Makefile index 3d9842af7f10..9dbe2273c9a1 100644 --- a/drivers/net/ethernet/freescale/dpaa2/Makefile +++ b/drivers/net/ethernet/freescale/dpaa2/Makefile @@ -4,14 +4,16 @@ # obj-$(CONFIG_FSL_DPAA2_ETH) += fsl-dpaa2-eth.o +obj-$(CONFIG_FSL_DPAA2_MAC) += fsl-dpaa2-mac.o obj-$(CONFIG_FSL_DPAA2_PTP_CLOCK) += fsl-dpaa2-ptp.o obj-$(CONFIG_FSL_DPAA2_SWITCH) += fsl-dpaa2-switch.o -fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o dpaa2-mac.o dpmac.o dpaa2-eth-devlink.o +fsl-dpaa2-eth-objs := dpaa2-eth.o dpaa2-ethtool.o dpni.o dpaa2-eth-devlink.o fsl-dpaa2-eth-${CONFIG_FSL_DPAA2_ETH_DCB} += dpaa2-eth-dcb.o fsl-dpaa2-eth-${CONFIG_DEBUG_FS} += dpaa2-eth-debugfs.o +fsl-dpaa2-mac-objs := dpaa2-mac.o dpmac.o fsl-dpaa2-ptp-objs := dpaa2-ptp.o dprtc.o -fsl-dpaa2-switch-objs := dpaa2-switch.o dpaa2-switch-ethtool.o dpsw.o dpaa2-switch-flower.o dpaa2-mac.o dpmac.o +fsl-dpaa2-switch-objs := dpaa2-switch.o dpaa2-switch-ethtool.o dpsw.o dpaa2-switch-flower.o # Needed by the tracing framework CFLAGS_dpaa2-eth.o := -I$(src) diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c index 8d029addddad..876c3ed6e2c5 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c @@ -28,6 +28,8 @@ #define CREATE_TRACE_POINTS #include "dpaa2-eth-trace.h" +MODULE_IMPORT_NS(FSL_DPAA2_MAC); + MODULE_LICENSE("Dual BSD/GPL"); MODULE_AUTHOR("Freescale Semiconductor, Inc"); MODULE_DESCRIPTION("Freescale DPAA2 Ethernet Driver"); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c index 49ff85633783..dc2c7cde5435 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c @@ -339,12 +339,14 @@ void dpaa2_mac_start(struct dpaa2_mac *mac) if (mac->serdes_phy) phy_power_on(mac->serdes_phy); } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_start, FSL_DPAA2_MAC); void dpaa2_mac_stop(struct dpaa2_mac *mac) { if (mac->serdes_phy) phy_power_off(mac->serdes_phy); } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_stop, FSL_DPAA2_MAC); int dpaa2_mac_connect(struct dpaa2_mac *mac) { @@ -435,6 +437,7 @@ int dpaa2_mac_connect(struct dpaa2_mac *mac) return err; } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_connect, FSL_DPAA2_MAC); void dpaa2_mac_disconnect(struct dpaa2_mac *mac) { @@ -447,6 +450,7 @@ void dpaa2_mac_disconnect(struct dpaa2_mac *mac) of_phy_put(mac->serdes_phy); mac->serdes_phy = NULL; } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_disconnect, FSL_DPAA2_MAC); int dpaa2_mac_open(struct dpaa2_mac *mac) { @@ -495,6 +499,7 @@ int dpaa2_mac_open(struct dpaa2_mac *mac) dpmac_close(mac->mc_io, 0, dpmac_dev->mc_handle); return err; } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_open, FSL_DPAA2_MAC); void dpaa2_mac_close(struct dpaa2_mac *mac) { @@ -504,8 +509,9 @@ void dpaa2_mac_close(struct dpaa2_mac *mac) if (mac->fw_node) fwnode_handle_put(mac->fw_node); } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_close, FSL_DPAA2_MAC); -static char dpaa2_mac_ethtool_stats[][ETH_GSTRING_LEN] = { +static const char * const dpaa2_mac_ethtool_stats[] = { [DPMAC_CNT_ING_ALL_FRAME] = "[mac] rx all frames", [DPMAC_CNT_ING_GOOD_FRAME] = "[mac] rx frames ok", [DPMAC_CNT_ING_ERR_FRAME] = "[mac] rx frame errors", @@ -542,6 +548,7 @@ int dpaa2_mac_get_sset_count(void) { return DPAA2_MAC_NUM_STATS; } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_get_sset_count, FSL_DPAA2_MAC); void dpaa2_mac_get_strings(u8 *data) { @@ -553,6 +560,7 @@ void dpaa2_mac_get_strings(u8 *data) p += ETH_GSTRING_LEN; } } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_get_strings, FSL_DPAA2_MAC); void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data) { @@ -572,3 +580,8 @@ void dpaa2_mac_get_ethtool_stats(struct dpaa2_mac *mac, u64 *data) *(data + i) = value; } } +EXPORT_SYMBOL_NS_GPL(dpaa2_mac_get_ethtool_stats, FSL_DPAA2_MAC); + +MODULE_LICENSE("Dual BSD/GPL"); +MODULE_AUTHOR("Freescale Semiconductor, Inc"); +MODULE_DESCRIPTION("Freescale DPAA2 MAC Driver"); diff --git a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c index 2b5909fa93cf..fccbaf75b512 100644 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-switch.c @@ -3534,5 +3534,7 @@ static void __exit dpaa2_switch_driver_exit(void) module_init(dpaa2_switch_driver_init); module_exit(dpaa2_switch_driver_exit); +MODULE_IMPORT_NS(FSL_DPAA2_MAC); + MODULE_LICENSE("GPL v2"); MODULE_DESCRIPTION("DPAA2 Ethernet Switch Driver");