Skip to content

Commit 26bd9e6

Browse files
authored
Merge pull request #105 from qualcomm/develop
merge develop branch to target main branch
2 parents 75501ac + 280c89a commit 26bd9e6

7 files changed

Lines changed: 128 additions & 19 deletions

File tree

src/windows/ndis/MPOID.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,8 +1386,8 @@ NDIS_STATUS MPOID_QueryInformation
13861386
driverCaps.Header.Type = NDIS_OBJECT_TYPE_DEFAULT;
13871387
driverCaps.Header.Revision = NDIS_WWAN_DRIVER_CAPS_REVISION_1;
13881388
driverCaps.Header.Size = sizeof(NDIS_WWAN_DRIVER_CAPS);
1389-
driverCaps.DriverCaps.ulMajorVersion = WWAN_MAJOR_VERSION;
1390-
driverCaps.DriverCaps.ulMinorVersion = WWAN_MINOR_VERSION;
1389+
driverCaps.DriverCaps.ulMajorVersion = WWAN_MAJOR_VERSION_1;
1390+
driverCaps.DriverCaps.ulMinorVersion = WWAN_MINOR_VERSION_0;
13911391
MPOID_GetInformation(&pInfo, &ulInfoLen, &driverCaps, sizeof(NDIS_WWAN_DRIVER_CAPS));
13921392
break;
13931393
}

src/windows/qcversion.h

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66
#define WSTRINGIFY(s) L#s
77
#define QCWSTR(str) WSTRINGIFY(str)
88

9-
#define QCOM_USB_DRIVERS_PRODUCT_VERSION 1.00.94.8
10-
#define QCOM_USB_DRIVERS_FILE_VERSION 1,00,94,8
9+
#define QCOM_USB_DRIVERS_PRODUCT_VERSION 1.00.95.1
10+
#define QCOM_USB_DRIVERS_FILE_VERSION 1,00,95,1
1111
#define QCOM_USB_DRIVERS_PRODUCT_VERSION_STRING QCSTR(QCOM_USB_DRIVERS_PRODUCT_VERSION)
1212
#define QCOM_USB_DRIVERS_PRODUCT_VERSION_STRING_W QCWSTR(QCOM_USB_DRIVERS_PRODUCT_VERSION)
1313

14-
#define QCOM_FILTER_VERSION 1.0.1.6
15-
#define QCOM_FILTER_FILE_VERSION 1,0,1,6
14+
#define QCOM_FILTER_VERSION 1.0.2.0
15+
#define QCOM_FILTER_FILE_VERSION 1,0,2,0
1616
#define QCOM_FILTER_FILE_VERSION_STRING QCSTR(QCOM_FILTER_VERSION)
1717

18-
#define QCOM_NET_VERSION 5.0.1.2
19-
#define QCOM_NET_FILE_VERSION 5,0,1,2
18+
#define QCOM_NET_VERSION 5.0.2.0
19+
#define QCOM_NET_FILE_VERSION 5,0,2,0
2020
#define QCOM_NET_FILE_VERSION_STRING QCSTR(QCOM_NET_VERSION)
2121

22-
#define QCOM_WDFSERIAL_VERSION 1.0.3.7
23-
#define QCOM_WDFSERIAL_FILE_VERSION 1,0,3,7
22+
#define QCOM_WDFSERIAL_VERSION 1.0.4.0
23+
#define QCOM_WDFSERIAL_FILE_VERSION 1,0,4,0
2424
#define QCOM_WDFSERIAL_FILE_VERSION_STRING QCSTR(QCOM_WDFSERIAL_VERSION)
2525

26-
#define QCOM_QDSS_VERSION 1.0.4.2
27-
#define QCOM_QDSS_FILE_VERSION 1,0,4,2
26+
#define QCOM_QDSS_VERSION 1.0.5.0
27+
#define QCOM_QDSS_FILE_VERSION 1,0,5,0
2828
#define QCOM_QDSS_FILE_VERSION_STRING QCSTR(QCOM_QDSS_VERSION)
2929

30-
#define QCOM_ADB_VERSION 1.0.1.7
30+
#define QCOM_ADB_VERSION 1.0.2.0
3131

