From patchwork Sun Nov 1 12:50:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 315897 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B8EBDC2D0A3 for ; Sun, 1 Nov 2020 12:52:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7C8DD2085B for ; Sun, 1 Nov 2020 12:52:30 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ET9UHHLD" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726710AbgKAMwX (ORCPT ); Sun, 1 Nov 2020 07:52:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38658 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgKAMwV (ORCPT ); Sun, 1 Nov 2020 07:52:21 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E79DBC0617A6; Sun, 1 Nov 2020 04:52:20 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id p93so11345018edd.7; Sun, 01 Nov 2020 04:52:20 -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=ITnQoREiD0R8hOb4gJjCxvyKcXTKP7bB6oFRcdeycc0=; b=ET9UHHLDha/cqMvEKHzV/K07aL4AX0NqK+hY7e9676uF9nW+/9zvQB3U7gW7/XXj1J zBAJ4stwnt0X6Auj7HfpGFfO30LalUJwxQ7Dd8KeAbqNjwKF7dFlAA2aYsC28VwnkhfU TuKajePEN47Kpcmpy0Rq+nV9/li8Xnxaussx74TtDR8yZICHi7h+DM79bkCruecK+ba1 IZNX/nHvRubeUoM9zm7QN4frBtcHn0IvSm6par4o91HVy+qJFQB8hKrMGl4J6TlqpFs9 46RWHAsZKt5yhTBxB9mGlIH2bH4UXcwwEO4av2XPRwWtdzrAfA61stbQk9SbG9kLw6qT bY8A== 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=ITnQoREiD0R8hOb4gJjCxvyKcXTKP7bB6oFRcdeycc0=; b=QeGoh0nrz14IK2PhNlZSJCb49cDOofv6yfUgfWQnUImb56lobJY3Yyy1Me8j/a2Ggn nRGi8d055Blm1Lfz/Bvx1/gm6sT1WKI+koKJ5tr2McuLlIJ4ttSy3SqfNqrqgyZt2/10 FHvIB2X2kfHESLlc/cTR0xWCJ2qieq8RFf4Z0zxijGSDSm8TANX1fk2jH39X1f5DL6Zn W+qNGVVEixtj6xXRiwLfOHISfPl2At9uezSo1Emg9/ANuEwMzk06uIvzvlfY6Bht0ziO tuhpwYwGVh5Iq7CFPk2erM7+MAa8xlBm7xKvrzHg4G/G5x77ilOAU9DTQFvfu0xtI2s5 lDLA== X-Gm-Message-State: AOAM530GnxOaFawuiHjtmYR0LP0Klw6eGn7Ha/WH4RpfqfMJUnw5Ftv9 i1oyirsJaHuiQWLFxSJrmU0= X-Google-Smtp-Source: ABdhPJxNVwjkameOvNKYxN7cZ5wwCM5rQd6pEgz/4WXk12m7mBmxj6CT764N0tKbBgg8E3z0DEPBxw== X-Received: by 2002:a50:e149:: with SMTP id i9mr12171491edl.56.1604235139679; Sun, 01 Nov 2020 04:52:19 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:19 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Alexandru Ardelean , Andre Edich , Antoine Tenart , Baruch Siach , Christophe Leroy , Dan Murphy , Divya Koppera , Hauke Mehrtens , Jerome Brunet , Kavya Sree Kotagiri , Linus Walleij , Marco Felsch , Marek Vasut , Martin Blumenstingl , Mathias Kresin , Maxim Kochetkov , Michael Walle , Neil Armstrong , Nisar Sayed , Oleksij Rempel , Philippe Schenker , Willy Liu , Yuiko Oshino Subject: [PATCH net-next v2 01/19] net: phy: export phy_error and phy_trigger_machine Date: Sun, 1 Nov 2020 14:50:56 +0200 Message-Id: <20201101125114.1316879-2-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei These functions are currently used by phy_interrupt() to either signal an error condition or to trigger the link state machine. In an attempt to actually support shared PHY IRQs, export these two functions so that the actual PHY drivers can use them. Cc: Alexandru Ardelean Cc: Andre Edich Cc: Antoine Tenart Cc: Baruch Siach Cc: Christophe Leroy Cc: Dan Murphy Cc: Divya Koppera Cc: Florian Fainelli Cc: Hauke Mehrtens Cc: Heiner Kallweit Cc: Jerome Brunet Cc: Kavya Sree Kotagiri Cc: Linus Walleij Cc: Marco Felsch Cc: Marek Vasut Cc: Martin Blumenstingl Cc: Mathias Kresin Cc: Maxim Kochetkov Cc: Michael Walle Cc: Neil Armstrong Cc: Nisar Sayed Cc: Oleksij Rempel Cc: Philippe Schenker Cc: Willy Liu Cc: Yuiko Oshino Signed-off-by: Ioana Ciornei --- Changes in v2: - none drivers/net/phy/phy.c | 6 ++++-- include/linux/phy.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/drivers/net/phy/phy.c b/drivers/net/phy/phy.c index 35525a671400..477bdf2f94df 100644 --- a/drivers/net/phy/phy.c +++ b/drivers/net/phy/phy.c @@ -493,10 +493,11 @@ EXPORT_SYMBOL(phy_queue_state_machine); * * @phydev: the phy_device struct */ -static void phy_trigger_machine(struct phy_device *phydev) +void phy_trigger_machine(struct phy_device *phydev) { phy_queue_state_machine(phydev, 0); } +EXPORT_SYMBOL(phy_trigger_machine); static void phy_abort_cable_test(struct phy_device *phydev) { @@ -924,7 +925,7 @@ void phy_stop_machine(struct phy_device *phydev) * Must not be called from interrupt context, or while the * phydev->lock is held. */ -static void phy_error(struct phy_device *phydev) +void phy_error(struct phy_device *phydev) { WARN_ON(1); @@ -934,6 +935,7 @@ static void phy_error(struct phy_device *phydev) phy_trigger_machine(phydev); } +EXPORT_SYMBOL(phy_error); /** * phy_disable_interrupts - Disable the PHY interrupts from the PHY side diff --git a/include/linux/phy.h b/include/linux/phy.h index eb3cb1a98b45..566b39f6cd64 100644 --- a/include/linux/phy.h +++ b/include/linux/phy.h @@ -1570,8 +1570,10 @@ void phy_drivers_unregister(struct phy_driver *drv, int n); int phy_driver_register(struct phy_driver *new_driver, struct module *owner); int phy_drivers_register(struct phy_driver *new_driver, int n, struct module *owner); +void phy_error(struct phy_device *phydev); void phy_state_machine(struct work_struct *work); void phy_queue_state_machine(struct phy_device *phydev, unsigned long jiffies); +void phy_trigger_machine(struct phy_device *phydev); void phy_mac_interrupt(struct phy_device *phydev); void phy_start_machine(struct phy_device *phydev); void phy_stop_machine(struct phy_device *phydev); From patchwork Sun Nov 1 12:50:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 315889 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C3D36C2D0A3 for ; Sun, 1 Nov 2020 12:55:01 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 78DA920719 for ; Sun, 1 Nov 2020 12:55:01 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="lXMiEldW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726753AbgKAMw1 (ORCPT ); Sun, 1 Nov 2020 07:52:27 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38668 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbgKAMwZ (ORCPT ); Sun, 1 Nov 2020 07:52:25 -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 4E894C0617A6; Sun, 1 Nov 2020 04:52:23 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id w25so11396661edx.2; Sun, 01 Nov 2020 04:52:23 -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=9GApglWVha/Wm6ZpEPj/3soIrOPKEJEBr7djBJ0S7Zc=; b=lXMiEldW7rgzDtLCQps8xDZ8V3/IUgPnOpcIX9vnQuZk05RQFZmhfMATZJAN+SH6Ag iTBzjB6PiiaW2lFDqG84O7ZFSkss58Uzv8RGCBg+J6mc1Baq0hsg4iph5p7jmzPE30q9 mJouEUfcjA1j31k3MC7DgL3jhrzpuLRjVbCFwcDDk4SczwT+4RlrO23OOe2GNOblmibX y7aLTe+a4kpGi/Hc+/RIX8l8YRH/MQuyR+F4RMaykcC8jC4nL+Ze4YD5gwt0CHH3pnxH l2sqrvn6yMwITWzi87OZGMLW1QcCQnJvyjuNUl2sZz5w/UPazI0yNJi62rD9jN6eswfw FhTQ== 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=9GApglWVha/Wm6ZpEPj/3soIrOPKEJEBr7djBJ0S7Zc=; b=ReDyl4qnAGZ+yYCZrRo954pl0i4bcPjl6YaHEWWiY4jK9t/I7iHZlz7O+OryLDpE8Y hBwGtrB7wxDqaHZ9AUJkYPn0wIyEkUnsYktk6AWOmnsc0vuzm5xDwsOuq1W0G0CkZ7CI Nl2oO7BAKOEViFG+v03v7pZezKx1cT3OkgqLrQpWTeRLLCpMWVWhe03H4UOZP58TlALM E0i9urebtn5a1uUn0Hlm2NZB+cnYrD9E2Yun15zvHuuorPvBx1283McQ7ySLaSanZJUt jeXQ/YO+woTohMc7dQb7CKIvc0S6Vu5iFTyePmB0YS0goMw3HfFCQAnMklVBwcDi7qyj j7gw== X-Gm-Message-State: AOAM530jAmmVOsxCpL+fvN2wi0LeBltxKppS7IvqdeZdAyzoNxkKq12z YBh9XoprX0ZI5IIIRMw5Mo8= X-Google-Smtp-Source: ABdhPJz/pCpsWrsyO2fhSFmCi48xw34OkxhYxZ/bv7m/tfwSOzlmBh8b3HYZyzXH0dmXTT0NkNdMFg== X-Received: by 2002:a50:fd99:: with SMTP id o25mr11355025edt.6.1604235142065; Sun, 01 Nov 2020 04:52:22 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:21 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Alexandru Ardelean , Andre Edich , Antoine Tenart , Baruch Siach , Christophe Leroy , Dan Murphy , Divya Koppera , Hauke Mehrtens , Jerome Brunet , Kavya Sree Kotagiri , Linus Walleij , Marco Felsch , Marek Vasut , Martin Blumenstingl , Mathias Kresin , Maxim Kochetkov , Michael Walle , Neil Armstrong , Nisar Sayed , Oleksij Rempel , Philippe Schenker , Willy Liu , Yuiko Oshino Subject: [PATCH net-next v2 02/19] net: phy: add a shutdown procedure Date: Sun, 1 Nov 2020 14:50:57 +0200 Message-Id: <20201101125114.1316879-3-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei In case of a board which uses a shared IRQ we can easily end up with an IRQ storm after a forced reboot. For example, a 'reboot -f' will trigger a call to the .shutdown() callbacks of all devices. Because phylib does not implement that hook, the PHY is not quiesced, thus it can very well leave its IRQ enabled. At the next boot, if that IRQ line is found asserted by the first PHY driver that uses it, but _before_ the driver that is _actually_ keeping the shared IRQ asserted is probed, the IRQ is not going to be acknowledged, thus it will keep being fired preventing the boot process of the kernel to continue. This is even worse when the second PHY driver is a module. To fix this, implement the .shutdown() callback and disable the interrupts if these are used. Note that we are still susceptible to IRQ storms if the previous kernel exited with a panic or if the bootloader left the shared IRQ active, but there is absolutely nothing we can do about these cases. Cc: Alexandru Ardelean Cc: Andre Edich Cc: Antoine Tenart Cc: Baruch Siach Cc: Christophe Leroy Cc: Dan Murphy Cc: Divya Koppera Cc: Florian Fainelli Cc: Hauke Mehrtens Cc: Heiner Kallweit Cc: Jerome Brunet Cc: Kavya Sree Kotagiri Cc: Linus Walleij Cc: Marco Felsch Cc: Marek Vasut Cc: Martin Blumenstingl Cc: Mathias Kresin Cc: Maxim Kochetkov Cc: Michael Walle Cc: Neil Armstrong Cc: Nisar Sayed Cc: Oleksij Rempel Cc: Philippe Schenker Cc: Willy Liu Cc: Yuiko Oshino Signed-off-by: Ioana Ciornei --- Changes in v2: - none drivers/net/phy/phy_device.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 5dab6be6fc38..413a0a2c5d51 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2947,6 +2947,13 @@ static int phy_remove(struct device *dev) return 0; } +static void phy_shutdown(struct device *dev) +{ + struct phy_device *phydev = to_phy_device(dev); + + phy_disable_interrupts(phydev); +} + /** * phy_driver_register - register a phy_driver with the PHY layer * @new_driver: new phy_driver to register @@ -2970,6 +2977,7 @@ int phy_driver_register(struct phy_driver *new_driver, struct module *owner) new_driver->mdiodrv.driver.bus = &mdio_bus_type; new_driver->mdiodrv.driver.probe = phy_probe; new_driver->mdiodrv.driver.remove = phy_remove; + new_driver->mdiodrv.driver.shutdown = phy_shutdown; new_driver->mdiodrv.driver.owner = owner; new_driver->mdiodrv.driver.probe_type = PROBE_FORCE_SYNCHRONOUS; From patchwork Sun Nov 1 12:50:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 315888 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 65422C4741F for ; Sun, 1 Nov 2020 12:55:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3095520719 for ; Sun, 1 Nov 2020 12:55:19 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="rNoYRpHi" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726999AbgKAMzR (ORCPT ); Sun, 1 Nov 2020 07:55:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38674 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726670AbgKAMw0 (ORCPT ); Sun, 1 Nov 2020 07:52:26 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C4B8AC061A04; Sun, 1 Nov 2020 04:52:25 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id v4so11399871edi.0; Sun, 01 Nov 2020 04:52:25 -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=n5W+ROLvWRCB6lTVb9DWGVA66kjGHAbhcZbQXXZedOg=; b=rNoYRpHigSkIPHKK39F4fwHBL8HBSpM4cGUhzwwZRnq+uPy9cA93A5uOuQL7Z/ykLS JJkHT5zeOtOr63pmuhVb4TGCpJhIM2XN2hm0eEvQqTACLqGBLthyVxj/eFwFe1/JbpBI 58c0QO4QQUbPqbZgkFF7ELbQeffSt1gNt8+eMcprPZkJXjgKPfbyzh7wQcMBtt8Dofpc aE020KmdbIVrSBqiKKAZcx5YrAf7CWrh0ESQaNuQi3p6JijFoAd6mn2hx47jyi5lndH5 MnmRhbzDNBolFBXGmhpzL1QI+a3ujUoTYKX3JeQNHgXHfyQybA/Oh6icQVyt4tII2gtb ic3g== 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=n5W+ROLvWRCB6lTVb9DWGVA66kjGHAbhcZbQXXZedOg=; b=Q1eiXgezzgjqDidhRx2LQ3we/ckmDRfJBPcenMyXRqwONxQbSzsj84MgoZhQc/5/WM Yw3QqX5WLaQXiyNNUbACiol3LhMRzSY80JoJIvkRHJ5C38o3A/7Q3Fz+VCjys1YIC8kJ m0zI2+PieBU6w4wT50akLBxRrnzzQPH13ZNlztCmOVcgCxPuOGPDnVmWytBgPjuSnoqM iEgubcJs8egoMbCJ4/4yQaDBRkHP04jil4zE5JHvxXmrw36WnrESEDzS4SyzRNXrhog4 r3+Wa/O9g5Rl2Lq4+SwrRA3aYrWkgV98RXHwXnrPU7BVocLewonAuap40ZKOOjly1mvV kD/A== X-Gm-Message-State: AOAM530egoVxNlWKPNkVv/LL5oEN0eiWvZq1td8o8gId/IIym/el/Wav LxXlVuU1PQ8EuIVaOjBQI9o= X-Google-Smtp-Source: ABdhPJzAYNkrYyPQUNa/4pLKbBoV50SqCed2+gaF+KvDzxLnOQcFSGxfLD8M1LjHo5Axh5MLHGvKiA== X-Received: by 2002:aa7:d1d5:: with SMTP id g21mr12071763edp.348.1604235144548; Sun, 01 Nov 2020 04:52:24 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:23 -0800 (PST) From: Ioana Ciornei To: Andrew Lunn , Heiner Kallweit , Russell King , Florian Fainelli , Jakub Kicinski , netdev@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Ioana Ciornei , Alexandru Ardelean , Andre Edich , Antoine Tenart , Baruch Siach , Christophe Leroy , Dan Murphy , Divya Koppera , Hauke Mehrtens , Jerome Brunet , Kavya Sree Kotagiri , Linus Walleij , Marco Felsch , Marek Vasut , Martin Blumenstingl , Mathias Kresin , Maxim Kochetkov , Michael Walle , Neil Armstrong , Nisar Sayed , Oleksij Rempel , Philippe Schenker , Willy Liu , Yuiko Oshino Subject: [PATCH net-next v2 03/19] net: phy: make .ack_interrupt() optional Date: Sun, 1 Nov 2020 14:50:58 +0200 Message-Id: <20201101125114.1316879-4-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-1-ciorneiioana@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org From: Ioana Ciornei As a first step into making phylib and all PHY drivers to actually have support for shared IRQs, make the .ack_interrupt() callback optional. After all drivers have been moved to implement the generic interrupt handle, the phy_drv_supports_irq() check will be changed again to only require the .handle_interrupts() callback. Cc: Alexandru Ardelean Cc: Andre Edich Cc: Antoine Tenart Cc: Baruch Siach Cc: Christophe Leroy Cc: Dan Murphy Cc: Divya Koppera Cc: Florian Fainelli Cc: Hauke Mehrtens Cc: Heiner Kallweit Cc: Jerome Brunet Cc: Kavya Sree Kotagiri Cc: Linus Walleij Cc: Marco Felsch Cc: Marek Vasut Cc: Martin Blumenstingl Cc: Mathias Kresin Cc: Maxim Kochetkov Cc: Michael Walle Cc: Neil Armstrong Cc: Nisar Sayed Cc: Oleksij Rempel Cc: Philippe Schenker Cc: Willy Liu Cc: Yuiko Oshino Signed-off-by: Ioana Ciornei --- Changes in v2: - none drivers/net/phy/phy_device.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c index 413a0a2c5d51..f54f483d7fd6 100644 --- a/drivers/net/phy/phy_device.c +++ b/drivers/net/phy/phy_device.c @@ -2815,7 +2815,7 @@ EXPORT_SYMBOL(phy_get_internal_delay); static bool phy_drv_supports_irq(struct phy_driver *phydrv) { - return phydrv->config_intr && phydrv->ack_interrupt; + return phydrv->config_intr && (phydrv->ack_interrupt || phydrv->handle_interrupt); } /** From patchwork Sun Nov 1 12:50:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ioana Ciornei X-Patchwork-Id: 315896 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 74DCEC2D0A3 for ; Sun, 1 Nov 2020 12:52:36 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3993A20756 for ; Sun, 1 Nov 2020 12:52:36 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="kgPmBeJM" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726788AbgKAMwe (ORCPT ); Sun, 1 Nov 2020 07:52:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38682 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726496AbgKAMw1 (ORCPT ); Sun, 1 Nov 2020 07:52:27 -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 49A4AC0617A6; Sun, 1 Nov 2020 04:52:27 -0800 (PST) Received: by mail-ej1-x641.google.com with SMTP id o9so12738088ejg.1; Sun, 01 Nov 2020 04:52:27 -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=zAr2ZpROTUIh8AyndHrw65H5Tjuc6RrJxRTm7QHUC9c=; b=kgPmBeJMeW0hJeo7er3LfchxAFxmGI/4Yb5AzlL6EpKM2mzcMolBfkLTL2cAdhv9IB pAOD7+6KO6FpijBMsw+jcwkJ9a2WTwqkASBBodgHog9Sf3+rOEYdrlb9AxJKSJttSgLL R/qfDNgYc42NjiC+NXj5tkTj//tWpvrUuWvOeGZDV839J6/PP20mII9dFzFOugUbrLT4 Jh8fvAKlmRRfGP5JMrLd4VRprUvYQ7P7AEGNyhzWsxoINfLtveY3xEg/geN6siEsX02z Js8PhPwtWpQCB+maBIYs9V2mtBXR7gIB/zvdKTOyzYgaQjqnijnLYNacCQCmcrTleyi6 DG4Q== 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=zAr2ZpROTUIh8AyndHrw65H5Tjuc6RrJxRTm7QHUC9c=; b=QNCKS0smjgrgjNoHIoQjMbbtFeQudOM6dxlwD4lCXpX/jy9uMjfOBmEdujCEvi7SPs IHENWpryS+9QufK6Hn2W3D6b9kyQZYOoouN2sIJ0ktJzojcz6lM12NiFPqa+Q7lHcFDs 8MUrL74ZqHTCfm/6WZkXS6WINboRlhkys5LhZi/jRW5V25uVkFR3Ewx571w/typZEbHd pBblEJaOHTyMkDAVcgddmHqjHq17FNPFB4OnYw2Ov+2s1rP84nN7VQQ0r1YsfNT6u/YP lSA1CB7wSl6xefWCn59E1GlQw6cRDVDl7zPPrbCivW77wT2u2zynmVL22cq+w2A80JCy yCAg== X-Gm-Message-State: AOAM533Zig5x/PJSjM2r2YaTSQrVC4Buk7UmCpG4Xo2IyQHARGkHEKhE jy/wA+rRwVm2b0LBb/ACP6c= X-Google-Smtp-Source: ABdhPJzryKXM/CZpRt22sJbREQXlV5y8WsJJxu3+mXkcAAzZAGZH5yM6kvF0BndBVI5VbsWm75/SVg== X-Received: by 2002:a17:906:260a:: with SMTP id h10mr4506040ejc.159.1604235146026; Sun, 01 Nov 2020 04:52:26 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:25 -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 , Oleksij Rempel , Michael Walle Subject: [PATCH net-next v2 04/19] net: phy: at803x: implement generic .handle_interrupt() callback Date: Sun, 1 Nov 2020 14:50:59 +0200 Message-Id: <20201101125114.1316879-5-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-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: Oleksij Rempel Cc: Michael Walle Signed-off-by: Ioana Ciornei Tested-by: Oleksij Rempel --- Changes in v2: - adjust .handle_interrupt() so that we only take into account the enabled IRQs. drivers/net/phy/at803x.c | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/drivers/net/phy/at803x.c b/drivers/net/phy/at803x.c index ed601a7e46a0..c7f91934cf82 100644 --- a/drivers/net/phy/at803x.c +++ b/drivers/net/phy/at803x.c @@ -628,6 +628,32 @@ static int at803x_config_intr(struct phy_device *phydev) return err; } +static irqreturn_t at803x_handle_interrupt(struct phy_device *phydev) +{ + int irq_status, int_enabled; + + irq_status = phy_read(phydev, AT803X_INTR_STATUS); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + /* Read the current enabled interrupts */ + int_enabled = phy_read(phydev, AT803X_INTR_ENABLE); + if (int_enabled < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + /* See if this was one of our enabled interrupts */ + if (!(irq_status & int_enabled)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static void at803x_link_change_notify(struct phy_device *phydev) { /* @@ -1064,6 +1090,7 @@ static struct phy_driver at803x_driver[] = { .read_status = at803x_read_status, .ack_interrupt = at803x_ack_interrupt, .config_intr = at803x_config_intr, + .handle_interrupt = at803x_handle_interrupt, .get_tunable = at803x_get_tunable, .set_tunable = at803x_set_tunable, .cable_test_start = at803x_cable_test_start, @@ -1084,6 +1111,7 @@ static struct phy_driver at803x_driver[] = { /* PHY_BASIC_FEATURES */ .ack_interrupt = at803x_ack_interrupt, .config_intr = at803x_config_intr, + .handle_interrupt = at803x_handle_interrupt, }, { /* Qualcomm Atheros AR8031/AR8033 */ PHY_ID_MATCH_EXACT(ATH8031_PHY_ID), @@ -1102,6 +1130,7 @@ static struct phy_driver at803x_driver[] = { .aneg_done = at803x_aneg_done, .ack_interrupt = &at803x_ack_interrupt, .config_intr = &at803x_config_intr, + .handle_interrupt = at803x_handle_interrupt, .get_tunable = at803x_get_tunable, .set_tunable = at803x_set_tunable, .cable_test_start = at803x_cable_test_start, @@ -1122,6 +1151,7 @@ static struct phy_driver at803x_driver[] = { /* PHY_BASIC_FEATURES */ .ack_interrupt = at803x_ack_interrupt, .config_intr = at803x_config_intr, + .handle_interrupt = at803x_handle_interrupt, .cable_test_start = at803x_cable_test_start, .cable_test_get_status = at803x_cable_test_get_status, }, { @@ -1134,6 +1164,7 @@ static struct phy_driver at803x_driver[] = { /* PHY_BASIC_FEATURES */ .ack_interrupt = &at803x_ack_interrupt, .config_intr = &at803x_config_intr, + .handle_interrupt = at803x_handle_interrupt, .cable_test_start = at803x_cable_test_start, .cable_test_get_status = at803x_cable_test_get_status, .read_status = at803x_read_status, From patchwork Sun Nov 1 12:51: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: 315895 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 86441C2D0A3 for ; Sun, 1 Nov 2020 12:52:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 44CD020719 for ; Sun, 1 Nov 2020 12:52:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="S1CUQxDX" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726997AbgKAMwr (ORCPT ); Sun, 1 Nov 2020 07:52:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38706 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726723AbgKAMwe (ORCPT ); Sun, 1 Nov 2020 07:52:34 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 92A14C061A04; Sun, 1 Nov 2020 04:52:32 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id k9so11382279edo.5; Sun, 01 Nov 2020 04:52:32 -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=EfqQt3242lrk5/PPkfKYwkypm+y6YbFO8gCqknLDny4=; b=S1CUQxDXVhPG+xo7ugNxYf1BMflN4657p8vy6Zv68iYOO3+RBdMcL+cAQqUdf3UU+S UokfHM1z85PBomTiPw6CM1wblZ7WhJ05JiuMJjQPdap2uaKEFH3xQR3zcX23xnHg+Mwp 5BjzB/si9BK87BBKngAnqKitSqQ1eSW7IaEgOQwi1vK1L80be7iZu29qkPabKIkAlOOA rTnGIwTDCsmZXBsjq4kECenfueFebkanL406GnwMhKYCQOOXvqSHeAhwhJ5tH1DdGDDS taJll1771hbIZn2Sa/sd59CZ/tlKboPfArgU/0vl8PvF5LAFfPnkt1Cdg7vf+cnsGvgI kRPg== 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=EfqQt3242lrk5/PPkfKYwkypm+y6YbFO8gCqknLDny4=; b=SYtLl8L/dJESv1OcUh7E5ZLXziBVWpDUkTGK++Pq+LQarlCqMgv09kR1HhbYpdXTuw 5qXUSGUvBJxOndn+gdrNFtPPaii2cIQFCpY8KSOH1dglSjbSnGrIptud3CK3YRaIgwFS ZHhOMdojUe6/ZA3Mxwz12q+1oU3R9cmPpzr83+G8tOJSYNm3rAQZQUzcDxpjSWBiccwR hK0ryW3kI/BxMuGIKxXyuUVAJdZLXzB7gszPByD6APvEwwqvj0hmYxx3QNNgr+WuAUGj dFPICTG3EU8A++kADSsx2MN9YXskj3m6re6MNTF64s2EmiBSrmmrqSL3gFdIPb738qBx G+uw== X-Gm-Message-State: AOAM533CGu5qBw3XRyzLIN3amcYDP8v0PW8N0GGkKRPcATvEjRFw2hDX YbX7xGNNxZ9RBdrTbvCvUM0= X-Google-Smtp-Source: ABdhPJyVQrgdG65YC/SKuy2KlP7/dw6SZ/JTTFlC5wNE8SmpV7lTpTEybJiIF2N3RcRtJQVGpBZt7w== X-Received: by 2002:a50:e705:: with SMTP id a5mr11962752edn.29.1604235151304; Sun, 01 Nov 2020 04:52:31 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:30 -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 , Antoine Tenart Subject: [PATCH net-next v2 08/19] net: phy: mscc: remove the use of .ack_interrupt() Date: Sun, 1 Nov 2020 14:51:03 +0200 Message-Id: <20201101125114.1316879-9-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-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: Antoine Tenart Signed-off-by: Ioana Ciornei Tested-by: Vladimir Oltean # VSC8514 --- Changes in v2: - none drivers/net/phy/mscc/mscc_main.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/mscc/mscc_main.c b/drivers/net/phy/mscc/mscc_main.c index 48883730bf6f..2f2157e3deab 100644 --- a/drivers/net/phy/mscc/mscc_main.c +++ b/drivers/net/phy/mscc/mscc_main.c @@ -1923,6 +1923,10 @@ static int vsc85xx_config_intr(struct phy_device *phydev) int rc; if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + rc = vsc85xx_ack_interrupt(phydev); + if (rc) + return rc; + vsc8584_config_macsec_intr(phydev); vsc8584_config_ts_intr(phydev); @@ -1933,6 +1937,10 @@ static int vsc85xx_config_intr(struct phy_device *phydev) if (rc < 0) return rc; rc = phy_read(phydev, MII_VSC85XX_INT_STATUS); + if (rc < 0) + return rc; + + rc = vsc85xx_ack_interrupt(phydev); } return rc; @@ -2338,7 +2346,6 @@ static struct phy_driver vsc85xx_driver[] = { .aneg_done = &genphy_aneg_done, .read_status = &vsc85xx_read_status, .handle_interrupt = &vsc8584_handle_interrupt, - .ack_interrupt = &vsc85xx_ack_interrupt, .config_intr = &vsc85xx_config_intr, .suspend = &genphy_suspend, .resume = &genphy_resume, @@ -2389,7 +2396,6 @@ static struct phy_driver vsc85xx_driver[] = { .aneg_done = &genphy_aneg_done, .read_status = &vsc85xx_read_status, .handle_interrupt = &vsc8584_handle_interrupt, - .ack_interrupt = &vsc85xx_ack_interrupt, .config_intr = &vsc85xx_config_intr, .suspend = &genphy_suspend, .resume = &genphy_resume, @@ -2413,7 +2419,6 @@ static struct phy_driver vsc85xx_driver[] = { .aneg_done = &genphy_aneg_done, .read_status = &vsc85xx_read_status, .handle_interrupt = &vsc8584_handle_interrupt, - .ack_interrupt = &vsc85xx_ack_interrupt, .config_intr = &vsc85xx_config_intr, .suspend = &genphy_suspend, .resume = &genphy_resume, @@ -2437,7 +2442,6 @@ static struct phy_driver vsc85xx_driver[] = { .aneg_done = &genphy_aneg_done, .read_status = &vsc85xx_read_status, .handle_interrupt = &vsc8584_handle_interrupt, - .ack_interrupt = &vsc85xx_ack_interrupt, .config_intr = &vsc85xx_config_intr, .suspend = &genphy_suspend, .resume = &genphy_resume, From patchwork Sun Nov 1 12:51: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: 315890 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 72B7FC55178 for ; Sun, 1 Nov 2020 12:54:45 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3341120719 for ; Sun, 1 Nov 2020 12:54:45 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FjEXTGrv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726754AbgKAMym (ORCPT ); Sun, 1 Nov 2020 07:54:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38702 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726832AbgKAMwe (ORCPT ); Sun, 1 Nov 2020 07:52:34 -0500 Received: from mail-ed1-x541.google.com (mail-ed1-x541.google.com [IPv6:2a00:1450:4864:20::541]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F24A7C0617A6; Sun, 1 Nov 2020 04:52:33 -0800 (PST) Received: by mail-ed1-x541.google.com with SMTP id b9so1151717edu.10; Sun, 01 Nov 2020 04:52:33 -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=0TfXwEdEcM2gE+zJ4+TFD7P1Hji79lCV+K46mLk+s54=; b=FjEXTGrv6H6vXnxI6hbEPjtiwuN3cBJy6HX4dnElAQOtJbkkyCDXHjflHI5o6k7dGV LAcJtCbXUyCqRbI+zztnQ00zThThN+H5HdmNFxnCW3xGm0SkXgJDUKg36Uy82RygCrBQ qc2BUjINPJ4KuDTn+WuRWRlcUq/iBJVx3mZghYb87BaJMSIlkHcaI3zb8PfYnJnZdbvf L0x4BSHsnq23jVeGLgZCfzEgBIF/Tq9I/M4wfYt83qWDxqm5ZtT1SqWMHqOdUmkmxioC U9snPE1upUiZQmWFtr+FrTg/j3Yuh44W2F4+tiAbB24vaWOyN3mnaFThKuUAkGqmfgKN LSwg== 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=0TfXwEdEcM2gE+zJ4+TFD7P1Hji79lCV+K46mLk+s54=; b=cY7KWHZjqSoIjKktpGo6QQOcpcVcsXkLle6O3B9m8RvG0kWMFcTeKIx4qwkatizXWM oXscWUKtdkzGgLl+TCqkk9NBAKJq2ZirPMZemxg8kJuh8m0jL0ZTriYXXR5e3zWJWfZc wTJjDEEsaC8xGkvd/wvDLb80pKNnptzdfOMOLpwX44ojSU8hUEf+j1KH98jdLZv3OQre w2+XebKrtThNplZtXS5DqAnnjk2kerXNxXZvtysz9eW4bFSJMWICJLQuawzVWZ9Dl4gv 6qTdBDAfym85ZpGd0DwixHBWFLUdijQVhTk6sNHzgkAX7kJ8AVvh8tfeuysm3ii47Avr H+/g== X-Gm-Message-State: AOAM533RGNVChfuEzaMIGwp39dHf/TVKIKSO3cj6Csy6F5M8WOkDWFJI kZf6s66uyxF7FykdP8tWARLuv02zHDLfLN+j X-Google-Smtp-Source: ABdhPJwCMOrosMN7EwS89TeufiD5JGPz0QCOnhVMAWMkNL08EiuxY00LABuXGnILZoXefowNu0l0zQ== X-Received: by 2002:aa7:cb1a:: with SMTP id s26mr11842701edt.219.1604235152733; Sun, 01 Nov 2020 04:52:32 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:32 -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 v2 09/19] net: phy: aquantia: implement generic .handle_interrupt() callback Date: Sun, 1 Nov 2020 14:51:04 +0200 Message-Id: <20201101125114.1316879-10-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-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: Heiner Kallweit Signed-off-by: Ioana Ciornei --- Changes in v2: - adjust .handle_interrupt() so that we only take into account the enabled IRQs. drivers/net/phy/aquantia_main.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/drivers/net/phy/aquantia_main.c b/drivers/net/phy/aquantia_main.c index 41e7c1432497..17b33f0cb179 100644 --- a/drivers/net/phy/aquantia_main.c +++ b/drivers/net/phy/aquantia_main.c @@ -52,6 +52,7 @@ #define MDIO_AN_TX_VEND_INT_STATUS1_DOWNSHIFT BIT(1) #define MDIO_AN_TX_VEND_INT_STATUS2 0xcc01 +#define MDIO_AN_TX_VEND_INT_STATUS2_MASK BIT(0) #define MDIO_AN_TX_VEND_INT_MASK2 0xd401 #define MDIO_AN_TX_VEND_INT_MASK2_LINK BIT(0) @@ -270,6 +271,25 @@ static int aqr_ack_interrupt(struct phy_device *phydev) return (reg < 0) ? reg : 0; } +static irqreturn_t aqr_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read_mmd(phydev, MDIO_MMD_AN, + MDIO_AN_TX_VEND_INT_STATUS2); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & MDIO_AN_TX_VEND_INT_STATUS2_MASK)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int aqr_read_status(struct phy_device *phydev) { int val; @@ -585,6 +605,7 @@ static struct phy_driver aqr_driver[] = { .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, .ack_interrupt = aqr_ack_interrupt, + .handle_interrupt = aqr_handle_interrupt, .read_status = aqr_read_status, }, { @@ -593,6 +614,7 @@ static struct phy_driver aqr_driver[] = { .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, .ack_interrupt = aqr_ack_interrupt, + .handle_interrupt = aqr_handle_interrupt, .read_status = aqr_read_status, }, { @@ -601,6 +623,7 @@ static struct phy_driver aqr_driver[] = { .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, .ack_interrupt = aqr_ack_interrupt, + .handle_interrupt = aqr_handle_interrupt, .read_status = aqr_read_status, .suspend = aqr107_suspend, .resume = aqr107_resume, @@ -611,6 +634,7 @@ static struct phy_driver aqr_driver[] = { .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, .ack_interrupt = aqr_ack_interrupt, + .handle_interrupt = aqr_handle_interrupt, .read_status = aqr_read_status, }, { @@ -621,6 +645,7 @@ static struct phy_driver aqr_driver[] = { .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, .ack_interrupt = aqr_ack_interrupt, + .handle_interrupt = aqr_handle_interrupt, .read_status = aqr107_read_status, .get_tunable = aqr107_get_tunable, .set_tunable = aqr107_set_tunable, @@ -639,6 +664,7 @@ static struct phy_driver aqr_driver[] = { .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, .ack_interrupt = aqr_ack_interrupt, + .handle_interrupt = aqr_handle_interrupt, .read_status = aqr107_read_status, .get_tunable = aqr107_get_tunable, .set_tunable = aqr107_set_tunable, @@ -655,6 +681,7 @@ static struct phy_driver aqr_driver[] = { .config_aneg = aqr_config_aneg, .config_intr = aqr_config_intr, .ack_interrupt = aqr_ack_interrupt, + .handle_interrupt = aqr_handle_interrupt, .read_status = aqr_read_status, }, }; From patchwork Sun Nov 1 12:51: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: 315891 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0442DC55178 for ; Sun, 1 Nov 2020 12:54:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9ED4220719 for ; Sun, 1 Nov 2020 12:54:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="eCfQjOpR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727129AbgKAMy3 (ORCPT ); Sun, 1 Nov 2020 07:54:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38724 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726889AbgKAMwk (ORCPT ); Sun, 1 Nov 2020 07:52:40 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0A0C6C0617A6; Sun, 1 Nov 2020 04:52:38 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id p93so11345467edd.7; Sun, 01 Nov 2020 04:52:37 -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=Zw4rs+DFNR/S9FRYseki/k8zysIGgEtxoZqA3FOwSMk=; b=eCfQjOpRxgLX+uM/hBjFB2J9e0irz1THD71LDjg9KUfh2A/1Gn6u0+1QxZlvBRTG67 lzyPXqJIRpIAPWEjhrVQ/SmxWZt4NolQlfbBa+E898gYObkG3bVpNdEQTjW3MSBSdyS9 H8wFrmWledDuMrBoq6PHITNUfBxBDgemrHj6AGeLNsEifwW3JHzi2XbI3YjF6DnXhU23 f6iFbH/foDS1uIYy9irenDTzDj265XTYAZCHsMxP5mI0yaY9ghZQYrcx38qYF7NEno/d +RBY1ONxvbFBRPSJaP3z0Zv1EgaWKcORL2sMUwSOVhlNzCvX8OPmXigpIkc39O7uiGX1 nY4w== 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=Zw4rs+DFNR/S9FRYseki/k8zysIGgEtxoZqA3FOwSMk=; b=CY85BOOaLBpiA9BTzIre55mZEzTeuCOsS1sI727UR4Z9w2ubna7bis++GhR7upRFjL 8ALXP1bwW7najM3i7BheGWNjgQCyc3OZNBy1tAR/b9ftpYD9WRLESZz9x4OO0z8hrPGn kfiPpyrZIbQ91hrnebZmjagIxtJ/+q1GKVoaCwgxAMz2V2y0qOF3gm2lz/ScJdkdY1nr UkN6fWRsVgx8rVA+5E04+a7BT+Yk/n1C9cyheVTgqaIHOXT1v3zOd0LfeoZ4lOuwpnoD mTjXsHNzmxWSY5hjXySkMcB7sSW+fJwmW8bQ7cOuRAaxpYID9Pm/Pe7HmYFT/YaqU0m5 wDdg== X-Gm-Message-State: AOAM533/HiNFrtDnX6PZXAJBkNdd+sz6E7eJ4IRHb2rWBiVJs2K83RR+ R/x8O5Y/dOHLWqp+6m5hmL4= X-Google-Smtp-Source: ABdhPJwQShQbLCnBXavFMfeh+qYouFdGhjsc9piFLXudriKupWMzQCy7cbJ7oXb4zUEOgHm1z9CyWg== X-Received: by 2002:aa7:dc09:: with SMTP id b9mr778405edu.285.1604235156751; Sun, 01 Nov 2020 04:52:36 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:36 -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 , Michael Walle Subject: [PATCH net-next v2 12/19] net: phy: broadcom: remove use of ack_interrupt() Date: Sun, 1 Nov 2020 14:51:07 +0200 Message-Id: <20201101125114.1316879-13-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-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: Michael Walle Cc: Florian Fainelli Signed-off-by: Ioana Ciornei --- Changes in v2: - none drivers/net/phy/bcm-cygnus.c | 1 - drivers/net/phy/bcm-phy-lib.c | 18 ++++++++++++++---- drivers/net/phy/bcm54140.c | 20 +++++++++++++++----- drivers/net/phy/bcm63xx.c | 18 +++++++++++++----- drivers/net/phy/bcm87xx.c | 34 +++++++++++++--------------------- drivers/net/phy/broadcom.c | 34 +++++++++++++--------------------- 6 files changed, 68 insertions(+), 57 deletions(-) diff --git a/drivers/net/phy/bcm-cygnus.c b/drivers/net/phy/bcm-cygnus.c index a236e0b8d04d..da8f7cb41b44 100644 --- a/drivers/net/phy/bcm-cygnus.c +++ b/drivers/net/phy/bcm-cygnus.c @@ -256,7 +256,6 @@ static struct phy_driver bcm_cygnus_phy_driver[] = { .name = "Broadcom Cygnus PHY", /* PHY_GBIT_FEATURES */ .config_init = bcm_cygnus_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, .suspend = genphy_suspend, diff --git a/drivers/net/phy/bcm-phy-lib.c b/drivers/net/phy/bcm-phy-lib.c index c232fcfe0e20..53282a6d5928 100644 --- a/drivers/net/phy/bcm-phy-lib.c +++ b/drivers/net/phy/bcm-phy-lib.c @@ -181,18 +181,28 @@ EXPORT_SYMBOL_GPL(bcm_phy_ack_intr); int bcm_phy_config_intr(struct phy_device *phydev) { - int reg; + int reg, err; reg = phy_read(phydev, MII_BCM54XX_ECR); if (reg < 0) return reg; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = bcm_phy_ack_intr(phydev); + if (err) + return err; + reg &= ~MII_BCM54XX_ECR_IM; - else + err = phy_write(phydev, MII_BCM54XX_ECR, reg); + } else { reg |= MII_BCM54XX_ECR_IM; + err = phy_write(phydev, MII_BCM54XX_ECR, reg); + if (err) + return err; - return phy_write(phydev, MII_BCM54XX_ECR, reg); + err = bcm_phy_ack_intr(phydev); + } + return err; } EXPORT_SYMBOL_GPL(bcm_phy_config_intr); diff --git a/drivers/net/phy/bcm54140.c b/drivers/net/phy/bcm54140.c index 36c899a88c5d..d8f3024860dc 100644 --- a/drivers/net/phy/bcm54140.c +++ b/drivers/net/phy/bcm54140.c @@ -681,7 +681,7 @@ static int bcm54140_config_intr(struct phy_device *phydev) BCM54140_RDB_TOP_IMR_PORT0, BCM54140_RDB_TOP_IMR_PORT1, BCM54140_RDB_TOP_IMR_PORT2, BCM54140_RDB_TOP_IMR_PORT3, }; - int reg; + int reg, err; if (priv->port >= ARRAY_SIZE(port_to_imr_bit)) return -EINVAL; @@ -690,12 +690,23 @@ static int bcm54140_config_intr(struct phy_device *phydev) if (reg < 0) return reg; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = bcm54140_ack_intr(phydev); + if (err) + return err; + reg &= ~port_to_imr_bit[priv->port]; - else + err = bcm54140_base_write_rdb(phydev, BCM54140_RDB_TOP_IMR, reg); + } else { reg |= port_to_imr_bit[priv->port]; + err = bcm54140_base_write_rdb(phydev, BCM54140_RDB_TOP_IMR, reg); + if (err) + return err; + + err = bcm54140_ack_intr(phydev); + } - return bcm54140_base_write_rdb(phydev, BCM54140_RDB_TOP_IMR, reg); + return err; } static int bcm54140_get_downshift(struct phy_device *phydev, u8 *data) @@ -850,7 +861,6 @@ static struct phy_driver bcm54140_drivers[] = { .flags = PHY_POLL_CABLE_TEST, .features = PHY_GBIT_FEATURES, .config_init = bcm54140_config_init, - .ack_interrupt = bcm54140_ack_intr, .handle_interrupt = bcm54140_handle_interrupt, .config_intr = bcm54140_config_intr, .probe = bcm54140_probe, diff --git a/drivers/net/phy/bcm63xx.c b/drivers/net/phy/bcm63xx.c index 818c853b6638..0eb33be824f1 100644 --- a/drivers/net/phy/bcm63xx.c +++ b/drivers/net/phy/bcm63xx.c @@ -25,12 +25,22 @@ static int bcm63xx_config_intr(struct phy_device *phydev) if (reg < 0) return reg; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = bcm_phy_ack_intr(phydev); + if (err) + return err; + reg &= ~MII_BCM63XX_IR_GMASK; - else + err = phy_write(phydev, MII_BCM63XX_IR, reg); + } else { reg |= MII_BCM63XX_IR_GMASK; + err = phy_write(phydev, MII_BCM63XX_IR, reg); + if (err) + return err; + + err = bcm_phy_ack_intr(phydev); + } - err = phy_write(phydev, MII_BCM63XX_IR, reg); return err; } @@ -67,7 +77,6 @@ static struct phy_driver bcm63xx_driver[] = { /* PHY_BASIC_FEATURES */ .flags = PHY_IS_INTERNAL, .config_init = bcm63xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm63xx_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -78,7 +87,6 @@ static struct phy_driver bcm63xx_driver[] = { /* PHY_BASIC_FEATURES */ .flags = PHY_IS_INTERNAL, .config_init = bcm63xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm63xx_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, } }; diff --git a/drivers/net/phy/bcm87xx.c b/drivers/net/phy/bcm87xx.c index f20cfb05ef04..4ac8fd190e9d 100644 --- a/drivers/net/phy/bcm87xx.c +++ b/drivers/net/phy/bcm87xx.c @@ -144,12 +144,22 @@ static int bcm87xx_config_intr(struct phy_device *phydev) if (reg < 0) return reg; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = phy_read(phydev, BCM87XX_LASI_STATUS); + if (err) + return err; + reg |= 1; - else + err = phy_write(phydev, BCM87XX_LASI_CONTROL, reg); + } else { reg &= ~1; + err = phy_write(phydev, BCM87XX_LASI_CONTROL, reg); + if (err) + return err; + + err = phy_read(phydev, BCM87XX_LASI_STATUS); + } - err = phy_write(phydev, BCM87XX_LASI_CONTROL, reg); return err; } @@ -171,22 +181,6 @@ static irqreturn_t bcm87xx_handle_interrupt(struct phy_device *phydev) return IRQ_HANDLED; } -static int bcm87xx_ack_interrupt(struct phy_device *phydev) -{ - int reg; - - /* Reading the LASI status clears it. */ - reg = phy_read(phydev, BCM87XX_LASI_STATUS); - - if (reg < 0) { - phydev_err(phydev, - "Error: Read of BCM87XX_LASI_STATUS failed: %d\n", - reg); - return 0; - } - return (reg & 1) != 0; -} - static int bcm8706_match_phy_device(struct phy_device *phydev) { return phydev->c45_ids.device_ids[4] == PHY_ID_BCM8706; @@ -206,7 +200,6 @@ static struct phy_driver bcm87xx_driver[] = { .config_init = bcm87xx_config_init, .config_aneg = bcm87xx_config_aneg, .read_status = bcm87xx_read_status, - .ack_interrupt = bcm87xx_ack_interrupt, .config_intr = bcm87xx_config_intr, .handle_interrupt = bcm87xx_handle_interrupt, .match_phy_device = bcm8706_match_phy_device, @@ -218,7 +211,6 @@ static struct phy_driver bcm87xx_driver[] = { .config_init = bcm87xx_config_init, .config_aneg = bcm87xx_config_aneg, .read_status = bcm87xx_read_status, - .ack_interrupt = bcm87xx_ack_interrupt, .config_intr = bcm87xx_config_intr, .handle_interrupt = bcm87xx_handle_interrupt, .match_phy_device = bcm8727_match_phy_device, diff --git a/drivers/net/phy/broadcom.c b/drivers/net/phy/broadcom.c index 8bcdb94ef2fc..8a4ec3222168 100644 --- a/drivers/net/phy/broadcom.c +++ b/drivers/net/phy/broadcom.c @@ -634,12 +634,22 @@ static int brcm_fet_config_intr(struct phy_device *phydev) if (reg < 0) return reg; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = brcm_fet_ack_interrupt(phydev); + if (err) + return err; + reg &= ~MII_BRCM_FET_IR_MASK; - else + err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); + } else { reg |= MII_BRCM_FET_IR_MASK; + err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); + if (err) + return err; + + err = brcm_fet_ack_interrupt(phydev); + } - err = phy_write(phydev, MII_BRCM_FET_INTREG, reg); return err; } @@ -699,7 +709,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM5411", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -708,7 +717,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM5421", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -717,7 +725,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM54210E", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -726,7 +733,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM5461", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -735,7 +741,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM54612E", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -745,7 +750,6 @@ static struct phy_driver broadcom_drivers[] = { /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, .config_aneg = bcm54616s_config_aneg, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, .read_status = bcm54616s_read_status, @@ -756,7 +760,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM5464", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, .suspend = genphy_suspend, @@ -768,7 +771,6 @@ static struct phy_driver broadcom_drivers[] = { /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, .config_aneg = bcm5481_config_aneg, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -778,7 +780,6 @@ static struct phy_driver broadcom_drivers[] = { /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, .config_aneg = bcm5481_config_aneg, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, .suspend = genphy_suspend, @@ -790,7 +791,6 @@ static struct phy_driver broadcom_drivers[] = { /* PHY_GBIT_FEATURES */ .config_init = bcm54811_config_init, .config_aneg = bcm5481_config_aneg, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, .suspend = genphy_suspend, @@ -802,7 +802,6 @@ static struct phy_driver broadcom_drivers[] = { /* PHY_GBIT_FEATURES */ .config_init = bcm5482_config_init, .read_status = bcm5482_read_status, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -811,7 +810,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM50610", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -820,7 +818,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM50610M", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -829,7 +826,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM57780", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -838,7 +834,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCMAC131", /* PHY_BASIC_FEATURES */ .config_init = brcm_fet_config_init, - .ack_interrupt = brcm_fet_ack_interrupt, .config_intr = brcm_fet_config_intr, .handle_interrupt = brcm_fet_handle_interrupt, }, { @@ -847,7 +842,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM5241", /* PHY_BASIC_FEATURES */ .config_init = brcm_fet_config_init, - .ack_interrupt = brcm_fet_ack_interrupt, .config_intr = brcm_fet_config_intr, .handle_interrupt = brcm_fet_handle_interrupt, }, { @@ -871,7 +865,6 @@ static struct phy_driver broadcom_drivers[] = { .get_stats = bcm53xx_phy_get_stats, .probe = bcm53xx_phy_probe, .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, }, { @@ -880,7 +873,6 @@ static struct phy_driver broadcom_drivers[] = { .name = "Broadcom BCM89610", /* PHY_GBIT_FEATURES */ .config_init = bcm54xx_config_init, - .ack_interrupt = bcm_phy_ack_intr, .config_intr = bcm_phy_config_intr, .handle_interrupt = bcm_phy_handle_interrupt, } }; From patchwork Sun Nov 1 12:51: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: 315892 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, 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 C0413C2D0A3 for ; Sun, 1 Nov 2020 12:53:52 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 869FD2085B for ; Sun, 1 Nov 2020 12:53:52 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BkErPnIG" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726977AbgKAMxr (ORCPT ); Sun, 1 Nov 2020 07:53:47 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38736 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726901AbgKAMwl (ORCPT ); Sun, 1 Nov 2020 07:52:41 -0500 Received: from mail-ed1-x543.google.com (mail-ed1-x543.google.com [IPv6:2a00:1450:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 67450C061A47; Sun, 1 Nov 2020 04:52:40 -0800 (PST) Received: by mail-ed1-x543.google.com with SMTP id e18so200887edy.6; Sun, 01 Nov 2020 04:52: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=l7XDSYM/M1bjp6B3mGcMlMpBp17+2oQJyNz+LsCC7C0=; b=BkErPnIGHExmK5i2T9n1bweyav+KSix7ZdkSOZVnnpP2xleH7nRWgsirkohDkSxglf E09WL/h2LeHQh+UEVkKmts9FV/0blWdVnae5CMKo3S2iau4pGvYoAgKUQU4PRtEFba3F 130fDRHP5M7nujMDHp3HVeF+I1iPK2GgxLA6r9Bwsjluhd8R42z+JA299RNQ1QWY6lZ2 q2z3tpXG6oNZBeVBttkzVFQcqgmXLJ0OQccBMl8u/ihn5HLRbxARe6h4kGU52zQaN23d 2af/XZs2hdGwdOOjaeXC83j6gLI9yZBNWPZhCj4HGm/plDDrF6/W5ByPiBf1icIIx1FN Hn8Q== 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=l7XDSYM/M1bjp6B3mGcMlMpBp17+2oQJyNz+LsCC7C0=; b=ii+9y+g5ddoe8ZJKD8pB+f2uJt5F7Km4HebuX37OPDfD4BociCgjU4ywEEFxOcTljm 4RQFaJ3wTG9dDab/eCEm48rPnVeAP8YT2xWm0y2WZYF8LQEU2SOLoQJOb3MdTMTMO+3s LPdKgmdXtbeNciRH0ULhETPHb4T5DmRpeapxUIWE+fYYmudaLbBT+AKRAjgcoGqEwvcD 1QjGFr2K6S/G5u3mMFsY8iD/HJXJoo89x0zld9bhBCa4yy8VvU82a3tyA1/GaWn+3LO6 JE8IcYIWPXIM7OiafrYWEXrtPyK22dDKrZFONMd0/1lkRphRQ4BDZhgzEtZzBcSlMzDK L67w== X-Gm-Message-State: AOAM533DYqa8qeZ1MzCE2/Bo2hNJ0UeX8vTohut2Yy2Kqlg5Kx3OhfTh O27bRwk0QO9xFNq6OHIFd/U= X-Google-Smtp-Source: ABdhPJzeEHD+lIlaKQR/Ny8kaHUajQD9L0rMdbl693s5IlA0WkuWt8FKD7IlX+f2th3Ev0TAMASH5g== X-Received: by 2002:a05:6402:b28:: with SMTP id bo8mr11982363edb.57.1604235159172; Sun, 01 Nov 2020 04:52:39 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.38 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:38 -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 v2 14/19] net: phy: cicada: remove the use of .ack_interrupt() Date: Sun, 1 Nov 2020 14:51:09 +0200 Message-Id: <20201101125114.1316879-15-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-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 --- Changes in v2: - none drivers/net/phy/cicada.c | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/drivers/net/phy/cicada.c b/drivers/net/phy/cicada.c index 086c62ff5293..ef5f412e101f 100644 --- a/drivers/net/phy/cicada.c +++ b/drivers/net/phy/cicada.c @@ -87,11 +87,20 @@ static int cis820x_config_intr(struct phy_device *phydev) { int err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = cis820x_ack_interrupt(phydev); + if (err) + return err; + err = phy_write(phydev, MII_CIS8201_IMASK, MII_CIS8201_IMASK_MASK); - else + } else { err = phy_write(phydev, MII_CIS8201_IMASK, 0); + if (err) + return err; + + err = cis820x_ack_interrupt(phydev); + } return err; } @@ -122,7 +131,6 @@ static struct phy_driver cis820x_driver[] = { .phy_id_mask = 0x000ffff0, /* PHY_GBIT_FEATURES */ .config_init = &cis820x_config_init, - .ack_interrupt = &cis820x_ack_interrupt, .config_intr = &cis820x_config_intr, .handle_interrupt = &cis820x_handle_interrupt, }, { @@ -131,7 +139,6 @@ static struct phy_driver cis820x_driver[] = { .phy_id_mask = 0x000fffc0, /* PHY_GBIT_FEATURES */ .config_init = &cis820x_config_init, - .ack_interrupt = &cis820x_ack_interrupt, .config_intr = &cis820x_config_intr, .handle_interrupt = &cis820x_handle_interrupt, } }; From patchwork Sun Nov 1 12:51: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: 315893 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id B11ABC4741F for ; Sun, 1 Nov 2020 12:53:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7897B2085B for ; Sun, 1 Nov 2020 12:53:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="hP+KxPtn" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727073AbgKAMxV (ORCPT ); Sun, 1 Nov 2020 07:53:21 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38748 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726942AbgKAMwn (ORCPT ); Sun, 1 Nov 2020 07:52:43 -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 027F5C0617A6; Sun, 1 Nov 2020 04:52:43 -0800 (PST) Received: by mail-ed1-x544.google.com with SMTP id l24so11347676edj.8; Sun, 01 Nov 2020 04:52: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=PnJLOEQTKLqjGEvrG6MYX2BGzArZcrHWdrn4+Hna4UY=; b=hP+KxPtnoByVASH9YQCPOaJeBz9XrZ/1IlIF4fiH4c65HO5qyO4M3KIOMvhr3uDoBD UrasPa0G/0Dzjo6Jr9lbzTVKLflQaSAELz9S6qq1bsYDL1IJ1Ubj7aECXiyWEVp/XcN6 yN6jK92tFRfhc/aiKGSZxxfMgK01ykchhrnKLyPv+F+zc+Gelj5qqucIP3BHAKLuSnYa SoyvAEu4EzDtOrkFBlRb9LKh2o0EHuhUgeu76xhAwjfIh0urC5Vk5qWURk98VfujVHWX i/7rWTVSYYhs3x1qLy7NvxcDfu7pCKATgak8h/Gl79B9swsxrKyJNh1pbW34tRGxqm+7 qUdg== 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=PnJLOEQTKLqjGEvrG6MYX2BGzArZcrHWdrn4+Hna4UY=; b=esJA7pAB8YhxCjyaYDoeSRuuoEH9EPMW0mqMvnEAHRaIaj0ZJHLqH0WBQ535hqfvx0 vvVg77PK32i0VGthlN7ybv8HR5Q73XWCPWCL7wzeUg1A4wS944CFLsgOpW3ugShhrszy pAhNMEFH7zPl6wPwPJcwrXi0CQvgcShxh7c/rQ5/USUrcKeYr/6aCfOZMOw3g/XHrT7C Fm7y4gfPkeGx4VtvL836TSALSJFmiumI3FlZbYeTWIjfBa2RBwDbkrw6YRWD1Y0C95Ox 0kaQXrYUOokKLc2mzCLVJSbSc4Yc5e8nmqUh8MFSo3sNPK3ZJ2S40LHK7tCpiKL3dGw/ Zp3w== X-Gm-Message-State: AOAM533j00A5aZhzfzL+CendzxrQNH+oRsobFQUSSc2+7ddpwL70odpY /NVEknEyfFwyj7Erz6+GzBw= X-Google-Smtp-Source: ABdhPJzuqoy+YhpsNz73akt0iHz7Msd65Xf0JyT5sXK9snKRR4vTS0AHwXRp4AdumPPy7TRsF6qnBg== X-Received: by 2002:aa7:d843:: with SMTP id f3mr12173304eds.354.1604235161716; Sun, 01 Nov 2020 04:52:41 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.40 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52: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 Subject: [PATCH net-next v2 16/19] net: phy: davicom: remove the use of .ack_interrupt() Date: Sun, 1 Nov 2020 14:51:11 +0200 Message-Id: <20201101125114.1316879-17-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-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 --- Changes in v2: - none drivers/net/phy/davicom.c | 37 +++++++++++++++++++++---------------- 1 file changed, 21 insertions(+), 16 deletions(-) diff --git a/drivers/net/phy/davicom.c b/drivers/net/phy/davicom.c index bfa6c835070f..a3b3842c67e5 100644 --- a/drivers/net/phy/davicom.c +++ b/drivers/net/phy/davicom.c @@ -61,24 +61,40 @@ MODULE_AUTHOR("Andy Fleming"); MODULE_LICENSE("GPL"); +static int dm9161_ack_interrupt(struct phy_device *phydev) +{ + int err = phy_read(phydev, MII_DM9161_INTR); + + return (err < 0) ? err : 0; +} + #define DM9161_DELAY 1 static int dm9161_config_intr(struct phy_device *phydev) { - int temp; + int temp, err; temp = phy_read(phydev, MII_DM9161_INTR); if (temp < 0) return temp; - if (PHY_INTERRUPT_ENABLED == phydev->interrupts) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = dm9161_ack_interrupt(phydev); + if (err) + return err; + temp &= ~(MII_DM9161_INTR_STOP); - else + err = phy_write(phydev, MII_DM9161_INTR, temp); + } else { temp |= MII_DM9161_INTR_STOP; + err = phy_write(phydev, MII_DM9161_INTR, temp); + if (err) + return err; - temp = phy_write(phydev, MII_DM9161_INTR, temp); + err = dm9161_ack_interrupt(phydev); + } - return temp; + return err; } static irqreturn_t dm9161_handle_interrupt(struct phy_device *phydev) @@ -154,13 +170,6 @@ static int dm9161_config_init(struct phy_device *phydev) return phy_write(phydev, MII_BMCR, BMCR_ANENABLE); } -static int dm9161_ack_interrupt(struct phy_device *phydev) -{ - int err = phy_read(phydev, MII_DM9161_INTR); - - return (err < 0) ? err : 0; -} - static struct phy_driver dm91xx_driver[] = { { .phy_id = 0x0181b880, @@ -169,7 +178,6 @@ static struct phy_driver dm91xx_driver[] = { /* PHY_BASIC_FEATURES */ .config_init = dm9161_config_init, .config_aneg = dm9161_config_aneg, - .ack_interrupt = dm9161_ack_interrupt, .config_intr = dm9161_config_intr, .handle_interrupt = dm9161_handle_interrupt, }, { @@ -179,7 +187,6 @@ static struct phy_driver dm91xx_driver[] = { /* PHY_BASIC_FEATURES */ .config_init = dm9161_config_init, .config_aneg = dm9161_config_aneg, - .ack_interrupt = dm9161_ack_interrupt, .config_intr = dm9161_config_intr, .handle_interrupt = dm9161_handle_interrupt, }, { @@ -189,7 +196,6 @@ static struct phy_driver dm91xx_driver[] = { /* PHY_BASIC_FEATURES */ .config_init = dm9161_config_init, .config_aneg = dm9161_config_aneg, - .ack_interrupt = dm9161_ack_interrupt, .config_intr = dm9161_config_intr, .handle_interrupt = dm9161_handle_interrupt, }, { @@ -197,7 +203,6 @@ static struct phy_driver dm91xx_driver[] = { .name = "Davicom DM9131", .phy_id_mask = 0x0ffffff0, /* PHY_BASIC_FEATURES */ - .ack_interrupt = dm9161_ack_interrupt, .config_intr = dm9161_config_intr, .handle_interrupt = dm9161_handle_interrupt, } }; From patchwork Sun Nov 1 12:51: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: 315894 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.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HK_RANDOM_FROM,INCLUDES_PATCH, MAILING_LIST_MULTI, SIGNED_OFF_BY, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8CCBBC4741F for ; Sun, 1 Nov 2020 12:53:06 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 469AF2085B for ; Sun, 1 Nov 2020 12:53:06 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="NLYlOGJV" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727026AbgKAMwz (ORCPT ); Sun, 1 Nov 2020 07:52:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38764 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726999AbgKAMwr (ORCPT ); Sun, 1 Nov 2020 07:52:47 -0500 Received: from mail-ed1-x542.google.com (mail-ed1-x542.google.com [IPv6:2a00:1450:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EF3EFC061A48; Sun, 1 Nov 2020 04:52:46 -0800 (PST) Received: by mail-ed1-x542.google.com with SMTP id a15so2553785edy.1; Sun, 01 Nov 2020 04:52: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=dzOityyH9yb/DG7iNqmb4hgLSIqdku/w0btbjwH1wPA=; b=NLYlOGJVtEIdbm0u/Romnf6yluLP0u9kd02EDX0jClbQ6pRlwsoSk14KoEWObw1JUB 7M6omqVFCsbGFeVH5ik2T0tpei7F+xU8z1e3y0S/u7KGVAuA3wZVlOskQWjpriLnrspA FTbVHfWoa4GVVjkY7KdKu9MVIbQ3a8n4lwAT3FU7URt/iMTr7tPdooix7/eaqSI9+1Sh AkjvOY+xutm3jG9usUlrFxA5sUpadlCWnYbcAOxZ8SddJ+IUKjSNkbFz7VRh7vmlwggr EY/LxNGMNSF6/SlSXp4/9ujpSDeqbAkbNTyjI2kMeqhTSwIT2yWSFzfZHfYILgybfTRI vdfA== 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=dzOityyH9yb/DG7iNqmb4hgLSIqdku/w0btbjwH1wPA=; b=dKGK812R7LRlcMYMMQ1YQ1qvhevykeI1K8EkReZFjWyrJS2CFlCjTxNWSmZoqX2cT2 0TNHBp/x7qjKLoe+cWrbvEvCx4Y8kml/BekyMbC3o/Pp56Qb/jRA99Zqrw20i9o6om+Z w6eHxUM3x9/dicMaYrVwt85o+2dMTOAh4sNr3Xnka+eqGo4QGRAMxNXhCNTYA6Zy+l1J b5ShXzk8M+NJPtJencrCPzvU4RJTxc6jA9vbdipBltJtrLOftdG06pZsIwCg/UlmiYvL 36JU4Xvibe5AiGZnwXMLyvcznnalxewZXoaEooNevAgXTiJR1Y/PRT6yixfPjwsZn6ly bV5w== X-Gm-Message-State: AOAM532OSWnNmPXgAaqpz31ntZzOrS055vENTzC35x49+DsAYKxjwWeD wpMAm/G9nYQCWf8S71P0TxM= X-Google-Smtp-Source: ABdhPJzzICF1pd1IwRqYWI6Ozl/8575x5CgnH1zvea6J1yDcpuhvVWhTE6JXS8j4Q3Hh7IbB4k7lIA== X-Received: by 2002:aa7:da13:: with SMTP id r19mr11781242eds.20.1604235165698; Sun, 01 Nov 2020 04:52:45 -0800 (PST) Received: from yoga-910.localhost ([188.25.2.177]) by smtp.gmail.com with ESMTPSA id c5sm8133603edx.58.2020.11.01.04.52.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 01 Nov 2020 04:52:45 -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 , Willy Liu Subject: [PATCH net-next v2 19/19] net: phy: realtek: remove the use of .ack_interrupt() Date: Sun, 1 Nov 2020 14:51:14 +0200 Message-Id: <20201101125114.1316879-20-ciorneiioana@gmail.com> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20201101125114.1316879-1-ciorneiioana@gmail.com> References: <20201101125114.1316879-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 Cc: Willy Liu Signed-off-by: Ioana Ciornei --- Changes in v2: - none drivers/net/phy/realtek.c | 68 ++++++++++++++++++++++++++++++--------- 1 file changed, 52 insertions(+), 16 deletions(-) diff --git a/drivers/net/phy/realtek.c b/drivers/net/phy/realtek.c index 820b4e8ef23a..231b32118054 100644 --- a/drivers/net/phy/realtek.c +++ b/drivers/net/phy/realtek.c @@ -108,24 +108,45 @@ static int rtl8211f_ack_interrupt(struct phy_device *phydev) static int rtl8201_config_intr(struct phy_device *phydev) { u16 val; + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = rtl8201_ack_interrupt(phydev); + if (err) + return err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) val = BIT(13) | BIT(12) | BIT(11); - else + err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); + } else { val = 0; + err = phy_write_paged(phydev, 0x7, RTL8201F_IER, val); + if (err) + return err; + + err = rtl8201_ack_interrupt(phydev); + } - return phy_write_paged(phydev, 0x7, RTL8201F_IER, val); + return err; } static int rtl8211b_config_intr(struct phy_device *phydev) { int err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = rtl821x_ack_interrupt(phydev); + if (err) + return err; + err = phy_write(phydev, RTL821x_INER, RTL8211B_INER_INIT); - else + } else { err = phy_write(phydev, RTL821x_INER, 0); + if (err) + return err; + + err = rtl821x_ack_interrupt(phydev); + } return err; } @@ -134,11 +155,20 @@ static int rtl8211e_config_intr(struct phy_device *phydev) { int err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = rtl821x_ack_interrupt(phydev); + if (err) + return err; + err = phy_write(phydev, RTL821x_INER, RTL8211E_INER_LINK_STATUS); - else + } else { err = phy_write(phydev, RTL821x_INER, 0); + if (err) + return err; + + err = rtl821x_ack_interrupt(phydev); + } return err; } @@ -146,13 +176,25 @@ static int rtl8211e_config_intr(struct phy_device *phydev) static int rtl8211f_config_intr(struct phy_device *phydev) { u16 val; + int err; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) { + err = rtl8211f_ack_interrupt(phydev); + if (err) + return err; - if (phydev->interrupts == PHY_INTERRUPT_ENABLED) val = RTL8211F_INER_LINK_STATUS; - else + err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); + } else { val = 0; + err = phy_write_paged(phydev, 0xa42, RTL821x_INER, val); + if (err) + return err; - return phy_write_paged(phydev, 0xa42, RTL821x_INER, val); + err = rtl8211f_ack_interrupt(phydev); + } + + return err; } static irqreturn_t rtl8201_handle_interrupt(struct phy_device *phydev) @@ -620,7 +662,6 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc816), .name = "RTL8201F Fast Ethernet", - .ack_interrupt = &rtl8201_ack_interrupt, .config_intr = &rtl8201_config_intr, .handle_interrupt = rtl8201_handle_interrupt, .suspend = genphy_suspend, @@ -647,7 +688,6 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc912), .name = "RTL8211B Gigabit Ethernet", - .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211b_config_intr, .handle_interrupt = rtl821x_handle_interrupt, .read_mmd = &genphy_read_mmd_unsupported, @@ -667,7 +707,6 @@ static struct phy_driver realtek_drvs[] = { }, { PHY_ID_MATCH_EXACT(0x001cc914), .name = "RTL8211DN Gigabit Ethernet", - .ack_interrupt = rtl821x_ack_interrupt, .config_intr = rtl8211e_config_intr, .handle_interrupt = rtl821x_handle_interrupt, .suspend = genphy_suspend, @@ -678,7 +717,6 @@ static struct phy_driver realtek_drvs[] = { PHY_ID_MATCH_EXACT(0x001cc915), .name = "RTL8211E Gigabit Ethernet", .config_init = &rtl8211e_config_init, - .ack_interrupt = &rtl821x_ack_interrupt, .config_intr = &rtl8211e_config_intr, .handle_interrupt = rtl821x_handle_interrupt, .suspend = genphy_suspend, @@ -689,7 +727,6 @@ static struct phy_driver realtek_drvs[] = { PHY_ID_MATCH_EXACT(0x001cc916), .name = "RTL8211F Gigabit Ethernet", .config_init = &rtl8211f_config_init, - .ack_interrupt = &rtl8211f_ack_interrupt, .config_intr = &rtl8211f_config_intr, .handle_interrupt = rtl8211f_handle_interrupt, .suspend = genphy_suspend, @@ -739,7 +776,6 @@ static struct phy_driver realtek_drvs[] = { * irq is requested and ACKed by reading the status register, * which is done by the irqchip code. */ - .ack_interrupt = genphy_no_ack_interrupt, .config_intr = genphy_no_config_intr, .handle_interrupt = genphy_handle_interrupt_no_ack, .suspend = genphy_suspend,