From patchwork Mon Nov 23 15:38:03 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 331986 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 1287AC56202 for ; Mon, 23 Nov 2020 15:39:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A00E8221E2 for ; Mon, 23 Nov 2020 15:39:04 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="YQCNjczo" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389475AbgKWPil (ORCPT ); Mon, 23 Nov 2020 10:38:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56832 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730956AbgKWPil (ORCPT ); Mon, 23 Nov 2020 10:38:41 -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 0C85BC0613CF; Mon, 23 Nov 2020 07:38:41 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id gj5so23913507ejb.8; Mon, 23 Nov 2020 07:38:40 -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=O376hIiadPt9uM3Z2r8C1fbpx9uQFLckLdaH17lGghA=; b=YQCNjczoDElNKOLT5PNITkYw4gVSZjcG7fpmZPxQFDGhgAlvkArTmYYWwR3yWN8tfc DdDPkp81GELd2FRSjhmDTu7umc1Nxbu3C4WE8JTOi4H9BVQWpAXS4S3q3FhHAb9JIkjE ekv/OgiXExf8aOGPHid8MZ6fg0YWLJbZYhN1cI9pFy8VBJGUHc0dIGgyQ2QfQF2bKon5 1WYKEArYgh3F/un/NlbtIPascyh0atDin/dBwHlMkk6uMm6ZSkRj4gjWwiJDu35hE/qm 2P/75BxEJ8uwIzdXkwC6S/Is5GZtjoP2YSiaN7YeJb9Sh5Rviy0vCMHl7O8IMsgEQX1T UX6A== 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=O376hIiadPt9uM3Z2r8C1fbpx9uQFLckLdaH17lGghA=; b=SK4bMDJ2JrP12CQmJOscmOe3p6YRYjG5RK1QNjXf1UtZnafde/7yW83dhNL76MShR1 3HIbPjvFIzk4TQfHDcxz769skINe/nhadXe4T+rqw5L63vCag+5KbQwZ2Z3OwB7cqr7J vHbDR03HKrZ0gL0YI6KAOFb6RYJpMEE1QXOBoJ3mALctWJVTTk0dhxQ6LxccZyrrrk60 T0wpJakvZPC/Onn5Aa8N9svmeduweLJRxAzvJAbRG+jCnPCF6PB52XTdChYjUenTZsmW H4u/lLMFPOWgpViAfW1Ge3w6wo8Udpo/L/2xZeUwkwyYBG0i8sQj2x/GJThY3iks29YM /kvw== X-Gm-Message-State: AOAM532aRcDf8AoCdaO9nqe0nHxBEC3xfiWHEv15+slUOLt2szc5qwz+ 79vfqmbhBXSo0a739NAuUdgz2d7qCxTh8A== X-Google-Smtp-Source: ABdhPJwxh0NOTfAsAkTFHoJq9zuREShkemefPDGlS/jqJWfj5UmYD9C12n7fGGyRvQmkLBHYpC+gZg== X-Received: by 2002:a17:906:180b:: with SMTP id v11mr177928eje.466.1606145919667; Mon, 23 Nov 2020 07:38:39 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38:39 -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 , Mathias Kresin , Hauke Mehrtens Subject: [PATCH net-next 01/15] net: phy: intel-xway: implement generic .handle_interrupt() callback Date: Mon, 23 Nov 2020 17:38:03 +0200 Message-Id: <20201123153817.1616814-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Mathias Kresin Cc: Hauke Mehrtens Signed-off-by: Ioana Ciornei --- drivers/net/phy/intel-xway.c | 46 ++++++++++++++++++++++-------------- 1 file changed, 28 insertions(+), 18 deletions(-) diff --git a/drivers/net/phy/intel-xway.c b/drivers/net/phy/intel-xway.c index b7875b36097f..1a27ae1bec5c 100644 --- a/drivers/net/phy/intel-xway.c +++ b/drivers/net/phy/intel-xway.c @@ -209,14 +209,6 @@ static int xway_gphy_ack_interrupt(struct phy_device *phydev) return (reg < 0) ? reg : 0; } -static int xway_gphy_did_interrupt(struct phy_device *phydev) -{ - int reg; - - reg = phy_read(phydev, XWAY_MDIO_ISTAT); - return reg & XWAY_MDIO_INIT_MASK; -} - static int xway_gphy_config_intr(struct phy_device *phydev) { u16 mask = 0; @@ -227,6 +219,24 @@ static int xway_gphy_config_intr(struct phy_device *phydev) return phy_write(phydev, XWAY_MDIO_IMASK, mask); } +static irqreturn_t xway_gphy_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, XWAY_MDIO_ISTAT); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & XWAY_MDIO_INIT_MASK)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static struct phy_driver xway_gphy[] = { { .phy_id = PHY_ID_PHY11G_1_3, @@ -236,7 +246,7 @@ static struct phy_driver xway_gphy[] = { .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -248,7 +258,7 @@ static struct phy_driver xway_gphy[] = { .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -260,7 +270,7 @@ static struct phy_driver xway_gphy[] = { .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -272,7 +282,7 @@ static struct phy_driver xway_gphy[] = { .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -283,7 +293,7 @@ static struct phy_driver xway_gphy[] = { /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -294,7 +304,7 @@ static struct phy_driver xway_gphy[] = { /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -305,7 +315,7 @@ static struct phy_driver xway_gphy[] = { /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -316,7 +326,7 @@ static struct phy_driver xway_gphy[] = { /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -327,7 +337,7 @@ static struct phy_driver xway_gphy[] = { /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, @@ -338,7 +348,7 @@ static struct phy_driver xway_gphy[] = { /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, .ack_interrupt = xway_gphy_ack_interrupt, - .did_interrupt = xway_gphy_did_interrupt, + .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, .resume = genphy_resume, From patchwork Mon Nov 23 15:38:04 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 330999 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 6E409C63798 for ; Mon, 23 Nov 2020 15:39:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19981221FD for ; Mon, 23 Nov 2020 15:39:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="EKPOLuBk" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389578AbgKWPio (ORCPT ); Mon, 23 Nov 2020 10:38:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56840 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389505AbgKWPin (ORCPT ); Mon, 23 Nov 2020 10:38:43 -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 86F95C061A4D; Mon, 23 Nov 2020 07:38:42 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id a16so23933978ejj.5; Mon, 23 Nov 2020 07:38:42 -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=Vn8Bkfbu1JnwwkVBWlSgjeaX8jpdmKjpBKcRBW0TQRw=; b=EKPOLuBkljJYw2yYR2+yQCx5b5qi2FrWrYKRhARtKlpIBgPmt2ib2fltLNrpZKSyWC N0P+y2uizaXpunOi/XkbXlEI1RNIN6PrxYvY+ya25tYBSyODdpgJ5sCeoJq15GBNHty9 MFx/GoUsFtawB38W0IIwEr3/Po28FGxCdMsbgqjEctRY6bhDafL8EVeJKxiUI4WuXaxU /TxFJWfOssxe/PkYbm0yQY7TatEvieVa4qScZPQ6a4MDCNfESrHcyf/WsQ2+Zd4GRfFH g3Gqb8OBLo887ezGY7Fd5txNkIgzhegAs0Hin9KLwYcyk5Zqimg5yLgGRPBV7VNzBY9H I1iA== 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=Vn8Bkfbu1JnwwkVBWlSgjeaX8jpdmKjpBKcRBW0TQRw=; b=IlTAwIGpNd83aFviMVQk6gzEJY8GCJKobLGf9aAVDKJKmhcOb7XcljSx0YnDzXieq7 uq+hn5IettL0aLHqKAT9wjd9ABdrzxLy4SYeyY8z4rOfmA4wLvkzHb9GKaxq0uB+r4bl 7saSbRwf9IQzMRSNF+Dsl18WcwnbQj+7iBcY39x0zo0tEqFCscSCdHWCBWATsqHE9reh eCtrBY/khy8qk/IGvdq8XJqSNBasNA3rtsbYcuPsPBKCq6c4BG5Hiu2XThLT9pfl6E59 hP94Q62QGkL5q3ACJ95xNKjnWNw//0O+8hFke1qVaq8NeEsl9sLm5l6kbEPDKiytADBU vfTA== X-Gm-Message-State: AOAM531UB1b4wZoBOOPGa1y9agGSpfnhyMSS7vP8MasEk1SL3nV5u8cu Z7GvyiNorMElO0s/9/AOTZM= X-Google-Smtp-Source: ABdhPJz7NBggxHS9j+OhMbUVoulEQ7FmeGWah2Jkb7FMkZvKdrSQaX8VHhMOUqNODdxxQTLXd5cj/w== X-Received: by 2002:a17:906:7b82:: with SMTP id s2mr131912ejo.435.1606145921230; Mon, 23 Nov 2020 07:38:41 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38:40 -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 , Mathias Kresin , Hauke Mehrtens Subject: [PATCH net-next 02/15] net: phy: intel-xway: remove the use of .ack_interrupt() Date: Mon, 23 Nov 2020 17:38:04 +0200 Message-Id: <20201123153817.1616814-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Mathias Kresin Cc: Hauke Mehrtens Signed-off-by: Ioana Ciornei --- drivers/net/phy/intel-xway.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/drivers/net/phy/intel-xway.c b/drivers/net/phy/intel-xway.c index 1a27ae1bec5c..6eac50d4b42f 100644 --- a/drivers/net/phy/intel-xway.c +++ b/drivers/net/phy/intel-xway.c @@ -212,11 +212,24 @@ static int xway_gphy_ack_interrupt(struct phy_device *phydev) static int xway_gphy_config_intr(struct phy_device *phydev) { u16 mask = 0; + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = xway_gphy_ack_interrupt(phydev); + if (err) + return err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) mask = XWAY_MDIO_INIT_MASK; + err = phy_write(phydev, XWAY_MDIO_IMASK, mask); + } else { + err = phy_write(phydev, XWAY_MDIO_IMASK, mask); + if (err) + return err; + + err = xway_gphy_ack_interrupt(phydev); + } - return phy_write(phydev, XWAY_MDIO_IMASK, mask); + return err; } static irqreturn_t xway_gphy_handle_interrupt(struct phy_device *phydev) @@ -245,7 +258,6 @@ static struct phy_driver xway_gphy[] = { /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -257,7 +269,6 @@ static struct phy_driver xway_gphy[] = { /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -269,7 +280,6 @@ static struct phy_driver xway_gphy[] = { /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -281,7 +291,6 @@ static struct phy_driver xway_gphy[] = { /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, .config_aneg = xway_gphy14_config_aneg, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -292,7 +301,6 @@ static struct phy_driver xway_gphy[] = { .name = "Intel XWAY PHY11G (PEF 7071/PEF 7072) v1.5 / v1.6", /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -303,7 +311,6 @@ static struct phy_driver xway_gphy[] = { .name = "Intel XWAY PHY22F (PEF 7061) v1.5 / v1.6", /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -314,7 +321,6 @@ static struct phy_driver xway_gphy[] = { .name = "Intel XWAY PHY11G (xRX v1.1 integrated)", /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -325,7 +331,6 @@ static struct phy_driver xway_gphy[] = { .name = "Intel XWAY PHY22F (xRX v1.1 integrated)", /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -336,7 +341,6 @@ static struct phy_driver xway_gphy[] = { .name = "Intel XWAY PHY11G (xRX v1.2 integrated)", /* PHY_GBIT_FEATURES */ .config_init = xway_gphy_config_init, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, @@ -347,7 +351,6 @@ static struct phy_driver xway_gphy[] = { .name = "Intel XWAY PHY22F (xRX v1.2 integrated)", /* PHY_BASIC_FEATURES */ .config_init = xway_gphy_config_init, - .ack_interrupt = xway_gphy_ack_interrupt, .handle_interrupt = xway_gphy_handle_interrupt, .config_intr = xway_gphy_config_intr, .suspend = genphy_suspend, From patchwork Mon Nov 23 15:38:05 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 331981 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 62A85C56202 for ; Mon, 23 Nov 2020 15:39:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E1D3208DB for ; Mon, 23 Nov 2020 15:39:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="T+/gEFeZ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389610AbgKWPit (ORCPT ); Mon, 23 Nov 2020 10:38:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728858AbgKWPiq (ORCPT ); Mon, 23 Nov 2020 10:38:46 -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 C75BFC0613CF; Mon, 23 Nov 2020 07:38:45 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id o9so23951026ejg.1; Mon, 23 Nov 2020 07:38:45 -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=ylL9xOBdQF/BS35q7ZH2N3c9DEUDL4zcBQVyTtlRMoU=; b=T+/gEFeZQ9gUcq3M5cLhO9XfSb7UuiqFAjxoFqRWwi8kg20Sn2eMds0VfeErmH8YWI JkWAv0ZZpGwH6GM5WbM5eOQ8XWa0h6MNkdd+SH+503CAk1M/+rKLteKKOl//Q2haWgdy OWx3sTFnSWQGwYcPQGy+QdENtrHkHqAbob4MaEhXaGwFAZKQMNbpP4Sus8qnZYc3yK4B 96PvYqYlsLwXCeym5IR6CSXTGRyshuyCDsMsoHkFawwLTfKRDB/bXJAKx8ap2mz3KpGd 8KaCRtzJvxXpq+f14W3njdGY+WzKt/CADnDgPK3CpiYTehK9/GtuyWZatbFOyG/x61Vz iMIw== 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=ylL9xOBdQF/BS35q7ZH2N3c9DEUDL4zcBQVyTtlRMoU=; b=mmQfm+TCBfsu1qz6YJgoGKoCJvtQOrO8yQpLwXNxHJJaB9jvonzO7r6qF1vtCb1a+4 +ktupKgzHun9ouXNkzSNjvLSvLeWr76iddeYqOuY9+NUhXzDZOwR3TCE87xEKBL2/LuS +cwIwzy1beeTbyD6shqfLW+QdW/jB5oXBeSs4sZnIFOHZAoNRX1NTVExBKsTA1UV8xTw TtMDwbQb088zCTjcMam2g2duTZYk7EhovFDd0/gf42esF59UGjfA76YZ1MMiCBSdCjGw mfyyFjROgC6eZhdgh5mVDfUcGI15Aq6idGQTH2R0sTYL2xWrg+V23IIFF/kluhZMVGf+ yD4w== X-Gm-Message-State: AOAM533uRs5AuTyS1Zhl/uyNUloymql6Rxpgt6g8pt0cnAz0ixRsFiRC f8jaLV4qpme9D/U3eu93rMc= X-Google-Smtp-Source: ABdhPJyGLoFGp2eRYrUDQZlGs8AEZ3n7GqQt+G8MYH8v5uQ2wl/ct1omXT9xIUQvVnvtfdnuPeXKGA== X-Received: by 2002:a17:906:c51:: with SMTP id t17mr127094ejf.523.1606145922408; Mon, 23 Nov 2020 07:38:42 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.41 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38:41 -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 , Martin Blumenstingl Subject: [PATCH net-next 03/15] net: phy: icplus: implement generic .handle_interrupt() callback Date: Mon, 23 Nov 2020 17:38:05 +0200 Message-Id: <20201123153817.1616814-4-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Martin Blumenstingl Signed-off-by: Ioana Ciornei --- drivers/net/phy/icplus.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c index d6e8516cd146..a74ff45fa99c 100644 --- a/drivers/net/phy/icplus.c +++ b/drivers/net/phy/icplus.c @@ -285,16 +285,24 @@ static int ip101a_g_config_intr(struct phy_device *phydev) return phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, val); } -static int ip101a_g_did_interrupt(struct phy_device *phydev) +static irqreturn_t ip101a_g_handle_interrupt(struct phy_device *phydev) { - int val = phy_read(phydev, IP101A_G_IRQ_CONF_STATUS); + int irq_status; - if (val < 0) - return 0; + irq_status = phy_read(phydev, IP101A_G_IRQ_CONF_STATUS); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & (IP101A_G_IRQ_SPEED_CHANGE | + IP101A_G_IRQ_DUPLEX_CHANGE | + IP101A_G_IRQ_LINK_CHANGE))) + return IRQ_NONE; + + phy_trigger_machine(phydev); - return val & (IP101A_G_IRQ_SPEED_CHANGE | - IP101A_G_IRQ_DUPLEX_CHANGE | - IP101A_G_IRQ_LINK_CHANGE); + return IRQ_HANDLED; } static int ip101a_g_ack_interrupt(struct phy_device *phydev) @@ -332,8 +340,8 @@ static struct phy_driver icplus_driver[] = { /* PHY_BASIC_FEATURES */ .probe = ip101a_g_probe, .config_intr = ip101a_g_config_intr, - .did_interrupt = ip101a_g_did_interrupt, .ack_interrupt = ip101a_g_ack_interrupt, + .handle_interrupt = ip101a_g_handle_interrupt, .config_init = &ip101a_g_config_init, .suspend = genphy_suspend, .resume = genphy_resume, From patchwork Mon Nov 23 15:38:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 330993 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 D56CDC8300B for ; Mon, 23 Nov 2020 15:39:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8129020719 for ; Mon, 23 Nov 2020 15:39:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lOQoRZPm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389770AbgKWPjp (ORCPT ); Mon, 23 Nov 2020 10:39:45 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389608AbgKWPis (ORCPT ); Mon, 23 Nov 2020 10:38:48 -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 C1A76C0613CF; Mon, 23 Nov 2020 07:38:46 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id mc24so2812809ejb.6; Mon, 23 Nov 2020 07:38:46 -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=uEhSuCuWwfzMW+QeM5P/cCH9mtQg5NrGbw5n/aF/ziI=; b=lOQoRZPmZGsy53rhdRaudNiRXggmb2wtjqeqVnfntbddSO1S1xtU6Cbfiq3SmZBkKr 6BBdo5NufbMdm3OAVdowDA/lANLAgrrAi1eLFMbT0C+VZeQpZeXWQOrgSFFKJ8rLT9pV k9TOVWNvhuey2BxHNDr4fW5jw8n63K20CRszBtxjAJWpgpsWZWDdeRu0ynDIbryOQlyg f/p7JMa+KouiWKEz3Aj/EUrK4O5EFl9io9hfiwUJNzTs0QW7Vb+L3uY/+FuvUp2m+YCd 7ZWFVkTs+7nkUpauj7a0HiP6y2i0Bnm/7mM3qXY/llr3DyuA0oPbI7DxNjyx/7xokOZ2 KSBQ== 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=uEhSuCuWwfzMW+QeM5P/cCH9mtQg5NrGbw5n/aF/ziI=; b=mwCKGLh+pL3i0DkH9x14Z39wFxLcD9U00tNJpr7VFXR4kq1yvmrS5b6PiTzlVZH/Tm 1w0f087s8upCEAB8scBt0jHHE+t/8i0si5knoP0n3O+atk0eiZypByG2owdIxQxdLcJ5 vGXpG4b1DWkTv/TmJREVcW8jtv6IL78pJJRXxzCSkv8awQ/jwRl+bqV3KnmRC7iC9rX4 x0Jn3hDBwbPlAWUNX7vNG5mc4GEk4Ob9F0NM/tAKI/7WUa1SEsEtOdOoySHal2KSlMvD 6HXWWBIRbdlCGAwyQysXxtQ4aRaGwrvchyMNxesEbJXWH0f1lx9YfgDYTEJg0NJYCDLk CHcw== X-Gm-Message-State: AOAM530sYRBLELo0jwifD0BhVCC4jfkbHA8ypdQcjWjvIpCB6EA+Hj3C YGLP0WUrS8jh52SLgjpCmTxON47M2Upaxg== X-Google-Smtp-Source: ABdhPJw7PRSfxSr/12H/xsTWrk77oLXEzcmBMzchwOuOSQ0rK7e3ttqPjlmV/962i7DnCuYNRALd2g== X-Received: by 2002:a17:906:5955:: with SMTP id g21mr152380ejr.271.1606145925503; Mon, 23 Nov 2020 07:38:45 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38:44 -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 , Martin Blumenstingl Subject: [PATCH net-next 04/15] net: phy: icplus: remove the use .ack_interrupt() Date: Mon, 23 Nov 2020 17:38:06 +0200 Message-Id: <20201123153817.1616814-5-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Martin Blumenstingl Signed-off-by: Ioana Ciornei --- drivers/net/phy/icplus.c | 38 +++++++++++++++++++++++++------------- 1 file changed, 25 insertions(+), 13 deletions(-) diff --git a/drivers/net/phy/icplus.c b/drivers/net/phy/icplus.c index a74ff45fa99c..b632947cbcdf 100644 --- a/drivers/net/phy/icplus.c +++ b/drivers/net/phy/icplus.c @@ -272,17 +272,39 @@ static int ip101a_g_config_init(struct phy_device *phydev) return phy_write(phydev, IP10XX_SPEC_CTRL_STATUS, c); } +static int ip101a_g_ack_interrupt(struct phy_device *phydev) +{ + int err = phy_read(phydev, IP101A_G_IRQ_CONF_STATUS); + + if (err < 0) + return err; + + return 0; +} + static int ip101a_g_config_intr(struct phy_device *phydev) { u16 val; + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = ip101a_g_ack_interrupt(phydev); + if (err) + return err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) /* INTR pin used: Speed/link/duplex will cause an interrupt */ val = IP101A_G_IRQ_PIN_USED; - else + err = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, val); + } else { val = IP101A_G_IRQ_ALL_MASK; + err = phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, val); + if (err) + return err; + + err = ip101a_g_ack_interrupt(phydev); + } - return phy_write(phydev, IP101A_G_IRQ_CONF_STATUS, val); + return err; } static irqreturn_t ip101a_g_handle_interrupt(struct phy_device *phydev) @@ -305,15 +327,6 @@ static irqreturn_t ip101a_g_handle_interrupt(struct phy_device *phydev) return IRQ_HANDLED; } -static int ip101a_g_ack_interrupt(struct phy_device *phydev) -{ - int err = phy_read(phydev, IP101A_G_IRQ_CONF_STATUS); - if (err < 0) - return err; - - return 0; -} - static struct phy_driver icplus_driver[] = { { .phy_id = 0x02430d80, @@ -340,7 +353,6 @@ static struct phy_driver icplus_driver[] = { /* PHY_BASIC_FEATURES */ .probe = ip101a_g_probe, .config_intr = ip101a_g_config_intr, - .ack_interrupt = ip101a_g_ack_interrupt, .handle_interrupt = ip101a_g_handle_interrupt, .config_init = &ip101a_g_config_init, .suspend = genphy_suspend, From patchwork Mon Nov 23 15:38:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 331985 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 6022BC6379F for ; Mon, 23 Nov 2020 15:39:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 08D672100A for ; Mon, 23 Nov 2020 15:39:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OafqMegF" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389625AbgKWPiu (ORCPT ); Mon, 23 Nov 2020 10:38:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389613AbgKWPit (ORCPT ); Mon, 23 Nov 2020 10:38:49 -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 07FA8C061A4D; Mon, 23 Nov 2020 07:38:49 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id bo9so18136566ejb.13; Mon, 23 Nov 2020 07:38:48 -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=+zImLwmtn3XFF2OyJg33BL86dhQqi/258wupRnjhZ7Y=; b=OafqMegFwBCTQh1D8TZKBdtcOyHp9D5sY3cVDnwFUciifKiXe9KfG9MDfymp0+NK3H agHwrgabaHqyNO0o88Olv416CjOZVAec6bNtks3Q3wCFh4WBOpW2OO55jnehqa+tBoQs jgK7USZ13qtLhKgYQ+mpnnNoxOhjBlHNIa1ZqzYmczMSCYv7yiq/bCvb6Sh4pOqNuxTA cg4FjKpVDjHfiDMD+lapSkAzAcrFEd2UWeBnW4trxp0X1mqkpo45y5zxvhoYZYA8uzsm dELebXusLhMK2sNFlL1JLyitRZ3HsYThIOvf8WW+aPWI9/fmlgoi0g7M6Ah0eUmT4b22 D79g== 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=+zImLwmtn3XFF2OyJg33BL86dhQqi/258wupRnjhZ7Y=; b=QXuiOCZuiDEjxKeQA7JO9Qo6Fx9subCEHivrv+sGkAzFiCzFZFdCFJjDYx1TM5/WHq tZ2wAwXAAav6P6QY99ManS/APmApEoIOxnZTwPPS5YAqEppsaGf1EG750UgbRHIIupQl qHiYci557VBDC7N2IVTRYB5HDlRtq8OOsvrUMtdvznuD4+VtE+seFQHJUp4iZlE95TbA S6nSKD2AAT6jvaZ1e2/CRrrap0KGgAo8pEiaFLYUM3pBPemOW/yqLf/thlmGn0beugJ5 f9muVDfCLSfa73xVpo/BN9qcot5YkSFQirLVb48OxO26vPvTkZuxA9n+jh61aRQMzLv0 xo9w== X-Gm-Message-State: AOAM5301gJItVEfzXOIIoSpglm9I7OZZBeWJEF5Antg7wFNii5eky0s9 Gh6SvBmsyQ+Esxe7Ve7lVKU= X-Google-Smtp-Source: ABdhPJyX9k/7vu7XAW0LN3wAOuzu5adxYCg93cfT8oB3Chja+L7Llqts38g/M1QI0mcqTu15wPI99A== X-Received: by 2002:a17:906:1542:: with SMTP id c2mr174700ejd.382.1606145926700; Mon, 23 Nov 2020 07:38:46 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 , Jerome Brunet , Neil Armstrong Subject: [PATCH net-next 05/15] net: phy: meson-gxl: implement generic .handle_interrupt() callback Date: Mon, 23 Nov 2020 17:38:07 +0200 Message-Id: <20201123153817.1616814-6-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Jerome Brunet Cc: Neil Armstrong Signed-off-by: Ioana Ciornei --- drivers/net/phy/meson-gxl.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c index e8f2ca625837..b16b1cc89165 100644 --- a/drivers/net/phy/meson-gxl.c +++ b/drivers/net/phy/meson-gxl.c @@ -222,6 +222,24 @@ static int meson_gxl_config_intr(struct phy_device *phydev) return phy_write(phydev, INTSRC_MASK, val); } +static irqreturn_t meson_gxl_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, INTSRC_FLAG); + 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 struct phy_driver meson_gxl_phy[] = { { PHY_ID_MATCH_EXACT(0x01814400), @@ -233,6 +251,7 @@ static struct phy_driver meson_gxl_phy[] = { .read_status = meson_gxl_read_status, .ack_interrupt = meson_gxl_ack_interrupt, .config_intr = meson_gxl_config_intr, + .handle_interrupt = meson_gxl_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -243,6 +262,7 @@ static struct phy_driver meson_gxl_phy[] = { .soft_reset = genphy_soft_reset, .ack_interrupt = meson_gxl_ack_interrupt, .config_intr = meson_gxl_config_intr, + .handle_interrupt = meson_gxl_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, }, From patchwork Mon Nov 23 15:38:08 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 331980 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 85A5BC71156 for ; Mon, 23 Nov 2020 15:39:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 46E722080A for ; Mon, 23 Nov 2020 15:39:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="OML6Fp6l" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389758AbgKWPjo (ORCPT ); Mon, 23 Nov 2020 10:39:44 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389616AbgKWPiu (ORCPT ); Mon, 23 Nov 2020 10:38:50 -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 F1D97C0613CF; Mon, 23 Nov 2020 07:38:49 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id k27so23859287ejs.10; Mon, 23 Nov 2020 07:38:49 -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=2S7ssQEEvdv31f1tGseCE7r/iFxGWNgPQ4dQxgviHtI=; b=OML6Fp6lXxFp23Xned5zxBnKUuVVpD/EO456tcT0xn6ETKG8uHsel+JC4XOWeQtpmh r/FoweK7oxvpFM3pN9EKy3NA7SVr+Zc92PglnhWp90RRfSjQBNF/H3HKcBSZQAbO2TFF OqSsvf0vFTZe+yJ427CUjA0ap7glMASAxRE2NMrgb/GqOfBj41dTJtEvMYL6U4/EnscP kahiuelTeeXR4w1A3AbF0mHF6WO6GBp8SBi7Aotih7lTfVIQN4vBtCO2slaXWAI/IuPL wMLT6xhAHDP62gomwBxPG57ccDrixYLkIFc3KsvLTao4BGR50Bo/hhNUfIC4tMmCVaqb 38TQ== 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=2S7ssQEEvdv31f1tGseCE7r/iFxGWNgPQ4dQxgviHtI=; b=QickqYY8Bv942R7WHycHqUqAzB9I5Dp098Y7JBtv2jyEAXmFDhh3aCFx7kb+pbvhNT eDmTuEKiVqtKSn9ZWYTNq5AgduaiAfU4U1Tj978PYfEPXNMW4o6dcLBi72SM/7dcZ3jt wqazUvLc3Toweqy7uzzMlabu9/tpxfwBOggWDKC+Oj64cREcfNXOwWou2JJlYZqOybr5 3O34VgBRwo8lr6nwdmtEZ4wi9cGTasgrMZz8KJLYAuJAxafbGwKKYzR61PlkJj5F6Xrs 4Y11DmXK4P7taNYcsdrdY8DDvqsfBmGzrHRq2BA429wZZkQt/S4q1u9I9eNbMEIPB64j Atug== X-Gm-Message-State: AOAM5334hKDd9d8vdelbtWKqhTo546awO8/UJms+trB+iTgzqWXkgbfc SQ/E1Viv2uJNurJWLU+Dx5c= X-Google-Smtp-Source: ABdhPJzif1mTjoEhoOgh7G2S0HTVMY90o1qMTc624OcHQYMy/KaoLHnbb2Iyfl1gTP3V0vc/6xO/wA== X-Received: by 2002:a17:906:c7d9:: with SMTP id dc25mr141743ejb.309.1606145928645; Mon, 23 Nov 2020 07:38:48 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38:48 -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 , Jerome Brunet , Neil Armstrong Subject: [PATCH net-next 06/15] net: phy: meson-gxl: remove the use of .ack_callback() Date: Mon, 23 Nov 2020 17:38:08 +0200 Message-Id: <20201123153817.1616814-7-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Jerome Brunet Cc: Neil Armstrong Signed-off-by: Ioana Ciornei --- drivers/net/phy/meson-gxl.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/drivers/net/phy/meson-gxl.c b/drivers/net/phy/meson-gxl.c index b16b1cc89165..7e7904fee1d9 100644 --- a/drivers/net/phy/meson-gxl.c +++ b/drivers/net/phy/meson-gxl.c @@ -204,22 +204,27 @@ static int meson_gxl_config_intr(struct phy_device *phydev) int ret; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + /* Ack any pending IRQ */ + ret = meson_gxl_ack_interrupt(phydev); + if (ret) + return ret; + val = INTSRC_ANEG_PR | INTSRC_PARALLEL_FAULT | INTSRC_ANEG_LP_ACK | INTSRC_LINK_DOWN | INTSRC_REMOTE_FAULT | INTSRC_ANEG_COMPLETE; + ret = phy_write(phydev, INTSRC_MASK, val); } else { val = 0; - } + ret = phy_write(phydev, INTSRC_MASK, val); - /* Ack any pending IRQ */ - ret = meson_gxl_ack_interrupt(phydev); - if (ret) - return ret; + /* Ack any pending IRQ */ + ret = meson_gxl_ack_interrupt(phydev); + } - return phy_write(phydev, INTSRC_MASK, val); + return ret; } static irqreturn_t meson_gxl_handle_interrupt(struct phy_device *phydev) @@ -249,7 +254,6 @@ static struct phy_driver meson_gxl_phy[] = { .soft_reset = genphy_soft_reset, .config_init = meson_gxl_config_init, .read_status = meson_gxl_read_status, - .ack_interrupt = meson_gxl_ack_interrupt, .config_intr = meson_gxl_config_intr, .handle_interrupt = meson_gxl_handle_interrupt, .suspend = genphy_suspend, @@ -260,7 +264,6 @@ static struct phy_driver meson_gxl_phy[] = { /* PHY_BASIC_FEATURES */ .flags = PHY_IS_INTERNAL, .soft_reset = genphy_soft_reset, - .ack_interrupt = meson_gxl_ack_interrupt, .config_intr = meson_gxl_config_intr, .handle_interrupt = meson_gxl_handle_interrupt, .suspend = genphy_suspend, From patchwork Mon Nov 23 15:38: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: 331982 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 F2362C64E90 for ; Mon, 23 Nov 2020 15:39:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 96E9D2080A for ; Mon, 23 Nov 2020 15:39:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="LgXhHcPS" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389647AbgKWPiy (ORCPT ); Mon, 23 Nov 2020 10:38:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56872 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389613AbgKWPix (ORCPT ); Mon, 23 Nov 2020 10:38:53 -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 8F707C0613CF; Mon, 23 Nov 2020 07:38:51 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id f23so23942248ejk.2; Mon, 23 Nov 2020 07:38:51 -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=sM8faEX0Cx9oXuKgSwivvFPThJ27cR2sjDuMpcARVXA=; b=LgXhHcPSE7B140XtJ8eSxIvW64IpuEy2xORJShJ9qjPDQ5Oj7Qh9DeuNT/ZsI4IPf4 FUoubsryKXdULQc7Ws/gwFzu8g3mQbQHToxDwj3dd6Ry9vkErkyKoj1SKPkm7JmfKHzt B+wPKqazzBUZZQiyAdnw2bPItwf5rDwru4cTRVqkSyOrqd8ZYbckPTyumZ/XADBWMNdw uYySDE65lAMypSNpT+MbWVBrLw8o5OjSnsAvGlofaya50ImCOwwmdH6BNA+yi8k2G+jb HyReqlRQpLdPNAx0II6UszwPkH2OeMYA1OqQxuauUUlYRz4AkzNxoBY4hyMztr3BFhZ5 dRgQ== 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=sM8faEX0Cx9oXuKgSwivvFPThJ27cR2sjDuMpcARVXA=; b=IFaYSsUAUv/CH1tu98/yY/rIfbAlF6hFGVEzYNgNStBZGLbW3W+Ou5Xn7NLiCt1yIK L5P8LjV9wvvpesuo/pVU4sIMv6S6gQCLo7thm9H8R5Gm8e6lHYbkQrrk6KB/tGoSqLsM SB7wHKoxdAe7C8NUKUcfteN7FjmXoSlhD8TRgokYpzj6I41P6f9HgRu+w2rdADbcO0// gWmrr402ee/Q6dlkt3vVmIbjGjRR8vETB6Ftw6DIdvmF6dAm2zBy1UqYZP4eHTuDMpss fLYYeg8QvUHV6E+4vuN/sc3eXbMGFdooCAENsthITmJDEGHi0932cKsnKuTBJj194wc0 9VYw== X-Gm-Message-State: AOAM531dBBBS5YcMUuBRTF5+hWFjdrc+iaQ0lxT08y26wajdtNZujlUN eG8f5MkWD5mBv1ZecD/zcOM= X-Google-Smtp-Source: ABdhPJynDRYVEgmTPOf9bjASaMxjGROrQ7/AkUwb+eIncUX3/wfTz1KvUbMrS+lwxHhJLFSmcRasKA== X-Received: by 2002:a17:906:33c4:: with SMTP id w4mr188763eja.380.1606145930282; Mon, 23 Nov 2020 07:38:50 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 , Divya Koppera , Oleksij Rempel , Philippe Schenker , Marek Vasut , Antoine Tenart Subject: [PATCH net-next 07/15] net: phy: micrel: implement generic .handle_interrupt() callback Date: Mon, 23 Nov 2020 17:38:09 +0200 Message-Id: <20201123153817.1616814-8-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Divya Koppera Cc: Oleksij Rempel Cc: Philippe Schenker Cc: Marek Vasut Cc: Antoine Tenart Signed-off-by: Ioana Ciornei --- drivers/net/phy/micrel.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index a7f74b3b97af..9aa96ebd31c8 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -48,6 +48,10 @@ #define KSZPHY_INTCS_LINK_UP BIT(8) #define KSZPHY_INTCS_ALL (KSZPHY_INTCS_LINK_UP |\ KSZPHY_INTCS_LINK_DOWN) +#define KSZPHY_INTCS_LINK_DOWN_STATUS BIT(2) +#define KSZPHY_INTCS_LINK_UP_STATUS BIT(0) +#define KSZPHY_INTCS_STATUS (KSZPHY_INTCS_LINK_DOWN_STATUS |\ + KSZPHY_INTCS_LINK_UP_STATUS) /* PHY Control 1 */ #define MII_KSZPHY_CTRL_1 0x1e @@ -182,6 +186,24 @@ static int kszphy_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_KSZPHY_INTCS, temp); } +static irqreturn_t kszphy_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_KSZPHY_INTCS); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if ((irq_status & KSZPHY_INTCS_STATUS)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int kszphy_rmii_clk_sel(struct phy_device *phydev, bool val) { int ctrl; @@ -1162,6 +1184,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = kszphy_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -1174,6 +1197,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = kszphy_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1189,6 +1213,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = kszphy_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1205,6 +1230,7 @@ static struct phy_driver ksphy_driver[] = { .config_aneg = ksz8041_config_aneg, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1220,6 +1246,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = kszphy_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1233,6 +1260,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = kszphy_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1249,6 +1277,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = kszphy_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1264,6 +1293,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = ksz8081_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1277,6 +1307,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = ksz8061_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, }, { @@ -1290,6 +1321,7 @@ static struct phy_driver ksphy_driver[] = { .config_init = ksz9021_config_init, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1309,6 +1341,7 @@ static struct phy_driver ksphy_driver[] = { .read_status = ksz9031_read_status, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, @@ -1338,6 +1371,7 @@ static struct phy_driver ksphy_driver[] = { .read_status = genphy_read_status, .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, + .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, .get_strings = kszphy_get_strings, .get_stats = kszphy_get_stats, From patchwork Mon Nov 23 15:38: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: 330994 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 18A46C71155 for ; Mon, 23 Nov 2020 15:39:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD1A32080A for ; Mon, 23 Nov 2020 15:39:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="udBgVt5h" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389639AbgKWPiy (ORCPT ); Mon, 23 Nov 2020 10:38:54 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389630AbgKWPix (ORCPT ); Mon, 23 Nov 2020 10:38:53 -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 1346EC061A4D; Mon, 23 Nov 2020 07:38:53 -0800 (PST) Received: by mail-ej1-x642.google.com with SMTP id oq3so23903963ejb.7; Mon, 23 Nov 2020 07:38: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=CV6UwT07nXETd6Jffx0QFSiDDCu+xqCT56jb99c/GxI=; b=udBgVt5hVzZ3IX46FEIJKwCFC7wvrtbHaIapMiBkSUmbEmTLyrlOEJ2abtdcQU7iK5 zyAgSC0M9SxTIqdBSsQH9n8XU7axyuld6ethW8LcEZ2kprz92SVCIcnNu6pcFiEItfu/ /8uSJOwE9Ti5nFbMlEUX2io2ebGsp7lD03XQEqd0BekrGsBysD3jMlk5gqSz1VSbIf0i IEZeQ+NdROvgwc1UTyNCZJnIvn58H7G6Y8btdAATXik1CGhTB4uYLWpcZ36//4Ovyyr+ Vn1zHckWhzpkp85RcCSBsnqBdA+TYrAWxFDtJhIv1w9bOswLYptFoCem37AFkM/cANUA aYhA== 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=CV6UwT07nXETd6Jffx0QFSiDDCu+xqCT56jb99c/GxI=; b=Gf6OUZohu6J4kfJ3jsVTP8hAop7hTfl6f6fZ6S4NiaeRaMrvVowLJuM9SxaEi7Zrvl HO3I3RfFRyAcpetgYhHl04u4PLVpZ3mc1lpv38OmzAj/dZgzlCi91Ioj+6irYkuC3775 SAt9BWQWgiSbD18l3Qf5FkY6naVzzzRR433xkcX+L2ivBiKHoP7IpeoYlUnfLExrq0Li oBAwQYOoYGiJc2sBlQZArADdxfhi0zbTTV6kTGrz97LCUhqXKXOdehNyb3Z8zj+H07P3 aQawgsH1PIBOFf9GtpqeqWKe+Cef7pgPA37/cLe6aOwEKTQ+xQbxvCq3Gi/8bWlCec1A 1g6w== X-Gm-Message-State: AOAM532X7GLFoSsgROW4InlXGgHQtlwDZ9YROoSu8VFc/o6f+8RDFTsO Xbx1wbXAHkiaBKfCFdWettU= X-Google-Smtp-Source: ABdhPJwv5AfIAm8gE9ZAbaT8RZ9Aiq+i6fXP3G1rFdMeiGJMEI9awwH/PzbOwh94WeaEQpI0nysfJQ== X-Received: by 2002:a17:906:5396:: with SMTP id g22mr172395ejo.111.1606145931787; Mon, 23 Nov 2020 07:38:51 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 , Divya Koppera , Oleksij Rempel , Philippe Schenker , Marek Vasut , Antoine Tenart Subject: [PATCH net-next 08/15] net: phy: micrel: remove the use of .ack_interrupt() Date: Mon, 23 Nov 2020 17:38:10 +0200 Message-Id: <20201123153817.1616814-9-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Divya Koppera Cc: Oleksij Rempel Cc: Philippe Schenker Cc: Marek Vasut Cc: Antoine Tenart Signed-off-by: Ioana Ciornei --- drivers/net/phy/micrel.c | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/drivers/net/phy/micrel.c b/drivers/net/phy/micrel.c index 9aa96ebd31c8..97f08f20630b 100644 --- a/drivers/net/phy/micrel.c +++ b/drivers/net/phy/micrel.c @@ -162,7 +162,7 @@ static int kszphy_ack_interrupt(struct phy_device *phydev) static int kszphy_config_intr(struct phy_device *phydev) { const struct kszphy_type *type = phydev->drv->driver_data; - int temp; + int temp, err; u16 mask; if (type && type->interrupt_level_mask) @@ -178,12 +178,23 @@ static int kszphy_config_intr(struct phy_device *phydev) phy_write(phydev, MII_KSZPHY_CTRL, temp); /* enable / disable interrupts */ - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = kszphy_ack_interrupt(phydev); + if (err) + return err; + temp = KSZPHY_INTCS_ALL; - else + err = phy_write(phydev, MII_KSZPHY_INTCS, temp); + } else { temp = 0; + err = phy_write(phydev, MII_KSZPHY_INTCS, temp); + if (err) + return err; + + err = kszphy_ack_interrupt(phydev); + } - return phy_write(phydev, MII_KSZPHY_INTCS, temp); + return err; } static irqreturn_t kszphy_handle_interrupt(struct phy_device *phydev) @@ -1182,7 +1193,6 @@ static struct phy_driver ksphy_driver[] = { /* PHY_BASIC_FEATURES */ .driver_data = &ks8737_type, .config_init = kszphy_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .suspend = genphy_suspend, @@ -1195,7 +1205,6 @@ static struct phy_driver ksphy_driver[] = { .driver_data = &ksz8021_type, .probe = kszphy_probe, .config_init = kszphy_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1211,7 +1220,6 @@ static struct phy_driver ksphy_driver[] = { .driver_data = &ksz8021_type, .probe = kszphy_probe, .config_init = kszphy_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1228,7 +1236,6 @@ static struct phy_driver ksphy_driver[] = { .probe = kszphy_probe, .config_init = ksz8041_config_init, .config_aneg = ksz8041_config_aneg, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1244,7 +1251,6 @@ static struct phy_driver ksphy_driver[] = { .driver_data = &ksz8041_type, .probe = kszphy_probe, .config_init = kszphy_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1258,7 +1264,6 @@ static struct phy_driver ksphy_driver[] = { .driver_data = &ksz8051_type, .probe = kszphy_probe, .config_init = kszphy_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1275,7 +1280,6 @@ static struct phy_driver ksphy_driver[] = { .driver_data = &ksz8041_type, .probe = kszphy_probe, .config_init = kszphy_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1291,7 +1295,6 @@ static struct phy_driver ksphy_driver[] = { .driver_data = &ksz8081_type, .probe = kszphy_probe, .config_init = ksz8081_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1305,7 +1308,6 @@ static struct phy_driver ksphy_driver[] = { .phy_id_mask = MICREL_PHY_ID_MASK, /* PHY_BASIC_FEATURES */ .config_init = ksz8061_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .suspend = genphy_suspend, @@ -1319,7 +1321,6 @@ static struct phy_driver ksphy_driver[] = { .probe = kszphy_probe, .get_features = ksz9031_get_features, .config_init = ksz9021_config_init, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1339,7 +1340,6 @@ static struct phy_driver ksphy_driver[] = { .config_init = ksz9031_config_init, .soft_reset = genphy_soft_reset, .read_status = ksz9031_read_status, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, @@ -1369,7 +1369,6 @@ static struct phy_driver ksphy_driver[] = { .probe = kszphy_probe, .config_init = ksz9131_config_init, .read_status = genphy_read_status, - .ack_interrupt = kszphy_ack_interrupt, .config_intr = kszphy_config_intr, .handle_interrupt = kszphy_handle_interrupt, .get_sset_count = kszphy_get_sset_count, From patchwork Mon Nov 23 15:38: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: 331984 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 D7899C2D0E4 for ; Mon, 23 Nov 2020 15:39:48 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6FC1520719 for ; Mon, 23 Nov 2020 15:39:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UpVfk6PL" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389660AbgKWPiz (ORCPT ); Mon, 23 Nov 2020 10:38:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56882 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389649AbgKWPiy (ORCPT ); Mon, 23 Nov 2020 10:38:54 -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 7492AC0613CF; Mon, 23 Nov 2020 07:38:54 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id a16so23934975ejj.5; Mon, 23 Nov 2020 07:38: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=/ERL5JsBG9HleDkhJxzsPpAkh9W+QG3iEnGrftSlwy8=; b=UpVfk6PLa+4AryVCIEwKkaYiFZmI3g+hgKRBbTkRQjojZExlL8ciiRkNgtf6ybrLJf otcSmB7ieizjR3anzA4XLGN2ESEKaTLkSh1/4Z5MVHNYKsIz8FvEBkaVwWfI2yrnQL7A GHBuQVqnN/FeYdk9w9o94dQanrn4MvjvzpTdelG0Zk6zaEfZlUdMUVXf4AeEZ0U8bBhx CcbCNoH8Btw355y9ikTYH1FX2HI+3CO3nYD/busw+hkSakpPcjQDXIqAx4AOBqHLN4yK lgz6Zq+wBByp5M9nKJTG9ovctvCFWTi5HNih3QwvXxLDpgxpT0ILaquTpZ81lJOVUtAH HOeQ== 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=/ERL5JsBG9HleDkhJxzsPpAkh9W+QG3iEnGrftSlwy8=; b=PHi4YIa0BmPWbPpkLss0YnaWB6dhWCTicQz5Mpczr8ONSGrvGCQG4ynydJHjcF9M64 JVZMGvLVyGiKPOelIQJF1eAJQSIqNm5dKkzH0HLr7XL5oQVocE4JyLz8newUJ96IJxft trB2NxSoZMjLvyflCnoXgSIowiDI7mbxro3JOJRtsXDxDGmLntRfFhydOdZhc9zwF6NO XIItbfGgN9feRXnAK7LbP4eF8NMXckQPdBK0bpuc57O8UbsMipobbLXeBlITWs/wYddX Mgz29hwRrkRzSFQ7f+B44SZrio3WOQb7i5cFKaCESFWNkPQngJ5Xqz0jo9VS2+/95tlC 81Mg== X-Gm-Message-State: AOAM533NUPuw8G9pGwsAphnRJ41edu7jkr+l3a+LHAs9Yb4rON9MhIEJ jYz5RGrgl917omDbLgsqCJk= X-Google-Smtp-Source: ABdhPJykkoMd1I+9Z1xnDExnu5m9B0zOaD24z7hVCqF3XLjQiRRb2/xR1BkRlpbTJGv/XnCmad94cA== X-Received: by 2002:a17:906:d8ab:: with SMTP id qc11mr197576ejb.64.1606145933130; Mon, 23 Nov 2020 07:38:53 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 Subject: [PATCH net-next 09/15] net: phy: national: implement generic .handle_interrupt() callback Date: Mon, 23 Nov 2020 17:38:11 +0200 Message-Id: <20201123153817.1616814-10-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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/national.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/net/phy/national.c b/drivers/net/phy/national.c index a5bf0874c7d8..8c71fd66b0b1 100644 --- a/drivers/net/phy/national.c +++ b/drivers/net/phy/national.c @@ -89,6 +89,27 @@ static int ns_ack_interrupt(struct phy_device *phydev) return ret; } +static irqreturn_t ns_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, DP83865_INT_STATUS); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & DP83865_INT_MASK_DEFAULT)) + return IRQ_NONE; + + /* clear the interrupt */ + phy_write(phydev, DP83865_INT_CLEAR, irq_status & ~0x7); + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static void ns_giga_speed_fallback(struct phy_device *phydev, int mode) { int bmcr = phy_read(phydev, MII_BMCR); @@ -135,6 +156,7 @@ static struct phy_driver dp83865_driver[] = { { .config_init = ns_config_init, .ack_interrupt = ns_ack_interrupt, .config_intr = ns_config_intr, + .handle_interrupt = ns_handle_interrupt, } }; module_phy_driver(dp83865_driver); From patchwork Mon Nov 23 15:38: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: 330998 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 21BACC64E75 for ; Mon, 23 Nov 2020 15:39:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BFED6208FE for ; Mon, 23 Nov 2020 15:39:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="mPaiftkb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389681AbgKWPjA (ORCPT ); Mon, 23 Nov 2020 10:39:00 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56888 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389649AbgKWPi4 (ORCPT ); Mon, 23 Nov 2020 10:38:56 -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 EAC88C0613CF; Mon, 23 Nov 2020 07:38:55 -0800 (PST) Received: by mail-ej1-x643.google.com with SMTP id k9so9088747ejc.11; Mon, 23 Nov 2020 07:38:55 -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=xG6uDKlgrW8upS/7a6NuAZ58QlyBJGLGwgNnAk0awZ4=; b=mPaiftkbj3DKiy+CAMAgVGvXeIMbALIGJPISrJWqQf56tQ6Mp0PaVaNOoziqx+i7vv qvIASwu9CfLzXI37Tsa+32dDlnOmjmhJZaCFyQtTofMSKk7najmc1NtjmoePBn3047v/ p4MqSw+2v178CWQstO6hXw9LvgoMH3otuKjrISV9EOdrqA9oC2U+o3t3SQPFJwEcHkZd DuvrBsG+LIBP0uStjMEs8aCx0Qgb459iS+cQ8I75T4YxdI0ZY54jlG7zw4aQRxBVe/02 PSWXVOQ1gTQjm2vKH5ZJfQ9bhtJX37aM38pnV7pZuXN9IPp4JirP/9Xm9iBBUpVqeOVl Cg/A== 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=xG6uDKlgrW8upS/7a6NuAZ58QlyBJGLGwgNnAk0awZ4=; b=nkyYYhPy/FypeiAmrZ6rzZkf4s6hlO/LX1WAsi13T//ttA5tzuLdaITuLeSbWLsg13 8D/ooT16G4Td/RRoUV1mnxMrxCq2c/2SgtfsAdkAKK04VO8tnpQn51d3EN75o3SN7s9b PaYbYzzhk5iqLmeKuMs82/jz1+jaBIs5Mu0Lz8z9oMU21yLyjvkKiXYrzBdJ4WoyfyGh MoAn4e7sJufHviyuKQ5j7bjY/GJm17tbKDgGH0TS7NK4EkftUM9PkEbL4i1M76rPhjIP 03lQ815DGttbjJD3oY7ZQ286E4sLOHDkkKHVVUAShsK1lZXqTc6hQWa4ndOgLXuY4DZj 8FYw== X-Gm-Message-State: AOAM532Xrh3FBCQq8nuuZcHbpCF+34GbqPkj/X0lTUn7ZMUET7Uamfda ikV2aVT5iWQQ0wsSP1etBFE= X-Google-Smtp-Source: ABdhPJzDGK/LHGD7/4kd8lGmrIOtibjByAwipK4SsTznS9iO+WROwbg775RdO6nFQLDI2BNCn9kPsw== X-Received: by 2002:a17:906:9501:: with SMTP id u1mr131210ejx.405.1606145934666; Mon, 23 Nov 2020 07:38:54 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 Subject: [PATCH net-next 10/15] net: phy: national: remove the use of the .ack_interrupt() Date: Mon, 23 Nov 2020 17:38:12 +0200 Message-Id: <20201123153817.1616814-11-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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/national.c | 36 ++++++++++++++++++++++-------------- 1 file changed, 22 insertions(+), 14 deletions(-) diff --git a/drivers/net/phy/national.c b/drivers/net/phy/national.c index 8c71fd66b0b1..5a8c8eb18582 100644 --- a/drivers/net/phy/national.c +++ b/drivers/net/phy/national.c @@ -63,19 +63,6 @@ static void ns_exp_write(struct phy_device *phydev, u16 reg, u8 data) phy_write(phydev, NS_EXP_MEM_DATA, data); } -static int ns_config_intr(struct phy_device *phydev) -{ - int err; - - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) - err = phy_write(phydev, DP83865_INT_MASK, - DP83865_INT_MASK_DEFAULT); - else - err = phy_write(phydev, DP83865_INT_MASK, 0); - - return err; -} - static int ns_ack_interrupt(struct phy_device *phydev) { int ret = phy_read(phydev, DP83865_INT_STATUS); @@ -110,6 +97,28 @@ static irqreturn_t ns_handle_interrupt(struct phy_device *phydev) return IRQ_HANDLED; } +static int ns_config_intr(struct phy_device *phydev) +{ + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = ns_ack_interrupt(phydev); + if (err) + return err; + + err = phy_write(phydev, DP83865_INT_MASK, + DP83865_INT_MASK_DEFAULT); + } else { + err = phy_write(phydev, DP83865_INT_MASK, 0); + if (err) + return err; + + err = ns_ack_interrupt(phydev); + } + + return err; +} + static void ns_giga_speed_fallback(struct phy_device *phydev, int mode) { int bmcr = phy_read(phydev, MII_BMCR); @@ -154,7 +163,6 @@ static struct phy_driver dp83865_driver[] = { { .name = "NatSemi DP83865", /* PHY_GBIT_FEATURES */ .config_init = ns_config_init, - .ack_interrupt = ns_ack_interrupt, .config_intr = ns_config_intr, .handle_interrupt = ns_handle_interrupt, } }; From patchwork Mon Nov 23 15:38: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: 330995 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 3545CC2D0E4 for ; Mon, 23 Nov 2020 15:39:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C26D020719 for ; Mon, 23 Nov 2020 15:39:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Ms7N6qLr" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389745AbgKWPj1 (ORCPT ); Mon, 23 Nov 2020 10:39:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389670AbgKWPi6 (ORCPT ); Mon, 23 Nov 2020 10:38:58 -0500 Received: from mail-ed1-x52a.google.com (mail-ed1-x52a.google.com [IPv6:2a00:1450:4864:20::52a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E8990C0613CF; Mon, 23 Nov 2020 07:38:57 -0800 (PST) Received: by mail-ed1-x52a.google.com with SMTP id q16so17541242edv.10; Mon, 23 Nov 2020 07:38:57 -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=QmtMdyzeHBYHPpq35X+F3862eXFIVMymWHYH6aQfZo4=; b=Ms7N6qLr2LyLgKoqkiPzc60J1/oEkRHlaQJa9/KdlAMnagJ2e1lmNej7u/B5EX/wJq eGzxF0b2LTaCwL36JKYnKt5GbpSbsw5pX7N1LdTB2V+xDAxNEG04WjfPOvN2NaBXUEzd hmdG3GrXNAasTjJZM013rWoOE3YdPAssLUi8aBW7E4PfvEccd2mPXGmwdO3JE1vYl+ja 0LSLobo+3ZgYK2T3vc3a+vQF+UOn07oTwC2gDWzz9AtYpGvT8F1n0TFYS/+qFhoLIbZ5 jtsIUQgU78RBvRJ6bNgC3U7qDT8v1drlOqpwZXLaqoeeRuV0HgxIROb9iorWoEVoFa06 EKYw== 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=QmtMdyzeHBYHPpq35X+F3862eXFIVMymWHYH6aQfZo4=; b=LjtJGNq+Mae2EpF4jCB6WQ02CECOlMH0KfMiI3Ot8GjTObq/JeQBlez8H/8xUaoABy 2inoFOcjZea47vMWivpU8g72dCg8Fv/K6w3VqssnmpKR2btHAGz5h8IRL1eNmp8nAzrH sZTeQxzRo9mzi+DXJlNY22NbTeKDMdxAMuA21GeB21iwyas7uK5NqRikQbPlkI2VSRgK T4oau40/vGmbkJr84u5gVHuhNHSEuiXqeVplp5e78AoyMvFzHzQqcjaUkWdXEV+Uxtgf JHKmY3n9XIebQYo63q4T+wDm+bNVxd7RG3etbcQwi7g58C1p1ZHEveyJQf+g1X52V5kB 1F8Q== X-Gm-Message-State: AOAM531gbuPKjCyeaAYHEOp4FqsmH87jUeT0VrrBe4eOO4aUi/U5/ZXY 4Q7bSrohr4fgl0dKMOQXtje4fZuXFu7rbQ== X-Google-Smtp-Source: ABdhPJx20BdcA8PWSj5x9MNiS9+g1m/uFabwE6rdEjwiBXh+LwZgeoUPmB9xOXwNufVX+3lB/Kpo9Q== X-Received: by 2002:a50:f147:: with SMTP id z7mr15095287edl.76.1606145936430; Mon, 23 Nov 2020 07:38:56 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 , Dan Murphy Subject: [PATCH net-next 11/15] net: phy: ti: implement generic .handle_interrupt() callback Date: Mon, 23 Nov 2020 17:38:13 +0200 Message-Id: <20201123153817.1616814-12-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Dan Murphy Signed-off-by: Ioana Ciornei --- drivers/net/phy/dp83640.c | 27 +++++++++++++++++++++++ drivers/net/phy/dp83822.c | 37 +++++++++++++++++++++++++++++++ drivers/net/phy/dp83848.c | 33 ++++++++++++++++++++++++++++ drivers/net/phy/dp83867.c | 25 +++++++++++++++++++++ drivers/net/phy/dp83869.c | 25 +++++++++++++++++++++ drivers/net/phy/dp83tc811.c | 44 +++++++++++++++++++++++++++++++++++++ 6 files changed, 191 insertions(+) diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index f2caccaf4408..89577f1d3576 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -50,6 +50,14 @@ #define MII_DP83640_MISR_LINK_INT_EN 0x20 #define MII_DP83640_MISR_ED_INT_EN 0x40 #define MII_DP83640_MISR_LQ_INT_EN 0x80 +#define MII_DP83640_MISR_ANC_INT 0x400 +#define MII_DP83640_MISR_DUP_INT 0x800 +#define MII_DP83640_MISR_SPD_INT 0x1000 +#define MII_DP83640_MISR_LINK_INT 0x2000 +#define MII_DP83640_MISR_INT_MASK (MII_DP83640_MISR_ANC_INT |\ + MII_DP83640_MISR_DUP_INT |\ + MII_DP83640_MISR_SPD_INT |\ + MII_DP83640_MISR_LINK_INT) /* phyter seems to miss the mark by 16 ns */ #define ADJTIME_FIX 16 @@ -1193,6 +1201,24 @@ static int dp83640_config_intr(struct phy_device *phydev) } } +static irqreturn_t dp83640_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_DP83640_MISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_DP83640_MISR_INT_MASK)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int dp83640_hwtstamp(struct mii_timestamper *mii_ts, struct ifreq *ifr) { struct dp83640_private *dp83640 = @@ -1517,6 +1543,7 @@ static struct phy_driver dp83640_driver = { .config_init = dp83640_config_init, .ack_interrupt = dp83640_ack_interrupt, .config_intr = dp83640_config_intr, + .handle_interrupt = dp83640_handle_interrupt, }; static int __init dp83640_init(void) diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index c162c9551bd1..bb512ac3f533 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -303,6 +303,41 @@ static int dp83822_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_DP83822_PHYSCR, physcr_status); } +static irqreturn_t dp83822_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + /* The MISR1 and MISR2 registers are holding the interrupt status in + * the upper half (15:8), while the lower half (7:0) is used for + * controlling the interrupt enable state of those individual interrupt + * sources. To determine the possible interrupt sources, just read the + * MISR* register and use it directly to know which interrupts have + * been enabled previously or not. + */ + irq_status = phy_read(phydev, MII_DP83822_MISR1); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + if (irq_status & ((irq_status & GENMASK(7, 0)) << 8)) + goto trigger_machine; + + irq_status = phy_read(phydev, MII_DP83822_MISR2); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + if (irq_status & ((irq_status & GENMASK(7, 0)) << 8)) + goto trigger_machine; + + return IRQ_NONE; + +trigger_machine: + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int dp8382x_disable_wol(struct phy_device *phydev) { int value = DP83822_WOL_EN | DP83822_WOL_MAGIC_EN | @@ -576,6 +611,7 @@ static int dp83822_resume(struct phy_device *phydev) .set_wol = dp83822_set_wol, \ .ack_interrupt = dp83822_ack_interrupt, \ .config_intr = dp83822_config_intr, \ + .handle_interrupt = dp83822_handle_interrupt, \ .suspend = dp83822_suspend, \ .resume = dp83822_resume, \ } @@ -591,6 +627,7 @@ static int dp83822_resume(struct phy_device *phydev) .set_wol = dp83822_set_wol, \ .ack_interrupt = dp83822_ack_interrupt, \ .config_intr = dp83822_config_intr, \ + .handle_interrupt = dp83822_handle_interrupt, \ .suspend = dp83822_suspend, \ .resume = dp83822_resume, \ } diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c index 54c7c1b44e4d..b707a9b27847 100644 --- a/drivers/net/phy/dp83848.c +++ b/drivers/net/phy/dp83848.c @@ -37,6 +37,20 @@ DP83848_MISR_SPD_INT_EN | \ DP83848_MISR_LINK_INT_EN) +#define DP83848_MISR_RHF_INT BIT(8) +#define DP83848_MISR_FHF_INT BIT(9) +#define DP83848_MISR_ANC_INT BIT(10) +#define DP83848_MISR_DUP_INT BIT(11) +#define DP83848_MISR_SPD_INT BIT(12) +#define DP83848_MISR_LINK_INT BIT(13) +#define DP83848_MISR_ED_INT BIT(14) + +#define DP83848_INT_MASK \ + (DP83848_MISR_ANC_INT | \ + DP83848_MISR_DUP_INT | \ + DP83848_MISR_SPD_INT | \ + DP83848_MISR_LINK_INT) + static int dp83848_ack_interrupt(struct phy_device *phydev) { int err = phy_read(phydev, DP83848_MISR); @@ -66,6 +80,24 @@ static int dp83848_config_intr(struct phy_device *phydev) return phy_write(phydev, DP83848_MICR, control); } +static irqreturn_t dp83848_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, DP83848_MISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & DP83848_INT_MASK)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int dp83848_config_init(struct phy_device *phydev) { int val; @@ -104,6 +136,7 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl); /* IRQ related */ \ .ack_interrupt = dp83848_ack_interrupt, \ .config_intr = dp83848_config_intr, \ + .handle_interrupt = dp83848_handle_interrupt, \ } static struct phy_driver dp83848_driver[] = { diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index 69d3eacc2b96..aba4e4c1f75c 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -310,6 +310,30 @@ static int dp83867_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_DP83867_MICR, micr_status); } +static irqreturn_t dp83867_handle_interrupt(struct phy_device *phydev) +{ + int irq_status, irq_enabled; + + irq_status = phy_read(phydev, MII_DP83867_ISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + irq_enabled = phy_read(phydev, MII_DP83867_MICR); + if (irq_enabled < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & irq_enabled)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int dp83867_read_status(struct phy_device *phydev) { int status = phy_read(phydev, MII_DP83867_PHYSTS); @@ -827,6 +851,7 @@ static struct phy_driver dp83867_driver[] = { /* IRQ related */ .ack_interrupt = dp83867_ack_interrupt, .config_intr = dp83867_config_intr, + .handle_interrupt = dp83867_handle_interrupt, .suspend = genphy_suspend, .resume = genphy_resume, diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c index cf6dec7b7d8e..487d1b8beec5 100644 --- a/drivers/net/phy/dp83869.c +++ b/drivers/net/phy/dp83869.c @@ -207,6 +207,30 @@ static int dp83869_config_intr(struct phy_device *phydev) return phy_write(phydev, MII_DP83869_MICR, micr_status); } +static irqreturn_t dp83869_handle_interrupt(struct phy_device *phydev) +{ + int irq_status, irq_enabled; + + irq_status = phy_read(phydev, MII_DP83869_ISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + irq_enabled = phy_read(phydev, MII_DP83869_MICR); + if (irq_enabled < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & irq_enabled)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int dp83869_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) { @@ -852,6 +876,7 @@ static struct phy_driver dp83869_driver[] = { /* IRQ related */ .ack_interrupt = dp83869_ack_interrupt, .config_intr = dp83869_config_intr, + .handle_interrupt = dp83869_handle_interrupt, .read_status = dp83869_read_status, .get_tunable = dp83869_get_tunable, diff --git a/drivers/net/phy/dp83tc811.c b/drivers/net/phy/dp83tc811.c index d73725312c7c..a93c64ac76a3 100644 --- a/drivers/net/phy/dp83tc811.c +++ b/drivers/net/phy/dp83tc811.c @@ -254,6 +254,49 @@ static int dp83811_config_intr(struct phy_device *phydev) return err; } +static irqreturn_t dp83811_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + /* The INT_STAT registers 1, 2 and 3 are holding the interrupt status + * in the upper half (15:8), while the lower half (7:0) is used for + * controlling the interrupt enable state of those individual interrupt + * sources. To determine the possible interrupt sources, just read the + * INT_STAT* register and use it directly to know which interrupts have + * been enabled previously or not. + */ + irq_status = phy_read(phydev, MII_DP83811_INT_STAT1); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + if (irq_status & ((irq_status & GENMASK(7, 0)) << 8)) + goto trigger_machine; + + irq_status = phy_read(phydev, MII_DP83811_INT_STAT2); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + if (irq_status & ((irq_status & GENMASK(7, 0)) << 8)) + goto trigger_machine; + + irq_status = phy_read(phydev, MII_DP83811_INT_STAT3); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + if (irq_status & ((irq_status & GENMASK(7, 0)) << 8)) + goto trigger_machine; + + return IRQ_NONE; + +trigger_machine: + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int dp83811_config_aneg(struct phy_device *phydev) { int value, err; @@ -345,6 +388,7 @@ static struct phy_driver dp83811_driver[] = { .set_wol = dp83811_set_wol, .ack_interrupt = dp83811_ack_interrupt, .config_intr = dp83811_config_intr, + .handle_interrupt = dp83811_handle_interrupt, .suspend = dp83811_suspend, .resume = dp83811_resume, }, From patchwork Mon Nov 23 15:38: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: 330996 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=-12.9 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_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS, UNWANTED_LANGUAGE_BODY,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 A92E9C64E7A for ; Mon, 23 Nov 2020 15:39:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 543DE20719 for ; Mon, 23 Nov 2020 15:39:50 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UIu2R2bh" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389735AbgKWPjV (ORCPT ); Mon, 23 Nov 2020 10:39:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56900 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389671AbgKWPi7 (ORCPT ); Mon, 23 Nov 2020 10:38:59 -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 265C0C061A4D; Mon, 23 Nov 2020 07:38:59 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id d18so17557736edt.7; Mon, 23 Nov 2020 07:38: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=wwB73Rsm8FBWnbvpf/xQy1++g6Ol49vkh6A+mPeRjjk=; b=UIu2R2bhoRMdWFafFO5W99F8jopHui1zsDFYd93/V6h76c7q0AJ8ej6v/8gdBlSGoo mu42ZDwok/TqDqNQenFc63I81In9EJMs6JZUAmaNZxWKLHQR8qUsQcs8xhXtOFl5446L lvtiCrOHLbUVZ6E19S7T4/zGEnRjh+7b3ha4PK2oGFLKFO/9bIL2yvzJUh4KWFGYLwsI noNp9/I1WxnFuxuqQg2LoNH4N+7tfggy7jy74s7w8SouoxBKA5bAuyb8o2SHnJiy2T1a aQB8jtc2TdbWkJh11i/ojBw5EvPs5FrKiMkq/tO7lvEcXwd0e8IqmtCSPMdoyoNEaivk 0R9A== 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=wwB73Rsm8FBWnbvpf/xQy1++g6Ol49vkh6A+mPeRjjk=; b=YVbBV9VutNNHk/SkokmVcAVtTCQlO7mtNJdzmGHREF17YWigZDLfYOnDu4BxO23X3s 5pQKQOfqjVYyioO2akYhzbHmRiKQsSuzapz/ejsyO9z7d0urLwuNBpy9VWVbN21T6Com sc0totwU6u0HEZ9sBgDxvEb44jq28Ys/GcIHArXw51kaUNcwdLKvEZd0flmyW4Z8+0v4 MJNpMmI/t/C/IzhpBGm54bbAIA55NPRayO8A2I8XoyfcWA420LHKc1TE32W1TTB0y/bP XTJ+xclvWKhAb3cpOozzlFQm2enqtY4eriH+IYGt71lBx09vJgTc56i3/UDlXz246xvo h71Q== X-Gm-Message-State: AOAM530CM3uO/+MoNGV1hoHBZqsjs7RXWAyI0X7HIY8Z0IGbQjFCAp8y QDu0RwLN8ZivnEmyx93C2Rk= X-Google-Smtp-Source: ABdhPJxoYVXS0T7HRmcIVMTPwHiBL0LaA4PspY0HyGSihwZIUnZHXKKZupkR41d7M1qcxHjxjCEsAw== X-Received: by 2002:aa7:d711:: with SMTP id t17mr47974769edq.83.1606145937829; Mon, 23 Nov 2020 07:38:57 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 , Dan Murphy Subject: [PATCH net-next 12/15] net: phy: ti: remove the use of .ack_interrupt() Date: Mon, 23 Nov 2020 17:38:14 +0200 Message-Id: <20201123153817.1616814-13-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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: Dan Murphy Signed-off-by: Ioana Ciornei --- drivers/net/phy/dp83640.c | 11 +++++++++-- drivers/net/phy/dp83822.c | 17 ----------------- drivers/net/phy/dp83848.c | 14 ++++++++++++-- drivers/net/phy/dp83867.c | 19 ++++++++++++++----- drivers/net/phy/dp83869.c | 17 +++++++++++++---- drivers/net/phy/dp83tc811.c | 9 ++++++++- 6 files changed, 56 insertions(+), 31 deletions(-) diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index 89577f1d3576..f1001ae1df51 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c @@ -1159,6 +1159,10 @@ static int dp83640_config_intr(struct phy_device *phydev) int err; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = dp83640_ack_interrupt(phydev); + if (err) + return err; + misr = phy_read(phydev, MII_DP83640_MISR); if (misr < 0) return misr; @@ -1197,7 +1201,11 @@ static int dp83640_config_intr(struct phy_device *phydev) MII_DP83640_MISR_DUP_INT_EN | MII_DP83640_MISR_SPD_INT_EN | MII_DP83640_MISR_LINK_INT_EN); - return phy_write(phydev, MII_DP83640_MISR, misr); + err = phy_write(phydev, MII_DP83640_MISR, misr); + if (err) + return err; + + return dp83640_ack_interrupt(phydev); } } @@ -1541,7 +1549,6 @@ static struct phy_driver dp83640_driver = { .remove = dp83640_remove, .soft_reset = dp83640_soft_reset, .config_init = dp83640_config_init, - .ack_interrupt = dp83640_ack_interrupt, .config_intr = dp83640_config_intr, .handle_interrupt = dp83640_handle_interrupt, }; diff --git a/drivers/net/phy/dp83822.c b/drivers/net/phy/dp83822.c index bb512ac3f533..fff371ca1086 100644 --- a/drivers/net/phy/dp83822.c +++ b/drivers/net/phy/dp83822.c @@ -119,21 +119,6 @@ struct dp83822_private { u16 fx_sd_enable; }; -static int dp83822_ack_interrupt(struct phy_device *phydev) -{ - int err; - - err = phy_read(phydev, MII_DP83822_MISR1); - if (err < 0) - return err; - - err = phy_read(phydev, MII_DP83822_MISR2); - if (err < 0) - return err; - - return 0; -} - static int dp83822_set_wol(struct phy_device *phydev, struct ethtool_wolinfo *wol) { @@ -609,7 +594,6 @@ static int dp83822_resume(struct phy_device *phydev) .read_status = dp83822_read_status, \ .get_wol = dp83822_get_wol, \ .set_wol = dp83822_set_wol, \ - .ack_interrupt = dp83822_ack_interrupt, \ .config_intr = dp83822_config_intr, \ .handle_interrupt = dp83822_handle_interrupt, \ .suspend = dp83822_suspend, \ @@ -625,7 +609,6 @@ static int dp83822_resume(struct phy_device *phydev) .config_init = dp8382x_config_init, \ .get_wol = dp83822_get_wol, \ .set_wol = dp83822_set_wol, \ - .ack_interrupt = dp83822_ack_interrupt, \ .config_intr = dp83822_config_intr, \ .handle_interrupt = dp83822_handle_interrupt, \ .suspend = dp83822_suspend, \ diff --git a/drivers/net/phy/dp83848.c b/drivers/net/phy/dp83848.c index b707a9b27847..937061acfc61 100644 --- a/drivers/net/phy/dp83848.c +++ b/drivers/net/phy/dp83848.c @@ -67,17 +67,28 @@ static int dp83848_config_intr(struct phy_device *phydev) return control; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + ret = dp83848_ack_interrupt(phydev); + if (ret) + return ret; + control |= DP83848_MICR_INT_OE; control |= DP83848_MICR_INTEN; ret = phy_write(phydev, DP83848_MISR, DP83848_INT_EN_MASK); if (ret < 0) return ret; + + ret = phy_write(phydev, DP83848_MICR, control); } else { control &= ~DP83848_MICR_INTEN; + ret = phy_write(phydev, DP83848_MICR, control); + if (ret) + return ret; + + ret = dp83848_ack_interrupt(phydev); } - return phy_write(phydev, DP83848_MICR, control); + return ret; } static irqreturn_t dp83848_handle_interrupt(struct phy_device *phydev) @@ -134,7 +145,6 @@ MODULE_DEVICE_TABLE(mdio, dp83848_tbl); .resume = genphy_resume, \ \ /* IRQ related */ \ - .ack_interrupt = dp83848_ack_interrupt, \ .config_intr = dp83848_config_intr, \ .handle_interrupt = dp83848_handle_interrupt, \ } diff --git a/drivers/net/phy/dp83867.c b/drivers/net/phy/dp83867.c index aba4e4c1f75c..9bd9a5c0b1db 100644 --- a/drivers/net/phy/dp83867.c +++ b/drivers/net/phy/dp83867.c @@ -288,9 +288,13 @@ static void dp83867_get_wol(struct phy_device *phydev, static int dp83867_config_intr(struct phy_device *phydev) { - int micr_status; + int micr_status, err; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = dp83867_ack_interrupt(phydev); + if (err) + return err; + micr_status = phy_read(phydev, MII_DP83867_MICR); if (micr_status < 0) return micr_status; @@ -303,11 +307,17 @@ static int dp83867_config_intr(struct phy_device *phydev) MII_DP83867_MICR_DUP_MODE_CHNG_INT_EN | MII_DP83867_MICR_SLEEP_MODE_CHNG_INT_EN); - return phy_write(phydev, MII_DP83867_MICR, micr_status); + err = phy_write(phydev, MII_DP83867_MICR, micr_status); + } else { + micr_status = 0x0; + err = phy_write(phydev, MII_DP83867_MICR, micr_status); + if (err) + return err; + + err = dp83867_ack_interrupt(phydev); } - micr_status = 0x0; - return phy_write(phydev, MII_DP83867_MICR, micr_status); + return err; } static irqreturn_t dp83867_handle_interrupt(struct phy_device *phydev) @@ -849,7 +859,6 @@ static struct phy_driver dp83867_driver[] = { .set_wol = dp83867_set_wol, /* IRQ related */ - .ack_interrupt = dp83867_ack_interrupt, .config_intr = dp83867_config_intr, .handle_interrupt = dp83867_handle_interrupt, diff --git a/drivers/net/phy/dp83869.c b/drivers/net/phy/dp83869.c index 487d1b8beec5..b30bc142d82e 100644 --- a/drivers/net/phy/dp83869.c +++ b/drivers/net/phy/dp83869.c @@ -186,9 +186,13 @@ static int dp83869_ack_interrupt(struct phy_device *phydev) static int dp83869_config_intr(struct phy_device *phydev) { - int micr_status = 0; + int micr_status = 0, err; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = dp83869_ack_interrupt(phydev); + if (err) + return err; + micr_status = phy_read(phydev, MII_DP83869_MICR); if (micr_status < 0) return micr_status; @@ -201,10 +205,16 @@ static int dp83869_config_intr(struct phy_device *phydev) MII_DP83869_MICR_DUP_MODE_CHNG_INT_EN | MII_DP83869_MICR_SLEEP_MODE_CHNG_INT_EN); - return phy_write(phydev, MII_DP83869_MICR, micr_status); + err = phy_write(phydev, MII_DP83869_MICR, micr_status); + } else { + err = phy_write(phydev, MII_DP83869_MICR, micr_status); + if (err) + return err; + + err = dp83869_ack_interrupt(phydev); } - return phy_write(phydev, MII_DP83869_MICR, micr_status); + return err; } static irqreturn_t dp83869_handle_interrupt(struct phy_device *phydev) @@ -874,7 +884,6 @@ static struct phy_driver dp83869_driver[] = { .soft_reset = dp83869_phy_reset, /* IRQ related */ - .ack_interrupt = dp83869_ack_interrupt, .config_intr = dp83869_config_intr, .handle_interrupt = dp83869_handle_interrupt, .read_status = dp83869_read_status, diff --git a/drivers/net/phy/dp83tc811.c b/drivers/net/phy/dp83tc811.c index a93c64ac76a3..688fadffb249 100644 --- a/drivers/net/phy/dp83tc811.c +++ b/drivers/net/phy/dp83tc811.c @@ -197,6 +197,10 @@ static int dp83811_config_intr(struct phy_device *phydev) int misr_status, err; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = dp83811_ack_interrupt(phydev); + if (err) + return err; + misr_status = phy_read(phydev, MII_DP83811_INT_STAT1); if (misr_status < 0) return misr_status; @@ -249,6 +253,10 @@ static int dp83811_config_intr(struct phy_device *phydev) return err; err = phy_write(phydev, MII_DP83811_INT_STAT3, 0); + if (err < 0) + return err; + + err = dp83811_ack_interrupt(phydev); } return err; @@ -386,7 +394,6 @@ static struct phy_driver dp83811_driver[] = { .soft_reset = dp83811_phy_reset, .get_wol = dp83811_get_wol, .set_wol = dp83811_set_wol, - .ack_interrupt = dp83811_ack_interrupt, .config_intr = dp83811_config_intr, .handle_interrupt = dp83811_handle_interrupt, .suspend = dp83811_suspend, From patchwork Mon Nov 23 15:38: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: 330997 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 4D485C63798 for ; Mon, 23 Nov 2020 15:39:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E8DE920719 for ; Mon, 23 Nov 2020 15:39:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="QhDIP0U2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389694AbgKWPjD (ORCPT ); Mon, 23 Nov 2020 10:39:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56908 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389685AbgKWPjC (ORCPT ); Mon, 23 Nov 2020 10:39:02 -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 EE348C0613CF; Mon, 23 Nov 2020 07:39:00 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id k1so4617307eds.13; Mon, 23 Nov 2020 07:39: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=cqDNeq3r/DZ3Fa6vyHKMYrzd94gpNO8C1c5X2bRnhJY=; b=QhDIP0U2vCHqonbpJ2sMdYVCddNT/RjlHFiSLCiW9/tJC+hwXnRnkAHhTfxvwqhYTT YozXdT//y7ra0VjjdywHFD7LpLsklOIPgUM1kAurCWB9ysp9Deyk95OoGqwfXVlM2tHv jOLWh7HWkluMjWuQU/LBWlXzMyWRMxQyGlTKevjlbrfkrF8kwGvacNaCpu1G4Pq+nhzK PtQ23WNU1TBnh51qcKC11cxPZureadf8Zx2eaonu7f+EvARzFgNoCTizOyrA84/ZPAS1 gpWVaVoXhd/auPNKt19H3LTVnFK9XF+TrRz3hO7614KreHhhGrsukisQGnZFVk/sFMiq eN9A== 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=cqDNeq3r/DZ3Fa6vyHKMYrzd94gpNO8C1c5X2bRnhJY=; b=HJgKNcLBM6OaPeO15cyYYi79kycZXb77arFw5UfiG3vIjD6P2Qm+RzNX2ghpkhG5VW C0xLi31C7pNSuW1g/1ZzjZH4N+FkM1Rlt89qSStOfLXFrLeA5E2SBi7ANGM1vxgF91SA t0edKB412VQ+cEOjbr0bRbYeJbdHcWe/KIK9JUCHvPlfUNGUiDIfoYON/AI3FNlV+/hH vXVGee84VIFGuMD5SIEHGV01K+Edq+A5dDIif9jDAfc97Yzy3pW2QWANL109rb0GUxWY UxzK6PPw0lc2V6fCvbxSwdqa05IHscrNwE/9Ba7zpVQVMFF/E/dHr9DYfsAxOEul1Jq/ l2+Q== X-Gm-Message-State: AOAM532PifCPRMa6ZMsxQ4ioLOuEjuzUfQ7YEszDtq32W4Edml9oGynr h6FqWAlHl+VVzxjTCkyEBmQ= X-Google-Smtp-Source: ABdhPJzHGXDkG++aTYU4CeeveWrHoP2UUo1eJ5SGSQiyUcx+H06KETz8U0JU2zEGPAy0yk3fvOJQjw== X-Received: by 2002:aa7:d615:: with SMTP id c21mr48136666edr.23.1606145939544; Mon, 23 Nov 2020 07:38:59 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:38: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 Subject: [PATCH net-next 13/15] net: phy: qsemi: implement generic .handle_interrupt() callback Date: Mon, 23 Nov 2020 17:38:15 +0200 Message-Id: <20201123153817.1616814-14-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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/qsemi.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c index 1b15a991ee06..97f29ed2f0ca 100644 --- a/drivers/net/phy/qsemi.c +++ b/drivers/net/phy/qsemi.c @@ -106,6 +106,27 @@ static int qs6612_config_intr(struct phy_device *phydev) } +static irqreturn_t qs6612_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read(phydev, MII_QS6612_ISR); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MII_QS6612_IMR_INIT)) + return IRQ_NONE; + + /* the interrupt source register is not self-clearing */ + qs6612_ack_interrupt(phydev); + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static struct phy_driver qs6612_driver[] = { { .phy_id = 0x00181440, .name = "QS6612", @@ -114,6 +135,7 @@ static struct phy_driver qs6612_driver[] = { { .config_init = qs6612_config_init, .ack_interrupt = qs6612_ack_interrupt, .config_intr = qs6612_config_intr, + .handle_interrupt = qs6612_handle_interrupt, } }; module_phy_driver(qs6612_driver); From patchwork Mon Nov 23 15:38: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: 331983 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 70957C63697 for ; Mon, 23 Nov 2020 15:39:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 33CD92080A for ; Mon, 23 Nov 2020 15:39:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="IurMSwYn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389705AbgKWPjE (ORCPT ); Mon, 23 Nov 2020 10:39:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389649AbgKWPjC (ORCPT ); Mon, 23 Nov 2020 10:39:02 -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 2D486C061A4D; Mon, 23 Nov 2020 07:39:02 -0800 (PST) Received: by mail-ej1-x644.google.com with SMTP id a16so23935599ejj.5; Mon, 23 Nov 2020 07:39: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=+FeXibTuIgwGfVQRfzn1QNcdeuVRN4zL8aR37xT1P1E=; b=IurMSwYnPKLYb4Iqmtc/C5bWUGna4RmdWi5lMn3oj6+TZM4aoCTJOatM+LSEcqAfc5 5+OU7an60iO34LKtloCoKslhW4st8kvXA5OsUrxRUxWEA92gwFBymUS9GsdWaWW3Wgpm gvru1ESD0UGXOlOPSTK3IqIdLEAL4FJAQv+FFq/W9dk5p5VtDAkay8mm7NvL4ltDHTu5 Tp34i13xf5oxXL8PSikjD2EmuESLBqkfSBZCbcflL17LwLjTVAdzcMKdkpo3EPzYo6xn lI+9KhosO4mGrMrg1furqV/We6lxHj95syomMT2fGggoyFltUu9WORRsatht7Y7awke0 x1pw== 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=+FeXibTuIgwGfVQRfzn1QNcdeuVRN4zL8aR37xT1P1E=; b=cmnUDFsDJEA0ZZWRMmdFlYDKcrYKlV/DJFK4TBcK3UCSTgn9KHyEJAcZGVVOYufPFE SXUh5XpC2/ojiYOR5mPDXLCcZya2+8wBw9zluBhfc5kXNgBNYVITpVVUrFLZTP11+jHO iTDCwldoXvF2laTT5VfZ4J4Nx1d/d5gS0/0qWhXs5zmWmq64ohx/QatBtG0ON3IbEVLv j3cWkma/mmEi9u7aBtmT8tZR+V4sZ9RXxmlLMHsjgXJWOKb4U3X5l0bLc2+QP5r/BOW6 bkn9CmA/U+K6XO221XJ1pQ7UOJ5kuRHSLjIsScsmQGgplRMW4ZGj9DLNgCcS+WpoyZgp bnMg== X-Gm-Message-State: AOAM530/GlpvPZBXgweNDToVJ3aVt/UU9kFeY+4eShaaLK7yWuSA5JyD lOZftWNBWnsD2OnGv8DZqho= X-Google-Smtp-Source: ABdhPJzbXW1OKamSInKqoX74QDVRyyD9wIGtXiZ+468HVMMYCEfeb5bXfTxii9EAgtnswat5868SQw== X-Received: by 2002:a17:906:f186:: with SMTP id gs6mr162629ejb.171.1606145940827; Mon, 23 Nov 2020 07:39:00 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.38.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:39: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 Subject: [PATCH net-next 14/15] net: phy: qsemi: remove the use of .ack_interrupt() Date: Mon, 23 Nov 2020 17:38:16 +0200 Message-Id: <20201123153817.1616814-15-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.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. Also, add a comment describing the multiple step interrupt acknoledgement process. Signed-off-by: Ioana Ciornei --- drivers/net/phy/qsemi.c | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/drivers/net/phy/qsemi.c b/drivers/net/phy/qsemi.c index 97f29ed2f0ca..d5c1aaa8236a 100644 --- a/drivers/net/phy/qsemi.c +++ b/drivers/net/phy/qsemi.c @@ -75,6 +75,10 @@ static int qs6612_ack_interrupt(struct phy_device *phydev) { int err; + /* The Interrupt Source register is not self-clearing, bits 4 and 5 are + * cleared when MII_BMSR is read and bits 1 and 3 are cleared when + * MII_EXPANSION is read + */ err = phy_read(phydev, MII_QS6612_ISR); if (err < 0) @@ -96,11 +100,22 @@ static int qs6612_ack_interrupt(struct phy_device *phydev) static int qs6612_config_intr(struct phy_device *phydev) { int err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + /* clear any interrupts before enabling them */ + err = qs6612_ack_interrupt(phydev); + if (err) + return err; + err = phy_write(phydev, MII_QS6612_IMR, MII_QS6612_IMR_INIT); - else + } else { err = phy_write(phydev, MII_QS6612_IMR, 0); + if (err) + return err; + + /* clear any leftover interrupts */ + err = qs6612_ack_interrupt(phydev); + } return err; @@ -133,7 +148,6 @@ static struct phy_driver qs6612_driver[] = { { .phy_id_mask = 0xfffffff0, /* PHY_BASIC_FEATURES */ .config_init = qs6612_config_init, - .ack_interrupt = qs6612_ack_interrupt, .config_intr = qs6612_config_intr, .handle_interrupt = qs6612_handle_interrupt, } }; From patchwork Mon Nov 23 15:38: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: 331979 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=-15.7 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_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, 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 02B83C64E69 for ; Mon, 23 Nov 2020 15:39:50 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A76BA2080A for ; Mon, 23 Nov 2020 15:39:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lct5lNVp" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2389719AbgKWPjG (ORCPT ); Mon, 23 Nov 2020 10:39:06 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56918 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389649AbgKWPjF (ORCPT ); Mon, 23 Nov 2020 10:39:05 -0500 Received: from mail-ej1-x62e.google.com (mail-ej1-x62e.google.com [IPv6:2a00:1450:4864:20::62e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BD9AEC0613CF; Mon, 23 Nov 2020 07:39:03 -0800 (PST) Received: by mail-ej1-x62e.google.com with SMTP id oq3so23904747ejb.7; Mon, 23 Nov 2020 07:39:03 -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=TusUGAwjKLhvqu+tAwG6fITFVtTTw0LT4cF+FlXu+uo=; b=lct5lNVp3AsngxY0QQET9C/ZGAopLnIgK2FJ/KrqUkVaBNiDKzBrhDHnLoXRujFHD6 t9Q1H0Mq9pB5o2B9+cGLVk+7Jx50/8v525SMiO5f3iORddHenHT8YMxvg77LD6VB1Ae+ u+TMrpzFl/B+CKrHPsoV6oc4E6BJl4b7ze3x+5468MtjTTCHK1SPszxBhxMfeYJ/cVCO 8HkxASoL27Xh+7LgJyPMyjuTx2aVdkJ9u03qYHUAXmT5JmnobAKhtfUvKGeMWWCf/SSN chNys5R2fy3TgVBMNZfWE5C47m+/aYEy0PuGBU4DkQj6/JYu39zsThuBfi4I98gxeq/F ih6g== 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=TusUGAwjKLhvqu+tAwG6fITFVtTTw0LT4cF+FlXu+uo=; b=OSV8WUBaPY6TLyQTNUm/6e0m3856Zwzxy+q81uMqvI6EL2/T9oLVERlzFbDkLKYZPs mpytNhWvqi5a99HYOOUoePeltRPynYYLFUkiu9hb5RPuVE4R7O9wN4bacg+YexdPCeJu xYzN7WDa9N/H5UCOf6dOSz4Ef4e5aTbnmEA3HKAmYe+sxJvcKeiLi8S/O76ee7wZpLq/ 3bfZ9idalPZ+OxZsQ0ePFSedEvi8t4CPTfMeRksAeDqs60QsZQARzW7uHmYwUKrVqypN g9a9Lmi82spCdMGctjbe6d2XlpwKyIBIq3rlT6JTIwQPsZGDtQhGfExdeXgTILtXLOLF 9++Q== X-Gm-Message-State: AOAM531r8uIj98HlBkXLqypUeP858v7RAHJ3fTYL6+OD1j8xJVlYwNgK yh5QNaxZf03VzGggVOcv7ys= X-Google-Smtp-Source: ABdhPJzJztZg8FGiG/ke0zahYFV5QlHlMngIEaluSmacSoZX20+HseiFrEW7anIfoUraziEWY4Sl4w== X-Received: by 2002:a17:906:7b82:: with SMTP id s2mr133342ejo.435.1606145942271; Mon, 23 Nov 2020 07:39:02 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c6sm4800126edy.62.2020.11.23.07.39.01 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Nov 2020 07:39:01 -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 net-next 15/15] net: phy: remove the .did_interrupt() and .ack_interrupt() callback Date: Mon, 23 Nov 2020 17:38:17 +0200 Message-Id: <20201123153817.1616814-16-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201123153817.1616814-1-ciorneiioana@gmail.com> References: <20201123153817.1616814-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei Now that all the PHY drivers have been migrated to directly implement the generic .handle_interrupt() callback for a seamless support of shared IRQs and all the .config_inter() implementations clear any pending interrupts, we can safely remove the two callbacks. With this patch, phylib has a proper support for shared IRQs (and not just for multi-PHY devices. A PHY driver must implement both the .handle_interrupt() and .config_intr() callbacks for the IRQs to be actually used. Signed-off-by: Ioana Ciornei --- drivers/net/phy/phy.c | 48 ++---------------------------------- drivers/net/phy/phy_device.c | 2 +- include/linux/phy.h | 19 +++----------- 3 files changed, 7 insertions(+), 62 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index dce86bad8231..45f75533c47c 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -113,23 +113,6 @@ void phy_print_status(struct phy_device *phydev) } EXPORT_SYMBOL(phy_print_status); -/** - * phy_clear_interrupt - Ack the phy device's interrupt - * @phydev: the phy_device struct - * - * If the @phydev driver has an ack_interrupt function, call it to - * ack and clear the phy device's interrupt. - * - * Returns 0 on success or < 0 on error. - */ -static int phy_clear_interrupt(struct phy_device *phydev) -{ - if (phydev->drv->ack_interrupt) - return phydev->drv->ack_interrupt(phydev); - - return 0; -} - /** * phy_config_interrupt - configure the PHY device for the requested interrupts * @phydev: the phy_device struct @@ -943,15 +926,8 @@ EXPORT_SYMBOL(phy_error); */ int phy_disable_interrupts(struct phy_device *phydev) { - int err; - /* Disable PHY interrupts */ - err = phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED); - if (err) - return err; - - /* Clear the interrupt */ - return phy_clear_interrupt(phydev); + return phy_config_interrupt(phydev, PHY_INTERRUPT_DISABLED); } /** @@ -966,22 +942,7 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) struct phy_device *phydev = phy_dat; struct phy_driver *drv = phydev->drv; - if (drv->handle_interrupt) - return drv->handle_interrupt(phydev); - - if (drv->did_interrupt && !drv->did_interrupt(phydev)) - return IRQ_NONE; - - /* reschedule state queue work to run as soon as possible */ - phy_trigger_machine(phydev); - - /* did_interrupt() may have cleared the interrupt already */ - if (!drv->did_interrupt && phy_clear_interrupt(phydev)) { - phy_error(phydev); - return IRQ_NONE; - } - - return IRQ_HANDLED; + return drv->handle_interrupt(phydev); } /** @@ -990,11 +951,6 @@ static irqreturn_t phy_interrupt(int irq, void *phy_dat) */ static int phy_enable_interrupts(struct phy_device *phydev) { - int err = phy_clear_interrupt(phydev); - - if (err < 0) - return err; - return phy_config_interrupt(phydev, PHY_INTERRUPT_ENABLED); } diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 81f672911305..80c2e646c093 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2826,7 +2826,7 @@ EXPORT_SYMBOL(phy_get_internal_delay); static bool phy_drv_supports_irq(struct phy_driver *phydrv) { - return phydrv->config_intr && (phydrv->ack_interrupt || phydrv->handle_interrupt); + return phydrv->config_intr && phydrv->handle_interrupt; } /** diff --git a/include/linux/phy.h b/include/linux/phy.h index 8849a00a093f..381a95732b6a 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -743,18 +743,11 @@ struct phy_driver { /** @read_status: Determines the negotiated speed and duplex */ int (*read_status)(struct phy_device *phydev); - /** @ack_interrupt: Clears any pending interrupts */ - int (*ack_interrupt)(struct phy_device *phydev); - - /** @config_intr: Enables or disables interrupts */ - int (*config_intr)(struct phy_device *phydev); - - /** - * @did_interrupt: Checks if the PHY generated an interrupt. - * For multi-PHY devices with shared PHY interrupt pin - * Set interrupt bits have to be cleared. + /** @config_intr: Enables or disables interrupts. + * It should also clear any pending interrupts prior to enabling the + * IRQs and after disabling them. */ - int (*did_interrupt)(struct phy_device *phydev); + int (*config_intr)(struct phy_device *phydev); /** @handle_interrupt: Override default interrupt handling */ irqreturn_t (*handle_interrupt)(struct phy_device *phydev); @@ -1487,10 +1480,6 @@ static inline int genphy_config_aneg(struct phy_device *phydev) return __genphy_config_aneg(phydev, false); } -static inline int genphy_no_ack_interrupt(struct phy_device *phydev) -{ - return 0; -} static inline int genphy_no_config_intr(struct phy_device *phydev) { return 0;