diff options
author | Greg Kroah-Hartman <gregkh@suse.de> | 2009-07-15 17:55:14 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2009-09-15 15:01:48 -0400 |
commit | a98f96eed5fa16f4868b4af2d50af77f57a1b231 (patch) | |
tree | 68fe1c314c1155e1d7fe512e4bcd933e9f06c198 /drivers/staging/hv | |
parent | 54411c425fe0f5f8a5fcc1f3098693419ae87306 (diff) |
Staging: hv: make RingInfo->RingLock a real spinlock
Don't use the wrapper functions for this lock, make it a real
lock so that we know what is going on.
I don't think we really want to be doing a irqsave for this code, but I
left it alone to preserve the original codepath. It should be reviewed
later.
Cc: Hank Janssen <hjanssen@microsoft.com>
Cc: Haiyang Zhang <haiyangz@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/hv')
-rw-r--r-- | drivers/staging/hv/RingBuffer.c | 24 | ||||
-rw-r--r-- | drivers/staging/hv/RingBuffer.h | 2 |
2 files changed, 14 insertions, 12 deletions
diff --git a/drivers/staging/hv/RingBuffer.c b/drivers/staging/hv/RingBuffer.c index 34d4adaa19b..21fc4cc6326 100644 --- a/drivers/staging/hv/RingBuffer.c +++ b/drivers/staging/hv/RingBuffer.c | |||
@@ -315,7 +315,7 @@ RingBufferInit( | |||
315 | RingInfo->RingSize = BufferLen; | 315 | RingInfo->RingSize = BufferLen; |
316 | RingInfo->RingDataSize = BufferLen - sizeof(RING_BUFFER); | 316 | RingInfo->RingDataSize = BufferLen - sizeof(RING_BUFFER); |
317 | 317 | ||
318 | RingInfo->RingLock = SpinlockCreate(); | 318 | spin_lock_init(&RingInfo->ring_lock); |
319 | 319 | ||
320 | return 0; | 320 | return 0; |
321 | } | 321 | } |
@@ -334,7 +334,6 @@ RingBufferCleanup( | |||
334 | RING_BUFFER_INFO* RingInfo | 334 | RING_BUFFER_INFO* RingInfo |
335 | ) | 335 | ) |
336 | { | 336 | { |
337 | SpinlockClose(RingInfo->RingLock); | ||
338 | } | 337 | } |
339 | 338 | ||
340 | /*++ | 339 | /*++ |
@@ -360,6 +359,7 @@ RingBufferWrite( | |||
360 | 359 | ||
361 | volatile u32 nextWriteLocation; | 360 | volatile u32 nextWriteLocation; |
362 | u64 prevIndices=0; | 361 | u64 prevIndices=0; |
362 | unsigned long flags; | ||
363 | 363 | ||
364 | DPRINT_ENTER(VMBUS); | 364 | DPRINT_ENTER(VMBUS); |
365 | 365 | ||
@@ -370,7 +370,7 @@ RingBufferWrite( | |||
370 | 370 | ||
371 | totalBytesToWrite += sizeof(u64); | 371 | totalBytesToWrite += sizeof(u64); |
372 | 372 | ||
373 | SpinlockAcquire(OutRingInfo->RingLock); | 373 | spin_lock_irqsave(&OutRingInfo->ring_lock, flags); |
374 | 374 | ||
375 | GetRingBufferAvailBytes(OutRingInfo, &byteAvailToRead, &byteAvailToWrite); | 375 | GetRingBufferAvailBytes(OutRingInfo, &byteAvailToRead, &byteAvailToWrite); |
376 | 376 | ||
@@ -384,7 +384,7 @@ RingBufferWrite( | |||
384 | { | 384 | { |
385 | DPRINT_DBG(VMBUS, "No more space left on outbound ring buffer (needed %u, avail %u)", totalBytesToWrite, byteAvailToWrite); | 385 | DPRINT_DBG(VMBUS, "No more space left on outbound ring buffer (needed %u, avail %u)", totalBytesToWrite, byteAvailToWrite); |
386 | 386 | ||
387 | SpinlockRelease(OutRingInfo->RingLock); | 387 | spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags); |
388 | 388 | ||
389 | DPRINT_EXIT(VMBUS); | 389 | DPRINT_EXIT(VMBUS); |
390 | 390 | ||
@@ -418,7 +418,7 @@ RingBufferWrite( | |||
418 | 418 | ||
419 | //DumpRingInfo(OutRingInfo, "AFTER "); | 419 | //DumpRingInfo(OutRingInfo, "AFTER "); |
420 | 420 | ||
421 | SpinlockRelease(OutRingInfo->RingLock); | 421 | spin_unlock_irqrestore(&OutRingInfo->ring_lock, flags); |
422 | 422 | ||
423 | DPRINT_EXIT(VMBUS); | 423 | DPRINT_EXIT(VMBUS); |
424 | 424 | ||
@@ -445,8 +445,9 @@ RingBufferPeek( | |||
445 | u32 bytesAvailToWrite; | 445 | u32 bytesAvailToWrite; |
446 | u32 bytesAvailToRead; | 446 | u32 bytesAvailToRead; |
447 | u32 nextReadLocation=0; | 447 | u32 nextReadLocation=0; |
448 | unsigned long flags; | ||
448 | 449 | ||
449 | SpinlockAcquire(InRingInfo->RingLock); | 450 | spin_lock_irqsave(&InRingInfo->ring_lock, flags); |
450 | 451 | ||
451 | GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); | 452 | GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); |
452 | 453 | ||
@@ -455,7 +456,7 @@ RingBufferPeek( | |||
455 | { | 456 | { |
456 | //DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); | 457 | //DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); |
457 | 458 | ||
458 | SpinlockRelease(InRingInfo->RingLock); | 459 | spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); |
459 | 460 | ||
460 | return -1; | 461 | return -1; |
461 | } | 462 | } |
@@ -468,7 +469,7 @@ RingBufferPeek( | |||
468 | BufferLen, | 469 | BufferLen, |
469 | nextReadLocation); | 470 | nextReadLocation); |
470 | 471 | ||
471 | SpinlockRelease(InRingInfo->RingLock); | 472 | spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); |
472 | 473 | ||
473 | return 0; | 474 | return 0; |
474 | } | 475 | } |
@@ -495,10 +496,11 @@ RingBufferRead( | |||
495 | u32 bytesAvailToRead; | 496 | u32 bytesAvailToRead; |
496 | u32 nextReadLocation=0; | 497 | u32 nextReadLocation=0; |
497 | u64 prevIndices=0; | 498 | u64 prevIndices=0; |
499 | unsigned long flags; | ||
498 | 500 | ||
499 | ASSERT(BufferLen > 0); | 501 | ASSERT(BufferLen > 0); |
500 | 502 | ||
501 | SpinlockAcquire(InRingInfo->RingLock); | 503 | spin_lock_irqsave(&InRingInfo->ring_lock, flags); |
502 | 504 | ||
503 | GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); | 505 | GetRingBufferAvailBytes(InRingInfo, &bytesAvailToRead, &bytesAvailToWrite); |
504 | 506 | ||
@@ -511,7 +513,7 @@ RingBufferRead( | |||
511 | { | 513 | { |
512 | DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); | 514 | DPRINT_DBG(VMBUS, "got callback but not enough to read <avail to read %d read size %d>!!", bytesAvailToRead, BufferLen); |
513 | 515 | ||
514 | SpinlockRelease(InRingInfo->RingLock); | 516 | spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); |
515 | 517 | ||
516 | return -1; | 518 | return -1; |
517 | } | 519 | } |
@@ -537,7 +539,7 @@ RingBufferRead( | |||
537 | 539 | ||
538 | //DumpRingInfo(InRingInfo, "AFTER "); | 540 | //DumpRingInfo(InRingInfo, "AFTER "); |
539 | 541 | ||
540 | SpinlockRelease(InRingInfo->RingLock); | 542 | spin_unlock_irqrestore(&InRingInfo->ring_lock, flags); |
541 | 543 | ||
542 | return 0; | 544 | return 0; |
543 | } | 545 | } |
diff --git a/drivers/staging/hv/RingBuffer.h b/drivers/staging/hv/RingBuffer.h index ba2d8a9455e..4217259890b 100644 --- a/drivers/staging/hv/RingBuffer.h +++ b/drivers/staging/hv/RingBuffer.h | |||
@@ -48,7 +48,7 @@ typedef struct _RING_BUFFER { | |||
48 | typedef struct _RING_BUFFER_INFO { | 48 | typedef struct _RING_BUFFER_INFO { |
49 | RING_BUFFER* RingBuffer; | 49 | RING_BUFFER* RingBuffer; |
50 | u32 RingSize; // Include the shared header | 50 | u32 RingSize; // Include the shared header |
51 | HANDLE RingLock; | 51 | spinlock_t ring_lock; |
52 | 52 | ||
53 | u32 RingDataSize; // < ringSize | 53 | u32 RingDataSize; // < ringSize |
54 | u32 RingDataStartOffset; | 54 | u32 RingDataStartOffset; |