From patchwork Fri Nov 13 16:52:09 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904253 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 440D8C55ABD for ; Fri, 13 Nov 2020 16:52:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F0BAF21D1A for ; Fri, 13 Nov 2020 16:52:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BRnS3vef" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726184AbgKMQwy (ORCPT ); Fri, 13 Nov 2020 11:52:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53436 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbgKMQwu (ORCPT ); Fri, 13 Nov 2020 11:52:50 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 37162C0613D1; Fri, 13 Nov 2020 08:52:50 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id b9so11461058edu.10; Fri, 13 Nov 2020 08:52:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Y8LXIYYpPzP9HNW+uSjQkTA7aSXHrHU/5a1QvbrK6pU=; b=BRnS3vef3+4JF4h814sKEEfzHzathTr3zP9eIHtPdfV2LY6NMW3ZiS5rXequD/PLUE 797x7iykRPBqI5QzsC4kDRKcUnaBnsYfZX6Ocuy2OArHcYKjZaEh9LLn0OCuaYLNuRG7 P2AuWM4V4LzFf25P+a19Mjkv+A6YouTXUluvtot90zkdChM+KnF7dReEnVESBCy9o39M qTa56cPHmRNobXzckwdlVXPZ3lgWR8Lr6sW+0E1JglYuBS+z/+JZDhcPeSXWH61KTlmE 9/G5k52bHJRSwPtaL1pxvBmpez+BR3GRY8X8/taVne4rS1nL/+/g0VMTEr5a8ocjPTTJ uPWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Y8LXIYYpPzP9HNW+uSjQkTA7aSXHrHU/5a1QvbrK6pU=; b=OJOYPcxjOl5ZfkcNTbvXoakMywbvQuVvm19mPo5kC+ZpCcB8vJlJJgb2LM04W9YaQC d374bTKd35YxHog7N9PhqdRV0sP6/CmAa/sIiA3+cWstt3yB9oc7v0e784EafxiHnzU+ GBfNM2C4p8Ls3vCq5caxevc1sSpOi9yu2zscWjPeVd9XBJjE2UFzIsC0ALoJcUtrwOH1 4J8VqtsuEuD9u/jHPP66Mh4dCKF+6ezvir/QwV00vOf4kbcqpExajFILswlBKM7PiqyE YlhrjCyxIsX57MoHO7hvgXDr7YN47VKJ4Ky80Z+gHCiSGIft8UiK4ZO5yhN9msq+/8OW IlLA== X-Gm-Message-State: AOAM530nHlkqYuAw0T7hjQW3bTQJC3aLJO9t1DTI/RsqDiA065frNFLM gpeujh1qUawzKs3mywQ6Vwo= X-Google-Smtp-Source: ABdhPJwi0WxXi8Pchm9qV3/xraYf8xF91/u9NFzgnSQAAUU2QIR+MyXTwADfn2M/oPQYvTJEMacOXQ== X-Received: by 2002:a05:6402:141:: with SMTP id s1mr3245649edu.87.1605286366930; Fri, 13 Nov 2020 08:52:46 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:46 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Kavya Sree Kotagiri , Linus Walleij Subject: [PATCH RESEND net-next 01/18] net: phy: vitesse: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:09 +0200 Message-Id: <20201113165226.561153-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Kavya Sree Kotagiri Cc: Linus Walleij Signed-off-by: Ioana Ciornei --- drivers/net/phy/vitesse.c | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c index bb680352708a..9f6cd6ec9747 100644 --- a/drivers/net/phy/vitesse.c +++ b/drivers/net/phy/vitesse.c @@ -40,6 +40,11 @@ #define MII_VSC8244_ISTAT_SPEED 0x4000 #define MII_VSC8244_ISTAT_LINK 0x2000 #define MII_VSC8244_ISTAT_DUPLEX 0x1000 +#define MII_VSC8244_ISTAT_MASK (MII_VSC8244_ISTAT_SPEED | \ + MII_VSC8244_ISTAT_LINK | \ + MII_VSC8244_ISTAT_DUPLEX) + +#define MII_VSC8221_ISTAT_MASK MII_VSC8244_ISTAT_LINK /* Vitesse Auxiliary Control/Status Register */ #define MII_VSC8244_AUX_CONSTAT 0x1c @@ -311,6 +316,31 @@ static int vsc82xx_config_intr(struct phy_device *phydev) return err; } +static irqreturn_t vsc82xx_handle_interrupt(struct phy_device *phydev) +{ + int irq_status, irq_mask; + + if (phydev->drv->phy_id == PHY_ID_VSC8244 || + phydev->drv->phy_id == PHY_ID_VSC8572 || + phydev->drv->phy_id == PHY_ID_VSC8601) + irq_mask = MII_VSC8244_ISTAT_MASK; + else + irq_mask = MII_VSC8221_ISTAT_MASK; + + irq_status = phy_read(phydev, MII_VSC8244_ISTAT); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & irq_mask)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int vsc8221_config_init(struct phy_device *phydev) { int err; @@ -392,6 +422,7 @@ static struct phy_driver vsc82xx_driver[] = { .config_aneg = &vsc82x4_config_aneg, .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, + .handle_interrupt = &vsc82xx_handle_interrupt, }, { .phy_id = PHY_ID_VSC8244, .name = "Vitesse VSC8244", @@ -401,6 +432,7 @@ static struct phy_driver vsc82xx_driver[] = { .config_aneg = &vsc82x4_config_aneg, .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, + .handle_interrupt = &vsc82xx_handle_interrupt, }, { .phy_id = PHY_ID_VSC8572, .name = "Vitesse VSC8572", @@ -410,6 +442,7 @@ static struct phy_driver vsc82xx_driver[] = { .config_aneg = &vsc82x4_config_aneg, .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, + .handle_interrupt = &vsc82xx_handle_interrupt, }, { .phy_id = PHY_ID_VSC8601, .name = "Vitesse VSC8601", @@ -418,6 +451,7 @@ static struct phy_driver vsc82xx_driver[] = { .config_init = &vsc8601_config_init, .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, + .handle_interrupt = &vsc82xx_handle_interrupt, }, { .phy_id = PHY_ID_VSC7385, .name = "Vitesse VSC7385", @@ -463,6 +497,7 @@ static struct phy_driver vsc82xx_driver[] = { .config_aneg = &vsc82x4_config_aneg, .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, + .handle_interrupt = &vsc82xx_handle_interrupt, }, { /* Vitesse 8221 */ .phy_id = PHY_ID_VSC8221, @@ -472,6 +507,7 @@ static struct phy_driver vsc82xx_driver[] = { .config_init = &vsc8221_config_init, .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, + .handle_interrupt = &vsc82xx_handle_interrupt, }, { /* Vitesse 8211 */ .phy_id = PHY_ID_VSC8211, @@ -481,6 +517,7 @@ static struct phy_driver vsc82xx_driver[] = { .config_init = &vsc8221_config_init, .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, + .handle_interrupt = &vsc82xx_handle_interrupt, } }; module_phy_driver(vsc82xx_driver); From patchwork Fri Nov 13 16:52:10 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904283 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C6741C55ABD for ; Fri, 13 Nov 2020 16:54:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 742F82222F for ; Fri, 13 Nov 2020 16:54:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Yrv2YuWO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726227AbgKMQw5 (ORCPT ); Fri, 13 Nov 2020 11:52:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726057AbgKMQwz (ORCPT ); Fri, 13 Nov 2020 11:52:55 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E3355C0613D1; Fri, 13 Nov 2020 08:52:54 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id p93so11457564edd.7; Fri, 13 Nov 2020 08:52:54 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=5eEkZyJuYqDgw3qo/V0uy1CW8YE9RreYkILxojzWYTQ=; b=Yrv2YuWOhbVzXh1LBqv1pj5PXOMpRA9ov8YzdJ5CniscasZ7AJ+tNSk0hYQNnYLHJf 8YVStB40Eu6+ON5xr2Yslu8VpJOGtMbCK/rXWOTJXd3o3kvUIPrqzzcWuFT5H6Z4LR1M cDSdthAZKWKgPO3x3jQ9ifQ4Q+gMOadEcb82oOQD/j6dzRa1HE89SZ0emwCPAn3lAPo/ oZyNUrvpcZvNJIEFz+PxUqKr+tGbrd8esSteuEe66eq9DuKK0PeawKj0MY+hPLYSGEms xlHqUcIrMACl+seKzPYnvddWVlOlY0UcLHN5F5oVvU0a6IbrQ/qBB1oh3qF2JStaBBKe PFfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=5eEkZyJuYqDgw3qo/V0uy1CW8YE9RreYkILxojzWYTQ=; b=TvgF1Ao91pkoNxOPokdEMPH2fOLDBw7fJxCb/TDcBBM+WGAFPWuvY3rS3JCHJWrAoi Q2rV4V3cgA/DhHYts5EPjSRyGUxDudOOt/MgLAV9Slg/xrgCNZ1D1xk12WYappKmZ0Cq oY0kt3R4SucSwk+tZbDs+Z5yZYtD0lmz4MD/XJ/SBu9tL6MZIBEnUpf179fH8WPKBoiZ ElTZf65MdT0EQ21CpQCoB0rSFDK6PURzJQI6opOk0jjM0XVOfpVkRYjZpaMk2/Dmtapd rOMckJ8GvGfiwVsBz9KcCVR4jsq4A48H3pnQSS+BskTJy2q3Vya3hjd4qO8jqaIcxOon l3SQ== X-Gm-Message-State: AOAM530gaZN/VUfkjzgxuiBlDi9PN008UU8CpTjL1+5w6M/oDp/D9u7S d3MGuKv8GNj4acEQx8AcFt0= X-Google-Smtp-Source: ABdhPJxpXIeUT8nrrPe1sXC/sPiJT0GYVlL7JD1l5aBTOVr/O4O7FPmlTfJTok6KyQr0zVCBwlDtCg== X-Received: by 2002:a05:6402:755:: with SMTP id p21mr3447192edy.349.1605286368789; Fri, 13 Nov 2020 08:52:48 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.47 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:47 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Kavya Sree Kotagiri , Linus Walleij Subject: [PATCH RESEND net-next 02/18] net: phy: vitesse: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:10 +0200 Message-Id: <20201113165226.561153-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Cc: Kavya Sree Kotagiri Cc: Linus Walleij Signed-off-by: Ioana Ciornei --- drivers/net/phy/vitesse.c | 24 +++--------------------- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/net/phy/vitesse.c b/drivers/net/phy/vitesse.c index 9f6cd6ec9747..16704e243162 100644 --- a/drivers/net/phy/vitesse.c +++ b/drivers/net/phy/vitesse.c @@ -275,25 +275,14 @@ static int vsc8601_config_init(struct phy_device *phydev) return 0; } -static int vsc824x_ack_interrupt(struct phy_device *phydev) -{ - int err = 0; - - /* Don't bother to ACK the interrupts if interrupts - * are disabled. The 824x cannot clear the interrupts - * if they are disabled. - */ - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) - err = phy_read(phydev, MII_VSC8244_ISTAT); - - return (err < 0) ? err : 0; -} - static int vsc82xx_config_intr(struct phy_device *phydev) { int err; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + /* Don't bother to ACK the interrupts since the 824x cannot + * clear the interrupts if they are disabled. + */ err = phy_write(phydev, MII_VSC8244_IMASK, (phydev->drv->phy_id == PHY_ID_VSC8234 || phydev->drv->phy_id == PHY_ID_VSC8244 || @@ -420,7 +409,6 @@ static struct phy_driver vsc82xx_driver[] = { /* PHY_GBIT_FEATURES */ .config_init = &vsc824x_config_init, .config_aneg = &vsc82x4_config_aneg, - .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { @@ -430,7 +418,6 @@ static struct phy_driver vsc82xx_driver[] = { /* PHY_GBIT_FEATURES */ .config_init = &vsc824x_config_init, .config_aneg = &vsc82x4_config_aneg, - .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { @@ -440,7 +427,6 @@ static struct phy_driver vsc82xx_driver[] = { /* PHY_GBIT_FEATURES */ .config_init = &vsc824x_config_init, .config_aneg = &vsc82x4_config_aneg, - .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { @@ -449,7 +435,6 @@ static struct phy_driver vsc82xx_driver[] = { .phy_id_mask = 0x000ffff0, /* PHY_GBIT_FEATURES */ .config_init = &vsc8601_config_init, - .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { @@ -495,7 +480,6 @@ static struct phy_driver vsc82xx_driver[] = { /* PHY_GBIT_FEATURES */ .config_init = &vsc824x_config_init, .config_aneg = &vsc82x4_config_aneg, - .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { @@ -505,7 +489,6 @@ static struct phy_driver vsc82xx_driver[] = { .name = "Vitesse VSC8221", /* PHY_GBIT_FEATURES */ .config_init = &vsc8221_config_init, - .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, }, { @@ -515,7 +498,6 @@ static struct phy_driver vsc82xx_driver[] = { .name = "Vitesse VSC8211", /* PHY_GBIT_FEATURES */ .config_init = &vsc8221_config_init, - .ack_interrupt = &vsc824x_ack_interrupt, .config_intr = &vsc82xx_config_intr, .handle_interrupt = &vsc82xx_handle_interrupt, } }; From patchwork Fri Nov 13 16:52:11 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904291 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E466C63699 for ; Fri, 13 Nov 2020 16:54:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EC4FD217A0 for ; Fri, 13 Nov 2020 16:54:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="u1sXVljz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726158AbgKMQxA (ORCPT ); Fri, 13 Nov 2020 11:53:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726210AbgKMQw5 (ORCPT ); Fri, 13 Nov 2020 11:52:57 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AB8C8C0613D1; Fri, 13 Nov 2020 08:52:56 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id o20so11497783eds.3; Fri, 13 Nov 2020 08:52:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Jk5b9nB+oqKMHLVq5uhhdOuhJ71EuKFqGbaLsLlT2HU=; b=u1sXVljzxQE8fN07BTgMN4byhFhFGw2MKjNA5R1Fn+MbaNfh+ZKS6xxCDSIlUXPPI3 kI5gIpxVBe0RFD1MdiXLDYL0GR4auKCajZia67ii3IM5Z9os1z+7X9FnQjZyPb08oxUk xs9fZv+/IP2HFz650JLliWmGXJtdWSsdr4G081Fb1KIoHDEZRR08B0eSyfUHP6OX42Pt BF8LK+xxbDSbpw9w1peuQ1ej7rFU6q5Y/w4P+FFFmwe2WbrUakAyc9/6G/Vt/umlN8tF FMD0VUhHt5CXnE3lgwLE69aQCY2HnA+g5/CnMP7i7iHiW2QBriKS4PEAcDPCOVR/WkuJ KJWA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Jk5b9nB+oqKMHLVq5uhhdOuhJ71EuKFqGbaLsLlT2HU=; b=dNlhq6wzvjdP+N6CId7d/P5mzTGXYxPlB2SHGaOgxatNH+H4xNuwAMB9axU3OJeu0h WDokEg2ILL3TKOHU5ZkySU5X3VBGgbm9ukzH0UdeB6pE67Cr7dTQobyYETXOpE96+2N6 KHrxtSmZnJeGPqudju4XOfdm/MGw73cgtCEHhjyAOsiZmnDjDO0dXsARKsYE26pMSDlB XSlIBM+70/NjSGagnVjES2bg87zwOlmD20iQyRi1X1BRSkyYka8ILNELBzhoASKyTCCI 4ko6iRF3cWhswAOvAyP87OtllnL+HqvvVrG8pn2uzGF2VGrrFS+erxjOCdUkYMCsjbC9 DU4A== X-Gm-Message-State: AOAM531U6/r4A9wXmQI3HmDT4ycjvdWw9nsNY/USCB9zYDH/DAWwnb+K H851p3+qsahJwEExVeVlUic= X-Google-Smtp-Source: ABdhPJyEg31SmQPPU+dDGjwKZzoqvgYEm2zzg+ZOjNUMZtVug93MSt+tGgwSFR3f4x0qRkVpXAsIIw== X-Received: by 2002:a50:dac9:: with SMTP id s9mr3275732edj.75.1605286370408; Fri, 13 Nov 2020 08:52:50 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:49 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Nisar Sayed , Yuiko Oshino Subject: [PATCH RESEND net-next 03/18] net: phy: microchip: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:11 +0200 Message-Id: <20201113165226.561153-4-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Nisar Sayed Cc: Yuiko Oshino Signed-off-by: Ioana Ciornei --- For the lan87xx_handle_interrupt() implementation, I do not know which exact bits denote a link change status (since I do not have access to a datasheet), so only in this driver's case, the phy state machine is triggered if any bit is asserted in the Interrupt status register. drivers/net/phy/microchip.c | 19 +++++++++++++++++++ drivers/net/phy/microchip_t1.c | 19 +++++++++++++++++++ 2 files changed, 38 insertions(+) diff --git a/drivers/net/phy/microchip.c b/drivers/net/phy/microchip.c index a644e8e5071c..b472a2149f08 100644 --- a/drivers/net/phy/microchip.c +++ b/drivers/net/phy/microchip.c @@ -56,6 +56,24 @@ static int lan88xx_phy_ack_interrupt(struct phy_device *phydev) return rc < 0 ? rc : 0; } +static irqreturn_t lan88xx_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, LAN88XX_INT_STS); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & LAN88XX_INT_STS_LINK_CHANGE_)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int lan88xx_suspend(struct phy_device *phydev) { struct lan88xx_priv *priv = phydev->priv; @@ -342,6 +360,7 @@ static struct phy_driver microchip_phy_driver[] = { .ack_interrupt = lan88xx_phy_ack_interrupt, .config_intr = lan88xx_phy_config_intr, + .handle_interrupt = lan88xx_handle_interrupt, .suspend = lan88xx_suspend, .resume = genphy_resume, diff --git a/drivers/net/phy/microchip_t1.c b/drivers/net/phy/microchip_t1.c index 1c9900162619..04cda8865deb 100644 --- a/drivers/net/phy/microchip_t1.c +++ b/drivers/net/phy/microchip_t1.c @@ -203,6 +203,24 @@ static int lan87xx_phy_ack_interrupt(struct phy_device *phydev) return rc < 0 ? rc : 0; } +static irqreturn_t lan87xx_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (irq_status == 0) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int lan87xx_config_init(struct phy_device *phydev) { int rc = lan87xx_phy_init(phydev); @@ -222,6 +240,7 @@ static struct phy_driver microchip_t1_phy_driver[] = { .ack_interrupt = lan87xx_phy_ack_interrupt, .config_intr = lan87xx_phy_config_intr, + .handle_interrupt = lan87xx_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, From patchwork Fri Nov 13 16:52:12 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904293 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 33DC7C55ABD for ; Fri, 13 Nov 2020 16:54:24 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D3DE3217A0 for ; Fri, 13 Nov 2020 16:54:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="job3IM+A" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726829AbgKMQyW (ORCPT ); Fri, 13 Nov 2020 11:54:22 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53446 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726162AbgKMQwy (ORCPT ); Fri, 13 Nov 2020 11:52:54 -0500 Received: from mail-ej1-x641.google.com (mail-ej1-x641.google.com [IPv6:2a00:1450:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 95F12C0617A6; Fri, 13 Nov 2020 08:52:53 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id cw8so14397084ejb.8; Fri, 13 Nov 2020 08:52:53 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=f7DDtazpnBZl5OQRGoKgmgElvXFLhF6bESa6gSu809g=; b=job3IM+AT1K2OzAvgg2qNUnnIvnNIbZX5fDvymu3WHOIMyFsvf76+JUSoeP0Saewje yi6nkUB6rQz70+W3vPOtiuSF2+n0IScHIGJyoxnG9e0smh6w9ca+1XBl0PLd0Z5lFljj ZFfV/tH9GwSkQPz6o/xmu/V4ZGJBlURPm3oVGfrWSF5FNCrlhQPwf4LX3cMXdt5HWgSH DZ4a1i22dSJnICpj6ZmSduZt89IxAot9f6ecC5mripUDY++vLVCCMgivUaBoOXNFeDVO YEWObrU0wPPtxM5tDVdMX1mjfXQmqwHXBJK5m8qpT1xyQlMQeShHuFn6N/xqSEQJ+5oo oF+Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=f7DDtazpnBZl5OQRGoKgmgElvXFLhF6bESa6gSu809g=; b=bRdvC8KULcRXLSjQiWc54J3I/Ic2gG8NLHqs1cdaa5DX2QPlGUv8zDy2dvtaMdMVrA 0PzLIdvFbQtfzU7Yp3eUgE2vPpRFeUXBXI2dWD4l+PBpkTYXLVFxeVWbBe9qtkKUII8a w5wCMkXOKRTUcn3FQvgVO5II5rxXI2JyraPktCOAsU5J6E+DeOEcmT7t2YJ1LQf6q5et OmajhEFHeUr42B7lEhIAxIvyS2aZMpBzW8dC8EeUAqbnNt9Cl2+HU3PwH3GVwHzoYrzV PhdFhLlZjBPS7XnekfFqKkZ869S/i24VKsEeATbEV/vD5JfB+dpO/6HZwky9yNFsZOwB Xkaw== X-Gm-Message-State: AOAM531g4VNvaVB4c79jl5YM0+rpQk5HJLgUQZdI0d46mwfffHAF7JYJ ewpA+WI96PQqZ7OnfNlW7ABBZq+UL3kE0A== X-Google-Smtp-Source: ABdhPJzHc1qHN9n6vBEIyDY0zy2WI109Wd4K9SjxePhRSOfa1bTsDnMVTGXrCG6sNXxTZsQn4UgPOg== X-Received: by 2002:a17:906:26c7:: with SMTP id u7mr2849817ejc.96.1605286371956; Fri, 13 Nov 2020 08:52:51 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:51 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Nisar Sayed , Yuiko Oshino Subject: [PATCH RESEND net-next 04/18] net: phy: microchip: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:12 +0200 Message-Id: <20201113165226.561153-5-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Cc: Nisar Sayed Cc: Yuiko Oshino Signed-off-by: Ioana Ciornei --- drivers/net/phy/microchip.c | 13 +++++-------- drivers/net/phy/microchip_t1.c | 17 +++++++---------- 2 files changed, 12 insertions(+), 18 deletions(-) diff --git a/drivers/net/phy/microchip.c b/drivers/net/phy/microchip.c index b472a2149f08..9f1f2b6c97d4 100644 --- a/drivers/net/phy/microchip.c +++ b/drivers/net/phy/microchip.c @@ -44,14 +44,12 @@ static int lan88xx_phy_config_intr(struct phy_device *phydev) LAN88XX_INT_MASK_LINK_CHANGE_); } else { rc = phy_write(phydev, LAN88XX_INT_MASK, 0); - } - - return rc < 0 ? rc : 0; -} + if (rc) + return rc; -static int lan88xx_phy_ack_interrupt(struct phy_device *phydev) -{ - int rc = phy_read(phydev, LAN88XX_INT_STS); + /* Ack interrupts after they have been disabled */ + rc = phy_read(phydev, LAN88XX_INT_STS); + } return rc < 0 ? rc : 0; } @@ -358,7 +356,6 @@ static struct phy_driver microchip_phy_driver[] = { .config_init = lan88xx_config_init, .config_aneg = lan88xx_config_aneg, - .ack_interrupt = lan88xx_phy_ack_interrupt, .config_intr = lan88xx_phy_config_intr, .handle_interrupt = lan88xx_handle_interrupt, diff --git a/drivers/net/phy/microchip_t1.c b/drivers/net/phy/microchip_t1.c index 04cda8865deb..4dc00bd5a8d2 100644 --- a/drivers/net/phy/microchip_t1.c +++ b/drivers/net/phy/microchip_t1.c @@ -189,16 +189,14 @@ static int lan87xx_phy_config_intr(struct phy_device *phydev) rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, 0x7FFF); rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE); val = LAN87XX_MASK_LINK_UP | LAN87XX_MASK_LINK_DOWN; - } - - rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, val); - - return rc < 0 ? rc : 0; -} + rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, val); + } else { + rc = phy_write(phydev, LAN87XX_INTERRUPT_MASK, val); + if (rc) + return rc; -static int lan87xx_phy_ack_interrupt(struct phy_device *phydev) -{ - int rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE); + rc = phy_read(phydev, LAN87XX_INTERRUPT_SOURCE); + } return rc < 0 ? rc : 0; } @@ -238,7 +236,6 @@ static struct phy_driver microchip_t1_phy_driver[] = { .config_init = lan87xx_config_init, - .ack_interrupt = lan87xx_phy_ack_interrupt, .config_intr = lan87xx_phy_config_intr, .handle_interrupt = lan87xx_handle_interrupt, From patchwork Fri Nov 13 16:52:13 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904289 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C4DF7C388F7 for ; Fri, 13 Nov 2020 16:54:09 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65275217A0 for ; Fri, 13 Nov 2020 16:54:09 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LAG/YVYn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726787AbgKMQyG (ORCPT ); Fri, 13 Nov 2020 11:54:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53474 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726270AbgKMQxA (ORCPT ); Fri, 13 Nov 2020 11:53:00 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C136AC0617A6; Fri, 13 Nov 2020 08:52:59 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id za3so14422300ejb.5; Fri, 13 Nov 2020 08:52:59 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7Dxgm0Fh4+mVDplG8D4f9NidT6Io7JYvUTeWlAV1zP4=; b=LAG/YVYnAcV1jEK77GCxF3CCd2jp0wHqNo67oikn8zKZlF3NENyGYoiUCIEW2bIw+I nlf+5Asa/iD6RPzxJxPMmy5A3Ze1iRzvRF7ZE+SZciWCDelB23dZ1M9zGa88nxMePpHE UYHKGAwX9tHVpFS9l03PEuBjxXOUW/w9Fx/SnAm119Cy8IPJKzBqUPF/sIFlQvWzzExK 9cY+AOaVodBVWI7v8IMzm1tt+qmw+GzTZ49m2eDmjCXeqnKWfWnkYbDE2aRWkbrFfJyj LaJjOjxla9jtRxUi+Blmx4RMjRbt+S4Tnnsz87bbKGFodTmHDM/ns/9aUMC7EYOUJgNl 8LwA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7Dxgm0Fh4+mVDplG8D4f9NidT6Io7JYvUTeWlAV1zP4=; b=SavrNDbuhiCNvxO0fi63D59AM5DrfIsu7TOWRW4XIRdU3BcpvGJktD4s24l8+NGlRF Nxj6ZjZtW8+e4HawKMghrZR8NcuXSSVomR3B7jD2+FIicYoARui/Yt9wfbHc3vnpjXHL nNrYBPh9ijzTkrBk/MnUl9CUI255Y9K2rRN1MwJnBabZZ8OB8hQiIBgg8ysoDzZqIhrk wBvQEjiPUv/ZaATNcqWWZrgHKDHNISklnV7Mj9nI2BTqJW5DlF+4wZo/G3eoJNOeLSBl cyDOPcgSm8TUO6P29yTzu/zWs7xtRNPxzhQWfTtI9f6RhKUbujSudpeWZF5E/1EVA9/V JLrQ== X-Gm-Message-State: AOAM5319yFWxqXokYt6E5uXYfrR4Hi3psQh7JtSINkMNhad9Ek8dx50W /gvwkac8Riju7grSifAVnEg= X-Google-Smtp-Source: ABdhPJw9uDMa8hwIIzwTPt848qbP937/aEK7w1XWYSoRbrY3LidzYNNCUDhBioZQCZHzDPCux/bKsQ== X-Received: by 2002:a17:906:d9ce:: with SMTP id qk14mr2738446ejb.522.1605286373426; Fri, 13 Nov 2020 08:52:53 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:52 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Maxim Kochetkov , Baruch Siach , Robert Hancock Subject: [PATCH RESEND net-next 05/18] net: phy: marvell: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:13 +0200 Message-Id: <20201113165226.561153-6-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Maxim Kochetkov Cc: Baruch Siach Cc: Robert Hancock Signed-off-by: Ioana Ciornei --- drivers/net/phy/marvell.c | 57 ++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 21 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index 2563526bf4a6..bb843b960436 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -327,6 +327,24 @@ static int marvell_config_intr(struct phy_device *phydev) return err; } +static irqreturn_t marvell_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_M1011_IEVENT); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_M1011_IMASK_INIT)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int marvell_set_polarity(struct phy_device *phydev, int polarity) { int reg; @@ -1659,18 +1677,6 @@ static int marvell_aneg_done(struct phy_device *phydev) return (retval < 0) ? retval : (retval & MII_M1011_PHY_STATUS_RESOLVED); } -static int m88e1121_did_interrupt(struct phy_device *phydev) -{ - int imask; - - imask = phy_read(phydev, MII_M1011_IEVENT); - - if (imask & MII_M1011_IMASK_INIT) - return 1; - - return 0; -} - static void m88e1318_get_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) { @@ -2699,6 +2705,7 @@ static struct phy_driver marvell_drivers[] = { .config_aneg = m88e1101_config_aneg, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2717,6 +2724,7 @@ static struct phy_driver marvell_drivers[] = { .config_aneg = marvell_config_aneg, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2738,6 +2746,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2759,6 +2768,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2779,6 +2789,7 @@ static struct phy_driver marvell_drivers[] = { .config_aneg = m88e1118_config_aneg, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2798,7 +2809,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2820,7 +2831,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .get_wol = m88e1318_get_wol, .set_wol = m88e1318_set_wol, .resume = genphy_resume, @@ -2842,6 +2853,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = genphy_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2862,6 +2874,7 @@ static struct phy_driver marvell_drivers[] = { .config_aneg = m88e1118_config_aneg, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2880,6 +2893,7 @@ static struct phy_driver marvell_drivers[] = { .config_aneg = marvell_config_aneg, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2897,6 +2911,7 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1116r_config_init, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2919,7 +2934,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .get_wol = m88e1318_get_wol, .set_wol = m88e1318_set_wol, .resume = marvell_resume, @@ -2948,7 +2963,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2974,7 +2989,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -2999,7 +3014,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -3020,7 +3035,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -3045,7 +3060,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, @@ -3067,7 +3082,7 @@ static struct phy_driver marvell_drivers[] = { .read_status = marvell_read_status, .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, - .did_interrupt = m88e1121_did_interrupt, + .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, .suspend = genphy_suspend, .read_page = marvell_read_page, From patchwork Fri Nov 13 16:52:14 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904279 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 964C8C55ABD for ; Fri, 13 Nov 2020 16:54:02 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4123E21D1A for ; Fri, 13 Nov 2020 16:54:02 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="dYDXpbAO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726300AbgKMQxC (ORCPT ); Fri, 13 Nov 2020 11:53:02 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726277AbgKMQxB (ORCPT ); Fri, 13 Nov 2020 11:53:01 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8449FC0613D1; Fri, 13 Nov 2020 08:53:00 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id s25so14416099ejy.6; Fri, 13 Nov 2020 08:53:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oNz8ucszFZGajN27xAe/ut4viosb6LUQd+Phco1FxbU=; b=dYDXpbAO0zu458DtRgxh4SP4FpjD55d76IJ/6znu2Fd4ZlqzGMLxPTV1VlmG8uDTAA y442kv+jmQEORHqyymjaWnE6H8ouxrO6SKbkht38ZHo5lBI95CoH1ZuwRZw0GSl4Gbb6 IdlqHAJjUr2wF40SnukOwSNybRyJvRkQE7INzPIvdsSTdQu0G1Em0QW3QatpOwCHD271 Xm7wE+VatFR5n+gCZ6hYTlKl8WqY5vv1Wy6YFfEWiIeJvlwDfL05KdJ6tBnJzbv++q7s +N+hzGYBqGm8yPlO4ZGkBcIKkW/o4+q0cfvfexqc5tvKvO+Y/tH1Oxzv0KqGzVk0JXky oTFQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oNz8ucszFZGajN27xAe/ut4viosb6LUQd+Phco1FxbU=; b=m/bsM+mmK3OT8HFK6N0LdEe9NqbZ3ftF/HNLZUSb+UNytkCTPIz0b/iKaPvjDK/BJs zwqc6LM37pBFA7Xwky5sb38MUUmmgDHFcEykYU9CLA2BMmyVHRDS1M7MOljZ6w1s/uvE GDvOmtPA+10u4JqFodrPyULcqaQVBwQ+LzX8InPwUXQh15aW4oX8Ezbn9HH0m5gua47X 9lUNm8C0aAVnoGpVAuV3cHENFIIrNmqS/ieOuLV9l6cQl20QO7NzqkSA2rQVZp9xFb4q sJteB0XcJrU+1Ka6QUx9oyzMF/7AYPXLd7xIhLlKSh5xgRg3F8ZSM3A6W6WlejBCp+Es w60w== X-Gm-Message-State: AOAM530yFiN2pxaoOJecg6uE2Dby2mWJZCdYVxciAtSoliB13h37h/Pn EQP1lW4nStDVLcjXvsSeuP8= X-Google-Smtp-Source: ABdhPJy6g2g0qtAu3SEZinpWPEr/Y6d0pFLt3N7OFluITX7UXL5+rxG/IwDHp/7gFRMvRhvWYplSdw== X-Received: by 2002:a17:906:748b:: with SMTP id e11mr2717387ejl.513.1605286374834; Fri, 13 Nov 2020 08:52:54 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:54 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Maxim Kochetkov , Baruch Siach , Robert Hancock Subject: [PATCH RESEND net-next 06/18] net: phy: marvell: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:14 +0200 Message-Id: <20201113165226.561153-7-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Cc: Maxim Kochetkov Cc: Baruch Siach Cc: Robert Hancock Signed-off-by: Ioana Ciornei Tested-by: Andrew Lunn --- drivers/net/phy/marvell.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/drivers/net/phy/marvell.c b/drivers/net/phy/marvell.c index bb843b960436..587930a7f48b 100644 --- a/drivers/net/phy/marvell.c +++ b/drivers/net/phy/marvell.c @@ -317,12 +317,21 @@ static int marvell_config_intr(struct phy_device *phydev) { int err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = marvell_ack_interrupt(phydev); + if (err) + return err; + err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_INIT); - else + } else { err = phy_write(phydev, MII_M1011_IMASK, MII_M1011_IMASK_CLEAR); + if (err) + return err; + + err = marvell_ack_interrupt(phydev); + } return err; } @@ -2703,7 +2712,6 @@ static struct phy_driver marvell_drivers[] = { .probe = marvell_probe, .config_init = marvell_config_init, .config_aneg = m88e1101_config_aneg, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2722,7 +2730,6 @@ static struct phy_driver marvell_drivers[] = { .probe = marvell_probe, .config_init = m88e1111_config_init, .config_aneg = marvell_config_aneg, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2744,7 +2751,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1111_config_init, .config_aneg = m88e1111_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2766,7 +2772,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1111_config_init, .config_aneg = m88e1111_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2787,7 +2792,6 @@ static struct phy_driver marvell_drivers[] = { .probe = marvell_probe, .config_init = m88e1118_config_init, .config_aneg = m88e1118_config_aneg, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2807,7 +2811,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = marvell_config_init, .config_aneg = m88e1121_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2829,7 +2832,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1318_config_init, .config_aneg = m88e1318_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .get_wol = m88e1318_get_wol, @@ -2851,7 +2853,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1145_config_init, .config_aneg = m88e1101_config_aneg, .read_status = genphy_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2872,7 +2873,6 @@ static struct phy_driver marvell_drivers[] = { .probe = marvell_probe, .config_init = m88e1149_config_init, .config_aneg = m88e1118_config_aneg, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2891,7 +2891,6 @@ static struct phy_driver marvell_drivers[] = { .probe = marvell_probe, .config_init = m88e1111_config_init, .config_aneg = marvell_config_aneg, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2909,7 +2908,6 @@ static struct phy_driver marvell_drivers[] = { /* PHY_GBIT_FEATURES */ .probe = marvell_probe, .config_init = m88e1116r_config_init, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2932,7 +2930,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e1510_config_init, .config_aneg = m88e1510_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .get_wol = m88e1318_get_wol, @@ -2961,7 +2958,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = marvell_config_init, .config_aneg = m88e1510_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -2987,7 +2983,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = marvell_config_init, .config_aneg = m88e1510_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -3012,7 +3007,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = m88e3016_config_init, .aneg_done = marvell_aneg_done, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -3033,7 +3027,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = marvell_config_init, .config_aneg = m88e6390_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -3058,7 +3051,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = marvell_config_init, .config_aneg = m88e1510_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, @@ -3080,7 +3072,6 @@ static struct phy_driver marvell_drivers[] = { .config_init = marvell_config_init, .config_aneg = m88e1510_config_aneg, .read_status = marvell_read_status, - .ack_interrupt = marvell_ack_interrupt, .config_intr = marvell_config_intr, .handle_interrupt = marvell_handle_interrupt, .resume = genphy_resume, From patchwork Fri Nov 13 16:52:15 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904265 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1898CC55ABD for ; Fri, 13 Nov 2020 16:53:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ADB3F21D79 for ; Fri, 13 Nov 2020 16:53:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ehH8Si/m" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726338AbgKMQxE (ORCPT ); Fri, 13 Nov 2020 11:53:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbgKMQxD (ORCPT ); Fri, 13 Nov 2020 11:53:03 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8544DC0613D1; Fri, 13 Nov 2020 08:53:02 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id me8so14421325ejb.10; Fri, 13 Nov 2020 08:53:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=T2XY8ttvdIFiCYz29ukEUuH1Xm19QPYXW7DIh+FSk/8=; b=ehH8Si/mvbYCdsxzZQi2rM0jGAzlYnjQ0aQvYHJZBhmxpTxkeJPo5sW9bOCczJwc1P Kby9pQ8ajPVBLr+fHf8KNRJYsrfQo0PTjVjCZ7zbqgHYKKPJ911CcIBAJA0Tn3Ox93Dn n7yLHv8KQHWq64SkPdyNb+pHuX0EDdUCAzRVjX1my3f9Du/6UTTeFe5NS8Ofvlzg9Rqn tWV31sFneqSDvyGph30xANuIv1Ip9YOWrptrvv8GFcpLaYED987S/PXwQDSlAvwC6nWw QU46+uDQH6rwd+vbJ9fUxmhfnE9edhFjYXk/WfnoLMEyZfeBz/U360f0PCI9RiLjOq19 bCtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=T2XY8ttvdIFiCYz29ukEUuH1Xm19QPYXW7DIh+FSk/8=; b=TOMDfQC04LrbM2XJ9ENyVW2VhOzOuI1UxjaUhG54QrxtJfInK/G+LIvpiW2pyzAQ8g Oo0T6MMmQhJQjyzc9+SV8up0OvLgQLUUc53W+oOEnwwVUbjExMNxTrn6Qb4ufuNKcopv CY7QGsrJ4B5gfmEltGvl4bMrNzmMqGv1NJio3JWdZbhX9dKXzA5BBFKyPpNet8ZLdqzp lr9gc727OgO/BAdysTJLGb7DorYDzCnbpg+utDZkqE80y4ljf1nlFGExU1Zwcv+ncg0w E2vGmPRQUfXu9MBOxx0EXa/011P0fUuYSFzsy8xt04ikdPPki0uQi39ZFYHQa64BB/nc BF8w== X-Gm-Message-State: AOAM53037oYZk1j0AJ2aOGCgBMLeYW3ZIAZmTwa/RU3/CnVuk5fXKfu2 qZzCypBgIE2fU78q86GnLTE= X-Google-Smtp-Source: ABdhPJwxgCC3PEVb/7JXrhR44g1s/vQkG0wg5Gf9wmqYKL+OqA20NfDAYc/7Y2cdHjKJxIbxNbABOg== X-Received: by 2002:a17:906:3a55:: with SMTP id a21mr2734205ejf.357.1605286376415; Fri, 13 Nov 2020 08:52:56 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:55 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Christophe Leroy Subject: [PATCH RESEND net-next 07/18] net: phy: lxt: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:15 +0200 Message-Id: <20201113165226.561153-8-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Christophe Leroy Signed-off-by: Ioana Ciornei --- drivers/net/phy/lxt.c | 50 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 50 insertions(+) diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c index fec58ad69e02..716d9936bc90 100644 --- a/drivers/net/phy/lxt.c +++ b/drivers/net/phy/lxt.c @@ -37,6 +37,8 @@ #define MII_LXT970_ISR 18 /* Interrupt Status Register */ +#define MII_LXT970_IRS_MINT BIT(15) + #define MII_LXT970_CONFIG 19 /* Configuration Register */ /* ------------------------------------------------------------------------- */ @@ -47,6 +49,7 @@ #define MII_LXT971_IER_IEN 0x00f2 #define MII_LXT971_ISR 19 /* Interrupt Status Register */ +#define MII_LXT971_ISR_MASK 0x00f0 /* register definitions for the 973 */ #define MII_LXT973_PCR 16 /* Port Configuration Register */ @@ -81,6 +84,33 @@ static int lxt970_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_LXT970_IER, 0); } +static irqreturn_t lxt970_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + /* The interrupt status register is cleared by reading BMSR + * followed by MII_LXT970_ISR + */ + irq_status = phy_read(phydev, MII_BMSR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + irq_status = phy_read(phydev, MII_LXT970_ISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_LXT970_IRS_MINT)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int lxt970_config_init(struct phy_device *phydev) { return phy_write(phydev, MII_LXT970_CONFIG, 0); @@ -105,6 +135,24 @@ static int lxt971_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_LXT971_IER, 0); } +static irqreturn_t lxt971_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_LXT971_ISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_LXT971_ISR_MASK)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + /* * A2 version of LXT973 chip has an ERRATA: it randomly return the contents * of the previous even register when you read a odd register regularly @@ -239,6 +287,7 @@ static struct phy_driver lxt97x_driver[] = { .config_init = lxt970_config_init, .ack_interrupt = lxt970_ack_interrupt, .config_intr = lxt970_config_intr, + .handle_interrupt = lxt970_handle_interrupt, }, { .phy_id = 0x001378e0, .name = "LXT971", @@ -246,6 +295,7 @@ static struct phy_driver lxt97x_driver[] = { /* PHY_BASIC_FEATURES */ .ack_interrupt = lxt971_ack_interrupt, .config_intr = lxt971_config_intr, + .handle_interrupt = lxt971_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, }, { From patchwork Fri Nov 13 16:52:16 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904287 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 11A99C61DD8 for ; Fri, 13 Nov 2020 16:54:14 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C6B4121D1A for ; Fri, 13 Nov 2020 16:54:13 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Oac01yGw" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726805AbgKMQyM (ORCPT ); Fri, 13 Nov 2020 11:54:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53470 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726202AbgKMQw7 (ORCPT ); Fri, 13 Nov 2020 11:52:59 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A6F2C0613D1; Fri, 13 Nov 2020 08:52:59 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id za3so14422269ejb.5; Fri, 13 Nov 2020 08:52:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=EHyQQOuXf5BU03as2u/ud2yF/KPxzFMDQ2v3ffUTBGc=; b=Oac01yGweCMZw6kb246TzAFc9ilEewb/HZbnmGUX6zedWmsgFK6tX58LKExOjTv7LY sR0/1GNxFdcbYbIz6xUB5rJRMST1LCVK7WwOpOz4A9YnAM8BUO1u6gMrxEwMBpKNjoLo C9CP7xNg7iKQszCoRt68u3Kkuegldndix+cdW/bTbsx9CubAQufzvL80B0unkThyAefg NDjjKoaEmWBfc/h4KJr8ZSM2OzB7NQA//rjWuJQLd7C9GwMq+ynmihP+Ii96/YKSMMMa sk1W5xCQ2FfY55epYqPM2jib/8udUoUefM8R8Hcdbd/tDTNhRXk6sZ5PJ5DhmrJOt50Y H0xw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=EHyQQOuXf5BU03as2u/ud2yF/KPxzFMDQ2v3ffUTBGc=; b=JXtKmmTzA/aS/C7jyY15n+/th3C7jSExn+/mvv7ZGVdlBMy/NeOYZnz4wUb0qMOZMm bC0ac+cBde3nQR5/muCCytC2vOhw7rkJayRSXygUIDAj/9WfygWFlD+sv6GXb5EtNY3/ LGwBHeU36blja9uZdu0vadpsn1CxR9D3dGzXR9W+TYG13MWHqe8eKi15bA2cAfq44ycc 20EvfMriVErHnmtWFkSGxiiDX52a+uD4eZNPfmvdfuMN9NyEhUvp0GdV7y9ZBYe3PUId ePWHh5wX5s46sISGCLLQc8OJW7Csn94NkrLFjPRzz9KyUii8P9DNkozPGfrEt4xtNqIg GpcA== X-Gm-Message-State: AOAM533bxIosjlhSV1rxWfb5FnKT1zacq9B23LVs4VbmYmL9RDMeusMU SjzxGuxsEPMG24+zhA4k7gtB4HGFF0Jo4w== X-Google-Smtp-Source: ABdhPJz1r0DmTYhLVU80IGjksPD85Ungzwvv9wsKtpDUE0KbejhhGNnG3LFWMpuXKT2zf6q1xJ3ZLg== X-Received: by 2002:a17:906:57cc:: with SMTP id u12mr2840322ejr.163.1605286377686; Fri, 13 Nov 2020 08:52:57 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:57 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Christophe Leroy Subject: [PATCH RESEND net-next 08/18] net: phy: lxt: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:16 +0200 Message-Id: <20201113165226.561153-9-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Cc: Christophe Leroy Signed-off-by: Ioana Ciornei --- drivers/net/phy/lxt.c | 44 +++++++++++++++++++++++++++++++++---------- 1 file changed, 34 insertions(+), 10 deletions(-) diff --git a/drivers/net/phy/lxt.c b/drivers/net/phy/lxt.c index 716d9936bc90..0ee23d29c0d4 100644 --- a/drivers/net/phy/lxt.c +++ b/drivers/net/phy/lxt.c @@ -78,10 +78,23 @@ static int lxt970_ack_interrupt(struct phy_device *phydev) static int lxt970_config_intr(struct phy_device *phydev) { - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) - return phy_write(phydev, MII_LXT970_IER, MII_LXT970_IER_IEN); - else - return phy_write(phydev, MII_LXT970_IER, 0); + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = lxt970_ack_interrupt(phydev); + if (err) + return err; + + err = phy_write(phydev, MII_LXT970_IER, MII_LXT970_IER_IEN); + } else { + err = phy_write(phydev, MII_LXT970_IER, 0); + if (err) + return err; + + err = lxt970_ack_interrupt(phydev); + } + + return err; } static irqreturn_t lxt970_handle_interrupt(struct phy_device *phydev) @@ -129,10 +142,23 @@ static int lxt971_ack_interrupt(struct phy_device *phydev) static int lxt971_config_intr(struct phy_device *phydev) { - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) - return phy_write(phydev, MII_LXT971_IER, MII_LXT971_IER_IEN); - else - return phy_write(phydev, MII_LXT971_IER, 0); + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = lxt971_ack_interrupt(phydev); + if (err) + return err; + + err = phy_write(phydev, MII_LXT971_IER, MII_LXT971_IER_IEN); + } else { + err = phy_write(phydev, MII_LXT971_IER, 0); + if (err) + return err; + + err = lxt971_ack_interrupt(phydev); + } + + return err; } static irqreturn_t lxt971_handle_interrupt(struct phy_device *phydev) @@ -285,7 +311,6 @@ static struct phy_driver lxt97x_driver[] = { .phy_id_mask = 0xfffffff0, /* PHY_BASIC_FEATURES */ .config_init = lxt970_config_init, - .ack_interrupt = lxt970_ack_interrupt, .config_intr = lxt970_config_intr, .handle_interrupt = lxt970_handle_interrupt, }, { @@ -293,7 +318,6 @@ static struct phy_driver lxt97x_driver[] = { .name = "LXT971", .phy_id_mask = 0xfffffff0, /* PHY_BASIC_FEATURES */ - .ack_interrupt = lxt971_ack_interrupt, .config_intr = lxt971_config_intr, .handle_interrupt = lxt971_handle_interrupt, .suspend = genphy_suspend, From patchwork Fri Nov 13 16:52:17 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904285 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 42CD1C388F7 for ; Fri, 13 Nov 2020 16:53:55 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E823821D1A for ; Fri, 13 Nov 2020 16:53:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EGR8EKGQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726759AbgKMQxy (ORCPT ); Fri, 13 Nov 2020 11:53:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53496 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726303AbgKMQxG (ORCPT ); Fri, 13 Nov 2020 11:53:06 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E38BAC0613D1; Fri, 13 Nov 2020 08:53:05 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id t11so11423165edj.13; Fri, 13 Nov 2020 08:53:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8ulq0yD0my4Otp65SkQZNLolrSXf+hFMzY6ErDKfcVE=; b=EGR8EKGQaHe6bFSQpGDmmNGl/WIB2HVmkjDDtcShtg0/I5abvMg85bKrkVNt2oWmvs 51zrGMDjJegpl4Pov7C0JQlk8Vl1ULinUT8ifbbeb1hNP5oijnDmTAsGVoZlNeLA0A2i 4rU5/z2CWu1Xm+bwxposVRMhZRoWLbIpsVxeJPFcs1cAkkNe5GAfA7nIhFnu91b1yPSR YwRaJDJ6qQgLytfz/uw1PaTAOIVyyblEuhNQPICnUkAPySrFcUjhIiIK0tvzxJVJmIXc 6P9PY68rKPk+0p52aJPOIajCqAn784T3FODZG1N0MB33xrsc3IkbR0tDDi8vDM7z56nV 5Qdg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8ulq0yD0my4Otp65SkQZNLolrSXf+hFMzY6ErDKfcVE=; b=GWjUQf7yoyEDWMlZ/WFSZyRzar0JNWWiQ7+7vV4fTxliHEgD41sgRbaO5ozf6RjyFh rkbY/7SosFT7bK68OOPeX7ugFzLoi21N+qDlup5fGkDkPpNXdDrj3PWPkrlmt/FJwo/7 Z4OKGX5pFU/eMoadDQquSYzTMjYUlNORq3dPN1lcK8BLWr/N2D5GxRvA5At0HxeBd/7T tDKSY1lkyHLPpUaq4KapiPQmZeeDg1PqOTFRLUykiVQsie9lGLhATejYIehBGCnjwho0 Yr0k+h5rtXLYIe+T3PcDz1aJQ1sPnmj/YaYQicufdku9uSUTZLau3hbqplywsY0S0Nh6 pKOA== X-Gm-Message-State: AOAM530ABzHtYDzuvbtI8gtoj7lFoFJWXOjr3mOLr4zAgDNmTrsQ2QGK Jo5xTL1zfA2+4hioRGvTEE0= X-Google-Smtp-Source: ABdhPJxPLDeDhiBlOMUqwYhYP2953OXnIxlVOx/MN6vQce2iimbxulsGPXwhypNzmGS0qtOz8mzPeA== X-Received: by 2002:aa7:d709:: with SMTP id t9mr3562326edq.305.1605286379576; Fri, 13 Nov 2020 08:52:59 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:52:58 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Marek Vasut , Oleksij Rempel Subject: [PATCH RESEND net-next 09/18] net: phy: nxp-tja11xx: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:17 +0200 Message-Id: <20201113165226.561153-10-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Marek Vasut Cc: Oleksij Rempel Signed-off-by: Ioana Ciornei --- drivers/net/phy/nxp-tja11xx.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index a72fa0d2e7c7..1c4c5c267fe6 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -44,6 +44,9 @@ #define MII_CFG2_SLEEP_REQUEST_TO_16MS 0x3 #define MII_INTSRC 21 +#define MII_INTSRC_LINK_FAIL BIT(10) +#define MII_INTSRC_LINK_UP BIT(9) +#define MII_INTSRC_MASK (MII_INTSRC_LINK_FAIL | MII_INTSRC_LINK_UP) #define MII_INTSRC_TEMP_ERR BIT(1) #define MII_INTSRC_UV_ERR BIT(3) @@ -604,6 +607,24 @@ static int tja11xx_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_INTEN, value); } +static irqreturn_t tja11xx_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_INTSRC); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_INTSRC_MASK)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int tja11xx_cable_test_start(struct phy_device *phydev) { int ret; @@ -749,6 +770,7 @@ static struct phy_driver tja11xx_driver[] = { .get_stats = tja11xx_get_stats, .ack_interrupt = tja11xx_ack_interrupt, .config_intr = tja11xx_config_intr, + .handle_interrupt = tja11xx_handle_interrupt, .cable_test_start = tja11xx_cable_test_start, .cable_test_get_status = tja11xx_cable_test_get_status, }, { @@ -772,6 +794,7 @@ static struct phy_driver tja11xx_driver[] = { .get_stats = tja11xx_get_stats, .ack_interrupt = tja11xx_ack_interrupt, .config_intr = tja11xx_config_intr, + .handle_interrupt = tja11xx_handle_interrupt, .cable_test_start = tja11xx_cable_test_start, .cable_test_get_status = tja11xx_cable_test_get_status, } From patchwork Fri Nov 13 16:52:18 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904257 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C9D20C55ABD for ; Fri, 13 Nov 2020 16:53:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 87A11217A0 for ; Fri, 13 Nov 2020 16:53:10 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ovoPHuwb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726392AbgKMQxI (ORCPT ); Fri, 13 Nov 2020 11:53:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53492 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726352AbgKMQxF (ORCPT ); Fri, 13 Nov 2020 11:53:05 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EC0D9C0613D1; Fri, 13 Nov 2020 08:53:04 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id o20so11498362eds.3; Fri, 13 Nov 2020 08:53:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=A3shoGVPTfTeSo9qIFJ3MH89QzogQsCpieTVJw1XX5s=; b=ovoPHuwb70D/6RxJYMAFmNGWDZQm4KWTYItMRGH4/h/gtn5F7L8cGqxGrHI/iuJI8/ 2QBylFfo1gPNE8USYs5G4TEWqICZL2bcA/AyRWe8Vmm2MGbRJPBuT2xDJ52QvxkcsB9Z 2nWQlft6AEiiZFnfWthl7/1lsXyEfWNUFbBbDKd40/tcYls/yID9jLXuPFGcmB6rXAcb p5FFHjmnGrhy2O3PwwD6TVVQcHvXDs8y4Eh1rT1PbGfw7gLHXqktIokbIpAE7rLtgq2y ikdMPB+TOmvy+xGC9bKbzQBxmC0sRBtItvZ6zvUIgQjiaSbHLk3iLr0UKKwuSiowhnnh uqZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=A3shoGVPTfTeSo9qIFJ3MH89QzogQsCpieTVJw1XX5s=; b=hMJjNT65EK1S93DSp8vbh5FsZwG7ILOzmr+3L1xDyOtFdZkpX5Ex0MoJW+9C3lqANH y9Jm8j19/ksOvdp4pS6uEMuMMWc/PGdweCMJorietgpJe8algS6A+BRIQYQp8kA7l5R0 yEjgR3aUcU6Bmm0HZTI4+TOJCwPp2bhEBj3ECYtEB4bL9IDWbwVF6YbTli4WsScIiP9n xitfLRrSoBaUSUa3+aihIkNbT6HrhoNq7R5QoQLOCOGbDsECUjA7eC+HwTy4+2n6v3/R KUtaDKxzIDH6c4/wFsQ4EY4hsiZgxgquohav3qcx61Hm/SywFRJjdb1HZnmNIp3iyAYn 8/Yg== X-Gm-Message-State: AOAM53325Er6CZk/f2RizOStnL+yOOacFd0tKzCoxsefwseJfK7TnG9L LaS5CkUBTdtb4e2vO8XSwutnl43p9vzUqA== X-Google-Smtp-Source: ABdhPJyhvt4kgI6EtNtAI6MvYKmADCPxHUL3o4mSl0xF4jT45tR4EsYQxPAIhzO1iaUlyFpXlsJ/Fw== X-Received: by 2002:a50:bb06:: with SMTP id y6mr3529713ede.278.1605286381524; Fri, 13 Nov 2020 08:53:01 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.52.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:00 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Marek Vasut , Oleksij Rempel Subject: [PATCH RESEND net-next 10/18] net: phy: nxp-tja11xx: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:18 +0200 Message-Id: <20201113165226.561153-11-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Cc: Marek Vasut Cc: Oleksij Rempel Signed-off-by: Ioana Ciornei --- drivers/net/phy/nxp-tja11xx.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/nxp-tja11xx.c b/drivers/net/phy/nxp-tja11xx.c index 1c4c5c267fe6..afd7afa1f498 100644 --- a/drivers/net/phy/nxp-tja11xx.c +++ b/drivers/net/phy/nxp-tja11xx.c @@ -600,11 +600,24 @@ static int tja11xx_ack_interrupt(struct phy_device *phydev) static int tja11xx_config_intr(struct phy_device *phydev) { int value = 0; + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = tja11xx_ack_interrupt(phydev); + if (err) + return err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) value = MII_INTEN_LINK_FAIL | MII_INTEN_LINK_UP; + err = phy_write(phydev, MII_INTEN, value); + } else { + err = phy_write(phydev, MII_INTEN, value); + if (err) + return err; + + err = tja11xx_ack_interrupt(phydev); + } - return phy_write(phydev, MII_INTEN, value); + return err; } static irqreturn_t tja11xx_handle_interrupt(struct phy_device *phydev) @@ -768,7 +781,6 @@ static struct phy_driver tja11xx_driver[] = { .get_sset_count = tja11xx_get_sset_count, .get_strings = tja11xx_get_strings, .get_stats = tja11xx_get_stats, - .ack_interrupt = tja11xx_ack_interrupt, .config_intr = tja11xx_config_intr, .handle_interrupt = tja11xx_handle_interrupt, .cable_test_start = tja11xx_cable_test_start, @@ -792,7 +804,6 @@ static struct phy_driver tja11xx_driver[] = { .get_sset_count = tja11xx_get_sset_count, .get_strings = tja11xx_get_strings, .get_stats = tja11xx_get_stats, - .ack_interrupt = tja11xx_ack_interrupt, .config_intr = tja11xx_config_intr, .handle_interrupt = tja11xx_handle_interrupt, .cable_test_start = tja11xx_cable_test_start, From patchwork Fri Nov 13 16:52:19 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904277 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BA04CC388F7 for ; Fri, 13 Nov 2020 16:53:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7448C21D1A for ; Fri, 13 Nov 2020 16:53:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mDKbjeC6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726433AbgKMQxM (ORCPT ); Fri, 13 Nov 2020 11:53:12 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53502 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726382AbgKMQxI (ORCPT ); Fri, 13 Nov 2020 11:53:08 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A25DCC0613D1; Fri, 13 Nov 2020 08:53:07 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id v4so11484703edi.0; Fri, 13 Nov 2020 08:53:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=GkNqvIU4e2wqvsaKr1NdRBEHW1oOns68JPzxdKku3G4=; b=mDKbjeC6R2mL6u1kRwXL70w7RNiOOFwp5xGjOCupZ3r+sxzvuNL8HuksUzq7CH7vfE JZP++8tmvsDpWvhgpeP+YzNL98KZeeP9UWKVZyjC6bFFxp1I/E3nIJLkx1zYQuN/5V+S DfviGc65InThZMIXfuYhxX0xHiT8u3zuia7HFJasp/C1weCpAg3vfBnbEGGLTlOOPJt9 GfxUNgghBIAhpG3kQIYxxIpDWQTigvWDDsQpY3TTGa5RUPG7kmlcQVE6VKp6lbKVI9Zs zGHJxAhAPwyphQr/vkN3fvbwFzHnXZwG3a+ldmq2noPzMfsW2Vlxir2nNvTn/EkxFH0Q naRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=GkNqvIU4e2wqvsaKr1NdRBEHW1oOns68JPzxdKku3G4=; b=bWklfDTJZiO7WX0boxSt2VBnujlSTRMIU7f5qUXwhtprEef4p38Ts6fWKVzC+3Qhtf 15zt4AdJ8MltIC2NOPQ5iD4xQtEoaPzN/qgXr+CFwNRj3bivUEaYyFOTd/eD5OwB2WTC ar7s7vvC2h7DlDqiDXY/am2/Csv4fWj10hHGJvuR9BK3RuhLjS7g07llTdntInDV/zB5 enRuw7uBFin7tTQXsMSk+2xQI2nQbjHdGewH8+oYk8mWiVXcvo0/nb1SfGjQNhKTNw3w fi89rTjxTgsMonZoFHO2T0+UK0ZFDPdCHICW9mOTzAA+wnqE9bgjRGHpjkS9Vr34m3ce 3ZHA== X-Gm-Message-State: AOAM530HdsYguTss2a7xjL/20+9CLQzq9mLdYBYSx14dXaEND9x1Y04g t8qFhRHcXGgkBhFE4xELsz8= X-Google-Smtp-Source: ABdhPJwcJWdwg7uw6oiJ1zxe29FQpTgbM/olBmy9chhNTNIdZPX3q9naNIK1TT4876pBFSCWuxn87w== X-Received: by 2002:aa7:df04:: with SMTP id c4mr3429393edy.25.1605286383281; Fri, 13 Nov 2020 08:53:03 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:02 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei Subject: [PATCH RESEND net-next 11/18] net: phy: amd: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:19 +0200 Message-Id: <20201113165226.561153-12-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Signed-off-by: Ioana Ciornei --- drivers/net/phy/amd.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/drivers/net/phy/amd.c b/drivers/net/phy/amd.c index eef35f8c8d45..ae75d95c398c 100644 --- a/drivers/net/phy/amd.c +++ b/drivers/net/phy/amd.c @@ -20,6 +20,10 @@ #define MII_AM79C_IR_EN_ANEG 0x0100 /* IR enable Aneg Complete */ #define MII_AM79C_IR_IMASK_INIT (MII_AM79C_IR_EN_LINK | MII_AM79C_IR_EN_ANEG) +#define MII_AM79C_IR_LINK_DOWN BIT(2) +#define MII_AM79C_IR_ANEG_DONE BIT(0) +#define MII_AM79C_IR_IMASK_STAT (MII_AM79C_IR_LINK_DOWN | MII_AM79C_IR_ANEG_DONE) + MODULE_DESCRIPTION("AMD PHY driver"); MODULE_AUTHOR("Heiko Schocher "); MODULE_LICENSE("GPL"); @@ -56,6 +60,24 @@ static int am79c_config_intr(struct phy_device *phydev) return err; } +static irqreturn_t am79c_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_AM79C_IR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_AM79C_IR_IMASK_STAT)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static struct phy_driver am79c_driver[] = { { .phy_id = PHY_ID_AM79C874, .name = "AM79C874", @@ -64,6 +86,7 @@ static struct phy_driver am79c_driver[] = { { .config_init = am79c_config_init, .ack_interrupt = am79c_ack_interrupt, .config_intr = am79c_config_intr, + .handle_interrupt = am79c_handle_interrupt, } }; module_phy_driver(am79c_driver); From patchwork Fri Nov 13 16:52:20 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904269 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 62BB5C388F7 for ; Fri, 13 Nov 2020 16:53:42 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1E09021D1A for ; Fri, 13 Nov 2020 16:53:42 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ycg0qMdd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726492AbgKMQxO (ORCPT ); Fri, 13 Nov 2020 11:53:14 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53514 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbgKMQxL (ORCPT ); Fri, 13 Nov 2020 11:53:11 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B99D0C0613D1; Fri, 13 Nov 2020 08:53:10 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id y4so5637885edy.5; Fri, 13 Nov 2020 08:53:10 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=MXHSBEvaUT7iZ7CGrQ4Tj9isAY8p/NdNFR8NBXTFZaY=; b=Ycg0qMdd8kGJF2r4GDgYOpj3mL+H6idNHerP1X2nvpW2ETVQXdVPUXgK+3Cw7oRAAA xBGJ+XWMqmchrMzrkDlokfjlIXrGA+V06RAmSq+IclgVUuBE8WsCedYbP/rf9j1trS/V a4AwGwBLZkQWdegEENHEtCNbJLjxjMb6AvWSPQoqwB6dYIn8A6ZYf2sPqZhd0Bhne+qr RClf2Sa+c9nALel5hIKBguyr6iFs96b5lhjyc7p3mUxe8nLc2p4vL4HoQNQnlUJhlIPV w1AVuThIa1FIPqef2oqU1RfpykiTMk9Jw2JSq31/E4fR4SNPidGuJqGaF1aCjhbk7XJd xPmg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=MXHSBEvaUT7iZ7CGrQ4Tj9isAY8p/NdNFR8NBXTFZaY=; b=L0MJ5KKQfjh8my+2qt4SYVP4oaOlgGQ816kZ4VK8Ghd87oZIokt6Fxt1N2umokiSp2 DCS1a3GPpjwnU5yLjXqlRzgscavjrDDb8YibpGgR7JYp/Gq/2QY9mKjv91PRLp4s5bgb y+f+MvJYuzTmdr9uk8rGV15q2Gr846ofYHhgrYxYKIAFRQHNxfkZA7r+RKhXq20b0hGf TEBgR8eG6nNhoF+5KDtoorhaB2sHgll//sAO75iKT4Cpe7wcCiPKj2yv8XJVIN6Kt9hY mRfigBg+kAkCxRNCedv2fGnZWSw8SZ/A/Ohq5fmHtzD2ye6Ufx5elw0VBfMzcwPG00hJ Ob2g== X-Gm-Message-State: AOAM53044lLU7e3fsOqMUxEiztVJwm+YntjVj+W2csg6XQOCWyiyjFFS 6532PZGDjkNkTU9wknCKrTw= X-Google-Smtp-Source: ABdhPJxKSMj1//HbrWqTlaTDPz+Mb3JdZrdsXFcEaKKL441EhfeoAUwtBWWvOgxtu82SzXOya5ARZw== X-Received: by 2002:a50:fe02:: with SMTP id f2mr3431191edt.97.1605286384661; Fri, 13 Nov 2020 08:53:04 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:03 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei Subject: [PATCH RESEND net-next 12/18] net: phy: amd: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:20 +0200 Message-Id: <20201113165226.561153-13-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Signed-off-by: Ioana Ciornei --- drivers/net/phy/amd.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/amd.c b/drivers/net/phy/amd.c index ae75d95c398c..001bb6d8bfce 100644 --- a/drivers/net/phy/amd.c +++ b/drivers/net/phy/amd.c @@ -52,10 +52,19 @@ static int am79c_config_intr(struct phy_device *phydev) { int err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = am79c_ack_interrupt(phydev); + if (err) + return err; + err = phy_write(phydev, MII_AM79C_IR, MII_AM79C_IR_IMASK_INIT); - else + } else { err = phy_write(phydev, MII_AM79C_IR, 0); + if (err) + return err; + + err = am79c_ack_interrupt(phydev); + } return err; } @@ -84,7 +93,6 @@ static struct phy_driver am79c_driver[] = { { .phy_id_mask = 0xfffffff0, /* PHY_BASIC_FEATURES */ .config_init = am79c_config_init, - .ack_interrupt = am79c_ack_interrupt, .config_intr = am79c_config_intr, .handle_interrupt = am79c_handle_interrupt, } }; From patchwork Fri Nov 13 16:52:21 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904281 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1B8FEC388F7 for ; Fri, 13 Nov 2020 16:53:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEB1A21D79 for ; Fri, 13 Nov 2020 16:53:47 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="CQx44aI6" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726647AbgKMQxp (ORCPT ); Fri, 13 Nov 2020 11:53:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726439AbgKMQxM (ORCPT ); Fri, 13 Nov 2020 11:53:12 -0500 Received: from mail-ej1-x643.google.com (mail-ej1-x643.google.com [IPv6:2a00:1450:4864:20::643]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 62E05C0613D1; Fri, 13 Nov 2020 08:53:12 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id o21so14439931ejb.3; Fri, 13 Nov 2020 08:53:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=V6jMD8aRzONibBh+E/XbB8QBNX+IURULm74n4EN/rLQ=; b=CQx44aI6193GjQCexgTAB2PYUHksVhqbQ1OuprPFMhsLmdeZlGtb8VcUbH+LMAGaIk NoBxN0/ioip5zMqgbMXYAjl/x9yU0WURwRPePkteRoJTF32jLAQfK8yDAg63ixDqOOi1 WTK/KYd33Gigpbb8yerFUnvHxfqHu/W0w+1RYrPMr9MS4fWKeO7LjWAobU2NqGICzy2u 0O9fbSucymyc2x0BRyYQByFdClZjuap/1/2QkchIlLzvJHGAcX8XJ0c8nRyNhxjmXmDg ujKxvuZT8AyLGpkNzeruspC0iASmllpYUKrNRkKfFZ9b/jWpyRowGqB9FWNotz8mpX3e OO5g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=V6jMD8aRzONibBh+E/XbB8QBNX+IURULm74n4EN/rLQ=; b=I3Z1zpgBJi+UW2xTg2G61lJA8MAG1dlwyR/KllbYfJ9UnSDHCoAsqglNr1vVImmcoO YjtOAhGKpaqEKIMXyfp9TPjpgPqQxj1YNbWorHlKzWnpSJ1sATpLlirWdn6kLIFbZE7B FCErgbqdb59x7EfEOxqPQWLBKxwfCI6nJT/Jy3pb9ZIpw82efvgzcAjuappHdsfcyde1 fSbGsl+05u/aYPnck5Ef4Ifmuh50jc2R6sTkC2mrJlo0L3GdbZlHhRYRKR1v/S5ojl9p nIueT+EiGRUtiBeR6pA7yxeekqfo2EQBS1+txhVxXfl/B2vmvYl00BCLCmls7j/AkB32 T49A== X-Gm-Message-State: AOAM5332g8NRRcAmDpIXS2Qlzdjl982H0IC6V24w4TD7TcmoychOVmjs zBPgZ8MHBUhhNnj/10aMnM4= X-Google-Smtp-Source: ABdhPJzDwI1eMkiCqTcgCjJsxp2/ZLGYrU9ub1nRiNNQbgy554jUc3XludrD/fcSZgMvwa8o+brXqg== X-Received: by 2002:a17:906:d94:: with SMTP id m20mr2940038eji.279.1605286386250; Fri, 13 Nov 2020 08:53:06 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:05 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Andre Edich , Marco Felsch Subject: [PATCH RESEND net-next 13/18] net: phy: smsc: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:21 +0200 Message-Id: <20201113165226.561153-14-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Andre Edich Cc: Marco Felsch Signed-off-by: Ioana Ciornei --- drivers/net/phy/smsc.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c index ec97669be5c2..8d9eb1b3d2df 100644 --- a/drivers/net/phy/smsc.c +++ b/drivers/net/phy/smsc.c @@ -72,6 +72,30 @@ static int smsc_phy_ack_interrupt(struct phy_device *phydev) return rc < 0 ? rc : 0; } +static irqreturn_t smsc_phy_handle_interrupt(struct phy_device *phydev) +{ + int irq_status, irq_enabled; + + irq_enabled = phy_read(phydev, MII_LAN83C185_IM); + if (irq_enabled < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + irq_status = phy_read(phydev, MII_LAN83C185_ISF); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & irq_enabled)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int smsc_phy_config_init(struct phy_device *phydev) { struct smsc_phy_priv *priv = phydev->priv; @@ -314,6 +338,7 @@ static struct phy_driver smsc_phy_driver[] = { /* IRQ related */ .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, + .handle_interrupt = smsc_phy_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, @@ -333,6 +358,7 @@ static struct phy_driver smsc_phy_driver[] = { /* IRQ related */ .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, + .handle_interrupt = smsc_phy_handle_interrupt, /* Statistics */ .get_sset_count = smsc_get_sset_count, @@ -362,6 +388,7 @@ static struct phy_driver smsc_phy_driver[] = { /* IRQ related */ .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, + .handle_interrupt = smsc_phy_handle_interrupt, /* Statistics */ .get_sset_count = smsc_get_sset_count, @@ -385,6 +412,7 @@ static struct phy_driver smsc_phy_driver[] = { /* IRQ related */ .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, + .handle_interrupt = smsc_phy_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, @@ -410,6 +438,7 @@ static struct phy_driver smsc_phy_driver[] = { /* IRQ related */ .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, + .handle_interrupt = smsc_phy_handle_interrupt, /* Statistics */ .get_sset_count = smsc_get_sset_count, @@ -436,6 +465,7 @@ static struct phy_driver smsc_phy_driver[] = { /* IRQ related */ .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, + .handle_interrupt = smsc_phy_handle_interrupt, /* Statistics */ .get_sset_count = smsc_get_sset_count, From patchwork Fri Nov 13 16:52:22 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904251 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6099FC388F7 for ; Fri, 13 Nov 2020 16:53:18 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F259B2225D for ; Fri, 13 Nov 2020 16:53:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EtZd8Owg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726530AbgKMQxR (ORCPT ); Fri, 13 Nov 2020 11:53:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53524 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726506AbgKMQxQ (ORCPT ); Fri, 13 Nov 2020 11:53:16 -0500 Received: from mail-ej1-x642.google.com (mail-ej1-x642.google.com [IPv6:2a00:1450:4864:20::642]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 363CDC0613D1; Fri, 13 Nov 2020 08:53:14 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id 7so14422514ejm.0; Fri, 13 Nov 2020 08:53:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=oGBDzVq5PZR4Pbyh6TLReVGAkLMraG8njIqpD/GjZy4=; b=EtZd8OwgbOLqoIZfd5Jb7pm4r6JzHOwyoxm/Tfz63atbND+7xIUhVMvgtAM6ngX4EK 2dPTUAqIu1nQKW706keacPPiKcyB1ZwECWZZ04Ds0HpNCAuHNJmSTdhXmWOi61vVBCj+ UCz2k0Tlb1JNPgTiDzPpBiJmvxcRTgB2GwH6aR8zm0VDVgvTp+I5kpXp35q3QdwoV8KO 49CqgWJbu77zasI13rALawSlOkM3kozxDyBfrfwBqS3KRhxjXs9ICoJyrR9Jgg2gXxrs R9qXOWfX+sZ3V7CRNdSBuKQy6cVwRUUvBnGdGeAczw/68qepY1jOgGtZjSNz0sq+qdCJ rasg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=oGBDzVq5PZR4Pbyh6TLReVGAkLMraG8njIqpD/GjZy4=; b=Ux3TdWsajnCJyteGRLLZphw/TkDsaDdvcncg2v+jhH03E/0qoT9mX6aYPvvshKHerA prrUg6O74I7UjW0XxTGiI3XgYVbun+rVqz4jADZXZK8h2bHrmUFgF4xYCnW7W5z87Dyh kkXuRwxxh9Up9+U0V9ueZzgpulynxFKUjPCE4Sio+mC0PCKkV2K6NkvbafGv+Z5u65oq HJxBvfTUi9Ag/CypeHmw3XTBhii+VRc3gI2lWffcYvlRPH36M+frNBFvJL1HDThl3lT2 1UPveTge7FtdWOaweFwNIsatC7yrEBRHRB3o0XY+bhM85ImfD4jvfBHiMfRNKSz6EQo4 GUFQ== X-Gm-Message-State: AOAM5333sF5dhBusxJRiG1qLmazFKxs3Zw28DSHY3nj8DgsYg02kiFTs Cbqc50S5anHGhbwa1XZPbAE= X-Google-Smtp-Source: ABdhPJzIsDh+m1soIX80keARC9jBzgVsaeveP4Xkiv9BsUe0nkC8CxTtS/vW7RnY80KFG8nG+eR7UA== X-Received: by 2002:a17:907:2175:: with SMTP id rl21mr2875737ejb.59.1605286387669; Fri, 13 Nov 2020 08:53:07 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:07 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Andre Edich , Marco Felsch Subject: [PATCH RESEND net-next 14/18] net: phy: smsc: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:22 +0200 Message-Id: <20201113165226.561153-15-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Cc: Andre Edich Cc: Marco Felsch Signed-off-by: Ioana Ciornei --- drivers/net/phy/smsc.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/net/phy/smsc.c b/drivers/net/phy/smsc.c index 8d9eb1b3d2df..bc05a4a9d10a 100644 --- a/drivers/net/phy/smsc.c +++ b/drivers/net/phy/smsc.c @@ -48,6 +48,13 @@ struct smsc_phy_priv { struct clk *refclk; }; +static int smsc_phy_ack_interrupt(struct phy_device *phydev) +{ + int rc = phy_read(phydev, MII_LAN83C185_ISF); + + return rc < 0 ? rc : 0; +} + static int smsc_phy_config_intr(struct phy_device *phydev) { struct smsc_phy_priv *priv = phydev->priv; @@ -55,19 +62,21 @@ static int smsc_phy_config_intr(struct phy_device *phydev) int rc; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + rc = smsc_phy_ack_interrupt(phydev); + if (rc) + return rc; + intmask = MII_LAN83C185_ISF_INT4 | MII_LAN83C185_ISF_INT6; if (priv->energy_enable) intmask |= MII_LAN83C185_ISF_INT7; - } - - rc = phy_write(phydev, MII_LAN83C185_IM, intmask); - - return rc < 0 ? rc : 0; -} + rc = phy_write(phydev, MII_LAN83C185_IM, intmask); + } else { + rc = phy_write(phydev, MII_LAN83C185_IM, intmask); + if (rc) + return rc; -static int smsc_phy_ack_interrupt(struct phy_device *phydev) -{ - int rc = phy_read (phydev, MII_LAN83C185_ISF); + rc = smsc_phy_ack_interrupt(phydev); + } return rc < 0 ? rc : 0; } @@ -336,7 +345,6 @@ static struct phy_driver smsc_phy_driver[] = { .soft_reset = smsc_phy_reset, /* IRQ related */ - .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, .handle_interrupt = smsc_phy_handle_interrupt, @@ -356,7 +364,6 @@ static struct phy_driver smsc_phy_driver[] = { .soft_reset = smsc_phy_reset, /* IRQ related */ - .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, .handle_interrupt = smsc_phy_handle_interrupt, @@ -386,7 +393,6 @@ static struct phy_driver smsc_phy_driver[] = { .config_aneg = lan87xx_config_aneg, /* IRQ related */ - .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, .handle_interrupt = smsc_phy_handle_interrupt, @@ -410,7 +416,6 @@ static struct phy_driver smsc_phy_driver[] = { .config_init = lan911x_config_init, /* IRQ related */ - .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, .handle_interrupt = smsc_phy_handle_interrupt, @@ -436,7 +441,6 @@ static struct phy_driver smsc_phy_driver[] = { .config_aneg = lan87xx_config_aneg_ext, /* IRQ related */ - .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, .handle_interrupt = smsc_phy_handle_interrupt, @@ -463,7 +467,6 @@ static struct phy_driver smsc_phy_driver[] = { .soft_reset = smsc_phy_reset, /* IRQ related */ - .ack_interrupt = smsc_phy_ack_interrupt, .config_intr = smsc_phy_config_intr, .handle_interrupt = smsc_phy_handle_interrupt, From patchwork Fri Nov 13 16:52:23 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904259 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 45A1AC55ABD for ; Fri, 13 Nov 2020 16:53:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F3E6B21D79 for ; Fri, 13 Nov 2020 16:53:20 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="KJq9q/kd" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726600AbgKMQxU (ORCPT ); Fri, 13 Nov 2020 11:53:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53530 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726429AbgKMQxP (ORCPT ); Fri, 13 Nov 2020 11:53:15 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6C1A2C0617A6; Fri, 13 Nov 2020 08:53:15 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id t9so11472485edq.8; Fri, 13 Nov 2020 08:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WRj8kGX7s7SWFRxtrV/mPs1BTo8dFHEN4BaCHQWnYmQ=; b=KJq9q/kdXRsrhvBiS0vVmLn9NOUaZvXxEgRajwcNbePCCFBhsUa0iQyBwEIsxkgP+m 1Y2kpCki1NpgCxk2C/npdzsBH0ibwCjRjkENOJeOwE2qKLzpIiQeIwp+KImto0st9u5i TNrymWok3Vnm42UEgSTSP6gjOPla6rDzx/CydvtRMFF31+MUGYh5bABrXXgk58x350qk gYOlUmt2GrVhSSBzKu78oCXmpUeOpxucS+ODdpvvrOlLbalQK4LmB+J9jCHiV/yqfxz5 CtMJq5yeJG46gnXj1VL1v6deowyEBoyEfNCCdhvxlogfl9XOuo3bW5RA4P3X8P7ShI/q i4Ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WRj8kGX7s7SWFRxtrV/mPs1BTo8dFHEN4BaCHQWnYmQ=; b=sOxcYTQcEkVGl4jT6t9Fwerbaxm/H8Gv9ryyNeLTTIEh2BWJARab9C5SMhO843TkfK q/0NmRDWguYqMLRtXKU82TBidLJb7IbvI1/PY+IYTn57Zx4zuxr0yPfv6S/gnAJfjQsC 3Kr3Bqud1heSC78G5Z7BGXihwR66RnQAoBwUmDbLLztT2z6p/IbdTpKVvc1T/Ye4GyD7 hiynF1BhGO6vybS6QdiMOO5ObN1V2wbD/03se+Y1xd4mKN/SU6e1tUcfN4SAaHD3zSWE 1A3GC52X065Euwp4KXhfTEvETHhj8Kns2ePHWucm1K8y9Pa+bj2WAUZBv42tWsI6Nlyh nG4g== X-Gm-Message-State: AOAM530cf163w9oLtZIMTRx/6IK+PFQ9U+1oKtIDHfT9NfRESvfMvbcn PqAULa5WmK1y5iIoBrWkpIk= X-Google-Smtp-Source: ABdhPJwp+Z+LZQtE8H02SuVcz5TQ7Zw7g5+8f6dxh+vlz2Eg1o/fsUFmy4QrnPl5Yza79RVTqOXtMw== X-Received: by 2002:a50:d582:: with SMTP id v2mr3451357edi.218.1605286389308; Fri, 13 Nov 2020 08:53:09 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:08 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei Subject: [PATCH RESEND net-next 15/18] net: phy: ste10Xp: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:23 +0200 Message-Id: <20201113165226.561153-16-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Signed-off-by: Ioana Ciornei --- drivers/net/phy/ste10Xp.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/phy/ste10Xp.c b/drivers/net/phy/ste10Xp.c index d735a01380ed..9f315332e0f2 100644 --- a/drivers/net/phy/ste10Xp.c +++ b/drivers/net/phy/ste10Xp.c @@ -76,6 +76,24 @@ static int ste10Xp_ack_interrupt(struct phy_device *phydev) return 0; } +static irqreturn_t ste10Xp_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_XCIIS); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_XIE_DEFAULT_MASK)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static struct phy_driver ste10xp_pdriver[] = { { .phy_id = STE101P_PHY_ID, @@ -85,6 +103,7 @@ static struct phy_driver ste10xp_pdriver[] = { .config_init = ste10Xp_config_init, .ack_interrupt = ste10Xp_ack_interrupt, .config_intr = ste10Xp_config_intr, + .handle_interrupt = ste10Xp_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -95,6 +114,7 @@ static struct phy_driver ste10xp_pdriver[] = { .config_init = ste10Xp_config_init, .ack_interrupt = ste10Xp_ack_interrupt, .config_intr = ste10Xp_config_intr, + .handle_interrupt = ste10Xp_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, } }; From patchwork Fri Nov 13 16:52:24 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904263 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E3517C388F7 for ; Fri, 13 Nov 2020 16:53:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 91D1521D1A for ; Fri, 13 Nov 2020 16:53:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hFTvM0KX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726619AbgKMQxV (ORCPT ); Fri, 13 Nov 2020 11:53:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53540 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726570AbgKMQxS (ORCPT ); Fri, 13 Nov 2020 11:53:18 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0D9C0C0613D1; Fri, 13 Nov 2020 08:53:18 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id oq3so14417934ejb.7; Fri, 13 Nov 2020 08:53:17 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=aWtwI+k7UCBs0l74OtNTgocL7WE2uWiSxbu1sqlhGi0=; b=hFTvM0KXcAWgZYGr94f2uXH2yeNL7use8w0TgX4TOZ8EPYJIzI57RODxLXbQDVi+oJ 0w4BGiHBCAVopmSHu+Kndle5eoR3PODnPfPh5RuS32uH1gPC472fLHJ5JVzg6N9SLZ/8 nyCGbQdE/LKBDw676PN+0EwnxaqcWs1BDqNymzWnfXg1PvCNEKG7PYByXSR/K+wbS6tS 4XCSyGWDaB1U3U4CHFCA628QoO4gG4dftzYG9Oy0Gpz0vV1stT/7nRzJOfWQtzOUB9jG yDgfpLW3Mvk6HbuNvvwpk8l/hzsVfX8UigQBfac8Eai3j8g0CgIJhmcLPq+rzZ2Exhq/ wZeA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=aWtwI+k7UCBs0l74OtNTgocL7WE2uWiSxbu1sqlhGi0=; b=ZYK3Sip9hYS+fSyzpGMzulwZq3m9UxyQhmGzUhRz8TBlIJFhzohPAISzssd0+RTkLq Tm+pGF71BMzNcdoyF45/XucV/JEIGImkOJPgADQd+V7GjxtjK/bWeVdEUgAW4P81L9ID uodQZYUHh1Wre8rP/3F/w6JqnLafgDa2fz91icPCZHLF/p5MZRbwe91cwxXmg52SUAJt reERGsELzm4ldH2FUmvpL7oj2Wa/4wanzvK5/erscSy1fbk8aDKTpZCmlKnOJ06C7f7w BrGWSllSY7CUJ2B2sUzX2a6/mj7hj5j0d3XacHDe74zEELXqSy/xzxvt1UwAiFmRIOVV xW5g== X-Gm-Message-State: AOAM5327L4K/S+HQajg8TbMDSajXJcTfK0bG2A/dAvd5474oxEwxAYHC Rn8sxbz970yZrmywZJ2XkFo= X-Google-Smtp-Source: ABdhPJzNnqyazxNApGEKsEr4UoLr+b5Hkh79+r62SMBF824IvIue2XnkbV1SgOkfmpP2kPT3n3BsZQ== X-Received: by 2002:a17:906:35da:: with SMTP id p26mr2795962ejb.256.1605286391510; Fri, 13 Nov 2020 08:53:11 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:10 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei Subject: [PATCH RESEND net-next 16/18] net: phy: ste10Xp: remove the use of .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:24 +0200 Message-Id: <20201113165226.561153-17-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Signed-off-by: Ioana Ciornei --- drivers/net/phy/ste10Xp.c | 41 +++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/drivers/net/phy/ste10Xp.c b/drivers/net/phy/ste10Xp.c index 9f315332e0f2..431fe5e0ce31 100644 --- a/drivers/net/phy/ste10Xp.c +++ b/drivers/net/phy/ste10Xp.c @@ -48,32 +48,37 @@ static int ste10Xp_config_init(struct phy_device *phydev) return 0; } +static int ste10Xp_ack_interrupt(struct phy_device *phydev) +{ + int err = phy_read(phydev, MII_XCIIS); + + if (err < 0) + return err; + + return 0; +} + static int ste10Xp_config_intr(struct phy_device *phydev) { - int err, value; + int err; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + /* clear any pending interrupts */ + err = ste10Xp_ack_interrupt(phydev); + if (err) + return err; + /* Enable all STe101P interrupts (PR12) */ err = phy_write(phydev, MII_XIE, MII_XIE_DEFAULT_MASK); - /* clear any pending interrupts */ - if (err == 0) { - value = phy_read(phydev, MII_XCIIS); - if (value < 0) - err = value; - } - } else + } else { err = phy_write(phydev, MII_XIE, 0); + if (err) + return err; - return err; -} - -static int ste10Xp_ack_interrupt(struct phy_device *phydev) -{ - int err = phy_read(phydev, MII_XCIIS); - if (err < 0) - return err; + err = ste10Xp_ack_interrupt(phydev); + } - return 0; + return err; } static irqreturn_t ste10Xp_handle_interrupt(struct phy_device *phydev) @@ -101,7 +106,6 @@ static struct phy_driver ste10xp_pdriver[] = { .name = "STe101p", /* PHY_BASIC_FEATURES */ .config_init = ste10Xp_config_init, - .ack_interrupt = ste10Xp_ack_interrupt, .config_intr = ste10Xp_config_intr, .handle_interrupt = ste10Xp_handle_interrupt, .suspend = genphy_suspend, @@ -112,7 +116,6 @@ static struct phy_driver ste10xp_pdriver[] = { .name = "STe100p", /* PHY_BASIC_FEATURES */ .config_init = ste10Xp_config_init, - .ack_interrupt = ste10Xp_ack_interrupt, .config_intr = ste10Xp_config_intr, .handle_interrupt = ste10Xp_handle_interrupt, .suspend = genphy_suspend, From patchwork Fri Nov 13 16:52:25 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904261 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D8D57C388F7 for ; Fri, 13 Nov 2020 16:53:37 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 859FF21D1A for ; Fri, 13 Nov 2020 16:53:37 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UdVXk3LX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726569AbgKMQxS (ORCPT ); Fri, 13 Nov 2020 11:53:18 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53532 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726507AbgKMQxQ (ORCPT ); Fri, 13 Nov 2020 11:53:16 -0500 Received: from mail-ed1-x544.google.com (mail-ed1-x544.google.com [IPv6:2a00:1450:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89BE1C0617A7; Fri, 13 Nov 2020 08:53:15 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id b9so11462737edu.10; Fri, 13 Nov 2020 08:53:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kaxRXeGuXfHak60d13Nyjn4fY/R1ELgbzE8j8qdmc+o=; b=UdVXk3LX0+GRq7VBXDPnmTmleY12yk6LDleSJEieYCQGg10aLewuXKmLP1yJGOuvTh pXjWnPphcb0PhsiW18phrbleNUx/HoLwJDJzXT9wUCRv/gxAF0C+AwooGVadqthIpE4l KmujtiEihqKxJoRiNPh/suTxu5EKU5/Gf7gT1q9U3Yv3l7/2ecodHeqxFIod7aY66HwK xsB3yFt06C85d43/ulRvqnuQIZaOC7fSTa109X8x2B+VstjyMSRsRzVu0neWuhYwJsEK n3SxrQe/TPIr3rjhca6ij0lgWvGKpm5F/mPf+CqXm57Pake9mLBi8y2/KYQD6v3PIGbA GJDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kaxRXeGuXfHak60d13Nyjn4fY/R1ELgbzE8j8qdmc+o=; b=B2lcka4hTtj9Tp84VVZ9Gh8MrKVX+l+MyEpy8jZIWFVGxBJvytbvS9fmw3FtmHXgor nvLc+WvTLf8gUuJ9pMalXK9mw+tZB6T2ieS0D1VPeAsgozbuNro9lzSsFWWxVpVEwO8K Ec2ODWXEB1zS9jWBcSrI5v3VossrR+MXHip/pWigNemxe9jh+hSH0AnGMyeXiFO2UqxB 8q2S0t8UuJhMN81PDEKA1VWfR04iIAw6/KuRRT1Z7XFwXISjRyEBnSucJl6jIeHef11+ L3SgApYPU4hXJO915eapuKIJpn6CEQHl+DSwGHPE1epoybp5mYrVkj6EHE9oQ/BkVrEn H+QA== X-Gm-Message-State: AOAM532tia2MPzeTRYTWZE+9qolrAqHZn/Z5hUPyL1ipKSrvSfd7L71T 9HkcRjGGQPyoYk15/z9pr6G8ov9Gr064gg== X-Google-Smtp-Source: ABdhPJz2EkVU09tx1Rcw5mQUK4NuHiuczcJxTf05ZadM6uY6f/l3+yPQcF3QkvrseVmQBE0jSSKnjw== X-Received: by 2002:a05:6402:141:: with SMTP id s1mr3247800edu.87.1605286394096; Fri, 13 Nov 2020 08:53:14 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:12 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Alexandru Ardelean Subject: [PATCH RESEND net-next 17/18] net: phy: adin: implement generic .handle_interrupt() callback Date: Fri, 13 Nov 2020 18:52:25 +0200 Message-Id: <20201113165226.561153-18-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In an attempt to actually support shared IRQs in phylib, we now move the responsibility of triggering the phylib state machine or just returning IRQ_NONE, based on the IRQ status register, to the PHY driver. Having 3 different IRQ handling callbacks (.handle_interrupt(), .did_interrupt() and .ack_interrupt() ) is confusing so let the PHY driver implement directly an IRQ handler like any other device driver. Make this driver follow the new convention. Cc: Alexandru Ardelean Signed-off-by: Ioana Ciornei Acked-by: Alexandru Ardelean --- drivers/net/phy/adin.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c index 3727b38addf7..ba24434b867d 100644 --- a/drivers/net/phy/adin.c +++ b/drivers/net/phy/adin.c @@ -479,6 +479,24 @@ static int adin_phy_config_intr(struct phy_device *phydev) ADIN1300_INT_MASK_EN); } +static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, ADIN1300_INT_STATUS_REG); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & ADIN1300_INT_LINK_STAT_CHNG_EN)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int adin_cl45_to_adin_reg(struct phy_device *phydev, int devad, u16 cl45_regnum) { @@ -879,6 +897,7 @@ static struct phy_driver adin_driver[] = { .set_tunable = adin_set_tunable, .ack_interrupt = adin_phy_ack_intr, .config_intr = adin_phy_config_intr, + .handle_interrupt = adin_phy_handle_interrupt, .get_sset_count = adin_get_sset_count, .get_strings = adin_get_strings, .get_stats = adin_get_stats, @@ -902,6 +921,7 @@ static struct phy_driver adin_driver[] = { .set_tunable = adin_set_tunable, .ack_interrupt = adin_phy_ack_intr, .config_intr = adin_phy_config_intr, + .handle_interrupt = adin_phy_handle_interrupt, .get_sset_count = adin_get_sset_count, .get_strings = adin_get_strings, .get_stats = adin_get_stats, From patchwork Fri Nov 13 16:52:26 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 11904267 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 X-Spam-Level: X-Spam-Status: No, score=-11.6 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 9A779C55ABD for ; Fri, 13 Nov 2020 16:53:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F80B217A0 for ; Fri, 13 Nov 2020 16:53:27 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kfbB3R2x" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726570AbgKMQx0 (ORCPT ); Fri, 13 Nov 2020 11:53:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:53552 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726647AbgKMQxX (ORCPT ); Fri, 13 Nov 2020 11:53:23 -0500 Received: from mail-ej1-x644.google.com (mail-ej1-x644.google.com [IPv6:2a00:1450:4864:20::644]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B2AEFC0613D1; Fri, 13 Nov 2020 08:53:21 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id f23so14474954ejk.2; Fri, 13 Nov 2020 08:53:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Qt4TBD0WTlxDExy+5uLdRHot9ANakmUntHhTQK8GBOE=; b=kfbB3R2x83Hu6nT+3hHGwjmrmOiohwfvD0yDmvglvsOnOLpTrvILVQJqs+RHIN2f5l Z3CUQdFrxWH1x05FuL8QjJvxXUpaLTo2fPCgue2OiTb1aO+ln/GZaXgUuVo/lptDOkbN FRHTPmeJAzhZJmG1aVTLoIq59FdONhMGlv4lmdDPDq6pSSvWriqQgj5HNJhcG7x8vdMQ fc3dGs/NY68ity9XdZuXliH7Wsvx+WBff17rVh5ifIQ0x0SroKn4GBFOuKfkK8ah5cfc zZjTQ4HO0T2AnMEuoQ0ZH/brxQYYRy5ujruB7fjFtpA2HoovrclNY1wJxT37k4UCE2b/ aszA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Qt4TBD0WTlxDExy+5uLdRHot9ANakmUntHhTQK8GBOE=; b=MGYtHe/FhJHraALTB5pXXsyvSptbW34Rb9xn1z99Wzb9Q+X+LC5H2IqNTV1MAvLG2L I55C8wcHxFrMUdpNqvkhul/uEYoVBz7FTwkLtj30Wf+N4QBeTMTDD8Nsq/J8R/hSfK+3 /HP/5BgnjAAnPpDr8Dcxx/f6lhpKL+IWEXldHX6a5/soy+mWClVzDZPwWF4e0CYwXLII D4MlCAXb4n5gOgicnBxz6l2RLxY2Rw+WPs9R18YYBy73DUEL4xR7OUn5kGpbVKjndhJQ 0n+6lcfqdm/NqRvu040haD4rRVCKB2G16xyVReR5DfOiJ1QuQ66Jt11v8dfVLOjIbbx3 btPg== X-Gm-Message-State: AOAM532W24O8p2UP0YKXw2YNzxZp2l6JSuUN+fJZcgQmZDxZzcuNNbo8 J7cMJJMpeLa5qnwi9KxbYiU= X-Google-Smtp-Source: ABdhPJyoyPGDwWoKSxMEnCkUgmYIBNdoxJDo5ofiZ1HeDi3NGt2fH13XAXYhfmXwGJYlDCXT1/iCsw== X-Received: by 2002:a17:906:ec9:: with SMTP id u9mr2814330eji.400.1605286395597; Fri, 13 Nov 2020 08:53:15 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id rp28sm4076570ejb.77.2020.11.13.08.53.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Nov 2020 08:53:14 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Alexandru Ardelean Subject: [PATCH RESEND net-next 18/18] net: phy: adin: remove the use of the .ack_interrupt() Date: Fri, 13 Nov 2020 18:52:26 +0200 Message-Id: <20201113165226.561153-19-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201113165226.561153-1-ciorneiioana@gmail.com> References: <20201113165226.561153-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Ioana Ciornei In preparation of removing the .ack_interrupt() callback, we must replace its occurrences (aka phy_clear_interrupt), from the 2 places where it is called from (phy_enable_interrupts and phy_disable_interrupts), with equivalent functionality. This means that clearing interrupts now becomes something that the PHY driver is responsible of doing, before enabling interrupts and after clearing them. Make this driver follow the new contract. Cc: Alexandru Ardelean Signed-off-by: Ioana Ciornei Acked-by: Alexandru Ardelean --- drivers/net/phy/adin.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/net/phy/adin.c b/drivers/net/phy/adin.c index ba24434b867d..55a0b91816e2 100644 --- a/drivers/net/phy/adin.c +++ b/drivers/net/phy/adin.c @@ -471,12 +471,25 @@ static int adin_phy_ack_intr(struct phy_device *phydev) static int adin_phy_config_intr(struct phy_device *phydev) { - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) - return phy_set_bits(phydev, ADIN1300_INT_MASK_REG, - ADIN1300_INT_MASK_EN); + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = adin_phy_ack_intr(phydev); + if (err) + return err; + + err = phy_set_bits(phydev, ADIN1300_INT_MASK_REG, + ADIN1300_INT_MASK_EN); + } else { + err = phy_clear_bits(phydev, ADIN1300_INT_MASK_REG, + ADIN1300_INT_MASK_EN); + if (err) + return err; + + err = adin_phy_ack_intr(phydev); + } - return phy_clear_bits(phydev, ADIN1300_INT_MASK_REG, - ADIN1300_INT_MASK_EN); + return err; } static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev) @@ -895,7 +908,6 @@ static struct phy_driver adin_driver[] = { .read_status = adin_read_status, .get_tunable = adin_get_tunable, .set_tunable = adin_set_tunable, - .ack_interrupt = adin_phy_ack_intr, .config_intr = adin_phy_config_intr, .handle_interrupt = adin_phy_handle_interrupt, .get_sset_count = adin_get_sset_count, @@ -919,7 +931,6 @@ static struct phy_driver adin_driver[] = { .read_status = adin_read_status, .get_tunable = adin_get_tunable, .set_tunable = adin_set_tunable, - .ack_interrupt = adin_phy_ack_intr, .config_intr = adin_phy_config_intr, .handle_interrupt = adin_phy_handle_interrupt, .get_sset_count = adin_get_sset_count,