From patchwork Fri Mar 24 17:51:27 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187075 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 70CE6C6FD20 for ; Fri, 24 Mar 2023 17:52:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231742AbjCXRwD (ORCPT ); Fri, 24 Mar 2023 13:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50482 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231561AbjCXRwA (ORCPT ); Fri, 24 Mar 2023 13:52:00 -0400 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 71F8B11164; Fri, 24 Mar 2023 10:51:41 -0700 (PDT) Received: by mail-qv1-xf33.google.com with SMTP id 31so2191789qvc.1; Fri, 24 Mar 2023 10:51:40 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680300; 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=HEKl1KK7ZlF8f1b0XHNy3aS7ALtOEGTZ1dh0r4qD514=; b=Y2KjvMxOjZnEjfu6VJ64oKgo0ZlCt2qKQz3IpvqttbRfllzpRD0i4q08cjo5VvCBtd 4P2pEdbcvSwGkPt5DuoTeAXJ1Fjkz3ChUCImIPREFAxs71VRRq8lnSuFWJ6c6o87kfnb sSclbHa8kjHUnXDnoL6tdNjMX7LtfkjsZ5bAZ4ibBxwYJ9Y32e0NWaIfUF70qUk6YyBD d139F1zWqVEPFBqn5AS47f1rQAvR9eAcyFa/JAQVLUSjpJ4M2rLYebjaREeJ1GW8HEm+ LHRMHgMQQvXCNKoQwtywSgqGSdd9cn/YVjfkYzu4zdZKxCRUbXX5HWgoTCheJrRy5a1x /1rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680300; 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=HEKl1KK7ZlF8f1b0XHNy3aS7ALtOEGTZ1dh0r4qD514=; b=7vHc53bHNxewJjP2Kn8QZMwADqJaxNY5yQbCNnB78AVueAbWFAJ8mvj0Oj18gJaRON eRj7WZsX42XhImX2Bf+Ka1keP5kNNCllJ/EzTdY/422K3WaESqN1Rn/czpQwhE4OrLWj EO9EbRVULKjkJ0FTVzdOftgqo4S0QTnPyzfSdvnb8vd/hN0HABA0WzlSZht/RBk/N9cs JKB+QjvHtF2FUEmy3eK2MkwA5e74f955WIg/0VYeUbE45IfGcKlj1bgEeZfyjUS0lhk1 WcoToqnhPF7QGbNZVMsEnQuJRWNDqc/eZrsMmB6rBDp5/gG24IYeLql3g7klATcN5Hic OWVQ== X-Gm-Message-State: AAQBX9cLJ5+nVhmEoRf7mwbfK7rEekD9oKkQCsDXTZgKdLmNwP5ynu8+ vlswEH9rfSj99ovmIi6b5A0= X-Google-Smtp-Source: AKy350YlgAF9hhE4PNRtjuZ7kiZQdD4E7aXLESIfB24AIm65l1ex8gz626fPyihD4LxZBXgo2qBiCg== X-Received: by 2002:a05:6214:2a8f:b0:5b4:55d3:90bc with SMTP id jr15-20020a0562142a8f00b005b455d390bcmr5384276qvb.35.1679680299813; Fri, 24 Mar 2023 10:51:39 -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 bp5-20020a05621407e500b005dd8b9345dcsm849889qvb.116.2023.03.24.10.51.39 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:39 -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 v4 01/10] net: sunhme: Fix uninitialized return code Date: Fri, 24 Mar 2023 13:51:27 -0400 Message-Id: <20230324175136.321588-2-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 Fix an uninitialized return code if we never found a qfe slot. It would be a bug if we ever got into this situation, but it's good to return something tracable. Fixes: acb3f35f920b ("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 v4: - Move this fix to its own commit drivers/net/ethernet/sun/sunhme.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index b0c7ab74a82e..7cf8210ebbec 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2834,7 +2834,7 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, int i, qfe_slot = -1; char prom_name[64]; u8 addr[ETH_ALEN]; - int err; + int err = -ENODEV; /* Now make sure pci_dev cookie is there. */ #ifdef CONFIG_SPARC From patchwork Fri Mar 24 17:51:28 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187076 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 C30E2C76196 for ; Fri, 24 Mar 2023 17:52:06 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231811AbjCXRwF (ORCPT ); Fri, 24 Mar 2023 13:52:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50486 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231575AbjCXRwB (ORCPT ); Fri, 24 Mar 2023 13:52:01 -0400 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 3A6101ABFF; Fri, 24 Mar 2023 10:51:42 -0700 (PDT) Received: by mail-qt1-x82c.google.com with SMTP id w25so2195796qtc.5; Fri, 24 Mar 2023 10:51:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680301; 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=QLbggjUBWDhCFAFfhTFn/HC3bA9ftKuc9kzs8SaypEw=; b=Km3u7U/hWu1WfQRVv0wtAQowQt7VdHwtGoQunxxrZFiarxq356cArSlobk6vhFnpYO B6BhpOUxqEgcnQwASKGXfhhloYvfQM16aNYaCQBM2jf7AEWaUGS4dzlF+L1JrSZYOHRm Er8M7l8P2Icj9U0Z5pO9gMbDn0fxnwWGl8vfq+Ck2B74llmXEq+QUkkMGeqIj40ENyHm Lh0cTQkqOrtFWxVSuPdaQLPHw09sCv71Z+78Oss1qbUXkART1z1utc0CrvZQp6k5J7hY CZ91kRJHNibQxOQm4ocWeE4tOUvOtxVBOokW/eZ/0kyK0vKqhY6G6YooJkzecaEG8E2g RslA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680301; 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=QLbggjUBWDhCFAFfhTFn/HC3bA9ftKuc9kzs8SaypEw=; b=lKHdNfX+GETCPeQxZSA9tILIx2DFNT2OBy62oKg7RJRayLUa4HiGv/5utNMHXGVfvf PUfHPGbHN5AQY6AfJ6Wu3QBLIyk6Kby1W7HAJt6mfZon41icwX1XnrxAvcpwPzI/j820 8vMo+4fE8GqEDwkRkd+WrgAS2XgAExCb5i+SkA2Fq0f2B0obVsoj6OwOk0flxh1SSUYR VdU60IMnKbVkpwulxxuPfg5ahxacvu4CBRLiKAqbyZ6F/Z4GE+YTUX6OoTcq0hzBcjAn IAVgPDbkFtR+BxM8Wqhf1F163lVldlewBWBSYMXWUSVPvhqPH0vCtfWNZaYNuht9xsFC +ZCA== X-Gm-Message-State: AO0yUKXljfrXMutFwOo/rXeeMXB2AH8wQrlavHXbzou8/4DY41vDF7to JWz7lg4l7UK5kjL1G7gaQZU= X-Google-Smtp-Source: AK7set+46/9A5AmXsNxTBiyOANyCPNhdwWXAZCRZgfC8v/PcsDn4TwwuwEH5uK1W6w7qVveRiT/JQA== X-Received: by 2002:a05:622a:206:b0:3da:cef1:79b5 with SMTP id b6-20020a05622a020600b003dacef179b5mr5070647qtx.26.1679680300788; Fri, 24 Mar 2023 10:51:40 -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 o5-20020a375a05000000b007464fcca543sm14421460qkb.50.2023.03.24.10.51.40 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:40 -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 v4 02/10] net: sunhme: Just restart autonegotiation if we can't bring the link up Date: Fri, 24 Mar 2023 13:51:28 -0400 Message-Id: <20230324175136.321588-3-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 7cf8210ebbec..e52f2d9305bc 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 Fri Mar 24 17:51:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187077 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 37A5FC76195 for ; Fri, 24 Mar 2023 17:52:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231558AbjCXRwH (ORCPT ); Fri, 24 Mar 2023 13:52:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231687AbjCXRwC (ORCPT ); Fri, 24 Mar 2023 13:52:02 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37B771A942; Fri, 24 Mar 2023 10:51:43 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id g19so2177938qts.9; Fri, 24 Mar 2023 10:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680302; 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=RUPIpsZjxKo1VufU8w58+RDz1sXH3grk0wMm+nJeAoE=; b=VZi/GPJvrFgaOaLTTnyuz85TjM+RyDUnaZ90AV3cZarYgxTfe9E+TO17Kk6BGzDGtQ BoI7fWpxUxFKsSAHzNMlnA76iJBLPwYgYS9h2U5xNZdw9a2ZMl5nzp9B/b/cq++iA04x mmkBpHLDDN7f+B33GjG9Btyh1/sUYlXuEPR/cxMTDiJ+72jIvuOgAPiWw+cIZvRC2I60 KjSqdW32by7oflh1B2klQHDjfIuHMmQZMoWtvq9FW1YQgsyZwGRlQgiYjlXojFEUpjbK t76R8uiqAxj03ohVc3z/oENRrQvPkyETJlioPGFhlXjtNMoAS9h3HUNnPdy3aVcm189d GsEw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680302; 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=RUPIpsZjxKo1VufU8w58+RDz1sXH3grk0wMm+nJeAoE=; b=QfKMcXnBHIpQcEY6QPzt4aGogEjWW2nRc5lOgueCGTdRekX5diSGBYjyf501lZiBtc Mku48Dfva74v9RgcXHMTI5YZy+c1B8x+WBZVncudFtleku9JmhBjxL6/K7c+AOQ7Z+gp y0JNxJ10Q7qsNc6pOxxwS7HuYguytunJh6BgsBfNo+jjUL8YBE97OQuRp0+Xw1oZufNL XhKwOUMCDpADkv4WIiUDiVc5S3gZ0lfk4AiylJOgZKUiUcz5UlpRPj3Cc18Dy3I1+DpI bey+Ch4KNyMfJOEWi3WR+PgaYvDM8PJ+cYyP1zYxW63NRrp2pfd5RPjaSAgU9V5rV5a0 r3cw== X-Gm-Message-State: AO0yUKWqmAeF9qbwqq3wfa7MJZ8zBmVHSA8Ojlx/LQFdEErsmAJddI/U rWAzfjf3nTuD6KZ9YPj0d2w= X-Google-Smtp-Source: AK7set8pi//swGrHRCdgO207gkQQCdQqTi4zkOvAKI2LfqN6BBcN9Cq0NPpjVL6F2NSLxtveFc9UCw== X-Received: by 2002:a05:622a:1a01:b0:3d8:8d4b:c7cc with SMTP id f1-20020a05622a1a0100b003d88d4bc7ccmr6563074qtb.46.1679680301846; Fri, 24 Mar 2023 10:51:41 -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 t21-20020ac87615000000b003e0945575dasm8875232qtq.1.2023.03.24.10.51.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:41 -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 v4 03/10] net: sunhme: Remove residual polling code Date: Fri, 24 Mar 2023 13:51:29 -0400 Message-Id: <20230324175136.321588-4-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 e52f2d9305bc..b02cb0b493ae 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 Fri Mar 24 17:51:30 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187078 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 26B5CC76196 for ; Fri, 24 Mar 2023 17:52:11 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231876AbjCXRwJ (ORCPT ); Fri, 24 Mar 2023 13:52:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231770AbjCXRwD (ORCPT ); Fri, 24 Mar 2023 13:52:03 -0400 Received: from mail-qv1-xf29.google.com (mail-qv1-xf29.google.com [IPv6:2607:f8b0:4864:20::f29]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C56581FFC; Fri, 24 Mar 2023 10:51:43 -0700 (PDT) Received: by mail-qv1-xf29.google.com with SMTP id qh28so2119507qvb.7; Fri, 24 Mar 2023 10:51:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680303; 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=NgJKHg78MHdqRNvWKyauhjjkOs7bo5j6sd6MIgpdJbg=; b=j93zMY7JyTwpNTMa/ssPwVL8D6fBYRUkGOQ5G+AAgswXjTKSp6r5XetzePkwX++TVV XUtplS3u9N72GXet6fdc9u0cTAWahrN535wq15nyYZl0l9pnnL05gHpLzi2D+/RTiikc aTeeS4H5Lv1AmY+rBSHZzBIz8zvfIyXHeMGd83bFgUR/c5uUtYi0ixv6HD2gxF142rFR fF3e/4v2Wx4La4/+kP9wzpu9IDvqIVGKsbknE5wQ66/4NixIyHWAeby9MKRhuHj9MYBb jprGEkUmM35VoicYguOigKr/SzLLqw72DOdZUiRRLwcYoUw7irY+qZYMInlj1h04aVMg Urxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680303; 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=NgJKHg78MHdqRNvWKyauhjjkOs7bo5j6sd6MIgpdJbg=; b=t1K1MrXRvuDZQ4U0AnCjWui4QstLAGYKvWDt1MBLDqYhdtY5MD5XmggTSaISyXerY5 ZTtYrqcSXzLN0waZFzmg5CMkZ/tkajSLX94k4fhNkbs8aD/1jK6g2ORq8ALJQ2lRwTeF Cfy/O/6VKs5fS5KtujVRmrJmzn1EfGX60stJn/UmdA3YKksm34VazIW/YySW+LVOb4LM grgJhHHAyTHF9aS3XZ59R5TIWjgmT7Bbjr7/5mGqzTFvoQMsiqu3ztfkwJ8Ln51x3lK8 NsVtPkMwSt30/0ZvLNbwi36t+QbKyJqbAxodXQpLojqaWDhjQUylG2vX21fblLLzV13y Sjdg== X-Gm-Message-State: AO0yUKVKnwgJ58rTlpGTzeIkg3G3oUoYT8nD56BVp8ipZNHJ8WS+uzcc bzzgs0UD2/Cdi0O1HDboH+Y= X-Google-Smtp-Source: AK7set8xCr+JdZMaQQkXRZSUFJySH0nslnEhbMJOEbO83qNlX8yYuIPbqN9KFB7eeozGy5ouLN3WcQ== X-Received: by 2002:a05:6214:501e:b0:584:8c13:3041 with SMTP id jo30-20020a056214501e00b005848c133041mr17371040qvb.24.1679680302874; Fri, 24 Mar 2023 10:51:42 -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 mu10-20020a056214328a00b005dd8b93459esm844243qvb.54.2023.03.24.10.51.42 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:42 -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 v4 04/10] net: sunhme: Unify IRQ requesting Date: Fri, 24 Mar 2023 13:51:30 -0400 Message-Id: <20230324175136.321588-5-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 b02cb0b493ae..4efcf60644aa 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 Fri Mar 24 17:51:31 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187079 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 CE550C6FD1C for ; Fri, 24 Mar 2023 17:52:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231923AbjCXRwK (ORCPT ); Fri, 24 Mar 2023 13:52:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50542 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231806AbjCXRwE (ORCPT ); Fri, 24 Mar 2023 13:52:04 -0400 Received: from mail-qt1-x831.google.com (mail-qt1-x831.google.com [IPv6:2607:f8b0:4864:20::831]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0E3941A65C; Fri, 24 Mar 2023 10:51:45 -0700 (PDT) Received: by mail-qt1-x831.google.com with SMTP id w25so2195928qtc.5; Fri, 24 Mar 2023 10:51:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680304; 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=U7ZD9kn2BY11SCfWQ4DwMeiI3/L1tegSbDSWDWtewTQ=; b=eWjkFDzrfnaPTsfw6HTF4lwhNdII6o59YHBnEGPTVbMY8W1r/ltw81OLAPLvqbLN8O RcRLnS4JtJtS7K4ECm6qWSxofiS+jRebewG8GZp4bz72XCrD+rV4PrxJP/96AIbnK6iD TUGas643K0pQZNLvXQsLYOb06rWLdICEgzsBTt/Tlc4pnsam+wN5Py8LsY3gKBd5D6RT CZTSAXAco1Ly0J5iImHqr8RkVCB/WWMhnohVZw+QBhBdniryuVUTtu5kiZWGAY8gTT9q UJXCbAnEQ5VaPgYwSuXVcVmxQkFkB17ECtjxOsjNM9PK3rLNvXk6PklYFEF06T4pek5N 190w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680304; 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=U7ZD9kn2BY11SCfWQ4DwMeiI3/L1tegSbDSWDWtewTQ=; b=i7ZzcUOnIlqtiYFXi+hA9pARyxCsBLP3eWXznNYuaKHEE3XD4p7HGjWyvfangpTEib xYpi4/RZ9XzN/W9P5HeI5BRt8RszzX1HQV7OlnldOU1MMP30vhLaW2jlXD7mmg8QWhKk Kfop05Uo9DLisrUkjO5kP1EaaRIWehRFajrU9aITfQj6PyJv6nXZCfnOp6w6zmXyjz8P 6mCC65dogwhr8meMLwOl3+fYnOCy02Lux/azI+wheK0ilS4MOgqSQnzIHqOW7DrakoSy QfkwmvFuy/0aqs/IUW7vgDAGJexfwAyTLGkrEJRxPMcYonb6DOyOkvf8OdpEyxvEwuOR Ulmg== X-Gm-Message-State: AO0yUKVhjNfKDnADXoqG07oi9ULMbHsLi1L0niGKot0fyoK+WBGaaLTV +ysUqJh//qL4mXqYk8kGL7E= X-Google-Smtp-Source: AKy350YMPRbmn0ZnCDPO3d8qnkow4YQXIcJKWtJZVMWGP0ORTOOKvSJzhUFXE7kwpPljqNMh5NsenQ== X-Received: by 2002:ac8:7d8d:0:b0:3bf:d4c3:365d with SMTP id c13-20020ac87d8d000000b003bfd4c3365dmr6425182qtd.14.1679680303959; Fri, 24 Mar 2023 10:51:43 -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 w9-20020ac843c9000000b003d8f78b82besm5338730qtn.70.2023.03.24.10.51.43 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:43 -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 v4 05/10] net: sunhme: Alphabetize includes Date: Fri, 24 Mar 2023 13:51:31 -0400 Message-Id: <20230324175136.321588-6-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 4efcf60644aa..e9613db3bdee 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 Fri Mar 24 17:51:32 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187080 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 A3082C6FD20 for ; Fri, 24 Mar 2023 17:52:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232116AbjCXRwl (ORCPT ); Fri, 24 Mar 2023 13:52:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231922AbjCXRwK (ORCPT ); Fri, 24 Mar 2023 13:52:10 -0400 Received: from mail-qv1-xf30.google.com (mail-qv1-xf30.google.com [IPv6:2607:f8b0:4864:20::f30]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id ACD0F1B2C0; Fri, 24 Mar 2023 10:51:46 -0700 (PDT) Received: by mail-qv1-xf30.google.com with SMTP id x8so2092440qvr.9; Fri, 24 Mar 2023 10:51:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680305; 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=wXQEQPWX7BChXSTzE5sZfWk0yY1AAKansMO3jYxACZw=; b=ivgR1jloxGZQfdlLuHFKvGk+JsXdNnK60atDZbah23gzHJlVSXexwTvl+E33i8DQbN /loLp3HMihM6p/826e8MWB+3f0sdDTBpx+S5Rbw5H6+2sDeCOigvosPx9GhlqKfXTzW/ /gyzTt61u+18M8kGBhf/2f3VCVNSd8shtgOiitW5vFPFOE33u9OFRhroMeYxC9Pj73wR J0F9fWiNw/+IpCkfzauBb2sn9PtcFtSpG7j3RqmIlJSagi3LAJrRDmOECWZmGDpPQABA tq8tgLYcA0Mdorm93Bg6mY8i6ekGG7lBK0EeLdlPFBxbvsotbLGlB4Xbj6XYtiqdiWgq 7qQA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680305; 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=wXQEQPWX7BChXSTzE5sZfWk0yY1AAKansMO3jYxACZw=; b=frjaP+GM1of4gxNxSWs0/ziYlpmMthbGcRTszF8D9orf3+kmZjhu5khI3a2IuPkce8 824L84pqrawcR2U8tSRHtXoieFru9vOzZSlYi4MojXERLINHNY60Zjff6oeKwWvVAAfm IYgpLpNSzHi9iJsl9WJLvX/ZJ+Ggh8Uqn+ccVRTHcAge5MuC8fq/g52ifpsj/FiN8Bvd vd77NqI+0FjkXkzLfUTp0uS+O+Em+62JyxNVU2XMLbzO4WUxCXJj7oKR4Ob1eOuiLnHd BJKkn7my8eh3E9gJW8dwi4z89vlXkGUcG7ppobbpgHyiDu+r5dV8CUgVuIZCXRrQh8k/ ONpQ== X-Gm-Message-State: AAQBX9cW1xmD9idsRVL+46o1Eti36EaHZPSWCn+Ce6gNnL2DDCwzZgcS PNsa6ytvAXc8TcbWL1QaO/E= X-Google-Smtp-Source: AKy350bT8j3Rm6Ve5ExWcGHNVuE/Cig+X5dvbER31s93FGk3hN2AYqOnFFp9AtqXqRdj/QRm/2r/tQ== X-Received: by 2002:a05:6214:48c:b0:56f:8ef:693 with SMTP id pt12-20020a056214048c00b0056f08ef0693mr6155609qvb.0.1679680304961; Fri, 24 Mar 2023 10:51:44 -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 i13-20020a056214030d00b005dd8b9345ccsm835936qvu.100.2023.03.24.10.51.44 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:44 -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 v4 06/10] net: sunhme: Switch SBUS to devres Date: Fri, 24 Mar 2023 13:51:32 -0400 Message-Id: <20230324175136.321588-7-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 e9613db3bdee..9cd3448aca3e 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 Fri Mar 24 17:51:33 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187083 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 18DC5C76196 for ; Fri, 24 Mar 2023 17:52:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231953AbjCXRws (ORCPT ); Fri, 24 Mar 2023 13:52:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231215AbjCXRwX (ORCPT ); Fri, 24 Mar 2023 13:52:23 -0400 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 37DED19F2F; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) Received: by mail-qt1-x82a.google.com with SMTP id a5so2188954qto.6; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680306; 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=cz49CpZ6Czp6rKLA4pkCmIY69gIAhzpolYioE4Fl79A=; b=jLv7vk6ZbnpKiJEeZSLVNRy7Pz+8MYfFjPLgeObJV3k20+pcmvM9ptmaC8zMDTb+gH tSB7xuPfOVStUwfjeQjIGzZhJhyLB7CNp0WrjySWxAeY3bm5z1Wvd/MkSg1gBhNBEzgU rOCDVgY4/a/b2IxbEwrQhGdOhQ8XH3tLy39gJjXU1cCV5ukUlDQtFBcWf3EuRzkMXd8x 9tbVARQxw6HhvromBUfOUtPUDR6zuqcw3g4No5jyjXh3FuX4++4m5JTPW1GtkcnSKXnK EZOb891Yupks59wMYRjsdho6MAQ6gDTdsDJxXcHkbBUAh7B8MH2BDgWpSOE1J9AmSFp/ 5Ekg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680306; 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=cz49CpZ6Czp6rKLA4pkCmIY69gIAhzpolYioE4Fl79A=; b=PREbOxA9ISgh/WhWoxF/U6rlcPRV9i8BDnHw4rMRvQ9TAx16Y3bFXiZwt829BDiGrt B9DwbNbORsG+uYkQJUZB5KbSxa1+4IOSMDcSnhpCpiXXsAZMnuRBjLLnMwPLnrcTAZcu dM0uP7QFUfzEBq0rPwyDXK0Sm+YskRFAZkH6lLZ1msWdfnHJMUUGz7sKBQwATsyv7k2G EnB95nLS65h0HVDHvvz9wt74h8CDwqXU11I6AKcgfvKQ+llBYMs8lA2A5i1jfib6gG+y H0cRNv8V+Zg0cpK19qv3c3nthfT2QdpaJwzgHjN3pcDTCEBL85+SajE1bl4DCBImzw8o DRVQ== X-Gm-Message-State: AAQBX9c1bGwWDJlig/8wzrmLSjWTxtreZi+u/PAUO7dUiEz2OVJbUIf/ o/WfDU/iDbmphUWsqMhr2AY= X-Google-Smtp-Source: AK7set/tRbFPxDixm6AkThORbLNMHpQo5dCEjXGqddxm/xWiDjkX4dqSyERXRalT8Mbk/UYNHnY2ow== X-Received: by 2002:ac8:5a09:0:b0:3e2:905:3331 with SMTP id n9-20020ac85a09000000b003e209053331mr6693166qta.51.1679680306056; Fri, 24 Mar 2023 10:51:46 -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-20020a05620a148800b0073bb0ef3a8esm14418663qkj.21.2023.03.24.10.51.45 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:45 -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 v4 07/10] net: sunhme: Consolidate mac address initialization Date: Fri, 24 Mar 2023 13:51:33 -0400 Message-Id: <20230324175136.321588-8-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 --- Changes in v4: - Tweak variable order for yuletide 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 9cd3448aca3e..4fe67623b924 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 device_node *dp = NULL; struct quattro *qp = NULL; -#ifdef CONFIG_SPARC - struct device_node *dp; -#endif struct happy_meal *hp; struct net_device *dev; void __iomem *hpreg_base; struct resource *hpreg_res; - int i, qfe_slot = -1; char prom_name[64]; - u8 addr[ETH_ALEN]; + int qfe_slot = -1; int err = -ENODEV; /* 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 Fri Mar 24 17:51:34 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187081 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 F315AC7619A for ; Fri, 24 Mar 2023 17:52:45 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232155AbjCXRwn (ORCPT ); Fri, 24 Mar 2023 13:52:43 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50994 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231953AbjCXRwO (ORCPT ); Fri, 24 Mar 2023 13:52:14 -0400 Received: from mail-qt1-x830.google.com (mail-qt1-x830.google.com [IPv6:2607:f8b0:4864:20::830]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 34924CDD3; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) Received: by mail-qt1-x830.google.com with SMTP id n2so2227891qtp.0; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680307; 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=PuV3IriHAW7aZC8rFN25zhcR9dc8l3Vh+GPx6NtpMpU=; b=eRtC81NEQErSKAXM26X0ZVcHMgVlSXptqsLo2uzPa5TVXpleoAySQirq87pHRV45tp qhk7ybka5bI+FSZDmoM9luXnUusiHRVXtNiZDaa9c/qAKKoY5AM+UxHMqIFu1WBaF3ig zlGXH2dtZixOq4IsBr+FIkJ5B5HrocEnaGb2kfDOHVzVsOpTk2r+hYWrWSVHTQjKYnaL NKVjBJIvOM2YONGm+6vA9JTRdgDJMkpZfz99oSUJPpdIZfkviYUyL3o3Gf68j4QpRdhM 9uiGucM9E+Cx+jzN5pEJV8pnMytFoMvCOEitO056sfXELl/KJ9xvVE2x5Wr+3BysQRLo WV9w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680307; 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=PuV3IriHAW7aZC8rFN25zhcR9dc8l3Vh+GPx6NtpMpU=; b=KMCBKb2FdH6GWwfVmMjSaE8ka56mrZl9g120gvIUuG41+Hbrm+sWXG5t729zdMeUpT JY7LULIEiaJk6FPYyR06jEUbBP44tE6hX4Xe0k0lYiI9weoLZiV6vdDWXzw8cn54Xyml BTHkZK1tuy0tFkHc1jCa5HJxEaHVm5rvZM/LbrIehvnZ89gMG3UWTvfDByyqSLeIUNs5 y23yDmQ5CExrGZoe2sLDKjWZ3Y8hUjjULrFbLk7Q7/D5nAImbLzbLzHigMbkiN6Q54Al cXfsBMk5BcLN+woXEZ+Ukr3ARzZ9qVD5l+kt0jFLn4lamIjWxQ66Meq3J+bv61JD0FDA 6Jgw== X-Gm-Message-State: AO0yUKXdUXuCk3SWbnuaJinhRmklzo1de92uMRTi5K4VfNmwVnKNqgwD 0jUrzPx62q0i9fl2W0f68Ue7PPcLuXMGqQ== X-Google-Smtp-Source: AK7set+r8l/F2yXLaXu5mH+cnXIvEz7HmBX4IEYNffVIBg2BQhTHV3haOyGSS/io9TY7B/4tpSVCWQ== X-Received: by 2002:ac8:5802:0:b0:3db:fba6:53f8 with SMTP id g2-20020ac85802000000b003dbfba653f8mr6667662qtg.25.1679680307357; Fri, 24 Mar 2023 10:51:47 -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 bk12-20020a05620a1a0c00b0074357a6529asm14512289qkb.105.2023.03.24.10.51.46 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:46 -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 v4 08/10] net: sunhme: Clean up mac address init Date: Fri, 24 Mar 2023 13:51:34 -0400 Message-Id: <20230324175136.321588-9-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 4fe67623b924..b51b8930bef1 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 Fri Mar 24 17:51:35 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187082 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 2AB59C76195 for ; Fri, 24 Mar 2023 17:52:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232184AbjCXRwp (ORCPT ); Fri, 24 Mar 2023 13:52:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50576 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229674AbjCXRwX (ORCPT ); Fri, 24 Mar 2023 13:52:23 -0400 Received: from mail-qv1-xf2d.google.com (mail-qv1-xf2d.google.com [IPv6:2607:f8b0:4864:20::f2d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 361CEFF31; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) Received: by mail-qv1-xf2d.google.com with SMTP id g9so2106495qvt.8; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680308; 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=Vrlw2rRFPR/eSSIFUVW3e377Xx72Gk415j7uJGfCXws=; b=qgEtp8vc+L5rmjlL9msnQ7wlRAgsFhZqspaoi7vXObSu4q23r7NawU/mukvwmEsRfm 3MYquyphkbvLjwoYkGoB4/WPKNPoyZlFj6Pubtxuji//dEjj6VY7ORyrgHoLnKqbPjTk rIaoTwIRZPxF2gJXT0nXIrjTAUp5Q5h2KTmqt+CWsVj6cU2WMGfU5YlGGhPHeOdorI1f xhr0lsVq7AvVhE7cJUKJ/r4WiBTaWSaOKdCZIxo1KFNdwc345/l1edmxgG5N4GBp3A3+ Tt5xKvvdVFjiw2lXa0JDyZpZZdFmJxrVKiMOKYegWF3U0AwbXvVJBXpKx5f/OimflCUw h5NA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680308; 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=Vrlw2rRFPR/eSSIFUVW3e377Xx72Gk415j7uJGfCXws=; b=KJRCA6ionw1MGutPzPIg5yCV7GJKeJom5KMnMEELjDM2MY8Mr7/n9sRQV64zkcixIw AckM9Z6//Gak6JoUpfhUzi4ornKolXfwPOiUZtu1Qt44Gw9t/+dyLUitUXKj/fgMWSIN P/HRshc3NWiLz2HpMg72FIiKi4UeQWDOMw1AUfX2heoDkeoztgX5vH5n0CGwf6Qr/jMV jKAsYmKaTf/gzV13B+Ks+Sn0Scol/picLQWTD6rQH9cyXXzxHfs9QDojyKSm7Ceuo6qD dZzoMs26Qv7ClXaWvaKuVd9tl73CTwrqv0wLJOGyELPFcMriVycUBlR8ft1ZkxqHxQ6F rbJg== X-Gm-Message-State: AAQBX9e9k+rFkQiZmBQKG9coxiuz5DVugrp0t5BZCoUlGN+IXyNweVei vF+CenErWhaxFV93ELr2y80= X-Google-Smtp-Source: AKy350agO0lFA3WOrJ94Nri5uWAMh4cV25PyeNM4L60yW+tCAd+U5jRUfMJOr2yG/SOoFsVcMlETHA== X-Received: by 2002:a05:6214:f67:b0:5a9:d6dd:271e with SMTP id iy7-20020a0562140f6700b005a9d6dd271emr7471074qvb.18.1679680308530; Fri, 24 Mar 2023 10:51:48 -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 mk5-20020a056214580500b005dd8b93459csm846081qvb.52.2023.03.24.10.51.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:48 -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 v4 09/10] net: sunhme: Inline error returns Date: Fri, 24 Mar 2023 13:51:35 -0400 Message-Id: <20230324175136.321588-10-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 Reviewed-by: Simon Horman Reviewed-by: Simon Horman --- Changes in v4: - Move uninitialized return to its own commit 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 b51b8930bef1..bd1925f575c4 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 Fri Mar 24 17:51:36 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Anderson X-Patchwork-Id: 13187084 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 96806C76195 for ; Fri, 24 Mar 2023 17:52:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232197AbjCXRwt (ORCPT ); Fri, 24 Mar 2023 13:52:49 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50506 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231805AbjCXRw3 (ORCPT ); Fri, 24 Mar 2023 13:52:29 -0400 Received: from mail-qt1-x829.google.com (mail-qt1-x829.google.com [IPv6:2607:f8b0:4864:20::829]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D60811A4BA; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) Received: by mail-qt1-x829.google.com with SMTP id x1so2184734qtr.7; Fri, 24 Mar 2023 10:51:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; t=1679680310; 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=72anf46FrFqHRmqQ5ODHzlxaMT8Ohp7RrTHcY1Db4ZM=; b=aD4Z41ehpWeqUGFPdDErmjO+iJy5K0BHox1wn+flh9uCdXRiZ1ejXiD3o7XY6Sa65G nkdlyTOTve5mbCyY0uw2KCEwaDqfCMH0+HuQGkrYtQ1Nlynwt0jRBX3f2i+PLYj+W5P3 vqGV61tjia2/8pA5rnC3be+O3MRz9Qy8nR3xTyq5W+FKAZJbf08ARB8Q/uqC3PQhIdMm Vxm0Wi2rbEV2zklRMFXb7n23GL1YpPehFh2Fq7FVUzV3v6tpHL9cCCGkJr384+fu7tKy 03e9VCNE/GEi6Foy1AUPT4REJZw7F2MbbLoIMA+fVWBb9fOwANRAXyfwt6jhVNOdNFh4 mYrQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1679680310; 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=72anf46FrFqHRmqQ5ODHzlxaMT8Ohp7RrTHcY1Db4ZM=; b=T8cgGFefeU0AtARn9CKXnPGD70xXuOnYGhhz11nUqxadFdZy8eui1txvDcaBmbVJ8y +jU84/b3uRpF0NBOkHKTJRYcH7LR+frWRw1OF+9lhYQD7JmQuxmBANhvOKYaXAfDdUEt gBQdjSjMYQHrZ2VrOuib0IkNeB2FyP0cWQR6uzKvjQBc5urN+zNE1AsKqiilSOXTYSM+ wfw1OGSgVfg4bkVvjDRKqDCaqBBf7SD//6C2D+tXHRS/5dZoH4dki72LHwT9qApGcbfc Ug0svhx/ZKej4q9G5XfEtBfwD+N7g/KI1cylmeplDfkteuSY0madEyqI9qWo3FGzVo8z 5Y/Q== X-Gm-Message-State: AO0yUKWYFuHYURB3vJ480XXDic/BcUdLU1N3J3r5Ny/82EFMKrrEjNT7 m9/UQjLSxU7wh1C2XsR377vcSeUBnbNF0g== X-Google-Smtp-Source: AK7set+UwKknWozIoGS9iR8T1u1IxXLj49ZGqvWsNWCYxcYqjXNMswx4XJ3FwyRUDaUtp1Uy7nBO4g== X-Received: by 2002:a05:622a:1a87:b0:3e3:824c:f9b7 with SMTP id s7-20020a05622a1a8700b003e3824cf9b7mr7351531qtc.49.1679680309818; Fri, 24 Mar 2023 10:51:49 -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 r16-20020a05620a299000b0074305413c73sm14542048qkp.95.2023.03.24.10.51.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 24 Mar 2023 10:51:49 -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 v4 10/10] net: sunhme: Consolidate common probe tasks Date: Fri, 24 Mar 2023 13:51:36 -0400 Message-Id: <20230324175136.321588-11-seanga2@gmail.com> X-Mailer: git-send-email 2.37.1 In-Reply-To: <20230324175136.321588-1-seanga2@gmail.com> References: <20230324175136.321588-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 Reviewed-by: Simon Horman --- Changes in v4: - Use correct SBUS/PCI accessors - Rework hme_version to set the default in pci/sbus_probe and override it (if necessary) in common_probe drivers/net/ethernet/sun/sunhme.c | 157 ++++++++++++------------------ 1 file changed, 64 insertions(+), 93 deletions(-) diff --git a/drivers/net/ethernet/sun/sunhme.c b/drivers/net/ethernet/sun/sunhme.c index bd1925f575c4..ec85aef35bf9 100644 --- a/drivers/net/ethernet/sun/sunhme.c +++ b/drivers/net/ethernet/sun/sunhme.c @@ -2430,6 +2430,58 @@ static void happy_meal_addr_init(struct happy_meal *hp, } } +static int happy_meal_common_probe(struct happy_meal *hp, + struct device_node *dp) +{ + struct net_device *dev = hp->dev; + int err; + +#ifdef CONFIG_SPARC + hp->hm_revision = of_getintprop_default(dp, "hm-rev", hp->hm_revision); +#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; + + + /* 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,50 +2563,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; + hp->hm_revision = 0xa0; 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; - 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) +#ifdef CONFIG_PCI /* Hook up SBUS register/descriptor accessors. */ hp->read_desc32 = sbus_hme_read_desc32; hp->write_txd = sbus_hme_write_txd; @@ -2563,18 +2583,9 @@ static int happy_meal_sbus_probe_one(struct platform_device *op, int is_qfe) 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"); + err = happy_meal_common_probe(hp, dp); + if (err) goto err_out_clear_quattro; - } platform_set_drvdata(op, hp); @@ -2689,20 +2700,10 @@ 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) + if (IS_ENABLED(CONFIG_SPARC)) 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; + else + hp->hm_revision = 0x20; if (qp != NULL) hp->happy_flags |= HFLAG_QUATTRO; @@ -2714,30 +2715,9 @@ 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) +#ifdef CONFIG_SBUS /* Hook up PCI register/descriptor accessors. */ hp->read_desc32 = pci_hme_read_desc32; hp->write_txd = pci_hme_write_txd; @@ -2746,18 +2726,9 @@ static int happy_meal_pci_probe(struct pci_dev *pdev, 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); + if (err) goto err_out_clear_quattro; - } pci_set_drvdata(pdev, hp);