lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20240827141612.2edc92eb@kernel.org>
Date: Tue, 27 Aug 2024 14:16:12 -0700
From: Jakub Kicinski <kuba@...nel.org>
To: Michael Chan <michael.chan@...adcom.com>
Cc: Michal Swiatkowski <michal.swiatkowski@...ux.intel.com>,
 davem@...emloft.net, netdev@...r.kernel.org, edumazet@...gle.com,
 pabeni@...hat.com, pavan.chebbi@...adcom.com,
 andrew.gospodarek@...adcom.com, horms@...nel.org, helgaas@...nel.org,
 przemyslaw.kitszel@...el.com, Hongguang Gao <hongguang.gao@...adcom.com>,
 Somnath Kotur <somnath.kotur@...adcom.com>
Subject: Re: [PATCH net-next v3 9/9] bnxt_en: Support dynamic MSIX

On Tue, 27 Aug 2024 09:32:03 +0200 Michal Swiatkowski wrote:
> > +static int bnxt_add_msix(struct bnxt *bp, int total)
> > +{
> > +	int i;
> > +
> > +	if (bp->total_irqs >= total)
> > +		return total;
> > +
> > +	for (i = bp->total_irqs; i < total; i++) {
> > +		struct msi_map map;
> > +
> > +		map = pci_msix_alloc_irq_at(bp->pdev, i, NULL);
> > +		if (map.index < 0)
> > +			break;
> > +		bp->irq_tbl[i].vector = map.virq;
> > +		bp->total_irqs++;
> > +	}
> > +	return bp->total_irqs;
> > +}
> > +
> > +static int bnxt_trim_msix(struct bnxt *bp, int total)
> > +{
> > +	int i;
> > +
> > +	if (bp->total_irqs <= total)
> > +		return total;
> > +
> > +	for (i = bp->total_irqs; i > total; i--) {
> > +		struct msi_map map;
> > +
> > +		map.index = i - 1;
> > +		map.virq = bp->irq_tbl[i - 1].vector;
> > +		pci_msix_free_irq(bp->pdev, map);
> > +		bp->total_irqs--;
> > +	}
> > +	return bp->total_irqs;
> > +}  
> 
> Patch looks fine, treat it only as suggestion:
> 
> You can save some lines of code by merging this two function.
> 
> static int bnxt_change_msix(struct bnxt *bp, int total)
> {
> 	int i;
> 
> 	/* add MSI-Xs if needed */
> 	for (i = bp->total_irqs; i < total; i++) {
> 		...
> 	}
> 
> 	/* remove MSI-Xs if needed */
> 	for (i = bp->total_irqs; i > total; i--) {
> 		...
> 	}
> 
> 	return bp->total_irqs;
> }

> > +	} else if (irq_change && !rc) {
> > +		int total;
> > +
> > +		if (irqs_required > bp->total_irqs)
> > +			total = bnxt_add_msix(bp, irqs_required);
> > +		else
> > +			total = bnxt_trim_msix(bp, irqs_required);
> > +
> > +		if (total != irqs_required)
> > +			rc = -ENOSPC;  
> 
> and here
> 
> if (bnxt_change_msix(bp, irqs_required) != irqs_required)
> 	rc = -ENOSPC;

👍️ that does look cleaner

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