]> git.openfabrics.org - ~shefty/rdma-win.git/commitdiff
[MTHCA] 1. Fixed an error in sanity check. 2. Fixed an error in event logging
authorleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 10 Apr 2006 09:33:56 +0000 (09:33 +0000)
committerleonidk <leonidk@ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86>
Mon, 10 Apr 2006 09:33:56 +0000 (09:33 +0000)
git-svn-id: svn://openib.tc.cornell.edu/gen1@298 ad392aa1-c5ef-ae45-8dd8-e69d62a5ef86

trunk/hw/mthca/kernel/mthca_log.c
trunk/hw/mthca/kernel/mthca_main.c

index 46825ff5edf75a8f5bf0becd5d427d15d9678c8d..5202460091fcdf418d666592afda51073d725fb3 100644 (file)
@@ -162,18 +162,20 @@ Return Value:
        PIO_ERROR_LOG_PACKET    l_pErrorLogEntry; 
        /* sizeof insertion string */
        int     l_Size = (int)((pi_InsertionStr) ? ((wcslen(pi_InsertionStr) + 1) * sizeof( WCHAR )) : 0);\r
-
+       int l_PktSize =sizeof(IO_ERROR_LOG_PACKET)+pi_nDataItems*sizeof(ULONG);\r
+       int l_TotalSize =l_PktSize +l_Size;\r
+\r
        /* Init the variable argument list */   
        va_start(l_Argptr, pi_nDataItems);
 
-       /* Allocate an error log entry */ 
-    l_pErrorLogEntry = 
-       (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(
-                                                               pi_pIoObject,
-                                                               (UCHAR)(sizeof(IO_ERROR_LOG_PACKET)+pi_nDataItems*sizeof(ULONG)+l_Size)
-                                                               ); 
-       /* Check allocation */
-    if ( l_pErrorLogEntry != NULL) 
+       /* Allocate an error log entry */ \r
+       if (l_TotalSize >= ERROR_LOG_MAXIMUM_SIZE - 2) \r
+               l_TotalSize = ERROR_LOG_MAXIMUM_SIZE - 2;\r
+       l_pErrorLogEntry = (PIO_ERROR_LOG_PACKET)IoAllocateErrorLogEntry(\r
+               pi_pIoObject,  (UCHAR)l_TotalSize );\r
+\r
+       /* Check allocation */\r
+       if ( l_pErrorLogEntry != NULL) \r
        { /* OK */
 
                /* Data item index */
@@ -206,11 +208,13 @@ Return Value:
 
                /* add insertion string */
                if (pi_InsertionStr) {
-                       char *ptr; 
+                       char *ptr; \r
+                       int sz = min( l_TotalSize - l_PktSize, l_Size );\r
                        l_pErrorLogEntry->NumberOfStrings = 1;
                        l_pErrorLogEntry->StringOffset = sizeof(IO_ERROR_LOG_PACKET) + l_pErrorLogEntry->DumpDataSize;
                        ptr = (char*)l_pErrorLogEntry + l_pErrorLogEntry->StringOffset;
-                       memcpy( ptr, pi_InsertionStr, l_Size );
+                       memcpy( ptr, pi_InsertionStr, sz );\r
+                       *(WCHAR*)&ptr[sz - 2] = (WCHAR)0;\r
                }
                
         /* Write the packet */
index 936d14bab03a3ff83fb3d3c9bace9b32417280af..9ee75845f8e4c1b3c4fd540caa01c811e9b6ee71 100644 (file)
@@ -175,10 +175,11 @@ static int  mthca_dev_lim(struct mthca_dev *mdev, struct mthca_dev_lim *dev_lim)
                return -ENODEV;
        }
 
-       if (dev_lim->uar_size > (int)pci_resource_len(mdev, 2)) {
+       if (dev_lim->uar_size > (int)pci_resource_len(mdev, HCA_BAR_TYPE_UAR)) {
                HCA_PRINT_EV(TRACE_LEVEL_ERROR ,HCA_DBG_LOW , ("HCA reported UAR size of 0x%x bigger than "
-                         "PCI resource 2 size of 0x%lx, aborting.\n",
-                         dev_lim->uar_size, (unsigned long)pci_resource_len(mdev, 2)));
+                         "Bar%d size of 0x%lx, aborting.\n",
+                         dev_lim->uar_size, HCA_BAR_TYPE_UAR, 
+                         (unsigned long)pci_resource_len(mdev, HCA_BAR_TYPE_UAR)));
                return -ENODEV;
        }