All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Xuan Zhuo <xuanzhuo@linux.alibaba.com>
Cc: netdev@vger.kernel.org, Andrew Lunn <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Wen Gu <guwen@linux.alibaba.com>,
	Philo Lu <lulie@linux.alibaba.com>,
	Vadim Fedorenko <vadim.fedorenko@linux.dev>,
	Lorenzo Bianconi <lorenzo@kernel.org>,
	Lukas Bulwahn <lukas.bulwahn@redhat.com>,
	Dong Yibo <dong100@mucse.com>,
	Vivian Wang <wangruikang@iscas.ac.cn>,
	MD Danish Anwar <danishanwar@ti.com>,
	Dust Li <dust.li@linux.alibaba.com>
Subject: Re: [PATCH net-next v18 1/6] eea: introduce PCI framework
Date: Wed, 7 Jan 2026 19:52:27 +0000	[thread overview]
Message-ID: <20260107195227.GE345651@kernel.org> (raw)
In-Reply-To: <20260105110712.22674-2-xuanzhuo@linux.alibaba.com>

On Mon, Jan 05, 2026 at 07:07:07PM +0800, Xuan Zhuo wrote:
> Add basic driver framework for the Alibaba Elastic Ethernet Adapter(EEA).
> 
> This commit implements the EEA PCI probe functionality.
> 
> Reviewed-by: Dust Li <dust.li@linux.alibaba.com>
> Reviewed-by: Philo Lu <lulie@linux.alibaba.com>
> Signed-off-by: Wen Gu <guwen@linux.alibaba.com>
> Signed-off-by: Xuan Zhuo <xuanzhuo@linux.alibaba.com>

...

> diff --git a/drivers/net/ethernet/alibaba/eea/eea_pci.c b/drivers/net/ethernet/alibaba/eea/eea_pci.c

...

> +static int eea_pci_setup(struct pci_dev *pci_dev, struct eea_pci_device *ep_dev)
> +{
> +	int err, n, ret;
> +
> +	ep_dev->pci_dev = pci_dev;
> +
> +	err = pci_enable_device(pci_dev);
> +	if (err)
> +		return err;
> +
> +	err = pci_request_regions(pci_dev, "EEA");
> +	if (err)
> +		goto err_disable_dev;
> +
> +	pci_set_master(pci_dev);
> +
> +	err = dma_set_mask_and_coherent(&pci_dev->dev, DMA_BIT_MASK(64));
> +	if (err) {
> +		dev_warn(&pci_dev->dev, "Failed to enable 64-bit DMA.\n");
> +		goto err_release_regions;
> +	}
> +
> +	ep_dev->reg = pci_iomap(pci_dev, 0, 0);
> +	if (!ep_dev->reg) {
> +		dev_err(&pci_dev->dev, "Failed to map pci bar!\n");
> +		err = -ENOMEM;
> +		goto err_release_regions;
> +	}
> +
> +	ep_dev->edev.rx_num = cfg_read32(ep_dev->reg, rx_num_max);
> +	ep_dev->edev.tx_num = cfg_read32(ep_dev->reg, tx_num_max);
> +
> +	/* 2: adminq, error handle*/
> +	n = ep_dev->edev.rx_num + ep_dev->edev.tx_num + 2;
> +	ret = pci_alloc_irq_vectors(ep_dev->pci_dev, n, n, PCI_IRQ_MSIX);
> +	if (ret != n)
> +		goto err_unmap_reg;

Hi,

As n is passed as both the min_vecs and max_vecs argument of
pci_alloc_irq_vectors() I believe that ret will either be n, on success,
or an negative error value error.

And on error I think it would be appropriate for this function
to return that error value, rather than 0 s is currently the case.

Something like this (completely untested!):

	err = pci_alloc_irq_vectors(ep_dev->pci_dev, n, n, PCI_IRQ_MSIX);
	if (err < 0)
		goto err_unmap_reg;

Function return value portion of the above flagged by Smatch.

> +
> +	ep_dev->msix_vec_n = ret;
> +
> +	ep_dev->db_base = ep_dev->reg + EEA_PCI_DB_OFFSET;
> +	ep_dev->edev.db_blk_size = cfg_read32(ep_dev->reg, db_blk_size);
> +
> +	return 0;
> +
> +err_unmap_reg:
> +	pci_iounmap(pci_dev, ep_dev->reg);
> +	ep_dev->reg = NULL;
> +
> +err_release_regions:
> +	pci_release_regions(pci_dev);
> +
> +err_disable_dev:
> +	pci_disable_device(pci_dev);
> +
> +	return err;
> +}

...

-- 
pw-bot: cr

  reply	other threads:[~2026-01-07 19:52 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-01-05 11:07 [PATCH net-next v18 0/6] eea: Add basic driver framework for Alibaba Elastic Ethernet Adaptor Xuan Zhuo
2026-01-05 11:07 ` [PATCH net-next v18 1/6] eea: introduce PCI framework Xuan Zhuo
2026-01-07 19:52   ` Simon Horman [this message]
2026-01-05 11:07 ` [PATCH net-next v18 2/6] eea: introduce ring and descriptor structures Xuan Zhuo
2026-01-05 11:07 ` [PATCH net-next v18 3/6] eea: probe the netdevice and create adminq Xuan Zhuo
2026-01-05 11:07 ` [PATCH net-next v18 4/6] eea: create/destroy rx,tx queues for netdevice open and stop Xuan Zhuo
2026-01-08  8:17   ` Simon Horman
2026-01-05 11:07 ` [PATCH net-next v18 5/6] eea: introduce ethtool support Xuan Zhuo
2026-01-05 11:07 ` [PATCH net-next v18 6/6] eea: introduce callback for ndo_get_stats64 Xuan Zhuo

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=20260107195227.GE345651@kernel.org \
    --to=horms@kernel.org \
    --cc=andrew+netdev@lunn.ch \
    --cc=danishanwar@ti.com \
    --cc=davem@davemloft.net \
    --cc=dong100@mucse.com \
    --cc=dust.li@linux.alibaba.com \
    --cc=edumazet@google.com \
    --cc=guwen@linux.alibaba.com \
    --cc=kuba@kernel.org \
    --cc=lorenzo@kernel.org \
    --cc=lukas.bulwahn@redhat.com \
    --cc=lulie@linux.alibaba.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=vadim.fedorenko@linux.dev \
    --cc=wangruikang@iscas.ac.cn \
    --cc=xuanzhuo@linux.alibaba.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.