From 207664f87ca603ef598382dfadc033d93beb4dda Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Wed, 10 May 2023 19:06:54 +0200 Subject: [PATCH 1/8] Removed 'illegal' header I've removed the vermagic.h header since it is not allowed to be included. --- Driver/Source.Plx9000/Driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Source.Plx9000/Driver.c b/Driver/Source.Plx9000/Driver.c index 669921c..2d0c8b5 100644 --- a/Driver/Source.Plx9000/Driver.c +++ b/Driver/Source.Plx9000/Driver.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include "ApiFunc.h" #include "Dispatch.h" #include "Driver.h" From aad13864e4c4374a3c665a33ed6c68e6ed36b42f Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Wed, 10 May 2023 19:12:28 +0200 Subject: [PATCH 2/8] Fixed error due to changes in mmap semaphore api --- Driver/Source.Plx9000/SuppFunc.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/Driver/Source.Plx9000/SuppFunc.c b/Driver/Source.Plx9000/SuppFunc.c index eeeb723..c15ab6c 100644 --- a/Driver/Source.Plx9000/SuppFunc.c +++ b/Driver/Source.Plx9000/SuppFunc.c @@ -953,7 +953,11 @@ PlxLockBufferAndBuildSgl( } // Obtain the mmap reader/writer semaphore - down_read( ¤t->mm->mmap_sem ); + #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + down_read( ¤t->mm->mmap_sem ); + #else + mmap_read_lock( current->mm ); + #endif // Attempt to lock the user buffer into memory rc = @@ -966,7 +970,11 @@ PlxLockBufferAndBuildSgl( ); // Release mmap semaphore - up_read( ¤t->mm->mmap_sem ); + #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + up_read( ¤t->mm->mmap_sem ); + #else + mmap_read_unlock( current->mm ); + #endif if (rc != TotalDescr) { From a83fcfbcd81f648cdb2991f5303bc01a740b4777 Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Wed, 3 Jan 2024 14:21:23 +0100 Subject: [PATCH 3/8] Patched the other driver files as well I've applied the patch on all the driver.c files. --- Driver/Source.Plx6000_NT/Driver.c | 2 +- Driver/Source.Plx8000_DMA/Driver.c | 2 +- Driver/Source.PlxSvc/Driver.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Driver/Source.Plx6000_NT/Driver.c b/Driver/Source.Plx6000_NT/Driver.c index ff038d6..2a02697 100644 --- a/Driver/Source.Plx6000_NT/Driver.c +++ b/Driver/Source.Plx6000_NT/Driver.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include "ApiFunc.h" #include "Dispatch.h" #include "Driver.h" diff --git a/Driver/Source.Plx8000_DMA/Driver.c b/Driver/Source.Plx8000_DMA/Driver.c index 4ccff22..35e75f2 100644 --- a/Driver/Source.Plx8000_DMA/Driver.c +++ b/Driver/Source.Plx8000_DMA/Driver.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include "ApiFunc.h" #include "Dispatch.h" #include "Driver.h" diff --git a/Driver/Source.PlxSvc/Driver.c b/Driver/Source.PlxSvc/Driver.c index 5c9a3bc..da6cd48 100644 --- a/Driver/Source.PlxSvc/Driver.c +++ b/Driver/Source.PlxSvc/Driver.c @@ -53,7 +53,7 @@ #include #include // For kmalloc() #include -#include +#include #include "Dispatch.h" #include "Driver.h" #include "PciFunc.h" From b42735d9c53ea04eba47e12f57ca366d6cb141e7 Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Wed, 3 Jan 2024 14:27:35 +0100 Subject: [PATCH 4/8] Removed call to deprecated ftime() As suggested by @rmathar the call to ftime() has been removed and replaced by the standard gettimeofday() --- PlxApi/SpiFlash.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/PlxApi/SpiFlash.c b/PlxApi/SpiFlash.c index 7a7a86e..168ac87 100644 --- a/PlxApi/SpiFlash.c +++ b/PlxApi/SpiFlash.c @@ -49,7 +49,7 @@ #include // For memset()/memcpy() -#include // For ftime() +#include // For getttimeofday() #include "SpiFlash.h" #include "PlxApiDebug.h" @@ -764,12 +764,13 @@ Spi_WaitControllerReady( U32 regVal; U32 elapsedTimeMs; PLX_STATUS status; - struct timeb endTime; - struct timeb startTime; + struct timeval endTime; + struct timeval startTime; + struct timeval deltaTime; // Note start time - ftime( &startTime ); + gettimeofday( &startTime, NULL ); // Wait until command valid is clear do @@ -790,8 +791,9 @@ Spi_WaitControllerReady( } // Verify we don't exceed poll time - ftime( &endTime ); - elapsedTimeMs = (U32)(PLX_DIFF_TIMEB( endTime, startTime ) * 1000); + gettimeofday( &endTime, NULL ); + timersub( &startTime, &endTime, &deltaTime); + elapsedTimeMs = (U32)( deltaTime.tv_sec*1000 + deltatTime.tv_usec/1000 ); if (elapsedTimeMs >= SPI_MAX_WAIT_CTRL_READY_MS) { ErrorPrintf(( From 750d5b9a1eb9481f8498d5fe2d027cc6cc654642 Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Wed, 3 Jan 2024 14:28:50 +0100 Subject: [PATCH 5/8] And the last file... --- Driver/Source.Plx8000_NT/Driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Driver/Source.Plx8000_NT/Driver.c b/Driver/Source.Plx8000_NT/Driver.c index 4c773b9..0767bff 100644 --- a/Driver/Source.Plx8000_NT/Driver.c +++ b/Driver/Source.Plx8000_NT/Driver.c @@ -52,7 +52,7 @@ #include #include #include -#include +#include #include "ApiFunc.h" #include "Dispatch.h" #include "Driver.h" From f881d0a9d4c0e3c5e6acb6e477cf54c3ac248523 Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Fri, 5 Jan 2024 14:39:08 +0100 Subject: [PATCH 6/8] Fixed typo --- PlxApi/SpiFlash.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PlxApi/SpiFlash.c b/PlxApi/SpiFlash.c index 168ac87..84bd9b1 100644 --- a/PlxApi/SpiFlash.c +++ b/PlxApi/SpiFlash.c @@ -793,7 +793,7 @@ Spi_WaitControllerReady( // Verify we don't exceed poll time gettimeofday( &endTime, NULL ); timersub( &startTime, &endTime, &deltaTime); - elapsedTimeMs = (U32)( deltaTime.tv_sec*1000 + deltatTime.tv_usec/1000 ); + elapsedTimeMs = (U32)( deltaTime.tv_sec*1000 + deltaTime.tv_usec/1000 ); if (elapsedTimeMs >= SPI_MAX_WAIT_CTRL_READY_MS) { ErrorPrintf(( From d1a5764f6185d09f42ba66b1c821b572c358f732 Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Fri, 5 Jan 2024 14:46:29 +0100 Subject: [PATCH 7/8] Propagate more error fixes... --- Driver/Source.Plx8000_DMA/SuppFunc.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/Driver/Source.Plx8000_DMA/SuppFunc.c b/Driver/Source.Plx8000_DMA/SuppFunc.c index aaf3df3..86a627b 100644 --- a/Driver/Source.Plx8000_DMA/SuppFunc.c +++ b/Driver/Source.Plx8000_DMA/SuppFunc.c @@ -991,7 +991,11 @@ PlxLockBufferAndBuildSgl( } // Obtain the mmap reader/writer semaphore - down_read( ¤t->mm->mmap_sem ); + #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + down_read( ¤t->mm->mmap_sem ); + #else + mmap_read_lock( current->mm ); + #endif // Attempt to lock the user buffer into memory rc = @@ -1004,7 +1008,10 @@ PlxLockBufferAndBuildSgl( ); // Release mmap semaphore - up_read( ¤t->mm->mmap_sem ); + #if LINUX_VERSION_CODE < KERNEL_VERSION(5, 8, 0) + up_read( ¤t->mm->mmap_sem ); + #else + mmap_read_unlock( current->mm ); if (rc != TotalDescr) { From 834d3e9af93a1307072dc97d7d88cabff711ea4d Mon Sep 17 00:00:00 2001 From: "Vetle W. Ingeberg" Date: Fri, 5 Jan 2024 14:46:56 +0100 Subject: [PATCH 8/8] Typo... --- Driver/Source.Plx8000_DMA/SuppFunc.c | 1 + 1 file changed, 1 insertion(+) diff --git a/Driver/Source.Plx8000_DMA/SuppFunc.c b/Driver/Source.Plx8000_DMA/SuppFunc.c index 86a627b..f54932b 100644 --- a/Driver/Source.Plx8000_DMA/SuppFunc.c +++ b/Driver/Source.Plx8000_DMA/SuppFunc.c @@ -1012,6 +1012,7 @@ PlxLockBufferAndBuildSgl( up_read( ¤t->mm->mmap_sem ); #else mmap_read_unlock( current->mm ); + #endif if (rc != TotalDescr) {