3232
#define QCOM_USB_DRIVERS_COMPANY_NAME "Qualcomm Technologies, Inc."
3333
#define QCOM_USB_DRIVERS_COMPANY_NAME_W L"Qualcomm Technologies, Inc."

src/windows/transport/usb/USBMRD.c

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,6 +843,25 @@ void USBMRD_L2MultiReadThread(PDEVICE_EXTENSION pDevExt)
843843
NULL
844844
)
845845

846+
// Acquire RemoveLock before calling IoCallDriver so that pDevExt
847+
// cannot be freed by IoReleaseRemoveLockAndWait for the entire
848+
// duration of this L2 IRP. A failed return value indicates that
849+
// the device is in the process of being removed; therefore, the
850+
// L2 thread should terminate.
851+
ntStatus = IoAcquireRemoveLock(pDevExt->pRemoveLock, pIrp);
852+
if (!NT_SUCCESS(ntStatus))
853+
{
854+
QCUSB_DbgPrint
855+
(
856+
QCUSB_DBG_MASK_READ,
857+
QCUSB_DBG_LEVEL_CRITICAL,
858+
("<%s> ML2: AcquireRemoveLock failed 0x%x, device removing\n",
859+
pDevExt->PortName, ntStatus)
860+
);
861+
pDevExt->bL2Stopped = TRUE;
862+
break;
863+
}
864+
846865
pDevExt->pL2ReadBuffer[pDevExt->L2IrpEndIdx].State = L2BUF_STATE_PENDING;
847866

848867
//PendingQueue
@@ -1390,6 +1409,7 @@ void USBMRD_L2MultiReadThread(PDEVICE_EXTENSION pDevExt)
13901409
IO_NO_INCREMENT,
13911410
FALSE
13921411
);
1412+
IoReleaseRemoveLock(pDevExt->pRemoveLock, pIrp);
13931413
goto wait_for_completion;
13941414
}
13951415
if (inDevState(DEVICE_STATE_PRESENT_AND_STARTED))
@@ -1417,6 +1437,7 @@ void USBMRD_L2MultiReadThread(PDEVICE_EXTENSION pDevExt)
14171437
if (pActiveL2Buf != NULL)
14181438
{
14191439
IoCancelIrp(pActiveL2Buf->Irp);
1440+
IoReleaseRemoveLock(pDevExt->pRemoveLock, pIrp);
14201441
goto wait_for_completion;
14211442
}
14221443
else
@@ -1455,6 +1476,7 @@ void USBMRD_L2MultiReadThread(PDEVICE_EXTENSION pDevExt)
14551476
pDevExt->bL2Stopped = TRUE;
14561477
}
14571478

1479+
IoReleaseRemoveLock(pDevExt->pRemoveLock, pIrp);
14581480
break;
14591481
} // default
14601482

@@ -1484,11 +1506,16 @@ void USBMRD_L2MultiReadThread(PDEVICE_EXTENSION pDevExt)
14841506
pDevExt->hRxLogFile = NULL;
14851507
}
14861508

1487-
// Empty the L2 completion queue
1509+
// Drain the L2 completion queue and release any RemoveLocks that were
1510+
// acquired when each IRP was submitted but whose completions were never
1511+
// processed by the main loop.
14881512
QcAcquireSpinLock(&pDevExt->L2Lock, &levelOrHandle);
14891513
while (!IsListEmpty(&pDevExt->L2CompletionQueue))
14901514
{
1515+
PUSBMRD_L2BUFFER pBuf;
14911516
headOfList = RemoveHeadList(&pDevExt->L2CompletionQueue);
1517+
pBuf = CONTAINING_RECORD(headOfList, USBMRD_L2BUFFER, List);
1518+
IoReleaseRemoveLock(pDevExt->pRemoveLock, pBuf->Irp);
14921519
}
14931520
QcReleaseSpinLock(&pDevExt->L2Lock, levelOrHandle);
14941521

