From: Andrew Lunn <andrew@lunn.ch>
To: "Bastien Curutchet (Schneider Electric)" <bastien.curutchet@bootlin.com>
Cc: "Woojung Huh" <woojung.huh@microchip.com>,
UNGLinuxDriver@microchip.com,
"Vladimir Oltean" <olteanv@gmail.com>,
"David S. Miller" <davem@davemloft.net>,
"Eric Dumazet" <edumazet@google.com>,
"Jakub Kicinski" <kuba@kernel.org>,
"Paolo Abeni" <pabeni@redhat.com>,
"Richard Cochran" <richardcochran@gmail.com>,
"Arun Ramadoss" <arun.ramadoss@microchip.com>,
"Pascal Eberhard" <pascal.eberhard@se.com>,
"Miquèl Raynal" <miquel.raynal@bootlin.com>,
"Thomas Petazzoni" <thomas.petazzoni@bootlin.com>,
netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net v3 4/4] net: dsa: microchip: Immediately assing IRQ numbers
Date: Fri, 14 Nov 2025 16:11:14 +0100 [thread overview]
Message-ID: <aeba78cf-a220-4a40-964c-08b9d852ef17@lunn.ch> (raw)
In-Reply-To: <20251114-ksz-fix-v3-4-acbb3b9cc32f@bootlin.com>
On Fri, Nov 14, 2025 at 08:20:23AM +0100, Bastien Curutchet (Schneider Electric) wrote:
> The IRQ numbers created through irq_create_mapping() are only assigned
> to ptpmsg_irq[n].num at the end of the IRQ setup. So if an error occurs
> between their creation and their assignment (for instance during the
> request_threaded_irq() step), we enter the error path and fail to
> release the newly created virtual IRQs because they aren't yet assigned
> to ptpmsg_irq[n].num.
>
> Assign the IRQ number at mapping creation.
>
> Fixes: cc13ab18b201 ("net: dsa: microchip: ptp: enable interrupt for timestamping")
> Signed-off-by: Bastien Curutchet (Schneider Electric) <bastien.curutchet@bootlin.com>
> ---
> drivers/net/dsa/microchip/ksz_ptp.c | 13 +++++++------
> 1 file changed, 7 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/net/dsa/microchip/ksz_ptp.c b/drivers/net/dsa/microchip/ksz_ptp.c
> index c8bfbe5e2157323ecf29149d1907b77e689aa221..a8ad99c6ee35ff60fb56cc5770520a793c86ff66 100644
> --- a/drivers/net/dsa/microchip/ksz_ptp.c
> +++ b/drivers/net/dsa/microchip/ksz_ptp.c
> @@ -1102,10 +1102,6 @@ static int ksz_ptp_msg_irq_setup(struct ksz_port *port, u8 n)
>
> strscpy(ptpmsg_irq->name, name[n]);
>
> - ptpmsg_irq->num = irq_find_mapping(port->ptpirq.domain, n);
> - if (ptpmsg_irq->num < 0)
> - return ptpmsg_irq->num;
> -
> return request_threaded_irq(ptpmsg_irq->num, NULL,
> ksz_ptp_msg_thread_fn, IRQF_ONESHOT,
> ptpmsg_irq->name, ptpmsg_irq);
static void ksz_ptp_msg_irq_free(struct ksz_port *port, u8 n)
{
struct ksz_ptp_irq *ptpmsg_irq;
ptpmsg_irq = &port->ptpmsg_irq[n];
free_irq(ptpmsg_irq->num, ptpmsg_irq);
irq_dispose_mapping(ptpmsg_irq->num);
}
This is supposed to be the opposite of ksz_ptp_msg_irq_setup()? The
opposite of irq_dispose_mapping() is irq_create_mapping()? But that
does not happen in ksz_ptp_msg_irq_setup()?
Maybe this change is enough to fix the issue, but it seems like there
is more asymmetry to correct in this code.
Andrew
prev parent reply other threads:[~2025-11-14 15:11 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-14 7:20 [PATCH net v3 0/4] net: dsa: microchip: Fix resource releases in error path Bastien Curutchet (Schneider Electric)
2025-11-14 7:20 ` [PATCH net v3 1/4] net: dsa: microchip: common: Fix checks on irq_find_mapping() Bastien Curutchet (Schneider Electric)
2025-11-14 14:51 ` Andrew Lunn
2025-11-14 7:20 ` [PATCH net v3 2/4] net: dsa: microchip: ptp: " Bastien Curutchet (Schneider Electric)
2025-11-14 14:51 ` Andrew Lunn
2025-11-14 7:20 ` [PATCH net v3 3/4] net: dsa: microchip: Ensure a ksz_irq is initialized before freeing it Bastien Curutchet (Schneider Electric)
2025-11-14 15:00 ` Andrew Lunn
2025-11-17 8:51 ` Bastien Curutchet
2025-11-14 7:20 ` [PATCH net v3 4/4] net: dsa: microchip: Immediately assing IRQ numbers Bastien Curutchet (Schneider Electric)
2025-11-14 15:11 ` Andrew Lunn [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aeba78cf-a220-4a40-964c-08b9d852ef17@lunn.ch \
--to=andrew@lunn.ch \
--cc=UNGLinuxDriver@microchip.com \
--cc=arun.ramadoss@microchip.com \
--cc=bastien.curutchet@bootlin.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=kuba@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=netdev@vger.kernel.org \
--cc=olteanv@gmail.com \
--cc=pabeni@redhat.com \
--cc=pascal.eberhard@se.com \
--cc=richardcochran@gmail.com \
--cc=thomas.petazzoni@bootlin.com \
--cc=woojung.huh@microchip.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®