Message ID | 20240121201511.8997-3-andre.werner@systec-electronic.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel+bounces-32175-ouuuleilei=gmail.com@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:2bc4:b0:101:a8e8:374 with SMTP id hx4csp2225093dyb; Sun, 21 Jan 2024 12:16:20 -0800 (PST) X-Google-Smtp-Source: AGHT+IHS+2420WBr7JkyIwyi8GhINjcpHWR2+mxFoRJ35D7G+blJ/7bvgzN7Uu8aQQPT76z328GN X-Received: by 2002:a05:6808:11ce:b0:3bd:a9c6:9bc1 with SMTP id p14-20020a05680811ce00b003bda9c69bc1mr3756452oiv.102.1705868180258; Sun, 21 Jan 2024 12:16:20 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1705868180; cv=pass; d=google.com; s=arc-20160816; b=i0jQl+kXp7QWNxQAvnkfMRvdHwoetnRcNQjrh7P0ywWnxh37wZhhsSbscJ4UGV9mrR Snt560zZ8WYl0tVVrT/ymMgaxYBhCnrGi3fq3NQOTVI7CGmIeOgkELkcTRTubvicI+2+ uYOGlH3x5F8ku09MW0bjw9UMFoGuQKy4yTlI/iMTTsxsfWDM8+9ToEliKq4o11sLb059 QO1MqxDKg3x7G3ViKgDeAWq8Pl3rN/JTg35kAKy0KtCuzX+sN8SKNG2rjnsch08mYAXG CfWjnkrQvTr2wQreHh8s1ASMIu/ONYhWWqFmBHgteFEVqbr5xzslg0maTeho2k1ZggZA mIDA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature:dkim-filter; bh=I79RkeIuOJntt4ag+ghEKT/mdW6n3a9EF+d3EcXI4Ps=; fh=EW95u4Nxu1efLMnFaTYf/hfJfmSzKgtewn9i4CVxfk8=; b=pDPii0EZ7hE5QRp7YXn/UVzJoRRJDUlM1J2Ee6mBoV12wTlXcPBm0vYmoYhcO7/Vot 9aaTIDUMLCfzUmgGynuBy+HFwt0t0LBsIHWS8ShMnU4PJ0jRgiec0o5/UjpdqoQp/roz umA0rWUzKYuA2z/4RudMT6ry4hU+uv+kYCZHS3Vc0UvVOh2kCN0/VUH5XPqDPFu2Ey+u /jhv8gaWQ4cxntGEShruyxMmIAOCMlerXzjDehwgI/pfXtcuKyuJP2xXxQi/v3Jv9+ro ZHAYmnWLsSM4KHQc4YaYs6iUBM6KYFTs/Vgt8hbM37DADfT8dvq7Buf46rtfumfFYo86 aReQ== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@systec-electronic.com header.s=B34D3B04-5DC7-11EE-83E3-4D8CAB78E8CD header.b=eRcrZ4Fj; arc=pass (i=1 spf=pass spfdomain=systec-electronic.com dkim=pass dkdomain=systec-electronic.com); spf=pass (google.com: domain of linux-kernel+bounces-32175-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32175-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b5-20020a056a000a8500b006d9e6a33523si9395193pfl.296.2024.01.21.12.16.20 for <ouuuleilei@gmail.com> (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jan 2024 12:16:20 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-32175-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@systec-electronic.com header.s=B34D3B04-5DC7-11EE-83E3-4D8CAB78E8CD header.b=eRcrZ4Fj; arc=pass (i=1 spf=pass spfdomain=systec-electronic.com dkim=pass dkdomain=systec-electronic.com); spf=pass (google.com: domain of linux-kernel+bounces-32175-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-32175-ouuuleilei=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 05DF0281CB6 for <ouuuleilei@gmail.com>; Sun, 21 Jan 2024 20:16:20 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3F6BC38FB9; Sun, 21 Jan 2024 20:15:30 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=systec-electronic.com header.i=@systec-electronic.com header.b="eRcrZ4Fj" Received: from mail.systec-electronic.com (mail.systec-electronic.com [77.220.239.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 1F8F538396; Sun, 21 Jan 2024 20:15:23 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=77.220.239.22 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705868127; cv=none; b=iqTXG8NqDrcZjLdNJhy/fQmVYjNc6iHJUIf9VQI9AePE/EkQ68GBpNdHGRImofMhgQSfDShIPJ3w3ebd7KTgSNeBg+qmNtmNBNZMV4s8gDb/a+YBzvGFbKoGzu0qKEGA0a7O5Qu2LTVBd6bDVtuboahDxp0+0ZezEAoRqf+o430= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1705868127; c=relaxed/simple; bh=DdaAMfAqRKaoKK0URN081uvxzjr0aE5O73JQyc3Qw08=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=JeYASHo5YUabT3KKpGJbznUjsRcKDCXAgsyalN7/ngegQ1wKv5moh+Rqtvkf+BOwGayTBNMq9P65LdD5AAFXUtD2B18JJhoKQuDsaA7ymQRFEaajs5PguXpsd9XOoEa4lCOXWW+6LpHCT1lv1d6clo7vkR9h/4TCQH18mfLNrxM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=systec-electronic.com; spf=pass smtp.mailfrom=systec-electronic.com; dkim=pass (2048-bit key) header.d=systec-electronic.com header.i=@systec-electronic.com header.b=eRcrZ4Fj; arc=none smtp.client-ip=77.220.239.22 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=systec-electronic.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=systec-electronic.com Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.systec-electronic.com (Postfix) with ESMTP id 19AFA9400107; Sun, 21 Jan 2024 21:15:16 +0100 (CET) Received: from mail.systec-electronic.com ([127.0.0.1]) by localhost (mail.systec-electronic.com [127.0.0.1]) (amavis, port 10032) with ESMTP id YYmRd1COwZLT; Sun, 21 Jan 2024 21:15:16 +0100 (CET) Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.systec-electronic.com (Postfix) with ESMTP id E7FD9941A5D1; Sun, 21 Jan 2024 21:15:15 +0100 (CET) DKIM-Filter: OpenDKIM Filter v2.10.3 mail.systec-electronic.com E7FD9941A5D1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=systec-electronic.com; s=B34D3B04-5DC7-11EE-83E3-4D8CAB78E8CD; t=1705868115; bh=I79RkeIuOJntt4ag+ghEKT/mdW6n3a9EF+d3EcXI4Ps=; h=From:To:Date:Message-ID:MIME-Version; b=eRcrZ4FjS6XsZnr8ZpUS539S9iKhucY2fzUOmXCLR/Dfyy9Hxyl/a+d/1piE41GeO C+9Jewp/EYruNpRgSaoHF++tJbkYrnC3UAa6j64hbWbM/kttl1h6kOyQn0fi7ly1s4 ybnG7uw4kd5ph3vf0X/n2uk3NgnVpoSQU+kkuZqX3f5ZI8SK31kwC1jr7lY+MViJ6o 5J12bW5mwYQmw/GwIwHaP1UapPapYVNlFDHA/GrUx6h4T7O+VOifKU1jYDYwSjcjFY xPxV2g13OPHuxVHhMg4tWun+yBFXuXzCWB78jArsxVJ+S8fHZquz1Qv8M/ZMxYBpzJ LQGCZDz/GEeLQ== X-Virus-Scanned: amavis at systec-electronic.com Received: from mail.systec-electronic.com ([127.0.0.1]) by localhost (mail.systec-electronic.com [127.0.0.1]) (amavis, port 10026) with ESMTP id 8APQRCsXv_pK; Sun, 21 Jan 2024 21:15:15 +0100 (CET) Received: from ws-565760.systec.local (unknown [212.185.67.148]) by mail.systec-electronic.com (Postfix) with ESMTPSA id 338D59400107; Sun, 21 Jan 2024 21:15:15 +0100 (CET) From: Andre Werner <andre.werner@systec-electronic.com> To: andrew@lunn.ch, hkallweit1@gmail.com, davem@davemloft.net, edumazet@google.com, kuba@kernel.org, pabeni@redhat.com Cc: linux@armlinux.org.uk, netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Andre Werner <andre.werner@systec-electronic.com> Subject: [RFC net-next v4 2/2] net: phy: adin1100: Add interrupt support for link change Date: Sun, 21 Jan 2024 20:54:49 +0100 Message-ID: <20240121201511.8997-3-andre.werner@systec-electronic.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240121201511.8997-1-andre.werner@systec-electronic.com> References: <20240121201511.8997-1-andre.werner@systec-electronic.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: <linux-kernel.vger.kernel.org> List-Subscribe: <mailto:linux-kernel+subscribe@vger.kernel.org> List-Unsubscribe: <mailto:linux-kernel+unsubscribe@vger.kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1788732432953080529 X-GMAIL-MSGID: 1788732432953080529 |
Series |
Prevent nullptr exceptions in ISR
|
|
Commit Message
Andre Werner
Jan. 21, 2024, 7:54 p.m. UTC
An interrupt handler was added to the driver as well as functions
to enable interrupts at the phy.
There are several interrupts maskable at the phy, but only link change
interrupts are handled by the driver yet.
Signed-off-by: Andre Werner <andre.werner@systec-electronic.com>
---
v4:
- Change read-modify-write behavior as suggested to phy_modify_mmd.
---
drivers/net/phy/adin1100.c | 56 ++++++++++++++++++++++++++++++++++++++
1 file changed, 56 insertions(+)
Comments
The 01/21/2024 20:54, Andre Werner wrote: Hi Andre, > An interrupt handler was added to the driver as well as functions > to enable interrupts at the phy. > > There are several interrupts maskable at the phy, but only link change > interrupts are handled by the driver yet. > > Signed-off-by: Andre Werner <andre.werner@systec-electronic.com> > --- > v4: > - Change read-modify-write behavior as suggested to phy_modify_mmd. Usually it is good to keep the change log also from the previous versions, so it is easier to see what has been changed. > --- > drivers/net/phy/adin1100.c | 56 ++++++++++++++++++++++++++++++++++++++ > 1 file changed, 56 insertions(+) > > diff --git a/drivers/net/phy/adin1100.c b/drivers/net/phy/adin1100.c > index 7619d6185801..7c82384e5d30 100644 > --- a/drivers/net/phy/adin1100.c > +++ b/drivers/net/phy/adin1100.c > @@ -18,6 +18,12 @@ > #define PHY_ID_ADIN1110 0x0283bc91 > #define PHY_ID_ADIN2111 0x0283bca1 > > +#define ADIN_PHY_SUBSYS_IRQ_MASK 0x0021 > +#define ADIN_LINK_STAT_CHNG_IRQ_EN BIT(1) > + > +#define ADIN_PHY_SUBSYS_IRQ_STATUS 0x0011 > +#define ADIN_LINK_STAT_CHNG BIT(1) > + > #define ADIN_FORCED_MODE 0x8000 > #define ADIN_FORCED_MODE_EN BIT(0) > > @@ -136,6 +142,54 @@ static int adin_config_aneg(struct phy_device *phydev) > return genphy_c45_config_aneg(phydev); > } > > +static int adin_phy_ack_intr(struct phy_device *phydev) > +{ > + /* Clear pending interrupts */ > + int rc = phy_read_mmd(phydev, MDIO_MMD_VEND2, > + ADIN_PHY_SUBSYS_IRQ_STATUS); > + > + return rc < 0 ? rc : 0; > +} > + > +static int adin_config_intr(struct phy_device *phydev) > +{ > + int ret; > + u16 irq_mask; Please use reverse x-mas notation here. > + > + ret = adin_phy_ack_intr(phydev); > + No new line here, between ret and if. > + if (ret) > + return ret; > + > + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) > + irq_mask = ADIN_LINK_STAT_CHNG_IRQ_EN; > + else > + irq_mask = 0; > + > + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, > + ADIN_PHY_SUBSYS_IRQ_MASK, > + ADIN_LINK_STAT_CHNG_IRQ_EN, irq_mask); > +} > + > +static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev) > +{ > + int irq_status; > + > + irq_status = phy_read_mmd(phydev, MDIO_MMD_VEND2, > + ADIN_PHY_SUBSYS_IRQ_STATUS); > + if (irq_status < 0) { > + phy_error(phydev); > + return IRQ_NONE; > + } > + > + if (!(irq_status & ADIN_LINK_STAT_CHNG)) > + return IRQ_NONE; > + > + phy_trigger_machine(phydev); > + > + return IRQ_HANDLED; > +} > + > static int adin_set_powerdown_mode(struct phy_device *phydev, bool en) > { > int ret; > @@ -275,6 +329,8 @@ static struct phy_driver adin_driver[] = { > .probe = adin_probe, > .config_aneg = adin_config_aneg, > .read_status = adin_read_status, > + .config_intr = adin_config_intr, > + .handle_interrupt = adin_phy_handle_interrupt, > .set_loopback = adin_set_loopback, > .suspend = adin_suspend, > .resume = adin_resume, > -- > 2.43.0 > >
Dear Maintainers, I'm a bit confused about the patch submitting process for net-next. Do I need to send the patchset again, if the merge window is opened again and the patchset was previously submitted as RFC? Best regards. Andre On Mon, 22 Jan 2024, Horatiu Vultur wrote: > The 01/21/2024 20:54, Andre Werner wrote: > > Hi Andre, > > >> An interrupt handler was added to the driver as well as functions >> to enable interrupts at the phy. >> >> There are several interrupts maskable at the phy, but only link change >> interrupts are handled by the driver yet. >> >> Signed-off-by: Andre Werner <andre.werner@systec-electronic.com> >> --- >> v4: >> - Change read-modify-write behavior as suggested to phy_modify_mmd. > > Usually it is good to keep the change log also from the previous > versions, so it is easier to see what has been changed. > >> --- >> drivers/net/phy/adin1100.c | 56 ++++++++++++++++++++++++++++++++++++++ >> 1 file changed, 56 insertions(+) >> >> diff --git a/drivers/net/phy/adin1100.c b/drivers/net/phy/adin1100.c >> index 7619d6185801..7c82384e5d30 100644 >> --- a/drivers/net/phy/adin1100.c >> +++ b/drivers/net/phy/adin1100.c >> @@ -18,6 +18,12 @@ >> #define PHY_ID_ADIN1110 0x0283bc91 >> #define PHY_ID_ADIN2111 0x0283bca1 >> >> +#define ADIN_PHY_SUBSYS_IRQ_MASK 0x0021 >> +#define ADIN_LINK_STAT_CHNG_IRQ_EN BIT(1) >> + >> +#define ADIN_PHY_SUBSYS_IRQ_STATUS 0x0011 >> +#define ADIN_LINK_STAT_CHNG BIT(1) >> + >> #define ADIN_FORCED_MODE 0x8000 >> #define ADIN_FORCED_MODE_EN BIT(0) >> >> @@ -136,6 +142,54 @@ static int adin_config_aneg(struct phy_device *phydev) >> return genphy_c45_config_aneg(phydev); >> } >> >> +static int adin_phy_ack_intr(struct phy_device *phydev) >> +{ >> + /* Clear pending interrupts */ >> + int rc = phy_read_mmd(phydev, MDIO_MMD_VEND2, >> + ADIN_PHY_SUBSYS_IRQ_STATUS); >> + >> + return rc < 0 ? rc : 0; >> +} >> + >> +static int adin_config_intr(struct phy_device *phydev) >> +{ >> + int ret; >> + u16 irq_mask; > > Please use reverse x-mas notation here. > >> + >> + ret = adin_phy_ack_intr(phydev); >> + > > No new line here, between ret and if. > >> + if (ret) >> + return ret; >> + >> + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) >> + irq_mask = ADIN_LINK_STAT_CHNG_IRQ_EN; >> + else >> + irq_mask = 0; >> + >> + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, >> + ADIN_PHY_SUBSYS_IRQ_MASK, >> + ADIN_LINK_STAT_CHNG_IRQ_EN, irq_mask); >> +} >> + >> +static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev) >> +{ >> + int irq_status; >> + >> + irq_status = phy_read_mmd(phydev, MDIO_MMD_VEND2, >> + ADIN_PHY_SUBSYS_IRQ_STATUS); >> + if (irq_status < 0) { >> + phy_error(phydev); >> + return IRQ_NONE; >> + } >> + >> + if (!(irq_status & ADIN_LINK_STAT_CHNG)) >> + return IRQ_NONE; >> + >> + phy_trigger_machine(phydev); >> + >> + return IRQ_HANDLED; >> +} >> + >> static int adin_set_powerdown_mode(struct phy_device *phydev, bool en) >> { >> int ret; >> @@ -275,6 +329,8 @@ static struct phy_driver adin_driver[] = { >> .probe = adin_probe, >> .config_aneg = adin_config_aneg, >> .read_status = adin_read_status, >> + .config_intr = adin_config_intr, >> + .handle_interrupt = adin_phy_handle_interrupt, >> .set_loopback = adin_set_loopback, >> .suspend = adin_suspend, >> .resume = adin_resume, >> -- >> 2.43.0 >> >> > > -- > /Horatiu >
On Mon, Jan 29, 2024 at 01:51:11PM +0100, Andre Werner wrote: > Dear Maintainers, > > I'm a bit confused about the patch submitting process for net-next. > Do I need to send the patchset again, if the merge window is opened again and > the patchset was previously submitted as RFC? RFC patches should in theory never be merged. So that alone is sufficient to require a resend. Anything sent during the merge window is also not eligible for merging. So please rebase on net-next, collect and add any Acked-by: Reviewed-by: etc and resend. Andrew
diff --git a/drivers/net/phy/adin1100.c b/drivers/net/phy/adin1100.c index 7619d6185801..7c82384e5d30 100644 --- a/drivers/net/phy/adin1100.c +++ b/drivers/net/phy/adin1100.c @@ -18,6 +18,12 @@ #define PHY_ID_ADIN1110 0x0283bc91 #define PHY_ID_ADIN2111 0x0283bca1 +#define ADIN_PHY_SUBSYS_IRQ_MASK 0x0021 +#define ADIN_LINK_STAT_CHNG_IRQ_EN BIT(1) + +#define ADIN_PHY_SUBSYS_IRQ_STATUS 0x0011 +#define ADIN_LINK_STAT_CHNG BIT(1) + #define ADIN_FORCED_MODE 0x8000 #define ADIN_FORCED_MODE_EN BIT(0) @@ -136,6 +142,54 @@ static int adin_config_aneg(struct phy_device *phydev) return genphy_c45_config_aneg(phydev); } +static int adin_phy_ack_intr(struct phy_device *phydev) +{ + /* Clear pending interrupts */ + int rc = phy_read_mmd(phydev, MDIO_MMD_VEND2, + ADIN_PHY_SUBSYS_IRQ_STATUS); + + return rc < 0 ? rc : 0; +} + +static int adin_config_intr(struct phy_device *phydev) +{ + int ret; + u16 irq_mask; + + ret = adin_phy_ack_intr(phydev); + + if (ret) + return ret; + + if (phydev->interrupts == PHY_INTERRUPT_ENABLED) + irq_mask = ADIN_LINK_STAT_CHNG_IRQ_EN; + else + irq_mask = 0; + + return phy_modify_mmd(phydev, MDIO_MMD_VEND2, + ADIN_PHY_SUBSYS_IRQ_MASK, + ADIN_LINK_STAT_CHNG_IRQ_EN, irq_mask); +} + +static irqreturn_t adin_phy_handle_interrupt(struct phy_device *phydev) +{ + int irq_status; + + irq_status = phy_read_mmd(phydev, MDIO_MMD_VEND2, + ADIN_PHY_SUBSYS_IRQ_STATUS); + if (irq_status < 0) { + phy_error(phydev); + return IRQ_NONE; + } + + if (!(irq_status & ADIN_LINK_STAT_CHNG)) + return IRQ_NONE; + + phy_trigger_machine(phydev); + + return IRQ_HANDLED; +} + static int adin_set_powerdown_mode(struct phy_device *phydev, bool en) { int ret; @@ -275,6 +329,8 @@ static struct phy_driver adin_driver[] = { .probe = adin_probe, .config_aneg = adin_config_aneg, .read_status = adin_read_status, + .config_intr = adin_config_intr, + .handle_interrupt = adin_phy_handle_interrupt, .set_loopback = adin_set_loopback, .suspend = adin_suspend, .resume = adin_resume,