src/windows/transport/usb/USBRD.c

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1176,6 +1176,25 @@ void QCUSB_ReadThread(PDEVICE_EXTENSION pDevExt)
11761176
NULL
11771177
)
11781178
QCPWR_CancelIdleTimer(pDevExt, QCUSB_BUSY_WT, TRUE, 20); // RX in progress, set busy and cancel idle IRP
1179+
1180+
// Acquire RemoveLock before calling IoCallDriver so that pDevExt
1181+
// cannot be freed by IoReleaseRemoveLockAndWait for the entire
1182+
// duration of this L2 IRP. A failed return value indicates that
1183+
// the device is in the process of being removed; therefore, the
1184+
// L2 thread should terminate.
1185+
ntStatus = IoAcquireRemoveLock(pDevExt->pRemoveLock, pIrp);
1186+
if (!NT_SUCCESS(ntStatus))
1187+
{
1188+
QCUSB_DbgPrint
1189+
(
1190+
QCUSB_DBG_MASK_READ,
1191+
QCUSB_DBG_LEVEL_CRITICAL,
1192+
("<%s> L2: AcquireRemoveLock failed 0x%x, device is being removed\n",
1193+
pDevExt->PortName, ntStatus)
1194+
);
1195+
pDevExt->bL2Stopped = TRUE;
1196+
goto wait_for_completion;
1197+
}
11791198
pDevExt->bL2ReadActive = TRUE;
11801199
ntStatus = IoCallDriver(pDevExt->StackDeviceObject, pIrp);
11811200
if (ntStatus != STATUS_PENDING)
@@ -1382,6 +1401,7 @@ void QCUSB_ReadThread(PDEVICE_EXTENSION pDevExt)
13821401
IO_NO_INCREMENT,
13831402
FALSE
13841403
);
1404+
IoReleaseRemoveLock(pDevExt->pRemoveLock, pIrp);
13851405
goto wait_for_completion;
13861406
}
13871407
}
@@ -1395,6 +1415,7 @@ void QCUSB_ReadThread(PDEVICE_EXTENSION pDevExt)
13951415
FALSE
13961416
);
13971417

1418+
IoReleaseRemoveLock(pDevExt->pRemoveLock, pIrp);
13981419
continue;
13991420
}
14001421

@@ -1411,6 +1432,7 @@ void QCUSB_ReadThread(PDEVICE_EXTENSION pDevExt)
14111432
pDevExt->bL2Stopped = TRUE;
14121433
}
14131434

1435+
IoReleaseRemoveLock(pDevExt->pRemoveLock, pIrp);
14141436
break;
14151437
}
14161438

src/windows/wdfserial/QCMAIN.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,6 +401,7 @@ WDF_DECLARE_CONTEXT_TYPE_WITH_NAME(REQUEST_CONTEXT, QCReqGetContext)
401401
// Registry Value Names
402402
#define VEN_DEV_PORT L"AssignedPortForQCDevice"
403403
#define VEN_DEV_TIME L"QCDeviceStamp"
404+
#define VEN_DEV_GENERATION L"QCDeviceGeneration"
404405
#define VEN_DEV_SERNUM L"QCDeviceSerialNumber"
405406
#define VEN_DEV_MSM_SERNUM L"QCDeviceMsmSerialNumber"
406407
#define VEN_DEV_PROTOC L"QCDeviceProtocol"

src/windows/wdfserial/QCPNP.c

Lines changed: 59 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -94,11 +94,6 @@ NTSTATUS QCPNP_EvtDeviceAdd
9494
goto exit;
9595
}
9696

97-
if (pDevContext->FdoDeviceType == FILE_DEVICE_SERIAL_PORT)
98-
{
99-
QCPNP_ReportDeviceName(pDevContext);
100-
}
101-
10297
exit:
10398
if (!NT_SUCCESS(status))
10499
{
@@ -267,6 +262,50 @@ NTSTATUS QCPNP_SetStamp
267262
return STATUS_SUCCESS;
268263
}
269264

