From patchwork Sat Mar 11 18:18:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170961 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 DCA84C6FD1C for ; Sat, 11 Mar 2023 18:19:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230400AbjCKSTR (ORCPT ); Sat, 11 Mar 2023 13:19:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229550AbjCKSTM (ORCPT ); Sat, 11 Mar 2023 13:19:12 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2BF9A46094; Sat, 11 Mar 2023 10:19:09 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id op8so5733923qvb.11; Sat, 11 Mar 2023 10:19:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558749; 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=kBhfXSJMkBpFIaGe77jZ2WSDzdVO6ZlN8zU6btY/Qfc=; b=IQ8ex2wC7k0e4aVZ9c92p+fwhn7JRRHwhmKfJYhMqpMQ+EXfXvjpu99naGWbViwvWJ xc/fyPnoLGbFZUSkJ1QwUOMFtaUalNz7sKkNb+FesKJGlNBhg7WukTbyOWcCTNCs1EMr pQ8orvR20oa1AgynbukZKx6RZMCXuUVn3n02jT+IZAK3FdHFnYZdGnvL0U25qXzuNlA2 z2qynA/gK+shgNeWnvKing3n2o//G3b4hIzpY28pX4qEQ4M+5/0NmzyCCnJY+KkThNz3 Oaq9HSBa+ATpTq9frHI2KhkcQTaKPlgPbyvYH4VWWyn5dYxeVZTgRxf6WTls20b/zXjW dEuA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558749; 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=kBhfXSJMkBpFIaGe77jZ2WSDzdVO6ZlN8zU6btY/Qfc=; b=LdkZuudPl/PwLnhGEbSrL8gWI4YjlcV6O/B6mz3mO2i8ciF+L5j1zGAgJGPtyMZr7f MTgxfgY7dUwIp9OSJh/3cNIVCU6vaCPLu++OrtWWGSEJ7tKyVxrzt5gJTnzB1LPpir7C NxkSicwVvN0CMJVBxxemwCOwucZTYynonl6j3qEYHwvnRQ0usNEg+3XkxcbWhapcN3GQ Qu9xui+fATkfeAxkQepIslIOebny+QTyd27QLELBoaXmgnbzEeUmghtf5PmF0m2kMDA+ YSd6zSuDFY6ye/XSPV1XCg/I9rdoVdA2wtIHMkH6cSxZCI3VoipmhE9GQHnIGPIobkKU JLbw== X-Gm-Message-State: AO0yUKXmbM9XsFSn5osAMe21pm3L0Ft2OKowaCWV69wPAPtlnRvEquXk ki2sHXPD9uxG5a/Y1dzYNIytucopU80= X-Google-Smtp-Source: AK7set+l4LicDMEKLVhyT4t+8d5I718Ce7DMd6q9c80eejfelQj8RyfQoCoFXDCmBYr+mHgDDfjCyA== X-Received: by 2002:a05:6214:3001:b0:56e:92a8:e18e with SMTP id ke1-20020a056214300100b0056e92a8e18emr5524951qvb.31.1678558748986; Sat, 11 Mar 2023 10:19:08 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id y194-20020a3764cb000000b00743a0096e8csm1813020qkb.39.2023.03.11.10.19.08 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:08 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 1/9] net: sunhme: Just restart autonegotiation if we can't bring the link up Date: Sat, 11 Mar 2023 13:18:57 -0500 Message-Id: <20230311181905.3593904-2-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 --- 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 dd14114cbcfb..4d850e4b2917 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 Sat Mar 11 18:18:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170962 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 52893C61DA4 for ; Sat, 11 Mar 2023 18:19:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230371AbjCKST2 (ORCPT ); Sat, 11 Mar 2023 13:19:28 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59822 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230188AbjCKSTN (ORCPT ); Sat, 11 Mar 2023 13:19:13 -0500 Received: from mail-qv1-xf34.google.com (mail-qv1-xf34.google.com [IPv6:2607:f8b0:4864:20::f34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3CB4D1F49F; Sat, 11 Mar 2023 10:19:11 -0800 (PST) Received: by mail-qv1-xf34.google.com with SMTP id nf5so5755327qvb.5; Sat, 11 Mar 2023 10:19:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558750; 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=2/ptgD6MDVbz5bFijxU3a9dI2bFfIEiKqRZ1PRQJTe8=; b=TjWkSRmrkKyZGpIcoMWMvKr+iGB3szqwxFh1r5FdzJk4w9zOj1eNJN5pQKgdSZEcSv wzVQf2uNzqeYUu4i3Q4H3E0Zpo0Sg3Ez+IEXTxOMNvOw8lVUSq8TfvBwx+a2IxLt8HoD 6ESlOmk/8fF65hlNn6DRyyb+1zAlwQ/dXWI+YdFhLOqnP5pia9n0tIGzqR+i9zrUEioN yFQ5AJgrktt0tSpsR0o2mI0JCDKumfkZk3dtVXS6N2y8vvLUIX3IHewhYi2midQ4B0Yx muiXx2inX2SPRWPNhyGwuW6QjJ4XLuXyBzhsEjgC/GKBwjBMcFYJasa5taWE1PEzJT0m +i7g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558750; 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=2/ptgD6MDVbz5bFijxU3a9dI2bFfIEiKqRZ1PRQJTe8=; b=3Zt6foPU5weZ1YBSXy/lbhdBaNf2Uao+PdzehoG2CS1unW9kAagzJ1tHV6Bxx9eGF6 QXCb5gz9qb3RnfcC4EwDNJFIw/iGMZAMx8EarA6sueXpcm7CLKVNhwiX/dI2f8K4o5TX 0UfKCAHoEbxbFRUJ262moCDNwoGl3ZIslJ8c2vbqKgTSl6xHRM2oesy/T3ARE8HmD9TM D2nxyjPEToLc1xOwDBZUDtjKchY1xxKRXVEF80z5xEWEJaVEWZusiLU84Yi/nIBEkut1 UtEg/LxrnXsOqT3weKWrpFMEh4a0DlN5HkMaslPYlzIfNeQOKJkDquHMNsP+MXlEIiUa NRKA== X-Gm-Message-State: AO0yUKWM3ZGde9l4IcY3rdrs2HunuB0ZVgxoHma27gieF/r1UfNVMljL 6OEnx2zMNrgwtg86T4HyWvU= X-Google-Smtp-Source: AK7set/MQY2Uy0ZarnFec/07F7rN/0cTdOVLcGZhS48eLzZ3YvZzVCYQHfyX0fgtbyodXvMBqTYDOw== X-Received: by 2002:a05:6214:29c1:b0:56e:a9d4:429b with SMTP id gh1-20020a05621429c100b0056ea9d4429bmr4796888qvb.1.1678558750211; Sat, 11 Mar 2023 10:19:10 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id i14-20020ac8764e000000b003c034837d8fsm2210254qtr.33.2023.03.11.10.19.09 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:09 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 2/9] net: sunhme: Remove residual polling code Date: Sat, 11 Mar 2023 13:18:58 -0500 Message-Id: <20230311181905.3593904-3-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 --- (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 4d850e4b2917..bb93fd69f4a9 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 Sat Mar 11 18:18:59 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170963 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 6022FC6FD1C for ; Sat, 11 Mar 2023 18:19:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230302AbjCKST3 (ORCPT ); Sat, 11 Mar 2023 13:19:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230316AbjCKSTO (ORCPT ); Sat, 11 Mar 2023 13:19:14 -0500 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 266F456166; Sat, 11 Mar 2023 10:19:12 -0800 (PST) Received: by mail-qt1-x834.google.com with SMTP id r16so9271852qtx.9; Sat, 11 Mar 2023 10:19:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558751; 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=qBS4YQTCBlLtFo3hOvq6pEbUYT0HI5CpCo0cMMsulC0=; b=AwqOQs5AwzwrE2WM9AYHERUNWqN2bL2NaYY6QbLcp65qbClIA6tXcQI3+fjecH7L9K 5Hj4t5hNa4sHiGd2e0gCTY18COiMhktHaWyQQeT0PQ1nR4N+32lvcwbKtBNbmLHq9+uh CxMoMKZgMoC5XBdfSx0pA30fS6drDT6fEx0x3kaxQsSppu4sN29omJa0eAXFoblJZcar k+x8QtrON4bDEseUQn55712WsO4OZDqEg9vmmXTMu2NpxV8o9ocE06VsbWdQnwzRDqrl AIBe8NaEFgJnMl9xG5qVtByPBVAM7gjIVzuWWrIw8Pp7Ljy0lt23YBn04Fylo7ABsqRL GPjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558751; 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=qBS4YQTCBlLtFo3hOvq6pEbUYT0HI5CpCo0cMMsulC0=; b=HUaemzGW4jU5C5G1RxRuZqng05Eemgoxl5LYGVDyTCr3M4nXcwDjYYQYDmn5/NBbjq ksCL/gE8bJoiv48pOuKqPv5vxRrTNzzJuXZin+ytHewdGG5MUmjN3ZZiOacBE4cTIyNm gBFtctz53oxe7Idz2ZYmOqJDDns4ytUEAF0DG4jdWwWAD1qbNdP+cusdIAWpAQQGfh5n BBgYq+/JW/txYJyGGCHhFOQyBgoWknpDmi2lXM0ligqMYK30i+Epu+sIo/dIG4Ohe+EE IRosKB6PK1KLXygKktSLANYDbGSZwDbk7upN0F1sgk5E8qf6k8GQkJf8z8Ig42JROzJb +zzQ== X-Gm-Message-State: AO0yUKU2RErrhtXrOb0IhGfd23X1C+VItbRIak3+oIQjysAK6ufVQVBO FpuPSpL2sRo0AwLVdOHDfmg= X-Google-Smtp-Source: AK7set8ZBJ+9RruMPa20EXWloETfIStnngpl8cGTmqmkNwpV3Jt8GR/v3S9dxFmofrVphTbILphz/Q== X-Received: by 2002:a05:622a:8:b0:3b6:36e1:ed42 with SMTP id x8-20020a05622a000800b003b636e1ed42mr47428438qtw.9.1678558751204; Sat, 11 Mar 2023 10:19:11 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id s10-20020ac8758a000000b003bfeb30c24dsm2212274qtq.39.2023.03.11.10.19.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:10 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 3/9] net: sunhme: Unify IRQ requesting Date: Sat, 11 Mar 2023 13:18:59 -0500 Message-Id: <20230311181905.3593904-4-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 --- (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 bb93fd69f4a9..cf13123b6ff6 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 @@ -3006,8 +2904,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); @@ -3051,19 +2947,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 Sat Mar 11 18:19:00 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170964 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 61927C7618A for ; Sat, 11 Mar 2023 18:19:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230422AbjCKSTb (ORCPT ); Sat, 11 Mar 2023 13:19:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60018 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230426AbjCKSTS (ORCPT ); Sat, 11 Mar 2023 13:19:18 -0500 Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4C4A85CED1; Sat, 11 Mar 2023 10:19:13 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id s12so9246179qtq.11; Sat, 11 Mar 2023 10:19:13 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558752; 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=QrXQNAz/M0d4nuMmuJlrut/rzP8JqShoqKn8x6aNlzA=; b=NnijRSbdvTo7d6tV4qYy5FOhWXsYyAZm9Y3rHjAu2vPJXsxtb9+27Q/Rqp3p60lNEW l+i+TV57KqtmFFKiKdgnPERrtZ54W20VyjcZprqdBQ2bW7hVcX9m4nNTI7zWLYTw2exo QB0fAieWPWU3O4hsLwb/gawa40+huXOiefQ4idNuQZKIISSRMg9KiKBqYtygV+/87mNY stNqtFGx17QOcopdpBqheftCYG9uoBzGVh/f4wpuDt9b6g0AI0wZ62T88MCpB37BAmY8 UbaAWGvxSlYVtGRwtoXWnDAw8dG0hAzOT7xlQu7YnypsXu0kaltJMAptvamazVK82ocU 6COw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558752; 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=QrXQNAz/M0d4nuMmuJlrut/rzP8JqShoqKn8x6aNlzA=; b=n5qMMRacu6Nh+fXLR4CMP2skedqq88UrFQHfOFW33BBgkCNUSRmTEVTRE2/Tp2B916 htV6FE2xbKUs7xvnKVR5nBsr3QQfyTk5Zy4CyAe1ZDH8JXDGCGG8z1qGABRzu3oaRx7z F/G70K/xop92D3U1UYIbm+xWKYwZnxwe/WCLDLmV6LSt3JiWXHTKbUMHEfey53VM/uLY wKK+yR1xcSzDzriRXegrDX6QjfpGcxgjaF+a9shP8APmXwRcxSJaMHG+eA6iNWBt+AeE CznHDSne1/mkPNLCzOp5hLJb3WLK4pOjFB3ttDs4HqWk5CpK6TJy/+3iqO9tNIBHvsv2 SN4w== X-Gm-Message-State: AO0yUKVXmd4fyR3CIita7JPIKAom4xO/KsEoX5bW2h1QTvUxn2lZLOl9 RF1v6ToM3oijGuQJMfp4WgU= X-Google-Smtp-Source: AK7set+GpGxDBEw+eRJ2l5UD01WPH39ouTrhgZUCLs+rtXZpkxjnnGngvZwwcuCiP5+KYRfXQrvE3w== X-Received: by 2002:a05:622a:1391:b0:3bf:c575:3f42 with SMTP id o17-20020a05622a139100b003bfc5753f42mr29163594qtk.33.1678558752279; Sat, 11 Mar 2023 10:19:12 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id o5-20020ac80245000000b003b9b41a32b7sm2249819qtg.81.2023.03.11.10.19.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:11 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 4/9] net: sunhme: Alphabetize includes Date: Sat, 11 Mar 2023 13:19:00 -0500 Message-Id: <20230311181905.3593904-5-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 --- 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 cf13123b6ff6..a6c4cb4f99f3 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 Sat Mar 11 18:19:01 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170965 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 274F8C6FD1C for ; Sat, 11 Mar 2023 18:19:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230407AbjCKSTd (ORCPT ); Sat, 11 Mar 2023 13:19:33 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60418 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230057AbjCKST1 (ORCPT ); Sat, 11 Mar 2023 13:19:27 -0500 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 685B162DBD; Sat, 11 Mar 2023 10:19:14 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id d7so9229892qtr.12; Sat, 11 Mar 2023 10:19:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558753; 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=9HJSpBLuc5WAYQT0d5gHGocIKuW88IDo8QVVL/Yyfo0=; b=m+l435cHxQhLH0tNw1oNRMVT1tHv3pnuaPpuYVgR/Z957DT7LDuqkxOQAwZc3ZVWkq cBg3013DTUq+kIHi6wfdxc/ikBQ37daEM9+XxzCaDJcUGiWtWFRcJ7yVAz6zFxVWaX0U AxKCkin/os4RGQG1koC6pq4hN65YUt6V4+zjeZSsztnYfJ682rD6VPL+C6bO5OgqCsJj /jBf4b6NWAqXHQYXDq1adyodQ1LH46cAZkqBEAep1aSy9Pz18mEeNgzz4JzUUvnrHC5d w1I5wfFIm1J8ziPo5FGJAWtsAreuVyr5e2kt2uZTpc0NTDlISYGOwzFTGDr3dlu2go8f SkTA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558753; 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=9HJSpBLuc5WAYQT0d5gHGocIKuW88IDo8QVVL/Yyfo0=; b=UP1bTM4Y7IIl9ddCGZIS2fif2RNGsEGuS0GPJSwWdOPI89wsVKRvuC89hA/q7lYRr0 4ihqB2TTPYq5KtdTsn3KLj+1voW9Jcpc8/C1ToIYLjGiCNcvYM2MqrKKkVf3ka9WPDQh GQstiPABnAr0kjm5N2TodfLuwetd5V4jKa4VO572oZQXLGTR+gWEq0Ea1iWRURETif+M jTZHOnKkshaWo6BQSZIfEKPixgADfFs3Yy5UY6nv2GkdYYaS2dJ2yeONqAIvnp6oyuAz KyjROLy0obMc2cjpdYh4Ex4BMJdKpgEzbEQajXw7TDqEgog2p08Cqsv8eOcWxb2+Le3A NloA== X-Gm-Message-State: AO0yUKXMuxK7NsBNLipAMjjvcwmr+aOFGtu6UzHrAG+K0+XvGPxUyslW MFnkO4Eousn2njc1QesjsgI= X-Google-Smtp-Source: AK7set8lWHmo78EJVakk9gY6CsSv2Zrhf54XldyaBWWJYbgYH+1FyYzmMQTIPgAmCOE6CYuvXFnxaA== X-Received: by 2002:ac8:7d0e:0:b0:3b9:b7c9:f0d1 with SMTP id g14-20020ac87d0e000000b003b9b7c9f0d1mr18274659qtb.39.1678558753561; Sat, 11 Mar 2023 10:19:13 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id x27-20020a05620a0b5b00b0074230493ccfsm2147528qkg.73.2023.03.11.10.19.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:13 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 5/9] net: sunhme: Switch SBUS to devres Date: Sat, 11 Mar 2023 13:19:01 -0500 Message-Id: <20230311181905.3593904-6-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 --- (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 a6c4cb4f99f3..24101d3d5f85 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 @@ -2892,28 +2867,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", @@ -2937,7 +2890,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 Sat Mar 11 18:19:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170967 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 69121C74A44 for ; Sat, 11 Mar 2023 18:19:39 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230517AbjCKSTg (ORCPT ); Sat, 11 Mar 2023 13:19:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60430 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230431AbjCKST1 (ORCPT ); Sat, 11 Mar 2023 13:19:27 -0500 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 98D1E59400; Sat, 11 Mar 2023 10:19:15 -0800 (PST) Received: by mail-qt1-x836.google.com with SMTP id l13so9304741qtv.3; Sat, 11 Mar 2023 10:19:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558754; 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=9PXLPzAtfehW08ZAXdSsYNbiCMYMth6hztWbsXm+Zsw=; b=SjvtErNmNuy5VCX0Ca+cNk4paRYsuCvEaTwQ3Xf4mtDdJBzBgOEhWwri+gl3uJl5cC pxjz1p27Xdl6vIJftlWoY7B1hUN1phH0LY2oQtjP7ppp2sKe2bJUSfGMbfb9rY+6mxYC TrUr0VxXfCbqCbV6ZYatpmyryGUDTPpRSQlRAbxO5gnC4S8v5c+5WqY2HGJzCk21qvLu y+loy/vIU8u0P3ndocyl9NEMmcfoFFSapL9jNyarjWsYDTcrGu6TqDOMKBHat5T1y8yV lqkBFvcOCCxRyUexYT7mHIU9HzZXqVng2GfZf8zVj/UOz9qnIGSxtWnOV9g0Z/mbi/0i KCvA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558754; 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=9PXLPzAtfehW08ZAXdSsYNbiCMYMth6hztWbsXm+Zsw=; b=VYOsvZO6sKv6JWCJcqCFQZr9/bZDoEDxxot3xtm7iGbUGEt1bUfLrxlULWy+lEf8g1 ajOc3JcvdMkb2QSBADGHj9ytF10dX4Qf2jpkMWoiqKU1Asu5lSCCqqb7Gb3suUGMOBKi EyKUMY3wZTlMxLiFJhXV7ERUQz4PaAEf1bXLIOWz7YmcoNx/MeNt7f7Gsj2dWtYGKjsZ xB4gsU/1vhLhwvF0nx+m1GMYIaMcBhhq8bmwfHW3oHGZnIqT7EAH/0B8h6u9lrHvZ+sI Zv1J59SpO3KdQHVIrJS+omasFj3UfEbIX0Nyxz/+2rGcuD2wJoYwp0LkTeH0Acobi6Vg yZww== X-Gm-Message-State: AO0yUKW2jqGJgvaGo51yt8oZsbvXbaqaRRxgYpAR/Y1MCZMNeA8UrCXw jK0izTr0SVgUh2bY4kRwCvg= X-Google-Smtp-Source: AK7set/oTG2zBactjb5RHftrC5+lfbtLdHBQ0FgcPWQfnsR53fFBtbCSrF5PW9KZSaxBi6QpGVkKXQ== X-Received: by 2002:a05:622a:1a86:b0:3bf:c355:9ad4 with SMTP id s6-20020a05622a1a8600b003bfc3559ad4mr50184397qtc.34.1678558754691; Sat, 11 Mar 2023 10:19:14 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id s20-20020a37a914000000b00741a984943fsm2213341qke.40.2023.03.11.10.19.14 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:14 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 6/9] net: sunhme: Consolidate mac address initialization Date: Sat, 11 Mar 2023 13:19:02 -0500 Message-Id: <20230311181905.3593904-7-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 --- (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 24101d3d5f85..c4280bce69d4 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. */ @@ -2635,7 +2650,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; @@ -2671,35 +2686,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); @@ -2748,7 +2735,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 Sat Mar 11 18:19:03 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170966 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 1B60CC74A5B for ; Sat, 11 Mar 2023 18:19:37 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229604AbjCKSTf (ORCPT ); Sat, 11 Mar 2023 13:19:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230435AbjCKST1 (ORCPT ); Sat, 11 Mar 2023 13:19:27 -0500 Received: from mail-qt1-x82c.google.com (mail-qt1-x82c.google.com [IPv6:2607:f8b0:4864:20::82c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2C805CC2E; Sat, 11 Mar 2023 10:19:16 -0800 (PST) Received: by mail-qt1-x82c.google.com with SMTP id r5so9301201qtp.4; Sat, 11 Mar 2023 10:19:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558756; 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=mzdNsG1rNrrudv1+HkYMVo34HG6M5gxJ8aIACXWrtpI=; b=kRwWWNqq5zcNDMgbAXYHz9WG0t1PP3AHNvaltDwBueLvW6K/fX/vZB+c7bX0uTHT4y Ya2WTq1nVC8S9OL8ARt6UoddgB8BPpYdo4rCHuUkmuVZhpz3a25TFCW5gga0M6zXCbgd khnh1ZzjCUOgunUxiuIp3O+8XtY1Ij5UTS9XbnuOHqYQyCLXazZ2tbUid6QkrBOYKiAI UEbvDDazq6TYnkc+wWDG2oJFhcR7u5SIDAgAPbmh33Jgi82/l4MgZuWshTOvhr2F20Os FYOno78b5ARYWUOvzuG12iNvcskn3AH9p5cYO+jfqBmy2Phk4sFkzeNIRhbmUqpu1QhF C9uw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558756; 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=mzdNsG1rNrrudv1+HkYMVo34HG6M5gxJ8aIACXWrtpI=; b=pqSUY3/artA8YaagfHsNefEBdKCS1/vJez1KjoevxBSt0kmO8l85RcxCKuvd0hTz0y mxPtfym0MxjVEblbIQOuGBPKLycFdUw1pvxLYafhre9woiOE78j1sHa9ypPNrX0ccFMX fjHb2ZUuoAgo+GsUbe34T1vd89acNjUdPx1T0guBs1j6HGP52EQWJHvwqjwVxGlBL0qg dX4ynmizOMLTwfaH7o/0aRNqY4pk5QcXuJt+SZJPMS4mnWrfUNfMO8ZzF9vRF+efZAs8 P64GQS+OYoxl/dFbEvuE5ensDfzhYSk8eYb8sQiUaxfZxAjWuW9dCXrPIoh3g5z0x5Rh poFQ== X-Gm-Message-State: AO0yUKXxHrHlt+hHwPLOqLeuC7BN8K2ixIHL1B/oZ44yKVRAMf1w78wH HFN9l2NZ1mXPBtQd2Ud0/Ec= X-Google-Smtp-Source: AK7set/rGMbVeek9jcpmmr1JPuIuZpU4/MHKuIPa6znZGTvkvJHdiatxkpfiGNXNKTbow42sY85lRQ== X-Received: by 2002:ac8:5a85:0:b0:3b6:35a2:bb04 with SMTP id c5-20020ac85a85000000b003b635a2bb04mr53435023qtc.7.1678558755744; Sat, 11 Mar 2023 10:19:15 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id i3-20020a37b803000000b007424239e4casm2162147qkf.117.2023.03.11.10.19.15 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:15 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 7/9] net: sunhme: Clean up mac address init Date: Sat, 11 Mar 2023 13:19:03 -0500 Message-Id: <20230311181905.3593904-8-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 --- 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 c4280bce69d4..41b2f941c607 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 Sat Mar 11 18:19:04 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13170968 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 98002C74A44 for ; Sat, 11 Mar 2023 18:19:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231132AbjCKSTl (ORCPT ); Sat, 11 Mar 2023 13:19:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230001AbjCKST2 (ORCPT ); Sat, 11 Mar 2023 13:19:28 -0500 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 EC74E5F534; Sat, 11 Mar 2023 10:19:17 -0800 (PST) Received: by mail-qt1-x82d.google.com with SMTP id r5so9301241qtp.4; Sat, 11 Mar 2023 10:19:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558757; 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=b1/QWyN+1rTXKKFO+psZRLLz7sEIRxuKnLx8615NJfo=; b=kABZzwS+f+kxgP9qwE6a+QVqZVqf36WgUvect6GHtczuVX4Qapk42L4yTC4j5D5AB4 J2tdU5cGVZPgQvxhG5qd+qZScQ9RRGO+cwnEPil80cwXQwaZJEXzFe17Mdm6yLO4u0ra T1KFnDGSJNDLULtOUA7smYUdgJnlWz2JRakfyEUMvQNEGOtA6e/5IW8z7pDIeB+70u73 zLWBFHMMmuC3Xm6OgmrWb5usN2064QNflN1dYt106ZGzRhXxsnPb5P1aq1nNeNNZB3Bo QMb++LDw6p+3yLEYSw37dzXMqGM8JzMjSR8EycSrEFRfIUsI87tAiRz4lcHLAEvqzjEi 7XJw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558757; 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=b1/QWyN+1rTXKKFO+psZRLLz7sEIRxuKnLx8615NJfo=; b=oum5x5zPF74iLXOSg0BZTVuDybqm3cmSpy75wu7MsRBl/pEgIB/NUWeTIjsFCcQbpW Gyyq4eSpVhnmNaTKO6bjvDys3/ExXsTFg0mDNLuzSyNzwPgE+1r8mLoCwQsWx9BZEViU a0A2Ec7SvacS4n5+Bj3oKloCb/GssuH2vdX+A+W/VXhFaeh17jmff5MfIh8BWAit+8nc q7fXa6SZHtRisAMV+Pjy2wbPNfn3GyRP72yf7Jv31sJyZyBjKmeTeIYcYbor6kXghOIv NW/rlRfKAMaWSJ7VKr3zk5ho4m5WE2cfKvMhi2y+aJH+SCFkrkWoydhWwlD+yTMTO3ee /CrA== X-Gm-Message-State: AO0yUKX52h75x+KromRr8HmJlsjPV0E9S46q6u8fKiC1XAhP/JvpLFt2 CKEQk29fuIHBKertDi66QmY= X-Google-Smtp-Source: AK7set95h1GZcZZjolX4JBnLly9/5WpT8elYlHe/moPp1qEFMSttHOD5qgn3Z2K9ct9duQ1fLrzFvQ== X-Received: by 2002:ac8:5acd:0:b0:3bf:b896:ff72 with SMTP id d13-20020ac85acd000000b003bfb896ff72mr51235588qtd.68.1678558756856; Sat, 11 Mar 2023 10:19:16 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id i3-20020a37b803000000b007424239e4casm2162172qkf.117.2023.03.11.10.19.16 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:16 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 8/9] net: sunhme: Inline error returns Date: Sat, 11 Mar 2023 13:19:04 -0500 Message-Id: <20230311181905.3593904-9-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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. Signed-off-by: Sean Anderson --- Changes in v2: - New drivers/net/ethernet/sun/sunhme.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index 41b2f941c607..0b903ece624a 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2622,30 +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]) goto found_slot; - err = -ENODEV; - goto err_out; + return -ENODEV; } found_slot: 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); @@ -2793,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 Sat Mar 11 18:19: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: 13170969 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 0993EC61DA4 for ; Sat, 11 Mar 2023 18:19:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230174AbjCKSTz (ORCPT ); Sat, 11 Mar 2023 13:19:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60020 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230470AbjCKSTa (ORCPT ); Sat, 11 Mar 2023 13:19:30 -0500 Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E42595B419; Sat, 11 Mar 2023 10:19:18 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id y3so5761223qvn.4; Sat, 11 Mar 2023 10:19:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1678558758; 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=+9qc042YGsZJMxlp8gBrIPO5C05rmMgtPlJZkGwaGiY=; b=GbPae1jg3ObtbqHz9p8sGK0acHd0Q95uJetufdC84Ma4+lIRPr5S8w/Puozgee9zPH GBvm11j6nufguY5QiVCmjmgE9Me3Mhd7OkaeklYXzPSMm34A2awhkt8Yik0z5cNm41iv OW50SWy2scYNf+Tg8CsH9X7cKXpPvqzdqPp9MQIQnOWHKjIlyuffBBmENIqTU3buOm5j ntKx+/9YDl/k5U+KxeWAM+YUhGjhqotE48IiRS9kB3/348/c1fJO/Nm4EiUiSDffO7Xz DawrM42qPWkTCm3ein+y2LDM1XdXT8v0BtEBr5Pqd8Ooo+enaYncN+d9Dx7axF3oENS8 L6+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1678558758; 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=+9qc042YGsZJMxlp8gBrIPO5C05rmMgtPlJZkGwaGiY=; b=B5p2hYZzR54bpUCx7D99jhAWNTox61intjOJGBX1Zkqr3Vqq4oLBUd9rBOFYNuZUnJ FWEcElvPMUrlefbxIfH8OHhGLWP/ldvAtlHMnq9PKMpl8SqCPviQug6z4c+cyPSx5A9k 6ux17dvOixrg9wxyRgNYEwwgUnCN3WRdvVm1zMI8kWY7zd3N8LnoF52RDecYVEmXbsq/ AdpxW0WSOlCFf+mlHQSJJdbo4Jn5hE5IQt+EqW6EQX89GaSvUQWTz+khoKWmqmSOoUkH Has75tVEwiLx3TpNgAWMocya9Ly/Z10r4xxr8LbZfazSx0RBa/2RS42a5YfW5n1IEhLo 7oCg== X-Gm-Message-State: AO0yUKXqfjpV13boaUNl6BVbQn+rBncs3lO8dets6d858Xdk/XSGhdKK ICbaQtNETzVJvUrCEGtVyjo= X-Google-Smtp-Source: AK7set+/8Mn/M3ucLyCcVBqPfTCtMDgcR1XTePfBwt8MJFHhv4pVj9Ac8rg0RtO336LNfRskJVSCNg== X-Received: by 2002:a05:6214:2523:b0:56e:a290:aa92 with SMTP id gg3-20020a056214252300b0056ea290aa92mr5846280qvb.9.1678558757972; Sat, 11 Mar 2023 10:19:17 -0800 (PST) Received: from localhost (pool-173-73-95-180.washdc.fios.verizon.net. [173.73.95.180]) by smtp.gmail.com with UTF8SMTPSA id y12-20020ac8524c000000b003b643951117sm2252556qtn.38.2023.03.11.10.19.17 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sat, 11 Mar 2023 10:19:17 -0800 (PST) From: Sean Anderson To: "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , netdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org, Simon Horman , Sean Anderson Subject: [PATCH net-next v2 9/9] net: sunhme: Consolidate common probe tasks Date: Sat, 11 Mar 2023 13:19:05 -0500 Message-Id: <20230311181905.3593904-10-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230311181905.3593904-1-seanga2@gmail.com> References: <20230311181905.3593904-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 0b903ece624a..5c66efe93fd0 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);