Received: by 2002:a05:6a10:9e8c:0:0:0:0 with SMTP id y12csp1654518pxx; Fri, 30 Oct 2020 15:46:52 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz+uTjbSmKzZmzasHIrTpjT+lq4dvUuLfBNQt7O9idPqjn8OSL3DfwA4h1sXi5quf/3dGLx X-Received: by 2002:a17:906:c7d9:: with SMTP id dc25mr4747811ejb.482.1604098012531; Fri, 30 Oct 2020 15:46:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1604098012; cv=none; d=google.com; s=arc-20160816; b=O1i1upxl5NKSuV5HwLtpfN8fLAAbmWVhnmpfD8lwAAezS3KoL9qM1QgcH4lFlDilsK FioOQfKF9PoNnipTnKZHyz3KpKY3tdqJjqxneB0oBJVD4/6ZaDYInZRRA+hlHNkfMMsW nxB/e34LAJLb5LI9scIVGprQx4ET9lrdGwIp6815ojKG/29zaae34kIgQ56a5QFEnX5i EjK/WuvASLgMQxl4k/uOTD6Q5nM1o4b2hh8GxxMhzryBSNo2AQwp4LTIeRO+ZA7oCLmC 9PmtAT/A8VGOQ4mfAybufcM/XQLp/N5GskixEdc3dO/UNeAqDYdsGtkUSp6LeO32JGu9 GbBw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=Ldf9nHDM5+h/GHVp04n6dFe8WCel+IPrH+AkDZsKWpk=; b=c/sK8cepqhjrAgNRlEiH8STT8FOoaF5eu6GNWr1YbMqWdNtqpq8dJTYBpMBsWKIN3D XqJZndk5w5+tbx+xcf9oaA/T2g+sd21FVuhcstHNliQ2AelUCncL7yMjArqJlhOIq4S/ cEPwh3qsjb+HySRhgwSv2JW0rzLqRKNOr2nIB8BNiLkvahqQwn5WUoh9uA0tX9JPeLXV 2wsXXFR4jPqLpY44X1Neg8HKI9HWXBUVZnkN5Enr5lUxxAAe+xaLiFGak5IY6wcUCa2Y 0YTEIFD7/kvIg7bLP9H9iPu1qnhdZeafxZKhySaUwoBZ2mAE4lOoJeyLJlO7polxk25E p3cQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=q8fHeQHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d22si4800588ejc.554.2020.10.30.15.46.29; Fri, 30 Oct 2020 15:46:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=q8fHeQHw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725976AbgJ3Wmr (ORCPT + 99 others); Fri, 30 Oct 2020 18:42:47 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55384 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725780AbgJ3Wmq (ORCPT ); Fri, 30 Oct 2020 18:42:46 -0400 Received: from mail-wm1-x342.google.com (mail-wm1-x342.google.com [IPv6:2a00:1450:4864:20::342]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 459E5C0613D5; Fri, 30 Oct 2020 15:42:44 -0700 (PDT) Received: by mail-wm1-x342.google.com with SMTP id l8so4251830wmg.3; Fri, 30 Oct 2020 15:42:44 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Ldf9nHDM5+h/GHVp04n6dFe8WCel+IPrH+AkDZsKWpk=; b=q8fHeQHwFpcH8+Btti7MBLlaKvAAsXw0lmlYOQA3hS/lpnsL6Svlk+zBWf22JdQFlo 9g7pQx81QrDaH9pImRXuFcKJJDaRntC64ziCfh89lfy6poXGojJ+QiVL/owMWTDic648 x2E0dlu3tMYsQr7D22gnxU5oKS/B5WkzzwW5UXSD22s5a8rvCIj72eEIAT8vv1lCvnkj 3qJw5KPGYP11cgOWRFz8Nvtj9beUE4bXBMWWbJ+Liu4KacLpghHhj42YmfvAF70U4Q00 RWug1dJtZuhVYb1o5BNMCv6WsaSnUZUCJ673dL+hIaxoeuF2SW5nA6CCRqn44HMTFNwb BdmA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Ldf9nHDM5+h/GHVp04n6dFe8WCel+IPrH+AkDZsKWpk=; b=tB5HF5NYkWRBhDrY8XvM3ioWi4t3tvkGqh9QWcdWBTbylHja5ljEeu4hq0HYpNRcb7 kQ+qrBWP5G40wkKssJn1NJZJknKvqQun89rvLS78j5GDZUNaMFST2Ntw03Z/cnNfBsAF Bx2TxXNhV67t/2WG0eJvI2vVseQZztEXA/FkXw8S2FQT7OLF+Bmq1WQ2fP6gfB+s4kyu h6TSO+Yv14o570P0+KHe3Zm1LjjgwgZGDfTF0sZbWEWK/a6RcqO/Zn4BfM2PqLgai+gZ 9jKCWY3D8ojmpUuhtyIACYYacVgCMMWayz5qhncOhNS5ad7MIlE5mgHcN3ROH7Nm0yM4 GsYQ== X-Gm-Message-State: AOAM532bQjflUtQrEpqUoD9/fw4gL75QZLdazCn+DPspVb2/a8lXRrUa hnC38KDZkWywxF8PBVj7Zsw= X-Received: by 2002:a1c:9695:: with SMTP id y143mr4829432wmd.146.1604097762971; Fri, 30 Oct 2020 15:42:42 -0700 (PDT) Received: from ?IPv6:2003:ea:8f23:2800:9d19:4c77:c465:2524? (p200300ea8f2328009d194c77c4652524.dip0.t-ipconnect.de. [2003:ea:8f23:2800:9d19:4c77:c465:2524]) by smtp.googlemail.com with ESMTPSA id u3sm10806096wro.33.2020.10.30.15.42.41 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 30 Oct 2020 15:42:42 -0700 (PDT) Subject: Re: [PATCH net-next 00/19] net: phy: add support for shared interrupts (part 1) To: Ioana Ciornei , Andrew Lunn , Russell King , 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 , Florian Fainelli , 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 References: <20201029100741.462818-1-ciorneiioana@gmail.com> From: Heiner Kallweit Message-ID: Date: Fri, 30 Oct 2020 23:42:36 +0100 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0 MIME-Version: 1.0 In-Reply-To: <20201029100741.462818-1-ciorneiioana@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 29.10.2020 11:07, Ioana Ciornei wrote: > From: Ioana Ciornei > > This patch set aims to actually add support for shared interrupts in > phylib and not only for multi-PHY devices. While we are at it, > streamline the interrupt handling in phylib. > > For a bit of context, at the moment, there are multiple phy_driver ops > that deal with this subject: > > - .config_intr() - Enable/disable the interrupt line. > > - .ack_interrupt() - Should quiesce any interrupts that may have been > fired. It's also used by phylib in conjunction with .config_intr() to > clear any pending interrupts after the line was disabled, and before > it is going to be enabled. > > - .did_interrupt() - Intended for multi-PHY devices with a shared IRQ > line and used by phylib to discern which PHY from the package was the > one that actually fired the interrupt. > > - .handle_interrupt() - Completely overrides the default interrupt > handling logic from phylib. The PHY driver is responsible for checking > if any interrupt was fired by the respective PHY and choose > accordingly if it's the one that should trigger the link state machine. > >>From my point of view, the interrupt handling in phylib has become > somewhat confusing with all these callbacks that actually read the same > PHY register - the interrupt status. A more streamlined approach would > be to just move the responsibility to write an interrupt handler to the > driver (as any other device driver does) and make .handle_interrupt() > the only way to deal with interrupts. > > Another advantage with this approach would be that phylib would gain > support for shared IRQs between different PHY (not just multi-PHY > devices), something which at the moment would require extending every > PHY driver anyway in order to implement their .did_interrupt() callback > and duplicate the same logic as in .ack_interrupt(). The disadvantage > of making .did_interrupt() mandatory would be that we are slightly > changing the semantics of the phylib API and that would increase > confusion instead of reducing it. > > What I am proposing is the following: > > - As a first step, make the .ack_interrupt() callback optional so that > we do not break any PHY driver amid the transition. > > - Every PHY driver gains a .handle_interrupt() implementation that, for > the most part, would look like below: > > irq_status = phy_read(phydev, INTR_STATUS); > if (irq_status < 0) { > phy_error(phydev); > return IRQ_NONE; > } > > if (irq_status == 0) Here I have a concern, bits may be set even if the respective interrupt source isn't enabled. Therefore we may falsely blame a device to have triggered the interrupt. irq_status should be masked with the actually enabled irq source bits. > return IRQ_NONE; > > phy_trigger_machine(phydev); > > return IRQ_HANDLED; > > - Remove each PHY driver's implementation of the .ack_interrupt() by > actually taking care of quiescing any pending interrupts before > enabling/after disabling the interrupt line. > > - Finally, after all drivers have been ported, remove the > .ack_interrupt() and .did_interrupt() callbacks from phy_driver. > > This patch set is part 1 and it addresses the changes needed in phylib > and 7 PHY drivers. The rest can be found on my Github branch here: > https://github.com/IoanaCiornei/linux/commits/phylib-shared-irq > > I do not have access to most of these PHY's, therefore I Cc-ed the > latest contributors to the individual PHY drivers in order to have > access, hopefully, to more regression testing. > > Ioana Ciornei (19): > net: phy: export phy_error and phy_trigger_machine > net: phy: add a shutdown procedure > net: phy: make .ack_interrupt() optional > net: phy: at803x: implement generic .handle_interrupt() callback > net: phy: at803x: remove the use of .ack_interrupt() > net: phy: mscc: use phy_trigger_machine() to notify link change > net: phy: mscc: implement generic .handle_interrupt() callback > net: phy: mscc: remove the use of .ack_interrupt() > net: phy: aquantia: implement generic .handle_interrupt() callback > net: phy: aquantia: remove the use of .ack_interrupt() > net: phy: broadcom: implement generic .handle_interrupt() callback > net: phy: broadcom: remove use of ack_interrupt() > net: phy: cicada: implement the generic .handle_interrupt() callback > net: phy: cicada: remove the use of .ack_interrupt() > net: phy: davicom: implement generic .handle_interrupt() calback > net: phy: davicom: remove the use of .ack_interrupt() > net: phy: add genphy_handle_interrupt_no_ack() > net: phy: realtek: implement generic .handle_interrupt() callback > net: phy: realtek: remove the use of .ack_interrupt() > > drivers/net/phy/aquantia_main.c | 57 ++++++++++---- > drivers/net/phy/at803x.c | 42 ++++++++-- > drivers/net/phy/bcm-cygnus.c | 2 +- > drivers/net/phy/bcm-phy-lib.c | 37 ++++++++- > drivers/net/phy/bcm-phy-lib.h | 1 + > drivers/net/phy/bcm54140.c | 39 +++++++--- > drivers/net/phy/bcm63xx.c | 20 +++-- > drivers/net/phy/bcm87xx.c | 50 ++++++------ > drivers/net/phy/broadcom.c | 70 ++++++++++++----- > drivers/net/phy/cicada.c | 35 ++++++++- > drivers/net/phy/davicom.c | 59 ++++++++++---- > drivers/net/phy/mscc/mscc_main.c | 70 +++++++++-------- > drivers/net/phy/phy.c | 6 +- > drivers/net/phy/phy_device.c | 23 +++++- > drivers/net/phy/realtek.c | 128 +++++++++++++++++++++++++++---- > include/linux/phy.h | 3 + > 16 files changed, 484 insertions(+), 158 deletions(-) > > 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 >