265+
/****************************************************************************
266+
*
267+
* function: QCPNP_IncrementGeneration
268+
*
269+
* purpose: Increments QCDeviceGeneration DWORD in the driver registry key
270+
* on every PrepareHardware so QDS can detect a re-enumeration even
271+
* when DevDesc/DevName/SerNum are identical across reboots.
272+
*
273+
* arguments:pDevContext = pointer to the device context.
274+
*
275+
* returns: NT Status
276+
*
277+
****************************************************************************/
278+
NTSTATUS QCPNP_IncrementGeneration(PDEVICE_CONTEXT pDevContext)
279+
{
280+
NTSTATUS status = STATUS_SUCCESS;
281+
WDFDEVICE device = pDevContext->Device;
282+
WDFKEY key;
283+
ULONG genValue = 0;
284+
DECLARE_CONST_UNICODE_STRING(valueName, VEN_DEV_GENERATION);
285+
286+
status = WdfDeviceOpenRegistryKey(device, PLUGPLAY_REGKEY_DRIVER,
287+
KEY_QUERY_VALUE | KEY_SET_VALUE, WDF_NO_OBJECT_ATTRIBUTES, &key);
288+
if (!NT_SUCCESS(status))
289+
{
290+
return status;
291+
}
292+
293+
WdfRegistryQueryValue(key, &valueName, REG_DWORD, &genValue, sizeof(genValue), NULL);
294+
WdfRegistryClose(key);
295+
296+
genValue++;
297+
status = QCMAIN_SetDriverRegistryDword((LPWSTR)valueName.Buffer, genValue, pDevContext);
298+
299+
QCSER_DbgPrint
300+
(
301+
QCSER_DBG_MASK_CONTROL,
302+
QCSER_DBG_LEVEL_DETAIL,
303+
("<%ws> QCPNP_IncrementGeneration new generation: %lu, status: 0x%x\n",
304+
pDevContext->PortName, genValue, status)
305+
);
306+
return status;
307+
}
308+
270309
/****************************************************************************
271310
*
272311
* function: QCPNP_DeviceCreate
@@ -1714,6 +1753,10 @@ NTSTATUS QCPNP_EvtDevicePrepareHardware
17141753
status = QCPNP_RegisterWmiPowerGuid(pDevContext);
17151754
}
17161755

1756+
// Increment QCDeviceGeneration so QDS can detect a re-enumeration even
1757+
// when the device identity (DevDesc/DevName/SerNum) is unchanged.
1758+
QCPNP_IncrementGeneration(pDevContext);
1759+
17171760
exit:
17181761
if (!NT_SUCCESS(status))
17191762
{
@@ -2234,6 +2277,14 @@ NTSTATUS QCPNP_EvtDeviceD0Entry
22342277
QCSER_DBG_LEVEL_TRACE,
22352278
("<%ws> QCPNP_EvtDeviceD0Entry Completed!\n", pDevContext->PortName)
22362279
);
2280+
2281+
// Re-announce diag device name to parent/filter on every D0 entry.
2282+
// EvtDeviceAdd fires only once; D0Entry fires on each re-enumeration.
2283+
if (pDevContext->FdoDeviceType == FILE_DEVICE_SERIAL_PORT)
2284+
{
2285+
QCPNP_ReportDeviceName(pDevContext);
2286+
}
2287+
22372288
return STATUS_SUCCESS;
22382289
}
22392290

@@ -3280,6 +3331,9 @@ NTSTATUS QCPNP_SetupIoThreadsAndQueues
32803331
LARGE_INTEGER threadInitTimeout;
32813332
threadInitTimeout.QuadPart = WDF_REL_TIMEOUT_IN_MS(QCPNP_THREAD_INIT_TIMEOUT_MS);
32823333

3334+
// Clear stale removal signal in case we're re-entering after a removal cycle
3335+
KeClearEvent(&pDevContext->DeviceRemoveEvent);
3336+
32833337
// Init write request list, lock and events
32843338
InitializeListHead(&pDevContext->WriteRequestPendingList);
32853339
WdfSpinLockCreate(WDF_NO_OBJECT_ATTRIBUTES, &pDevContext->WriteRequestPendingListLock);

src/windows/wdfserial/QCPNP.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,4 +184,9 @@ NTSTATUS QCPNP_SetStamp
184184
PDEVICE_CONTEXT pDevContext,
185185
BOOLEAN Startup
186186
);
187+
188+
NTSTATUS QCPNP_IncrementGeneration
189+
(
190+
PDEVICE_CONTEXT pDevContext
191+
);
187192
#endif // QCPNP_H

0 commit comments

Comments
 (0)