Linux-HyperV Archive on lore.kernel.org
 help / color / Atom feed
From: Dexuan Cui <decui@microsoft.com>
To: Jakub Kicinski <kuba@kernel.org>
Cc: "davem@davemloft.net" <davem@davemloft.net>,
	KY Srinivasan <kys@microsoft.com>,
	Haiyang Zhang <haiyangz@microsoft.com>,
	Stephen Hemminger <sthemmin@microsoft.com>,
	"wei.liu@kernel.org" <wei.liu@kernel.org>,
	Wei Liu <liuwe@microsoft.com>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"leon@kernel.org" <leon@kernel.org>,
	"andrew@lunn.ch" <andrew@lunn.ch>,
	"bernd@petrovitsch.priv.at" <bernd@petrovitsch.priv.at>,
	"rdunlap@infradead.org" <rdunlap@infradead.org>,
	Shachar Raindel <shacharr@microsoft.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"linux-hyperv@vger.kernel.org" <linux-hyperv@vger.kernel.org>
Subject: RE: [PATCH v5 net-next] net: mana: Add a driver for Microsoft Azure Network Adapter (MANA)
Date: Tue, 13 Apr 2021 19:40:45 +0000
Message-ID: <MW2PR2101MB089261344E20347A4824C7C8BF4F9@MW2PR2101MB0892.namprd21.prod.outlook.com> (raw)
In-Reply-To: <20210413120324.18983187@kicinski-fedora-pc1c0hjn.dhcp.thefacebook.com>

> From: Jakub Kicinski <kuba@kernel.org>
> Sent: Tuesday, April 13, 2021 12:03 PM
> 
> On Mon, 12 Apr 2021 19:35:09 -0700 Dexuan Cui wrote:
> > +	apc->port_st_save = apc->port_is_up;
> > +	apc->port_is_up = false;
> > +	apc->start_remove = true;
> > +
> > +	/* Ensure port state updated before txq state */
> > +	smp_wmb();
> > +
> > +	netif_tx_disable(ndev);
> 
> In your napi poll method there is no barrier between port_is_up check
> and netif_tx_queue_stopped().

Thanks for spotting this! We'll make the below change:

--- a/drivers/net/ethernet/microsoft/mana/mana_en.c
+++ b/drivers/net/ethernet/microsoft/mana/mana_en.c
@@ -938,16 +938,19 @@ static void mana_poll_tx_cq(struct mana_cq *cq)
        avail_space = mana_gd_wq_avail_space(gdma_wq);

        /* Ensure tail updated before checking q stop */
        smp_mb();

        net_txq = txq->net_txq;
        txq_stopped = netif_tx_queue_stopped(net_txq);

+       /* Ensure checking txq_stopped before apc->port_is_up. */
+       smp_rmb();
+
        if (txq_stopped && apc->port_is_up && avail_space >= MAX_TX_WQE_SIZE) {
                netif_tx_wake_queue(net_txq);
                apc->eth_stats.wake_queue++;
        }

        if (atomic_sub_return(pkt_transmitted, &txq->pending_sends) < 0)
                WARN_ON_ONCE(1);
 }

> > +	netif_carrier_off(ndev);
> > +
> > +	/* No packet can be transmitted now since apc->port_is_up is false.
> > +	 * There is still a tiny chance that mana_poll_tx_cq() can re-enable
> > +	 * a txq because it may not timely see apc->port_is_up being cleared
> > +	 * to false, but it doesn't matter since mana_start_xmit() drops any
> > +	 * new packets due to apc->port_is_up being false.
> > +	 *
> > +	 * Drain all the in-flight TX packets
> > +	 */
> > +	for (i = 0; i < apc->num_queues; i++) {
> > +		txq = &apc->tx_qp[i].txq;
> > +
> > +		while (atomic_read(&txq->pending_sends) > 0)
> > +			usleep_range(1000, 2000);
> > +	}
> 
> > +		/* All cleanup actions should stay after rtnl_lock(), otherwise
> > +		 * other functions may access partially cleaned up data.
> > +		 */
> > +		rtnl_lock();
> > +
> > +		mana_detach(ndev);
> > +
> > +		unregister_netdevice(ndev);
> > +
> > +		rtnl_unlock();
> 
> I find the resource management somewhat strange. Why is mana_attach()
> and mana_detach() called at probe/remove time, and not when the
> interface is brought up? Presumably when the user ifdowns the interface
> there is no point holding the resources? Your open/close methods are
> rather empty.

Thanks for the suggestion! Will move the functions to open/close().

> > +	if ((eq_addr & PAGE_MASK) != eq_addr)
> > +		return -EINVAL;
> > +
> > +	if ((cq_addr & PAGE_MASK) != cq_addr)
> > +		return -EINVAL;
> > +
> > +	if ((rq_addr & PAGE_MASK) != rq_addr)
> > +		return -EINVAL;
> > +
> > +	if ((sq_addr & PAGE_MASK) != sq_addr)
> > +		return -EINVAL;

Will change to PAGE_ALIGNED(). 

Thanks,
Dexuan

      reply index

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <20210413023509.51952-1-decui@microsoft.com>
2021-04-13 19:03 ` Jakub Kicinski
2021-04-13 19:40   ` Dexuan Cui [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=MW2PR2101MB089261344E20347A4824C7C8BF4F9@MW2PR2101MB0892.namprd21.prod.outlook.com \
    --to=decui@microsoft.com \
    --cc=andrew@lunn.ch \
    --cc=bernd@petrovitsch.priv.at \
    --cc=davem@davemloft.net \
    --cc=haiyangz@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=liuwe@microsoft.com \
    --cc=netdev@vger.kernel.org \
    --cc=rdunlap@infradead.org \
    --cc=shacharr@microsoft.com \
    --cc=sthemmin@microsoft.com \
    --cc=wei.liu@kernel.org \
    /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

Linux-HyperV Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/linux-hyperv/0 linux-hyperv/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 linux-hyperv linux-hyperv/ https://lore.kernel.org/linux-hyperv \
		linux-hyperv@vger.kernel.org
	public-inbox-index linux-hyperv

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.kernel.vger.linux-hyperv


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git