mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Andrew Lunn <andrew@lunn.ch>
To: Haiyang Zhang <haiyangz@linux.microsoft.com>
Cc: linux-hyperv@vger.kernel.org, netdev@vger.kernel.org,
	haiyangz@microsoft.com, paulros@microsoft.com,
	decui@microsoft.com, kys@microsoft.com, wei.liu@kernel.org,
	edumazet@google.com, davem@davemloft.net, kuba@kernel.org,
	pabeni@redhat.com, longli@microsoft.com,
	ssengar@linux.microsoft.com, ernis@linux.microsoft.com,
	dipayanroy@linux.microsoft.com, kotaranov@microsoft.com,
	horms@kernel.org, shradhagupta@linux.microsoft.com,
	leon@kernel.org, mlevitsk@redhat.com, yury.norov@gmail.com,
	shirazsaleem@microsoft.com, andrew+netdev@lunn.ch,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next] net: mana: Support HW link state events
Date: Mon, 13 Oct 2025 23:13:20 +0200	[thread overview]
Message-ID: <74490632-68da-401d-89a7-3d937d63cbe3@lunn.ch> (raw)
In-Reply-To: <1760384001-30805-1-git-send-email-haiyangz@linux.microsoft.com>

> +static void mana_link_state_handle(struct work_struct *w)
> +{
> +	struct mana_context *ac =
> +		container_of(w, struct mana_context, link_change_work.work);
> +	struct mana_port_context *apc;
> +	struct net_device *ndev;
> +	bool link_up;
> +	int i;

Since you don't need ac here, i would postpone the assignment into the
body of the function, so keeping with reverse christmass tree.

> +
> +	if (!rtnl_trylock()) {
> +		schedule_delayed_work(&ac->link_change_work, 1);
> +		return;
> +	}

Is there a deadlock you are trying to avoid here? Why not wait for the
lock?

> +
> +	if (ac->link_event == HWC_DATA_HW_LINK_CONNECT)
> +		link_up = true;
> +	else if (ac->link_event == HWC_DATA_HW_LINK_DISCONNECT)
> +		link_up = false;
> +	else
> +		goto out;
> +
> +	/* Process all ports */
> +	for (i = 0; i < ac->num_ports; i++) {
> +		ndev = ac->ports[i];
> +		if (!ndev)
> +			continue;
> +
> +		apc = netdev_priv(ndev);
> +
> +		if (link_up) {
> +			netif_carrier_on(ndev);
> +
> +			if (apc->port_is_up)
> +				netif_tx_wake_all_queues(ndev);
> +
> +			__netdev_notify_peers(ndev);
> +		} else {
> +			if (netif_carrier_ok(ndev)) {
> +				netif_tx_disable(ndev);
> +				netif_carrier_off(ndev);
> +			}
> +		}

It is odd this is asymmetric. Up and down should really be opposites.

> @@ -3500,6 +3548,8 @@ void mana_remove(struct gdma_dev *gd, bool suspending)
>  	int err;
>  	int i;
>  
> +	cancel_delayed_work_sync(&ac->link_change_work);

I don't know delayed work too well. Is this sufficient when the work
requeues itself because it cannot get RTNL?

	Andrew

  reply	other threads:[~2025-10-13 21:13 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-13 19:33 Haiyang Zhang
2025-10-13 21:13 ` Andrew Lunn [this message]
2025-10-13 21:47   ` [EXTERNAL] " Haiyang Zhang
2025-10-13 23:21     ` Andrew Lunn
2025-10-14 14:11       ` Haiyang Zhang

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=74490632-68da-401d-89a7-3d937d63cbe3@lunn.ch \
    --to=andrew@lunn.ch \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=decui@microsoft.com \
    --cc=dipayanroy@linux.microsoft.com \
    --cc=edumazet@google.com \
    --cc=ernis@linux.microsoft.com \
    --cc=haiyangz@linux.microsoft.com \
    --cc=haiyangz@microsoft.com \
    --cc=horms@kernel.org \
    --cc=kotaranov@microsoft.com \
    --cc=kuba@kernel.org \
    --cc=kys@microsoft.com \
    --cc=leon@kernel.org \
    --cc=linux-hyperv@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    --cc=longli@microsoft.com \
    --cc=mlevitsk@redhat.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=paulros@microsoft.com \
    --cc=shirazsaleem@microsoft.com \
    --cc=shradhagupta@linux.microsoft.com \
    --cc=ssengar@linux.microsoft.com \
    --cc=wei.liu@kernel.org \
    --cc=yury.norov@gmail.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®