From patchwork Tue Mar 14 00:36:05 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173494 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B0D42C6FD1F for ; Tue, 14 Mar 2023 00:36:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230205AbjCNAgi (ORCPT ); Mon, 13 Mar 2023 20:36:38 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52992 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230128AbjCNAg2 (ORCPT ); Mon, 13 Mar 2023 20:36:28 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E552A81CEB; Mon, 13 Mar 2023 17:36:17 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id c18so15209188qte.5; Mon, 13 Mar 2023 17:36:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=zP6/6VellR9zpNG91XRLqE0O91bPnn3bDhnGg/ksvAE=; b=llJQtWjO2TuusC3nq4QIeeMkkvVsBTHnmTLu8mYb3F8h8petY2P5Ku5cZ5rKxjv0tr 1LJvyCUpCjUaDkEjOv3P0HrgyfgL0KuWXWTqVD52lpcT8eP3cFk89PyTka5oFUOmyHr1 8qMJUcjHGDPxh+kWq3r5zf8x67wZgMwuwWrhz070IgMlYgYocC7mzhML01pwKjysX8oo ZNd8tphQ9NwW5BrtPoMJg5RipM8O4W7mXDl5VBFBRsHLLe3qYrYK2cADPcQkRQFPrJdr Y4BY400icOkjQzrsu3bFEcCD5l+Ra5O32QWlUwG14vNGhN0uC3GAl5aQA58ijsTe9qcR DF2w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754177; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=zP6/6VellR9zpNG91XRLqE0O91bPnn3bDhnGg/ksvAE=; b=ajWxDjZCzcp+L1djKCNKu0/8I0NytRdRldB/gYVSZ+HLmwyUkZatxVsOVEMOL/tP37 Rgw1/ZHSpIXP+9EavDknw4NawkeChaNnusn5LwXfs/fPdtfVh/WqAMx2ZWDRxg4eauzV 5cmJ8cjzU7wAtfh7WmZwdJWkTsJEkcSvfMTM1b2WEIw7ptrfRGq/NdAI4pb0Mom2LXMK MUyJlEFtJA4OzMFNa1w22TA5en+anDY/rMZ5wATwUPW8KodQqegQLMRYSGsC3y4u/Vij EPo2dpcQ/nToGLLmiG8vwGqejLhfDEuhjuIdo00Jfowa7rB3B9dibr0Dyjse0E5H1/Uj FbBA== X-Gm-Message-State: AO0yUKX9ucL9H4F7E5B8t0LIucuj44KdCPgrsEVuSx01hEKsqXW1yR6+ rLC3IVCyfXP0thOpG9fyWBE= X-Google-Smtp-Source: AK7set8wRZ8VEWUH4Bi1e0FZFprHbxSbRHwSUYAgUQ50xJfgBUENbVDRtfNnZ74aqoB6Xa/wfzdnPw== X-Received: by 2002:a05:622a:453:b0:3bf:d9ee:882d with SMTP id o19-20020a05622a045300b003bfd9ee882dmr64747995qtx.40.1678754176935; Mon, 13 Mar 2023 17:36:16 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id c13-20020ac87dcd000000b003b835e7e283sm836248qte.44.2023.03.13.17.36.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:16 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 1/9] net: sunhme: Just restart autonegotiation if we can't bring the link up Date: Mon, 13 Mar 2023 20:36:05 -0400 Message-Id: <20230314003613.3874089-2-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org If we've tried regular autonegotiation and forcing the link mode, just restart autonegotiation instead of reinitializing the whole NIC. Signed-off-by: Sean Anderson Reviewed-by: Simon Horman --- (no changes since v2) Changes in v2: - Move happy_meal_begin_auto_negotiation earlier and remove forward declaration drivers/net/ethernet/sun/sunhme.c | 245 +++++++++++++++--------------- 1 file changed, 119 insertions(+), 126 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index b0c7ab74a82e..65733ee5ddd9 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -589,8 +589,6 @@ static int set_happy_link_modes(struct happy_meal *hp, void __iomem *tregs) return 1; } -static int happy_meal_init(struct happy_meal *hp); - static int is_lucent_phy(struct happy_meal *hp) { void __iomem *tregs = hp->tcvregs; @@ -606,6 +604,124 @@ static int is_lucent_phy(struct happy_meal *hp) return ret; } +/* hp->happy_lock must be held */ +static void +happy_meal_begin_auto_negotiation(struct happy_meal *hp, + void __iomem *tregs, + const struct ethtool_link_ksettings *ep) +{ + int timeout; + + /* Read all of the registers we are interested in now. */ + hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); + hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); + hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); + hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); + + /* XXX Check BMSR_ANEGCAPABLE, should not be necessary though. */ + + hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); + if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { + /* Advertise everything we can support. */ + if (hp->sw_bmsr & BMSR_10HALF) + hp->sw_advertise |= (ADVERTISE_10HALF); + else + hp->sw_advertise &= ~(ADVERTISE_10HALF); + + if (hp->sw_bmsr & BMSR_10FULL) + hp->sw_advertise |= (ADVERTISE_10FULL); + else + hp->sw_advertise &= ~(ADVERTISE_10FULL); + if (hp->sw_bmsr & BMSR_100HALF) + hp->sw_advertise |= (ADVERTISE_100HALF); + else + hp->sw_advertise &= ~(ADVERTISE_100HALF); + if (hp->sw_bmsr & BMSR_100FULL) + hp->sw_advertise |= (ADVERTISE_100FULL); + else + hp->sw_advertise &= ~(ADVERTISE_100FULL); + happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); + + /* XXX Currently no Happy Meal cards I know off support 100BaseT4, + * XXX and this is because the DP83840 does not support it, changes + * XXX would need to be made to the tx/rx logic in the driver as well + * XXX so I completely skip checking for it in the BMSR for now. + */ + + ASD("Advertising [ %s%s%s%s]\n", + hp->sw_advertise & ADVERTISE_10HALF ? "10H " : "", + hp->sw_advertise & ADVERTISE_10FULL ? "10F " : "", + hp->sw_advertise & ADVERTISE_100HALF ? "100H " : "", + hp->sw_advertise & ADVERTISE_100FULL ? "100F " : ""); + + /* Enable Auto-Negotiation, this is usually on already... */ + hp->sw_bmcr |= BMCR_ANENABLE; + happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); + + /* Restart it to make sure it is going. */ + hp->sw_bmcr |= BMCR_ANRESTART; + happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); + + /* BMCR_ANRESTART self clears when the process has begun. */ + + timeout = 64; /* More than enough. */ + while (--timeout) { + hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); + if (!(hp->sw_bmcr & BMCR_ANRESTART)) + break; /* got it. */ + udelay(10); + } + if (!timeout) { + netdev_err(hp->dev, + "Happy Meal would not start auto negotiation BMCR=0x%04x\n", + hp->sw_bmcr); + netdev_notice(hp->dev, + "Performing force link detection.\n"); + goto force_link; + } else { + hp->timer_state = arbwait; + } + } else { +force_link: + /* Force the link up, trying first a particular mode. + * Either we are here at the request of ethtool or + * because the Happy Meal would not start to autoneg. + */ + + /* Disable auto-negotiation in BMCR, enable the duplex and + * speed setting, init the timer state machine, and fire it off. + */ + if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { + hp->sw_bmcr = BMCR_SPEED100; + } else { + if (ep->base.speed == SPEED_100) + hp->sw_bmcr = BMCR_SPEED100; + else + hp->sw_bmcr = 0; + if (ep->base.duplex == DUPLEX_FULL) + hp->sw_bmcr |= BMCR_FULLDPLX; + } + happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); + + if (!is_lucent_phy(hp)) { + /* OK, seems we need do disable the transceiver for the first + * tick to make sure we get an accurate link state at the + * second tick. + */ + hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, + DP83840_CSCONFIG); + hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); + happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, + hp->sw_csconfig); + } + hp->timer_state = ltrywait; + } + + hp->timer_ticks = 0; + hp->happy_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */ + add_timer(&hp->happy_timer); +} + static void happy_meal_timer(struct timer_list *t) { struct happy_meal *hp = from_timer(hp, t, happy_timer); @@ -743,12 +859,7 @@ static void happy_meal_timer(struct timer_list *t) netdev_notice(hp->dev, "Link down, cable problem?\n"); - ret = happy_meal_init(hp); - if (ret) { - /* ho hum... */ - netdev_err(hp->dev, - "Error, cannot re-init the Happy Meal.\n"); - } + happy_meal_begin_auto_negotiation(hp, tregs, NULL); goto out; } if (!is_lucent_phy(hp)) { @@ -1201,124 +1312,6 @@ static void happy_meal_init_rings(struct happy_meal *hp) HMD("done\n"); } -/* hp->happy_lock must be held */ -static void -happy_meal_begin_auto_negotiation(struct happy_meal *hp, - void __iomem *tregs, - const struct ethtool_link_ksettings *ep) -{ - int timeout; - - /* Read all of the registers we are interested in now. */ - hp->sw_bmsr = happy_meal_tcvr_read(hp, tregs, MII_BMSR); - hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); - hp->sw_physid1 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID1); - hp->sw_physid2 = happy_meal_tcvr_read(hp, tregs, MII_PHYSID2); - - /* XXX Check BMSR_ANEGCAPABLE, should not be necessary though. */ - - hp->sw_advertise = happy_meal_tcvr_read(hp, tregs, MII_ADVERTISE); - if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { - /* Advertise everything we can support. */ - if (hp->sw_bmsr & BMSR_10HALF) - hp->sw_advertise |= (ADVERTISE_10HALF); - else - hp->sw_advertise &= ~(ADVERTISE_10HALF); - - if (hp->sw_bmsr & BMSR_10FULL) - hp->sw_advertise |= (ADVERTISE_10FULL); - else - hp->sw_advertise &= ~(ADVERTISE_10FULL); - if (hp->sw_bmsr & BMSR_100HALF) - hp->sw_advertise |= (ADVERTISE_100HALF); - else - hp->sw_advertise &= ~(ADVERTISE_100HALF); - if (hp->sw_bmsr & BMSR_100FULL) - hp->sw_advertise |= (ADVERTISE_100FULL); - else - hp->sw_advertise &= ~(ADVERTISE_100FULL); - happy_meal_tcvr_write(hp, tregs, MII_ADVERTISE, hp->sw_advertise); - - /* XXX Currently no Happy Meal cards I know off support 100BaseT4, - * XXX and this is because the DP83840 does not support it, changes - * XXX would need to be made to the tx/rx logic in the driver as well - * XXX so I completely skip checking for it in the BMSR for now. - */ - - ASD("Advertising [ %s%s%s%s]\n", - hp->sw_advertise & ADVERTISE_10HALF ? "10H " : "", - hp->sw_advertise & ADVERTISE_10FULL ? "10F " : "", - hp->sw_advertise & ADVERTISE_100HALF ? "100H " : "", - hp->sw_advertise & ADVERTISE_100FULL ? "100F " : ""); - - /* Enable Auto-Negotiation, this is usually on already... */ - hp->sw_bmcr |= BMCR_ANENABLE; - happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); - - /* Restart it to make sure it is going. */ - hp->sw_bmcr |= BMCR_ANRESTART; - happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); - - /* BMCR_ANRESTART self clears when the process has begun. */ - - timeout = 64; /* More than enough. */ - while (--timeout) { - hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); - if (!(hp->sw_bmcr & BMCR_ANRESTART)) - break; /* got it. */ - udelay(10); - } - if (!timeout) { - netdev_err(hp->dev, - "Happy Meal would not start auto negotiation BMCR=0x%04x\n", - hp->sw_bmcr); - netdev_notice(hp->dev, - "Performing force link detection.\n"); - goto force_link; - } else { - hp->timer_state = arbwait; - } - } else { -force_link: - /* Force the link up, trying first a particular mode. - * Either we are here at the request of ethtool or - * because the Happy Meal would not start to autoneg. - */ - - /* Disable auto-negotiation in BMCR, enable the duplex and - * speed setting, init the timer state machine, and fire it off. - */ - if (!ep || ep->base.autoneg == AUTONEG_ENABLE) { - hp->sw_bmcr = BMCR_SPEED100; - } else { - if (ep->base.speed == SPEED_100) - hp->sw_bmcr = BMCR_SPEED100; - else - hp->sw_bmcr = 0; - if (ep->base.duplex == DUPLEX_FULL) - hp->sw_bmcr |= BMCR_FULLDPLX; - } - happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); - - if (!is_lucent_phy(hp)) { - /* OK, seems we need do disable the transceiver for the first - * tick to make sure we get an accurate link state at the - * second tick. - */ - hp->sw_csconfig = happy_meal_tcvr_read(hp, tregs, - DP83840_CSCONFIG); - hp->sw_csconfig &= ~(CSCONFIG_TCVDISAB); - happy_meal_tcvr_write(hp, tregs, DP83840_CSCONFIG, - hp->sw_csconfig); - } - hp->timer_state = ltrywait; - } - - hp->timer_ticks = 0; - hp->happy_timer.expires = jiffies + (12 * HZ)/10; /* 1.2 sec. */ - add_timer(&hp->happy_timer); -} - /* hp->happy_lock must be held */ static int happy_meal_init(struct happy_meal *hp) { From patchwork Tue Mar 14 00:36:06 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173495 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9BAF1C6FD19 for ; Tue, 14 Mar 2023 00:36:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230325AbjCNAgl (ORCPT ); Mon, 13 Mar 2023 20:36:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52698 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230020AbjCNAgd (ORCPT ); Mon, 13 Mar 2023 20:36:33 -0400 Received: from mail-qv1-xf2a.google.com (mail-qv1-xf2a.google.com [IPv6:2607:f8b0:4864:20::f2a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6DF3C8483F; Mon, 13 Mar 2023 17:36:19 -0700 (PDT) Received: by mail-qv1-xf2a.google.com with SMTP id op8so9356016qvb.11; Mon, 13 Mar 2023 17:36:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754178; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=T3oCvGhOIAfNAN34fB9zFjt1eWCU7yIVd60a97RfYfo=; b=XWieiZ01w++gZXb8p833YAEv+j3KYzB/qb7Gv+KBgG91qXApTGTWDBJhdP1WdjU4Wh pOIctAidN+NQ2vYoQrXm1OLt1SGZADgYzA+276qkwgrAzznifX8W3RfQrV+N8r/3t1bj DhcC+WygaorEnqYRBdaqnWJaBXLTqVY53GfLfEWwYXiHSMcQVcwfXB0OgKWfH3mcKSFK 2shO0IMwaJNl4F+unfOgQCAu9ZXZB4ie58KjngFpcIjNjG7GCJigEh38i6fO/igWoRce RMkayPULFxPUhUxanLWv0T7jk+GqLf8oJy7jjE37BepN4GttzWT2l5C2QiW0QzUPZaCF P/ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754178; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=T3oCvGhOIAfNAN34fB9zFjt1eWCU7yIVd60a97RfYfo=; b=oiQvGt9Yb5gFvjYz8vXlySwy7EVX6Ht+RpVQYu+V3mKzIXVrTNf8Nxg3DZenlPuZtg YTzjFx/nnO1YYKdNW77MItJqKul+qzYl05ijzh6kq+qLRLzJwK0jv8+wnJ6lET1K6yEI jfNkaPx6i+Z0bZlSyBMKrrsiJxPqlg1P4hPoHe/l27aQsIgHbckMhdKEw0IIPODjlCNy vd/j+Qc1Mhh4rIMBCkqdROhptd7o/rSPG3Z0JdNYVdvnW5HUA8HRQfzfR67ghlZop6NM eaQi0Lj8+Wx3wBlN2TbrnnnY7ukREWUsfYEvWya0a3b7w/O3ji+1cJz+We3qwcMvoT5Y qlFQ== X-Gm-Message-State: AO0yUKUFOA0FQVofSMqnCizmCc6wVmc5cc2gBnnaXneOIuWt5tZPqM2M 7S4avtnzThxa9ToavUJPdG5R+N3oH4+VBg== X-Google-Smtp-Source: AK7set8v8keA22ptxDcuDGg/Ia3NkehZqFPl6MMqaWLh9zXKXhawpLxEmvZ0l2rG2LzlhpdTpBrXgA== X-Received: by 2002:a05:6214:c2b:b0:5a9:d6dd:271f with SMTP id a11-20020a0562140c2b00b005a9d6dd271fmr5627339qvd.23.1678754177957; Mon, 13 Mar 2023 17:36:17 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id c5-20020ae9ed05000000b007459236d2dcsm734989qkg.69.2023.03.13.17.36.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:17 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 2/9] net: sunhme: Remove residual polling code Date: Mon, 13 Mar 2023 20:36:06 -0400 Message-Id: <20230314003613.3874089-3-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The sunhme driver never used the hardware MII polling feature. Even the if-def'd out happy_meal_poll_start was removed by 2002 [1]. Remove the various places in the driver which needlessly guard against MII interrupts which will never be enabled. [1] https://lwn.net/2002/0411/a/2.5.8-pre3.php3 Signed-off-by: Sean Anderson Reviewed-by: Simon Horman --- (no changes since v1) drivers/net/ethernet/sun/sunhme.c | 134 ++++-------------------------- drivers/net/ethernet/sun/sunhme.h | 6 +- 2 files changed, 18 insertions(+), 122 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 65733ee5ddd9..6bcafe820a9e 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -985,32 +985,6 @@ static void happy_meal_get_counters(struct happy_meal *hp, void __iomem *bregs) hme_write32(hp, bregs + BMAC_LTCTR, 0); } -/* hp->happy_lock must be held */ -static void happy_meal_poll_stop(struct happy_meal *hp, void __iomem *tregs) -{ - /* If polling disabled or not polling already, nothing to do. */ - if ((hp->happy_flags & (HFLAG_POLLENABLE | HFLAG_POLL)) != - (HFLAG_POLLENABLE | HFLAG_POLL)) { - ASD("not polling, return\n"); - return; - } - - /* Shut up the MIF. */ - ASD("were polling, mif ints off, polling off\n"); - hme_write32(hp, tregs + TCVR_IMASK, 0xffff); - - /* Turn off polling. */ - hme_write32(hp, tregs + TCVR_CFG, - hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_PENABLE)); - - /* We are no longer polling. */ - hp->happy_flags &= ~(HFLAG_POLL); - - /* Let the bits set. */ - udelay(200); - ASD("done\n"); -} - /* Only Sun can take such nice parts and fuck up the programming interface * like this. Good job guys... */ @@ -1115,57 +1089,26 @@ static int happy_meal_tcvr_reset(struct happy_meal *hp, void __iomem *tregs) static void happy_meal_transceiver_check(struct happy_meal *hp, void __iomem *tregs) { unsigned long tconfig = hme_read32(hp, tregs + TCVR_CFG); + u32 reread = hme_read32(hp, tregs + TCVR_CFG); ASD("tcfg=%08lx\n", tconfig); - if (hp->happy_flags & HFLAG_POLL) { - /* If we are polling, we must stop to get the transceiver type. */ - if (hp->tcvr_type == internal) { - if (tconfig & TCV_CFG_MDIO1) { - happy_meal_poll_stop(hp, tregs); - hp->paddr = TCV_PADDR_ETX; - hp->tcvr_type = external; - tconfig &= ~(TCV_CFG_PENABLE); - tconfig |= TCV_CFG_PSELECT; - hme_write32(hp, tregs + TCVR_CFG, tconfig); - ASD("poll stop, internal->external\n"); - } - } else { - if (hp->tcvr_type == external) { - if (!(hme_read32(hp, tregs + TCVR_STATUS) >> 16)) { - happy_meal_poll_stop(hp, tregs); - hp->paddr = TCV_PADDR_ITX; - hp->tcvr_type = internal; - hme_write32(hp, tregs + TCVR_CFG, - hme_read32(hp, tregs + TCVR_CFG) & - ~(TCV_CFG_PSELECT)); - ASD("poll stop, external->internal\n"); - } - } else { - ASD("polling, none\n"); - } - } + if (reread & TCV_CFG_MDIO1) { + hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); + hp->paddr = TCV_PADDR_ETX; + hp->tcvr_type = external; + ASD("not polling, external\n"); } else { - u32 reread = hme_read32(hp, tregs + TCVR_CFG); - - /* Else we can just work off of the MDIO bits. */ - if (reread & TCV_CFG_MDIO1) { - hme_write32(hp, tregs + TCVR_CFG, tconfig | TCV_CFG_PSELECT); - hp->paddr = TCV_PADDR_ETX; - hp->tcvr_type = external; - ASD("not polling, external\n"); + if (reread & TCV_CFG_MDIO0) { + hme_write32(hp, tregs + TCVR_CFG, + tconfig & ~(TCV_CFG_PSELECT)); + hp->paddr = TCV_PADDR_ITX; + hp->tcvr_type = internal; + ASD("not polling, internal\n"); } else { - if (reread & TCV_CFG_MDIO0) { - hme_write32(hp, tregs + TCVR_CFG, - tconfig & ~(TCV_CFG_PSELECT)); - hp->paddr = TCV_PADDR_ITX; - hp->tcvr_type = internal; - ASD("not polling, internal\n"); - } else { - netdev_err(hp->dev, - "Transceiver and a coke please."); - hp->tcvr_type = none; /* Grrr... */ - ASD("not polling, none\n"); - } + netdev_err(hp->dev, + "Transceiver and a coke please."); + hp->tcvr_type = none; /* Grrr... */ + ASD("not polling, none\n"); } } } @@ -1334,10 +1277,6 @@ static int happy_meal_init(struct happy_meal *hp) happy_meal_get_counters(hp, bregs); } - /* Stop polling. */ - HMD("to happy_meal_poll_stop\n"); - happy_meal_poll_stop(hp, tregs); - /* Stop transmitter and receiver. */ HMD("to happy_meal_stop\n"); happy_meal_stop(hp, gregs); @@ -1346,11 +1285,6 @@ static int happy_meal_init(struct happy_meal *hp) HMD("to happy_meal_init_rings\n"); happy_meal_init_rings(hp); - /* Shut up the MIF. */ - HMD("Disable all MIF irqs (old[%08x])\n", - hme_read32(hp, tregs + TCVR_IMASK)); - hme_write32(hp, tregs + TCVR_IMASK, 0xffff); - /* See if we can enable the MIF frame on this card to speak to the DP83840. */ if (hp->happy_flags & HFLAG_FENABLE) { HMD("use frame old[%08x]\n", @@ -1605,7 +1539,6 @@ static void happy_meal_set_initial_advertisement(struct happy_meal *hp) void __iomem *gregs = hp->gregs; happy_meal_stop(hp, gregs); - hme_write32(hp, tregs + TCVR_IMASK, 0xffff); if (hp->happy_flags & HFLAG_FENABLE) hme_write32(hp, tregs + TCVR_CFG, hme_read32(hp, tregs + TCVR_CFG) & ~(TCV_CFG_BENABLE)); @@ -1762,34 +1695,6 @@ static int happy_meal_is_not_so_happy(struct happy_meal *hp, u32 status) return 0; } -/* hp->happy_lock must be held */ -static void happy_meal_mif_interrupt(struct happy_meal *hp) -{ - void __iomem *tregs = hp->tcvregs; - - netdev_info(hp->dev, "Link status change.\n"); - hp->sw_bmcr = happy_meal_tcvr_read(hp, tregs, MII_BMCR); - hp->sw_lpa = happy_meal_tcvr_read(hp, tregs, MII_LPA); - - /* Use the fastest transmission protocol possible. */ - if (hp->sw_lpa & LPA_100FULL) { - netdev_info(hp->dev, "Switching to 100Mbps at full duplex.\n"); - hp->sw_bmcr |= (BMCR_FULLDPLX | BMCR_SPEED100); - } else if (hp->sw_lpa & LPA_100HALF) { - netdev_info(hp->dev, "Switching to 100MBps at half duplex.\n"); - hp->sw_bmcr |= BMCR_SPEED100; - } else if (hp->sw_lpa & LPA_10FULL) { - netdev_info(hp->dev, "Switching to 10MBps at full duplex.\n"); - hp->sw_bmcr |= BMCR_FULLDPLX; - } else { - netdev_info(hp->dev, "Using 10Mbps at half duplex.\n"); - } - happy_meal_tcvr_write(hp, tregs, MII_BMCR, hp->sw_bmcr); - - /* Finally stop polling and shut up the MIF. */ - happy_meal_poll_stop(hp, tregs); -} - /* hp->happy_lock must be held */ static void happy_meal_tx(struct happy_meal *hp) { @@ -1973,9 +1878,6 @@ static irqreturn_t happy_meal_interrupt(int irq, void *dev_id) goto out; } - if (happy_status & GREG_STAT_MIFIRQ) - happy_meal_mif_interrupt(hp); - if (happy_status & GREG_STAT_TXALL) happy_meal_tx(hp); @@ -2003,7 +1905,6 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie) HMD("status=%08x\n", happy_status); if (!(happy_status & (GREG_STAT_ERRORS | - GREG_STAT_MIFIRQ | GREG_STAT_TXALL | GREG_STAT_RXTOHOST))) continue; @@ -2014,9 +1915,6 @@ static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie) if (happy_meal_is_not_so_happy(hp, happy_status)) goto next; - if (happy_status & GREG_STAT_MIFIRQ) - happy_meal_mif_interrupt(hp); - if (happy_status & GREG_STAT_TXALL) happy_meal_tx(hp); diff --git a/drivers/net/ethernet/sun/sunhme.h b/drivers/net/ethernet/sun/sunhme.h index 9118c60c9426..258b4c7fe962 100644 --- a/drivers/net/ethernet/sun/sunhme.h +++ b/drivers/net/ethernet/sun/sunhme.h @@ -462,22 +462,20 @@ struct happy_meal { }; /* Here are the happy flags. */ -#define HFLAG_POLL 0x00000001 /* We are doing MIF polling */ #define HFLAG_FENABLE 0x00000002 /* The MII frame is enabled */ #define HFLAG_LANCE 0x00000004 /* We are using lance-mode */ #define HFLAG_RXENABLE 0x00000008 /* Receiver is enabled */ #define HFLAG_AUTO 0x00000010 /* Using auto-negotiation, 0 = force */ #define HFLAG_FULL 0x00000020 /* Full duplex enable */ #define HFLAG_MACFULL 0x00000040 /* Using full duplex in the MAC */ -#define HFLAG_POLLENABLE 0x00000080 /* Actually try MIF polling */ #define HFLAG_RXCV 0x00000100 /* XXX RXCV ENABLE */ #define HFLAG_INIT 0x00000200 /* Init called at least once */ #define HFLAG_LINKUP 0x00000400 /* 1 = Link is up */ #define HFLAG_PCI 0x00000800 /* PCI based Happy Meal */ #define HFLAG_QUATTRO 0x00001000 /* On QFE/Quattro card */ -#define HFLAG_20_21 (HFLAG_POLLENABLE | HFLAG_FENABLE) -#define HFLAG_NOT_A0 (HFLAG_POLLENABLE | HFLAG_FENABLE | HFLAG_LANCE | HFLAG_RXCV) +#define HFLAG_20_21 HFLAG_FENABLE +#define HFLAG_NOT_A0 (HFLAG_FENABLE | HFLAG_LANCE | HFLAG_RXCV) /* Support for QFE/Quattro cards. */ struct quattro { From patchwork Tue Mar 14 00:36:07 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173493 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C7411C6FD1D for ; Tue, 14 Mar 2023 00:36:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230265AbjCNAgk (ORCPT ); Mon, 13 Mar 2023 20:36:40 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52726 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230169AbjCNAgf (ORCPT ); Mon, 13 Mar 2023 20:36:35 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C5407F02A; Mon, 13 Mar 2023 17:36:20 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id z6so15284204qtv.0; Mon, 13 Mar 2023 17:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=jFB1wNneUOYVLeis7EpoktboWL6/1c9abGa1i0Dym9U=; b=fbS6b4X8SJbfGSKU4UToHCexyI7owpuqoCLqLBYg5echcpIRSflAoGHlFET+qZParT HsFX6OUQGhdJtZP40mf1FvbzGjUlJhWAlWyFzOQRLhjf8RhJTuzHI1t8wu6rgXRUhqix v1mzEcCHJYDWxZpV2lViNve4rH59Og72zUqX56L1owf9Va4KjJBQ4ZB9IRxJfi3pLJdH vw7dQ0jqKRVaKBQlbuqjrQqcKAYWpt7VcZ6ooTUnOGOylEkIpkFz+j/nX11rJaMnM314 3llz3UZWtzAI/+gXn9pbsWQp83Vt79TI3GQYHoO/rLaUuNTSmToWRkqFOIHY8dqAnvFw FWPQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754179; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=jFB1wNneUOYVLeis7EpoktboWL6/1c9abGa1i0Dym9U=; b=mVjdcOdJ91AY3Qj7IR7aFphYbEEI/aMtoRQS/HyCiEvTvTPZKrMN+bxmmvooS00LX1 ySm7DRKYpC8rHZihP0rTqAurl4phHfHMlhL2CX4Ky2YoySPmPWtWI/mqBSvbQieXqlTN s/nc1ZdnCBcBpd1XDzwDl9ABbXpMzpIDo2ofU9rfXj0h0J95wpe2HHLk3BHZOHlJYydj uThKibsqV1BrzwfGUh94fVP0W7GWyxwtubenYxp+y873uoWeQTxtfHrkRMmxQkX5lAPp fDGeCnR9E8hqOKh6CUjRKUd9IHU/GpJPGXB5ZVWjZhqx6KAkjuLwOuT+++kraTsKT1at /R/Q== X-Gm-Message-State: AO0yUKXKoA+H71VDC/k53gg6zIcmjJw0Drz11lZyGm1LcK9PPR8Thj+Q F8Z1wckgtGvv7OtkZa1Wq94= X-Google-Smtp-Source: AK7set/rlDK9SA5YbVds88AtMr6gnHqmr7YCzNJLyqJkNPsFVhFn97rVrZdapOfQotDLAoZVj5zu9Q== X-Received: by 2002:a05:622a:d6:b0:3bf:e471:69a3 with SMTP id p22-20020a05622a00d600b003bfe47169a3mr60436113qtw.65.1678754179109; Mon, 13 Mar 2023 17:36:19 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id s6-20020a05622a1a8600b003b6382f66b1sm827154qtc.29.2023.03.13.17.36.18 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:18 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 3/9] net: sunhme: Unify IRQ requesting Date: Mon, 13 Mar 2023 20:36:07 -0400 Message-Id: <20230314003613.3874089-4-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Instead of registering one interrupt handler for all four SBUS Quattro HMEs, let each HME register its own handler. To make this work, we don't handle the IRQ if none of the status bits are set. This reduces the complexity of the driver, and makes it easier to ensure things happen before/after enabling IRQs. I'm not really sure why we request IRQs in two different places (and leave them running after removing the driver!). A lot of things in this driver seem to just be crusty, and not necessarily intentional. I'm assuming that's the case here as well. This really needs to be tested by someone with an SBUS Quattro card. Signed-off-by: Sean Anderson Reviewed-by: Simon Horman --- (no changes since v1) drivers/net/ethernet/sun/sunhme.c | 131 +++--------------------------- 1 file changed, 10 insertions(+), 121 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 6bcafe820a9e..5e17b1cdf016 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -1870,6 +1870,8 @@ static irqreturn_t happy_meal_interrupt(int irq, void *dev_id) u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); HMD("status=%08x\n", happy_status); + if (!happy_status) + return IRQ_NONE; spin_lock(&hp->happy_lock); @@ -1891,62 +1893,16 @@ static irqreturn_t happy_meal_interrupt(int irq, void *dev_id) return IRQ_HANDLED; } -#ifdef CONFIG_SBUS -static irqreturn_t quattro_sbus_interrupt(int irq, void *cookie) -{ - struct quattro *qp = (struct quattro *) cookie; - int i; - - for (i = 0; i < 4; i++) { - struct net_device *dev = qp->happy_meals[i]; - struct happy_meal *hp = netdev_priv(dev); - u32 happy_status = hme_read32(hp, hp->gregs + GREG_STAT); - - HMD("status=%08x\n", happy_status); - - if (!(happy_status & (GREG_STAT_ERRORS | - GREG_STAT_TXALL | - GREG_STAT_RXTOHOST))) - continue; - - spin_lock(&hp->happy_lock); - - if (happy_status & GREG_STAT_ERRORS) - if (happy_meal_is_not_so_happy(hp, happy_status)) - goto next; - - if (happy_status & GREG_STAT_TXALL) - happy_meal_tx(hp); - - if (happy_status & GREG_STAT_RXTOHOST) - happy_meal_rx(hp, dev); - - next: - spin_unlock(&hp->happy_lock); - } - HMD("done\n"); - - return IRQ_HANDLED; -} -#endif - static int happy_meal_open(struct net_device *dev) { struct happy_meal *hp = netdev_priv(dev); int res; - /* On SBUS Quattro QFE cards, all hme interrupts are concentrated - * into a single source which we register handling at probe time. - */ - if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) { - res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED, - dev->name, dev); - if (res) { - HMD("EAGAIN\n"); - netdev_err(dev, "Can't order irq %d to go.\n", hp->irq); - - return -EAGAIN; - } + res = request_irq(hp->irq, happy_meal_interrupt, IRQF_SHARED, + dev->name, dev); + if (res) { + netdev_err(dev, "Can't order irq %d to go.\n", hp->irq); + return res; } HMD("to happy_meal_init\n"); @@ -1955,7 +1911,7 @@ static int happy_meal_open(struct net_device *dev) res = happy_meal_init(hp); spin_unlock_irq(&hp->happy_lock); - if (res && ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO)) + if (res) free_irq(hp->irq, dev); return res; } @@ -1973,12 +1929,7 @@ static int happy_meal_close(struct net_device *dev) spin_unlock_irq(&hp->happy_lock); - /* On Quattro QFE cards, all hme interrupts are concentrated - * into a single source which we register handling at probe - * time and never unregister. - */ - if ((hp->happy_flags & (HFLAG_QUATTRO|HFLAG_PCI)) != HFLAG_QUATTRO) - free_irq(hp->irq, dev); + free_irq(hp->irq, dev); return 0; } @@ -2311,59 +2262,6 @@ static struct quattro *quattro_sbus_find(struct platform_device *child) platform_set_drvdata(op, qp); return qp; } - -/* After all quattro cards have been probed, we call these functions - * to register the IRQ handlers for the cards that have been - * successfully probed and skip the cards that failed to initialize - */ -static int __init quattro_sbus_register_irqs(void) -{ - struct quattro *qp; - - for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { - struct platform_device *op = qp->quattro_dev; - int err, qfe_slot, skip = 0; - - for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) { - if (!qp->happy_meals[qfe_slot]) - skip = 1; - } - if (skip) - continue; - - err = request_irq(op->archdata.irqs[0], - quattro_sbus_interrupt, - IRQF_SHARED, "Quattro", - qp); - if (err != 0) { - dev_err(&op->dev, - "Quattro HME: IRQ registration error %d.\n", - err); - return err; - } - } - - return 0; -} - -static void quattro_sbus_free_irqs(void) -{ - struct quattro *qp; - - for (qp = qfe_sbus_list; qp != NULL; qp = qp->next) { - struct platform_device *op = qp->quattro_dev; - int qfe_slot, skip = 0; - - for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) { - if (!qp->happy_meals[qfe_slot]) - skip = 1; - } - if (skip) - continue; - - free_irq(op->archdata.irqs[0], qp); - } -} #endif /* CONFIG_SBUS */ #ifdef CONFIG_PCI @@ -3005,8 +2903,6 @@ static int hme_sbus_remove(struct platform_device *op) unregister_netdev(net_dev); - /* XXX qfe parent interrupt... */ - of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); @@ -3050,19 +2946,12 @@ static struct platform_driver hme_sbus_driver = { static int __init happy_meal_sbus_init(void) { - int err; - - err = platform_driver_register(&hme_sbus_driver); - if (!err) - err = quattro_sbus_register_irqs(); - - return err; + return platform_driver_register(&hme_sbus_driver); } static void happy_meal_sbus_exit(void) { platform_driver_unregister(&hme_sbus_driver); - quattro_sbus_free_irqs(); while (qfe_sbus_list) { struct quattro *qfe = qfe_sbus_list; From patchwork Tue Mar 14 00:36:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173496 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id BC17FC6FD19 for ; Tue, 14 Mar 2023 00:36:55 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230378AbjCNAgx (ORCPT ); Mon, 13 Mar 2023 20:36:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53034 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230195AbjCNAgh (ORCPT ); Mon, 13 Mar 2023 20:36:37 -0400 Received: from mail-qt1-x836.google.com (mail-qt1-x836.google.com [IPv6:2607:f8b0:4864:20::836]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E2F0856AD; Mon, 13 Mar 2023 17:36:21 -0700 (PDT) Received: by mail-qt1-x836.google.com with SMTP id c1so1246346qtw.1; Mon, 13 Mar 2023 17:36:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=hQ2E6fONpVmwnalpjCD7FfF7Bo09AwDHDCdSmBwilYo=; b=bCzrUYHA9KSn5xjDlX5q+zvFdZ4zkN6ZwN9H/trCXQ+/NCkUjV2x9jtCx/u56A1G1z TaANRTTQj6XyUGola/eJKrn+4M1FTOeYE46Je7UuTWp95Ml5o85mhTQL6GbXhENmUXjb eFgyBYpU83sF8kPaduXtqgNCF/tYi9QYnFkCWuk8Wgn0W3E3sA6IwBhVr4VLdCMDJJKT BkCx7adX58p6ImLMIsh+V7gcVGFxmq0eB9WvGm9FWUq0UlFXZr3HDnTw9zy43hNEr/X2 X0Tu78sC6JXWCv6tAWRYKuODSQ8fOm97uILZZQmw577Y9ntkHt24k++1KeqvKD2yokJm F/dA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754180; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=hQ2E6fONpVmwnalpjCD7FfF7Bo09AwDHDCdSmBwilYo=; b=Ps+kbtAVNE6hJXdSLZ3Hn0tQDLkMUiIvy98WJScxSfSYDu2WCv7R9p1Jv7E/ZNSveI watPy2B73LWSM6036IZJRBze7t7KK67d/XUYUgYfFdWN7F+2sq7rtXe/HFckTboBRRyk RJH/tK2NaJjRbdNmtdU2Alb+XV/c1m0SU8P7tAMVQhQ9oAOFc3QHByDMNRG6wzWdPqOv v93vp4xdk8A/sv9wEALi7ZGln1h8p3GgrBtBfrdZuFKcv2z14AncHIdsbYjR6WD0Le/R 3QXgBSFeemmQ3G0VCEssqxgTyNjyAtgCFi2u0ajSDLNykaVP04VZVjaFY+5olJmTbBV3 lkEQ== X-Gm-Message-State: AO0yUKV3gLM+X26TqRBYHoBqLPHHMlVWa0AT+mlj43bw/FEC6s4q3Qlq wOJUfPF1VzLyrJkJyxlgkWc= X-Google-Smtp-Source: AK7set+UnEUT/H341lXDrviuCGtM2d+N+KLrxdEch/LIOQpTx1n5qnLiekpa2fy90O42UBABsLflig== X-Received: by 2002:ac8:7d95:0:b0:3bf:b0c6:4993 with SMTP id c21-20020ac87d95000000b003bfb0c64993mr63869759qtd.44.1678754180154; Mon, 13 Mar 2023 17:36:20 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id j15-20020ac8404f000000b003b323387c1asm571161qtl.18.2023.03.13.17.36.19 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:19 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 4/9] net: sunhme: Alphabetize includes Date: Mon, 13 Mar 2023 20:36:08 -0400 Message-Id: <20230314003613.3874089-5-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Alphabetize includes to make it clearer where to add new ones. Signed-off-by: Sean Anderson Reviewed-by: Simon Horman --- (no changes since v2) Changes in v2: - Make some more includes common drivers/net/ethernet/sun/sunhme.c | 59 ++++++++++++++----------------- 1 file changed, 27 insertions(+), 32 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 5e17b1cdf016..acdcae2cb49a 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -14,48 +14,43 @@ * argument : macaddr=0x00,0x10,0x20,0x30,0x40,0x50 */ -#include -#include -#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include #include -#include -#include #include -#include -#include -#include #include -#include +#include +#include +#include +#include #include -#include -#include -#include -#include -#include -#include #include -#include -#include - -#include -#include -#include - -#ifdef CONFIG_SPARC -#include +#include +#include #include +#include +#include +#include +#include +#include +#include +#include +#include + +#ifdef CONFIG_SPARC +#include #include #include #include #include -#include -#endif -#include - -#include - -#ifdef CONFIG_PCI -#include #endif #include "sunhme.h" From patchwork Tue Mar 14 00:36:09 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173497 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id AFCC3C6FD19 for ; Tue, 14 Mar 2023 00:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229565AbjCNAg5 (ORCPT ); Mon, 13 Mar 2023 20:36:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53594 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230061AbjCNAgj (ORCPT ); Mon, 13 Mar 2023 20:36:39 -0400 Received: from mail-qt1-x833.google.com (mail-qt1-x833.google.com [IPv6:2607:f8b0:4864:20::833]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1085F86DEF; Mon, 13 Mar 2023 17:36:22 -0700 (PDT) Received: by mail-qt1-x833.google.com with SMTP id h19so15181058qtk.7; Mon, 13 Mar 2023 17:36:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=ifAgnTIVVjI/zij0ehRAnz6xciCu/2xrwUn/q1pKvlU=; b=NDxf6hJ3AVdSQUsHwQrh0Xt0KIoYA47wpUW0Ef59sku2RasAB0Ui/4I9vBvFwmneUM Q+dF2LcxXjTMxPUlVfeboA1tmeYv6jHdrdwal1pdIFvDRlTpy4VS/1qsLKQfzwZOtEY7 FPNfQUYoy/bYfcO/Wi4GIdutDvv81VgNYSSUjK3ReVG2FJ+6wSZbZFfRetPdS95xvGAD BxBj1g9DbQhTiExCoKy1oD9ODus8pIYJDEt8vw4qnpll0tpHXmvfqhyvS7CntPNR6y/N VpO9yb7cHm0LZFFuJTRV11pzJGcQyCGQu5ENXc+jR7OGx0pBHV7kF1/kIGT3yZTVRCBY hfiw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754181; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ifAgnTIVVjI/zij0ehRAnz6xciCu/2xrwUn/q1pKvlU=; b=3cMVBrW2KsCaoVz4Bb7IGznaT7yDLzoBshTc5FSvdgJzbuM/FLM7ou0kcwtgrAXiFP GFZbORcyQPeDrp9pethMBoOXZS7m6oOC2y8q9qZrM/15OwK3/HlFmzOlbZ/L26uA/EEi kKRDPVz1DJEVqSezVt6SSQo2zEmULrwMfedW+j4Zj+mWfsQIIykmteWWslfjgEZwRQGJ lZaXAgN/gYbGW2y4/1ZfBUuVFUH0HWpNiZFcBkr/6RLe2iiNpk5VRU64KI9qEI/DKPHZ 7xiMxSl/h7x2ph/xX/69+zZoo6KiqjjgepI+s+qR/sfNFL4J6qJ02/wHvDLkDR16JFB3 qIBA== X-Gm-Message-State: AO0yUKUMnesfjHXFOAAfDr0BEswjyJBw3Iibue2XPILlfps6qb89NWFQ UvugkUTqOkoFyROz7qOq8k8= X-Google-Smtp-Source: AK7set8+4YtgqiaDEjKxSuIU6+0Msm8/z0E28j/+3mbT4pZnVJMnUlpN+D++YJUKzR3T31EcbmDUGw== X-Received: by 2002:ac8:5a07:0:b0:3bf:db86:e538 with SMTP id n7-20020ac85a07000000b003bfdb86e538mr58942713qta.68.1678754181154; Mon, 13 Mar 2023 17:36:21 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id c13-20020ac87dcd000000b003b835e7e283sm836320qte.44.2023.03.13.17.36.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:20 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 5/9] net: sunhme: Switch SBUS to devres Date: Mon, 13 Mar 2023 20:36:09 -0400 Message-Id: <20230314003613.3874089-6-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The PCI half of this driver was converted in commit 914d9b2711dd ("sunhme: switch to devres"). Do the same for the SBUS half. Signed-off-by: Sean Anderson Reviewed-by: Simon Horman --- (no changes since v1) drivers/net/ethernet/sun/sunhme.c | 118 +++++++++--------------------- 1 file changed, 35 insertions(+), 83 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index acdcae2cb49a..3072578c334a 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2313,29 +2313,28 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) struct net_device *dev; int i, qfe_slot = -1; u8 addr[ETH_ALEN]; - int err = -ENODEV; + int err; sbus_dp = op->dev.parent->of_node; /* We can match PCI devices too, do not accept those here. */ if (!of_node_name_eq(sbus_dp, "sbus") && !of_node_name_eq(sbus_dp, "sbi")) - return err; + return -ENODEV; if (is_qfe) { qp = quattro_sbus_find(op); if (qp == NULL) - goto err_out; + return -ENODEV; for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) if (qp->happy_meals[qfe_slot] == NULL) break; if (qfe_slot == 4) - goto err_out; + return -ENODEV; } - err = -ENOMEM; - dev = alloc_etherdev(sizeof(struct happy_meal)); + dev = devm_alloc_etherdev(&op->dev, sizeof(struct happy_meal)); if (!dev) - goto err_out; + return -ENOMEM; SET_NETDEV_DEV(dev, &op->dev); /* If user did not specify a MAC address specifically, use @@ -2369,46 +2368,45 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) spin_lock_init(&hp->happy_lock); - err = -ENODEV; if (qp != NULL) { hp->qfe_parent = qp; hp->qfe_ent = qfe_slot; qp->happy_meals[qfe_slot] = dev; } - hp->gregs = of_ioremap(&op->resource[0], 0, - GREG_REG_SIZE, "HME Global Regs"); - if (!hp->gregs) { + hp->gregs = devm_platform_ioremap_resource(op, 0); + if (IS_ERR(hp->gregs)) { dev_err(&op->dev, "Cannot map global registers.\n"); - goto err_out_free_netdev; + err = PTR_ERR(hp->gregs); + goto err_out_clear_quattro; } - hp->etxregs = of_ioremap(&op->resource[1], 0, - ETX_REG_SIZE, "HME TX Regs"); - if (!hp->etxregs) { + hp->etxregs = devm_platform_ioremap_resource(op, 1); + if (IS_ERR(hp->etxregs)) { dev_err(&op->dev, "Cannot map MAC TX registers.\n"); - goto err_out_iounmap; + err = PTR_ERR(hp->etxregs); + goto err_out_clear_quattro; } - hp->erxregs = of_ioremap(&op->resource[2], 0, - ERX_REG_SIZE, "HME RX Regs"); - if (!hp->erxregs) { + hp->erxregs = devm_platform_ioremap_resource(op, 2); + if (IS_ERR(hp->erxregs)) { dev_err(&op->dev, "Cannot map MAC RX registers.\n"); - goto err_out_iounmap; + err = PTR_ERR(hp->erxregs); + goto err_out_clear_quattro; } - hp->bigmacregs = of_ioremap(&op->resource[3], 0, - BMAC_REG_SIZE, "HME BIGMAC Regs"); - if (!hp->bigmacregs) { + hp->bigmacregs = devm_platform_ioremap_resource(op, 3); + if (IS_ERR(hp->bigmacregs)) { dev_err(&op->dev, "Cannot map BIGMAC registers.\n"); - goto err_out_iounmap; + err = PTR_ERR(hp->bigmacregs); + goto err_out_clear_quattro; } - hp->tcvregs = of_ioremap(&op->resource[4], 0, - TCVR_REG_SIZE, "HME Tranceiver Regs"); - if (!hp->tcvregs) { + hp->tcvregs = devm_platform_ioremap_resource(op, 4); + if (IS_ERR(hp->tcvregs)) { dev_err(&op->dev, "Cannot map TCVR registers.\n"); - goto err_out_iounmap; + err = PTR_ERR(hp->tcvregs); + goto err_out_clear_quattro; } hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); @@ -2428,13 +2426,12 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) hp->happy_bursts = of_getintprop_default(sbus_dp, "burst-sizes", 0x00); - hp->happy_block = dma_alloc_coherent(hp->dma_dev, - PAGE_SIZE, - &hp->hblock_dvma, - GFP_ATOMIC); - err = -ENOMEM; - if (!hp->happy_block) - goto err_out_iounmap; + hp->happy_block = dmam_alloc_coherent(&op->dev, PAGE_SIZE, + &hp->hblock_dvma, GFP_KERNEL); + if (!hp->happy_block) { + err = -ENOMEM; + goto err_out_clear_quattro; + } /* Force check of the link first time we are brought up. */ hp->linkcheck = 0; @@ -2472,10 +2469,10 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) happy_meal_set_initial_advertisement(hp); spin_unlock_irq(&hp->happy_lock); - err = register_netdev(hp->dev); + err = devm_register_netdev(&op->dev, dev); if (err) { dev_err(&op->dev, "Cannot register net device, aborting.\n"); - goto err_out_free_coherent; + goto err_out_clear_quattro; } platform_set_drvdata(op, hp); @@ -2490,31 +2487,9 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) return 0; -err_out_free_coherent: - dma_free_coherent(hp->dma_dev, - PAGE_SIZE, - hp->happy_block, - hp->hblock_dvma); - -err_out_iounmap: - if (hp->gregs) - of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); - if (hp->etxregs) - of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); - if (hp->erxregs) - of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); - if (hp->bigmacregs) - of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); - if (hp->tcvregs) - of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); - +err_out_clear_quattro: if (qp) qp->happy_meals[qfe_slot] = NULL; - -err_out_free_netdev: - free_netdev(dev); - -err_out: return err; } #endif @@ -2891,28 +2866,6 @@ static int hme_sbus_probe(struct platform_device *op) return happy_meal_sbus_probe_one(op, is_qfe); } -static int hme_sbus_remove(struct platform_device *op) -{ - struct happy_meal *hp = platform_get_drvdata(op); - struct net_device *net_dev = hp->dev; - - unregister_netdev(net_dev); - - of_iounmap(&op->resource[0], hp->gregs, GREG_REG_SIZE); - of_iounmap(&op->resource[1], hp->etxregs, ETX_REG_SIZE); - of_iounmap(&op->resource[2], hp->erxregs, ERX_REG_SIZE); - of_iounmap(&op->resource[3], hp->bigmacregs, BMAC_REG_SIZE); - of_iounmap(&op->resource[4], hp->tcvregs, TCVR_REG_SIZE); - dma_free_coherent(hp->dma_dev, - PAGE_SIZE, - hp->happy_block, - hp->hblock_dvma); - - free_netdev(net_dev); - - return 0; -} - static const struct of_device_id hme_sbus_match[] = { { .name = "SUNW,hme", @@ -2936,7 +2889,6 @@ static struct platform_driver hme_sbus_driver = { .of_match_table = hme_sbus_match, }, .probe = hme_sbus_probe, - .remove = hme_sbus_remove, }; static int __init happy_meal_sbus_init(void) From patchwork Tue Mar 14 00:36:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173498 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A47C0C61DA4 for ; Tue, 14 Mar 2023 00:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230169AbjCNAhG (ORCPT ); Mon, 13 Mar 2023 20:37:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:52994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230350AbjCNAgo (ORCPT ); Mon, 13 Mar 2023 20:36:44 -0400 Received: from mail-qt1-x834.google.com (mail-qt1-x834.google.com [IPv6:2607:f8b0:4864:20::834]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 629358C0D1; Mon, 13 Mar 2023 17:36:23 -0700 (PDT) Received: by mail-qt1-x834.google.com with SMTP id r16so15178621qtx.9; Mon, 13 Mar 2023 17:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0KmVLruLvF+jqsWPykecvC0B6jc53T3HrET1KAnIWSc=; b=M22ugzcytkQax8h5vFHcZ+GsyxFWQLBMtYFV5g41ljMTg8q5qZVkj3qRBd2XJVMGb8 M6WbXi9ee0io4rdv6ubgCaMdDYTGRQqTVOzTtPohj3U+V6wg0nfj/TNBYC9Vw+tm9beH 7jiGjy/CrcLPZYsAv7vljZfGpN9VCtHIPikuzyTqYQKlYWz4bU9W+zVj+nvoThnv/4eL uCgiOOiDlTR5c4jkXimqoZZTTooFaKE38Zcp0DOFLPB0V+/e98VSXzjbAKN5cbcluuU0 4nR09XnaxGEgS/ouYkEG2Po3UYi0c97Ijvz3oW4VpKTYfrAwfd20VpDLKo7u8Kmry/xb GENA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754182; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0KmVLruLvF+jqsWPykecvC0B6jc53T3HrET1KAnIWSc=; b=zHqhQMF29R+nBEGwyT4nD6HXbJUxQyrOzsZKhTrhfkYqKabKTz+iVvg7Hwdvvnb4/6 PIhy7taihbOQyWIAsKGg118u8OZpf/awVy6qc+oHeHGwxS/RzRAsVOltB/QKklS7qfCC a9K60oIJdi70u0+t82d0rbGGE0ly8f3dqelTwShjo7Y2fzrVDmm8P2J1RELMRyLM7bqz BAZLpTAKndcDTHwqLmnPvJKSen8KKCk9rCskXhe8JjfZph6mE4ojEkwN2yGAhw3q9/48 tOPrGT/3pSfTTBN4QwYWbOm1Jy17O4qz/QDbOkpvS/WB553aJF0crNQ/GtIcw8q9FFWY uDXw== X-Gm-Message-State: AO0yUKUi85Hp2gQwYoYgTBN8JYQBJfF0ofP8U7hkAUSzV7BmeOWGCDQd URCJ4rmkjluU4dBuEOFfbvg= X-Google-Smtp-Source: AK7set+30C8RSZIW0F1eBmZfSCH6faUpIHoIMY+BGBHKMRUipU+2PAWpIZ8rC+GMgjOhPMNXPhoU4A== X-Received: by 2002:a05:622a:1714:b0:3d1:1b8e:62f2 with SMTP id h20-20020a05622a171400b003d11b8e62f2mr1639212qtk.31.1678754182254; Mon, 13 Mar 2023 17:36:22 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id w8-20020a05620a148800b0073b81e888bfsm704360qkj.56.2023.03.13.17.36.21 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:22 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 6/9] net: sunhme: Consolidate mac address initialization Date: Mon, 13 Mar 2023 20:36:10 -0400 Message-Id: <20230314003613.3874089-7-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The mac address initialization is braodly the same between PCI and SBUS, and one was clearly copied from the other. Consolidate them. We still have to have some ifdefs because pci_(un)map_rom is only implemented for PCI, and idprom is only implemented for SPARC. Signed-off-by: Sean Anderson Reviewed-by: Simon Horman --- (no changes since v1) drivers/net/ethernet/sun/sunhme.c | 282 ++++++++++++++---------------- 1 file changed, 134 insertions(+), 148 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 3072578c334a..c2737f26afbe 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2304,6 +2304,133 @@ static const struct net_device_ops hme_netdev_ops = { .ndo_validate_addr = eth_validate_addr, }; +#ifdef CONFIG_PCI +static int is_quattro_p(struct pci_dev *pdev) +{ + struct pci_dev *busdev = pdev->bus->self; + struct pci_dev *this_pdev; + int n_hmes; + + if (!busdev || busdev->vendor != PCI_VENDOR_ID_DEC || + busdev->device != PCI_DEVICE_ID_DEC_21153) + return 0; + + n_hmes = 0; + list_for_each_entry(this_pdev, &pdev->bus->devices, bus_list) { + if (this_pdev->vendor == PCI_VENDOR_ID_SUN && + this_pdev->device == PCI_DEVICE_ID_SUN_HAPPYMEAL) + n_hmes++; + } + + if (n_hmes != 4) + return 0; + + return 1; +} + +/* Fetch MAC address from vital product data of PCI ROM. */ +static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr) +{ + int this_offset; + + for (this_offset = 0x20; this_offset < len; this_offset++) { + void __iomem *p = rom_base + this_offset; + + if (readb(p + 0) != 0x90 || + readb(p + 1) != 0x00 || + readb(p + 2) != 0x09 || + readb(p + 3) != 0x4e || + readb(p + 4) != 0x41 || + readb(p + 5) != 0x06) + continue; + + this_offset += 6; + p += 6; + + if (index == 0) { + int i; + + for (i = 0; i < 6; i++) + dev_addr[i] = readb(p + i); + return 1; + } + index--; + } + return 0; +} + +static void __maybe_unused get_hme_mac_nonsparc(struct pci_dev *pdev, + unsigned char *dev_addr) +{ + size_t size; + void __iomem *p = pci_map_rom(pdev, &size); + + if (p) { + int index = 0; + int found; + + if (is_quattro_p(pdev)) + index = PCI_SLOT(pdev->devfn); + + found = readb(p) == 0x55 && + readb(p + 1) == 0xaa && + find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); + pci_unmap_rom(pdev, p); + if (found) + return; + } + + /* Sun MAC prefix then 3 random bytes. */ + dev_addr[0] = 0x08; + dev_addr[1] = 0x00; + dev_addr[2] = 0x20; + get_random_bytes(&dev_addr[3], 3); +} +#endif /* !(CONFIG_SPARC) */ + +static void happy_meal_addr_init(struct happy_meal *hp, + struct device_node *dp, int qfe_slot) +{ + int i; + + for (i = 0; i < 6; i++) { + if (macaddr[i] != 0) + break; + } + + if (i < 6) { /* a mac address was given */ + u8 addr[ETH_ALEN]; + + for (i = 0; i < 6; i++) + addr[i] = macaddr[i]; + eth_hw_addr_set(hp->dev, addr); + macaddr[5]++; + } else { +#ifdef CONFIG_SPARC + const unsigned char *addr; + int len; + + /* If user did not specify a MAC address specifically, use + * the Quattro local-mac-address property... + */ + if (qfe_slot != -1) { + addr = of_get_property(dp, "local-mac-address", &len); + if (addr && len == 6) { + eth_hw_addr_set(hp->dev, addr); + return; + } + } + + eth_hw_addr_set(hp->dev, idprom->id_ethaddr); +#else + u8 addr[ETH_ALEN]; + + get_hme_mac_nonsparc(hp->happy_dev, addr); + eth_hw_addr_set(hp->dev, addr); +#endif + } +} + #ifdef CONFIG_SBUS static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) { @@ -2311,8 +2438,7 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) struct quattro *qp = NULL; struct happy_meal *hp; struct net_device *dev; - int i, qfe_slot = -1; - u8 addr[ETH_ALEN]; + int qfe_slot = -1; int err; sbus_dp = op->dev.parent->of_node; @@ -2337,34 +2463,11 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) return -ENOMEM; SET_NETDEV_DEV(dev, &op->dev); - /* If user did not specify a MAC address specifically, use - * the Quattro local-mac-address property... - */ - for (i = 0; i < 6; i++) { - if (macaddr[i] != 0) - break; - } - if (i < 6) { /* a mac address was given */ - for (i = 0; i < 6; i++) - addr[i] = macaddr[i]; - eth_hw_addr_set(dev, addr); - macaddr[5]++; - } else { - const unsigned char *addr; - int len; - - addr = of_get_property(dp, "local-mac-address", &len); - - if (qfe_slot != -1 && addr && len == ETH_ALEN) - eth_hw_addr_set(dev, addr); - else - eth_hw_addr_set(dev, idprom->id_ethaddr); - } - hp = netdev_priv(dev); - + hp->dev = dev; hp->happy_dev = op; hp->dma_dev = &op->dev; + happy_meal_addr_init(hp, dp, qfe_slot); spin_lock_init(&hp->happy_lock); @@ -2442,7 +2545,6 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) timer_setup(&hp->happy_timer, happy_meal_timer, 0); - hp->dev = dev; dev->netdev_ops = &hme_netdev_ops; dev->watchdog_timeo = 5*HZ; dev->ethtool_ops = &hme_ethtool_ops; @@ -2495,104 +2597,17 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) #endif #ifdef CONFIG_PCI -#ifndef CONFIG_SPARC -static int is_quattro_p(struct pci_dev *pdev) -{ - struct pci_dev *busdev = pdev->bus->self; - struct pci_dev *this_pdev; - int n_hmes; - - if (busdev == NULL || - busdev->vendor != PCI_VENDOR_ID_DEC || - busdev->device != PCI_DEVICE_ID_DEC_21153) - return 0; - - n_hmes = 0; - list_for_each_entry(this_pdev, &pdev->bus->devices, bus_list) { - if (this_pdev->vendor == PCI_VENDOR_ID_SUN && - this_pdev->device == PCI_DEVICE_ID_SUN_HAPPYMEAL) - n_hmes++; - } - - if (n_hmes != 4) - return 0; - - return 1; -} - -/* Fetch MAC address from vital product data of PCI ROM. */ -static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsigned char *dev_addr) -{ - int this_offset; - - for (this_offset = 0x20; this_offset < len; this_offset++) { - void __iomem *p = rom_base + this_offset; - - if (readb(p + 0) != 0x90 || - readb(p + 1) != 0x00 || - readb(p + 2) != 0x09 || - readb(p + 3) != 0x4e || - readb(p + 4) != 0x41 || - readb(p + 5) != 0x06) - continue; - - this_offset += 6; - p += 6; - - if (index == 0) { - int i; - - for (i = 0; i < 6; i++) - dev_addr[i] = readb(p + i); - return 1; - } - index--; - } - return 0; -} - -static void get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) -{ - size_t size; - void __iomem *p = pci_map_rom(pdev, &size); - - if (p) { - int index = 0; - int found; - - if (is_quattro_p(pdev)) - index = PCI_SLOT(pdev->devfn); - - found = readb(p) == 0x55 && - readb(p + 1) == 0xaa && - find_eth_addr_in_vpd(p, (64 * 1024), index, dev_addr); - pci_unmap_rom(pdev, p); - if (found) - return; - } - - /* Sun MAC prefix then 3 random bytes. */ - dev_addr[0] = 0x08; - dev_addr[1] = 0x00; - dev_addr[2] = 0x20; - get_random_bytes(&dev_addr[3], 3); -} -#endif /* !(CONFIG_SPARC) */ - static int happy_meal_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { struct quattro *qp = NULL; -#ifdef CONFIG_SPARC - struct device_node *dp; -#endif + struct device_node *dp = NULL; struct happy_meal *hp; struct net_device *dev; void __iomem *hpreg_base; struct resource *hpreg_res; - int i, qfe_slot = -1; + int qfe_slot = -1; char prom_name[64]; - u8 addr[ETH_ALEN]; int err; /* Now make sure pci_dev cookie is there. */ @@ -2634,7 +2649,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, SET_NETDEV_DEV(dev, &pdev->dev); hp = netdev_priv(dev); - + hp->dev = dev; hp->happy_dev = pdev; hp->dma_dev = &pdev->dev; @@ -2670,35 +2685,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, goto err_out_clear_quattro; } - for (i = 0; i < 6; i++) { - if (macaddr[i] != 0) - break; - } - if (i < 6) { /* a mac address was given */ - for (i = 0; i < 6; i++) - addr[i] = macaddr[i]; - eth_hw_addr_set(dev, addr); - macaddr[5]++; - } else { -#ifdef CONFIG_SPARC - const unsigned char *addr; - int len; - - if (qfe_slot != -1 && - (addr = of_get_property(dp, "local-mac-address", &len)) - != NULL && - len == 6) { - eth_hw_addr_set(dev, addr); - } else { - eth_hw_addr_set(dev, idprom->id_ethaddr); - } -#else - u8 addr[ETH_ALEN]; - - get_hme_mac_nonsparc(pdev, addr); - eth_hw_addr_set(dev, addr); -#endif - } + happy_meal_addr_init(hp, dp, qfe_slot); /* Layout registers. */ hp->gregs = (hpreg_base + 0x0000UL); @@ -2747,7 +2734,6 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, timer_setup(&hp->happy_timer, happy_meal_timer, 0); hp->irq = pdev->irq; - hp->dev = dev; dev->netdev_ops = &hme_netdev_ops; dev->watchdog_timeo = 5*HZ; dev->ethtool_ops = &hme_ethtool_ops; From patchwork Tue Mar 14 00:36:11 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173499 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id CEA8BC6FD1D for ; Tue, 14 Mar 2023 00:37:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230175AbjCNAhJ (ORCPT ); Mon, 13 Mar 2023 20:37:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230356AbjCNAgr (ORCPT ); Mon, 13 Mar 2023 20:36:47 -0400 Received: from mail-qv1-xf2e.google.com (mail-qv1-xf2e.google.com [IPv6:2607:f8b0:4864:20::f2e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5CA948C592; Mon, 13 Mar 2023 17:36:24 -0700 (PDT) Received: by mail-qv1-xf2e.google.com with SMTP id m6so421617qvq.0; Mon, 13 Mar 2023 17:36:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=MUg2QzMJL1lA1j5wto2RGOAT+HfO1sOCXGSoRe+2FbI=; b=AsuqJYecuA53+MFcru+ZjyCCc9wkzivS506xH+97NFFJFbdT/WtI90A2neYLGTQf/d viZGY7R8mMswLzXYl/0nA3nkd6sws/C7l1KlTpiPxa4cuf3W4cv2HiwfhIRSrqLV6btv CMDyHqbAgUwFD/jwX4xIVQcXQTT82e9mTRdTsXWjsMsaPt/eArU6+a0hsyMJ0ems/FEe KkrKCQZlNKG3n32Jp7o4iLtQHcjNwig2gC/hovTo31X6OTD5ado7kdIdpWBnhXbphFwO ys93eDnBJ7Jmep+MxlOt/TKa/U812EZsJFr4knS71oysIpPb7D1HI9ozT8cz93gKKOkY DXmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=MUg2QzMJL1lA1j5wto2RGOAT+HfO1sOCXGSoRe+2FbI=; b=osCxVhO2oSdpYWgnQGC7S8+o2xj/8x+r8fjt4dn3mWgmBELpqi1A8L+l2PTxAooxyf OvrYqSi8Y0pkyeOaY+xpD2mU3PJnqQoKCX36rV3+gfFGMEwkXzybnbjSxb46MS2rx0YD kBjy3GbbZKk+Q2T2qRc3nfy4E2IICiglLdn03e90ioPPTVvLlWak1ExVhMXZVOvvGSPW S0mhWlfX91Q9mmfuVzyOhzkRtHEFncUOc/HJpKD1BGWeoKjHvVCLiQvFyA4zTo9HTrOw /le9+w6W9T+i3uU9kC3yA61WWecmRSkoFD0RZpg23ipw/Zi4QM3xDOKpqYNRUOZwu+Tb vTAg== X-Gm-Message-State: AO0yUKVA4i7N8VDaC7PiE+xS8nMpVqvuxgvniUB5dG0eVxQoWM83QKPd DrXU7MY0Rq+2E6F8+83SY50= X-Google-Smtp-Source: AK7set9CvsNjayW00Os2w+QYcHeQFTFuRyByYy+M9yQwPjev0vWePVnyHkWNb6/z2+L3ieQ33hOqbQ== X-Received: by 2002:ad4:5d64:0:b0:56e:9d09:5150 with SMTP id fn4-20020ad45d64000000b0056e9d095150mr19035317qvb.15.1678754183287; Mon, 13 Mar 2023 17:36:23 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id c186-20020a379ac3000000b007456c75edbbsm677695qke.129.2023.03.13.17.36.22 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:23 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 7/9] net: sunhme: Clean up mac address init Date: Mon, 13 Mar 2023 20:36:11 -0400 Message-Id: <20230314003613.3874089-8-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Clean up some oddities suggested during review. Signed-off-by: Sean Anderson Reviewed-by: Simon Horman --- (no changes since v2) Changes in v2: - New drivers/net/ethernet/sun/sunhme.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index c2737f26afbe..1f27e99abf17 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2348,9 +2348,7 @@ static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsi p += 6; if (index == 0) { - int i; - - for (i = 0; i < 6; i++) + for (int i = 0; i < 6; i++) dev_addr[i] = readb(p + i); return 1; } @@ -2362,9 +2360,10 @@ static int find_eth_addr_in_vpd(void __iomem *rom_base, int len, int index, unsi static void __maybe_unused get_hme_mac_nonsparc(struct pci_dev *pdev, unsigned char *dev_addr) { + void __iomem *p; size_t size; - void __iomem *p = pci_map_rom(pdev, &size); + p = pci_map_rom(pdev, &size); if (p) { int index = 0; int found; @@ -2386,7 +2385,7 @@ static void __maybe_unused get_hme_mac_nonsparc(struct pci_dev *pdev, dev_addr[2] = 0x20; get_random_bytes(&dev_addr[3], 3); } -#endif /* !(CONFIG_SPARC) */ +#endif static void happy_meal_addr_init(struct happy_meal *hp, struct device_node *dp, int qfe_slot) From patchwork Tue Mar 14 00:36:12 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173500 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 13154C6FD19 for ; Tue, 14 Mar 2023 00:37:22 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230426AbjCNAhU (ORCPT ); Mon, 13 Mar 2023 20:37:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54548 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230203AbjCNAgt (ORCPT ); Mon, 13 Mar 2023 20:36:49 -0400 Received: from mail-qt1-x82d.google.com (mail-qt1-x82d.google.com [IPv6:2607:f8b0:4864:20::82d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4EBF5838BD; Mon, 13 Mar 2023 17:36:25 -0700 (PDT) Received: by mail-qt1-x82d.google.com with SMTP id c18so15209437qte.5; Mon, 13 Mar 2023 17:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=SOCOjPd5JpdHiLSR/P7sXnrUCKXyem7paBgrkQ5Wp0o=; b=UaCYiEHEWdVEKZ35OqXD+F2I1+pJVYxTIGR0lIjznZpNsKRAU3sLqHKElISUQVlqm5 SGMeGndNYHG7M0YJP/xAs3+UmIedBOD72oV2XmUQHjTErtYQJ5kfjLJqlZYudcYu4ZHy DjUrqrcveg60WeIWR5T2yXmeogoK6KTVx4yJaI6lYEOZw98CtCq9jTnHyJrqQtIwqV9t r5eu3h8cFR6sG6/b15NE7/LslVhwWsfeCxrbyJ9Tk6FKusJKL8JO0GtQ4xOzofguD4lN 1xegTf9tgJwRbpPOdtkGZ/hE4Zlr0iRPTimDh9j4IJgWPcjof3q3mxeMviTOfkCzqIeM Y6Ng== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754184; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=SOCOjPd5JpdHiLSR/P7sXnrUCKXyem7paBgrkQ5Wp0o=; b=qf4jLRTsVbzEsT+sWEqXP+YihR0kEKdB09lnKVDwBYItBVI8xBjS/97EMOehwFbHFS LuPDEFCl0JYslIfsQ9s6sbbCBsheQN6Cqn9eSOBxC4UoQoFLr20iwcsYSiwQnl0cxuJG 1y6Enc8nOQUBsN4ey06co2lrzH7zmmOxUV6Y49jCXvslk2f3aFFJtmc3sC2BHWu37xRU Q2VH5P688bi9R3ajYygcuDvb0B4cqfL5nZzzE59PHWVEo+2hacns+ZGm3HN+8tonlCAZ sEbXNGkoWXBsogyVxwRwK6Pye9IpOD9zDPOJPEaB0pxDQpUXRicG19l2x6+V/+oHfGYO 2l2w== X-Gm-Message-State: AO0yUKU/p4j7HEEqQtqAgMVny974ci/hcX8DKj+ov8NFoX5IZ/DjP23z w8EGs2ih9hPX1iHCmHvY4J8= X-Google-Smtp-Source: AK7set96rxov+2IiQhKKbU+qGrxezwXTHwxe4qUajECCw5UhdYZRog3KjQLrtyj1kDRE2MvDCRK+gg== X-Received: by 2002:a05:622a:148c:b0:3bf:b829:1939 with SMTP id t12-20020a05622a148c00b003bfb8291939mr27838813qtx.3.1678754184342; Mon, 13 Mar 2023 17:36:24 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id a23-20020ac86117000000b003b868cdc689sm841185qtm.5.2023.03.13.17.36.23 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:24 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson , kernel test robot , Dan Carpenter Subject: [PATCH net-next v3 8/9] net: sunhme: Inline error returns Date: Mon, 13 Mar 2023 20:36:12 -0400 Message-Id: <20230314003613.3874089-9-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org The err_out label used to have cleanup. Now that it just returns, inline it everywhere. While we're at it, fix an uninitialized return code if we never found a qfe slot. Fixes: 96c6e9faecf1 ("sunhme: forward the error code from pci_enable_device()") Reported-by: kernel test robot Reported-by: Dan Carpenter Signed-off-by: Sean Anderson --- Changes in v3: - Incorperate a fix from another series into this commit Changes in v2: - New drivers/net/ethernet/sun/sunhme.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 1f27e99abf17..a59b998062d9 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2622,29 +2622,25 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, err = pcim_enable_device(pdev); if (err) - goto err_out; + return err; pci_set_master(pdev); if (!strcmp(prom_name, "SUNW,qfe") || !strcmp(prom_name, "qfe")) { qp = quattro_pci_find(pdev); - if (IS_ERR(qp)) { - err = PTR_ERR(qp); - goto err_out; - } + if (IS_ERR(qp)) + return PTR_ERR(qp); for (qfe_slot = 0; qfe_slot < 4; qfe_slot++) if (!qp->happy_meals[qfe_slot]) break; if (qfe_slot == 4) - goto err_out; + return -ENODEV; } dev = devm_alloc_etherdev(&pdev->dev, sizeof(struct happy_meal)); - if (!dev) { - err = -ENOMEM; - goto err_out; - } + if (!dev) + return -ENOMEM; SET_NETDEV_DEV(dev, &pdev->dev); hp = netdev_priv(dev); @@ -2792,8 +2788,6 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, err_out_clear_quattro: if (qp != NULL) qp->happy_meals[qfe_slot] = NULL; - -err_out: return err; } From patchwork Tue Mar 14 00:36:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13173502 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id C2DD7C6FD1F for ; Tue, 14 Mar 2023 00:37:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230460AbjCNAha (ORCPT ); Mon, 13 Mar 2023 20:37:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53362 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230372AbjCNAgw (ORCPT ); Mon, 13 Mar 2023 20:36:52 -0400 Received: from mail-qt1-x82f.google.com (mail-qt1-x82f.google.com [IPv6:2607:f8b0:4864:20::82f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 52E6D82A9B; Mon, 13 Mar 2023 17:36:26 -0700 (PDT) Received: by mail-qt1-x82f.google.com with SMTP id c1so1246520qtw.1; Mon, 13 Mar 2023 17:36:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678754185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=U8Npc50X5KuAY+Y1yr956zaaESW6+08Bvn+jbPGD8L8=; b=R2VT8Y4Hb0BS8ErGj77BH8D/VQnG6puKEFLsUTfoQiOc8RTGrQ6yvUxO4zVixzh4UK SGSkLWGKbjK6nfmOFfv8zK2hJEf5iZ9Ahm+MdIgP2yW1W7JamJVBIGrWvKpSJLDOqX5/ xy0dMhtyuzQ9b8CoqYwEbiBx91l+TsX9mD33+MtcoWdh0E2nyvAovydpHQVn7I/+h6v6 ojePl6HBZ/YIf/c2OwPH/S1MMETgUFV56xTEkjZCSGB6tIaallsAt2NhRq12dPZHU9rH E24l2vOynGHSSVZ8vlpYOjnMiQ3ckTYwB4Ah3kRtawTyOrkDbXn6M0rqeMkruRFCEJHE 97/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678754185; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=U8Npc50X5KuAY+Y1yr956zaaESW6+08Bvn+jbPGD8L8=; b=NDAMCKjBfMKn96G/8pjRsdodXWwse8WcTdVD6VcRy+Y8qn3c6d3Q37d+9u15kwJvlZ lzvzNfImaRFSIowmpR6ZDzoCiqD9NC8x8X3o7ljZuUh5kipVrf2XVqUda1dewdNzvMaD Rs7GFRHT/+BHXnzcw/t5tiJUlY4hluNCWae9pIWEZHG/ZdldzchzSHI2M43SDXf0xHmT XdFR2z8LKdYAl1hQ08miLxMDmi1DyTdAkm7LGDQ2pZuzbH1wb5VF5cBhkTWbYCeYoNhG r3vAvbM0WxCL64C1QIPg0icUvf7oBVIkFTHjeOZ2Xt6gKpIbBUYVJVZ+2zXLomgz9GRJ WuUw== X-Gm-Message-State: AO0yUKWTMxeCTZS5Vq9m61m6HpcTbizfRW6ohOfvfOOVuqofiZqYYtET 4CSKLi+BQ2XV0z7Ddm7ZnKI= X-Google-Smtp-Source: AK7set/J0zBHnPa2g5cVVHqNZyq9yy9TE9AmZ3oRUP6Z9t7XYro/51rWg3GGM5UxUcqtYfcdN9jR9Q== X-Received: by 2002:ac8:57cd:0:b0:3bf:be20:544c with SMTP id w13-20020ac857cd000000b003bfbe20544cmr60885235qta.39.1678754185365; Mon, 13 Mar 2023 17:36:25 -0700 (PDT) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id x9-20020ac87a89000000b003a530a32f67sm772247qtr.65.2023.03.13.17.36.24 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Mar 2023 17:36:25 -0700 (PDT) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: Simon Horman , linux-kernel@vger.kernel.org, Sean Anderson Subject: [PATCH net-next v3 9/9] net: sunhme: Consolidate common probe tasks Date: Mon, 13 Mar 2023 20:36:13 -0400 Message-Id: <20230314003613.3874089-10-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230314003613.3874089-1-seanga2@gmail.com> References: <20230314003613.3874089-1-seanga2@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org Most of the second half of the PCI/SBUS probe functions are the same. Consolidate them into a common function. Signed-off-by: Sean Anderson --- (no changes since v1) drivers/net/ethernet/sun/sunhme.c | 183 ++++++++++++------------------ 1 file changed, 71 insertions(+), 112 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index a59b998062d9..a384b162c46d 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2430,6 +2430,71 @@ static void happy_meal_addr_init(struct happy_meal *hp, } } +static int happy_meal_common_probe(struct happy_meal *hp, + struct device_node *dp, int minor_rev) +{ + struct net_device *dev = hp->dev; + int err; + +#ifdef CONFIG_SPARC + hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); + if (hp->hm_revision == 0xff) + hp->hm_revision = 0xc0 | minor_rev; +#else + /* works with this on non-sparc hosts */ + hp->hm_revision = 0x20; +#endif + + /* Now enable the feature flags we can. */ + if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) + hp->happy_flags |= HFLAG_20_21; + else if (hp->hm_revision != 0xa0) + hp->happy_flags |= HFLAG_NOT_A0; + + hp->happy_block = dmam_alloc_coherent(hp->dma_dev, PAGE_SIZE, + &hp->hblock_dvma, GFP_KERNEL); + if (!hp->happy_block) + return -ENOMEM; + + /* Force check of the link first time we are brought up. */ + hp->linkcheck = 0; + + /* Force timer state to 'asleep' with count of zero. */ + hp->timer_state = asleep; + hp->timer_ticks = 0; + + timer_setup(&hp->happy_timer, happy_meal_timer, 0); + + dev->netdev_ops = &hme_netdev_ops; + dev->watchdog_timeo = 5 * HZ; + dev->ethtool_ops = &hme_ethtool_ops; + + /* Happy Meal can do it all... */ + dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; + dev->features |= dev->hw_features | NETIF_F_RXCSUM; + +#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) + /* Hook up SBUS register/descriptor accessors. */ + hp->read_desc32 = sbus_hme_read_desc32; + hp->write_txd = sbus_hme_write_txd; + hp->write_rxd = sbus_hme_write_rxd; + hp->read32 = sbus_hme_read32; + hp->write32 = sbus_hme_write32; +#endif + + /* Grrr, Happy Meal comes up by default not advertising + * full duplex 100baseT capabilities, fix this. + */ + spin_lock_irq(&hp->happy_lock); + happy_meal_set_initial_advertisement(hp); + spin_unlock_irq(&hp->happy_lock); + + err = devm_register_netdev(hp->dma_dev, dev); + if (err) + dev_err(hp->dma_dev, "Cannot register net device, aborting.\n"); + return err; +} + #ifdef CONFIG_SBUS static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) { @@ -2511,70 +2576,18 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) goto err_out_clear_quattro; } - hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); - if (hp->hm_revision == 0xff) - hp->hm_revision = 0xa0; - - /* Now enable the feature flags we can. */ - if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) - hp->happy_flags = HFLAG_20_21; - else if (hp->hm_revision != 0xa0) - hp->happy_flags = HFLAG_NOT_A0; - if (qp != NULL) hp->happy_flags |= HFLAG_QUATTRO; + hp->irq = op->archdata.irqs[0]; + /* Get the supported DVMA burst sizes from our Happy SBUS. */ hp->happy_bursts = of_getintprop_default(sbus_dp, "burst-sizes", 0x00); - hp->happy_block = dmam_alloc_coherent(&op->dev, PAGE_SIZE, - &hp->hblock_dvma, GFP_KERNEL); - if (!hp->happy_block) { - err = -ENOMEM; + err = happy_meal_common_probe(hp, dp, 0); + if (err) goto err_out_clear_quattro; - } - - /* Force check of the link first time we are brought up. */ - hp->linkcheck = 0; - - /* Force timer state to 'asleep' with count of zero. */ - hp->timer_state = asleep; - hp->timer_ticks = 0; - - timer_setup(&hp->happy_timer, happy_meal_timer, 0); - - dev->netdev_ops = &hme_netdev_ops; - dev->watchdog_timeo = 5*HZ; - dev->ethtool_ops = &hme_ethtool_ops; - - /* Happy Meal can do it all... */ - dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; - dev->features |= dev->hw_features | NETIF_F_RXCSUM; - - hp->irq = op->archdata.irqs[0]; - -#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) - /* Hook up SBUS register/descriptor accessors. */ - hp->read_desc32 = sbus_hme_read_desc32; - hp->write_txd = sbus_hme_write_txd; - hp->write_rxd = sbus_hme_write_rxd; - hp->read32 = sbus_hme_read32; - hp->write32 = sbus_hme_write32; -#endif - - /* Grrr, Happy Meal comes up by default not advertising - * full duplex 100baseT capabilities, fix this. - */ - spin_lock_irq(&hp->happy_lock); - happy_meal_set_initial_advertisement(hp); - spin_unlock_irq(&hp->happy_lock); - - err = devm_register_netdev(&op->dev, dev); - if (err) { - dev_err(&op->dev, "Cannot register net device, aborting.\n"); - goto err_out_clear_quattro; - } platform_set_drvdata(op, hp); @@ -2689,21 +2702,6 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, hp->bigmacregs = (hpreg_base + 0x6000UL); hp->tcvregs = (hpreg_base + 0x7000UL); -#ifdef CONFIG_SPARC - hp->hm_revision = of_getintprop_default(dp, "hm-rev", 0xff); - if (hp->hm_revision == 0xff) - hp->hm_revision = 0xc0 | (pdev->revision & 0x0f); -#else - /* works with this on non-sparc hosts */ - hp->hm_revision = 0x20; -#endif - - /* Now enable the feature flags we can. */ - if (hp->hm_revision == 0x20 || hp->hm_revision == 0x21) - hp->happy_flags = HFLAG_20_21; - else if (hp->hm_revision != 0xa0 && hp->hm_revision != 0xc0) - hp->happy_flags = HFLAG_NOT_A0; - if (qp != NULL) hp->happy_flags |= HFLAG_QUATTRO; @@ -2714,50 +2712,11 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, /* Assume PCI happy meals can handle all burst sizes. */ hp->happy_bursts = DMA_BURSTBITS; #endif - - hp->happy_block = dmam_alloc_coherent(&pdev->dev, PAGE_SIZE, - &hp->hblock_dvma, GFP_KERNEL); - if (!hp->happy_block) { - err = -ENOMEM; - goto err_out_clear_quattro; - } - - hp->linkcheck = 0; - hp->timer_state = asleep; - hp->timer_ticks = 0; - - timer_setup(&hp->happy_timer, happy_meal_timer, 0); - hp->irq = pdev->irq; - dev->netdev_ops = &hme_netdev_ops; - dev->watchdog_timeo = 5*HZ; - dev->ethtool_ops = &hme_ethtool_ops; - /* Happy Meal can do it all... */ - dev->hw_features = NETIF_F_SG | NETIF_F_HW_CSUM; - dev->features |= dev->hw_features | NETIF_F_RXCSUM; - -#if defined(CONFIG_SBUS) && defined(CONFIG_PCI) - /* Hook up PCI register/descriptor accessors. */ - hp->read_desc32 = pci_hme_read_desc32; - hp->write_txd = pci_hme_write_txd; - hp->write_rxd = pci_hme_write_rxd; - hp->read32 = pci_hme_read32; - hp->write32 = pci_hme_write32; -#endif - - /* Grrr, Happy Meal comes up by default not advertising - * full duplex 100baseT capabilities, fix this. - */ - spin_lock_irq(&hp->happy_lock); - happy_meal_set_initial_advertisement(hp); - spin_unlock_irq(&hp->happy_lock); - - err = devm_register_netdev(&pdev->dev, dev); - if (err) { - dev_err(&pdev->dev, "Cannot register net device, aborting.\n"); + err = happy_meal_common_probe(hp, dp, pdev->revision & 0x0f); + if (err) goto err_out_clear_quattro; - } pci_set_drvdata(pdev, hp);