Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 13 Aug 2014 00:14:27 +0000 (UTC)
From:      Neel Natu <neel@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r269896 - head/usr.sbin/bhyve
Message-ID:  <201408130014.s7D0ER3j059836@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: neel
Date: Wed Aug 13 00:14:26 2014
New Revision: 269896
URL: http://svnweb.freebsd.org/changeset/base/269896

Log:
  Minor cleanup:
  - Set 'pirq_cold' to '0' on the first PIRQ allocation.
  - Make assertions stronger.
  
  Reviewed by:	jhb
  CR:		https://phabric.freebsd.org/D592

Modified:
  head/usr.sbin/bhyve/pci_irq.c

Modified: head/usr.sbin/bhyve/pci_irq.c
==============================================================================
--- head/usr.sbin/bhyve/pci_irq.c	Tue Aug 12 23:48:37 2014	(r269895)
+++ head/usr.sbin/bhyve/pci_irq.c	Wed Aug 13 00:14:26 2014	(r269896)
@@ -115,7 +115,7 @@ void
 pci_irq_reserve(int irq)
 {
 
-	assert(irq < nitems(irq_counts));
+	assert(irq >= 0 && irq < nitems(irq_counts));
 	assert(pirq_cold);
 	assert(irq_counts[irq] == 0 || irq_counts[irq] == IRQ_DISABLED);
 	irq_counts[irq] = IRQ_DISABLED;
@@ -125,10 +125,10 @@ void
 pci_irq_use(int irq)
 {
 
-	assert(irq < nitems(irq_counts));
+	assert(irq >= 0 && irq < nitems(irq_counts));
 	assert(pirq_cold);
-	if (irq_counts[irq] != IRQ_DISABLED)
-		irq_counts[irq]++;
+	assert(irq_counts[irq] != IRQ_DISABLED);
+	irq_counts[irq]++;
 }
 
 void
@@ -197,7 +197,7 @@ pirq_alloc_pin(struct vmctx *ctx)
 {
 	int best_count, best_irq, best_pin, irq, pin;
 
-	pirq_cold = 1;
+	pirq_cold = 0;
 
 	/* First, find the least-used PIRQ pin. */
 	best_pin = 0;
@@ -222,7 +222,7 @@ pirq_alloc_pin(struct vmctx *ctx)
 				best_count = irq_counts[irq];
 			}
 		}
-		assert(best_irq != 0);
+		assert(best_irq >= 0);
 		irq_counts[best_irq]++;
 		pirqs[best_pin].reg = best_irq;
 		vm_isa_set_irq_trigger(ctx, best_irq, LEVEL_TRIGGER);
@@ -234,9 +234,6 @@ pirq_alloc_pin(struct vmctx *ctx)
 int
 pirq_irq(int pin)
 {
-
-	if (pin == -1)
-		return (255);
 	assert(pin > 0 && pin <= nitems(pirqs));
 	return (pirqs[pin - 1].reg & PIRQ_IRQ);
 }



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201408130014.s7D0ER3j059836>