A USB bus delay monitoring method, device and related equipment
Patent Information
- Application Number
- CN202310826466.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-07-06
- Publication Date
- 2026-09-18
- Estimated Expiration
- 2043-07-06
AI Technical Summary
这是系统故障诊断、性能优化的重要指标,然而标准USB协议并没有提供测量这段延时的机制,Linux内核社区也没有现成的开源实现
[0035] As can be seen from the above technical solution, when the USB bus controller submits a DMA request, this application obtains a first timestamp. The first timestamp reflects the moment the USB bus controller submits the DMA request, i.e., the moment data transmission begins. When the USB bus controller completes the DMA request, it obtains a second timestamp. The second timestamp reflects the moment the USB bus controller completes the DMA request, i.e., the moment data transmission is complete. Subtracting the first timestamp from the second timestamp yields a delay value. This delay value reflects the time consumed in data transmission within the USB module. Finally, it is determined whether the delay value exceeds a preset threshold. If it exceeds the threshold, a preset command is sent to a preset takeover module, allowing the takeover module to handle related tasks. This application can measure the USB transmission delay value and, when the delay value exceeds a preset threshold, notify the takeover module to handle related tasks, improving the reliability and safety of the autonomous driving system.
Smart Images

Figure CN116886568B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of autonomous driving technology, and more specifically, to a USB bus delay monitoring method, apparatus, and related equipment. Background Technology
[0002] Autonomous driving systems employ various sensors, some of which connect to the system via a USB bus. A key metric is the total latency from sensor sampling to the output of the downstream perception module. When excessive latency is encountered, it's often necessary to further break down the total latency; for example, the time elapsed from the sensor's output to the USB bus controller's receipt is termed USB bus latency. This is a crucial indicator for system fault diagnosis and performance optimization; however, the standard USB protocol does not provide a mechanism for measuring this latency, and the Linux kernel community lacks a readily available open-source implementation. Summary of the Invention
[0003] In view of this, this application provides a USB bus latency monitoring method, apparatus and related equipment to realize the detection and control of USB latency.
[0004] To achieve the above objectives, the first aspect of this application provides a USB bus delay monitoring method, comprising:
[0005] When the USB bus controller submits a direct memory access (DMA) request, obtain the first timestamp;
[0006] When the USB bus controller completes the DMA request, it obtains the second timestamp;
[0007] Subtract the first timestamp from the second timestamp to obtain the delay value;
[0008] Determine whether the delay value exceeds a preset threshold; if so, send a preset command to a preset takeover module.
[0009] Preferably, the process of obtaining the first timestamp when the USB bus controller submits a direct memory access (DMA) request includes:
[0010] When the USB bus controller submits a DMA request, the first timestamp is obtained using the first probe.
[0011] The first probe is pre-deployed in the driver of the USB bus controller in the form of code instrumentation, and the instrumentation position of the first probe is set in the DMA request submission procedure of the driver.
[0012] Preferably, the process of obtaining the second timestamp when the USB bus controller completes the DMA request includes:
[0013] When the USB bus controller completes the DMA request, it uses the second probe to obtain the second timestamp.
[0014] The second probe is pre-deployed in the driver of the USB bus controller in the form of code instrumentation, and the instrumentation position of the second probe is set in the DMA request response program of the driver.
[0015] Preferably, the process of pre-deploying the first probe in the driver of the USB bus controller in the form of code instrumentation includes:
[0016] The first probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology;
[0017] The process of pre-deploying the second probe in the driver of the USB bus controller in the form of code instrumentation includes:
[0018] The second probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology.
[0019] Preferably, after obtaining the delay value, the method further includes:
[0020] The delay value and the first timestamp are stored in memory as delay value pairs, and each delay value pair in memory is periodically saved to a preset file.
[0021] Preferably, after periodically saving each delay value pair in memory to a preset file, the method further includes:
[0022] Import the delay values from the preset file into a preset database in the cloud;
[0023] When a data query request is received, target data is retrieved from the database based on the data query request. The target data includes at least one delayed value pair.
[0024] Preferably, after retrieving the target data from the database based on the data query request, the method further includes:
[0025] A delay curve is generated based on the target data.
[0026] A second aspect of this application provides a USB bus delay monitoring device, comprising:
[0027] The start point acquisition unit is used to acquire the first timestamp when the USB bus controller submits a direct memory access (DMA) request;
[0028] The endpoint acquisition unit is used to acquire a second timestamp when the USB bus controller completes the DMA request;
[0029] The delay calculation unit is used to subtract the first timestamp from the second timestamp to obtain the delay value;
[0030] The takeover judgment module is used to determine whether the delay value exceeds a preset threshold; if so, a preset command is sent to the preset takeover module.
[0031] A third aspect of this application provides a USB bus delay monitoring device, comprising: a memory and a processor;
[0032] The memory is used to store programs;
[0033] The processor is used to execute the program to implement the various steps of the USB bus delay monitoring method described above.
[0034] A fourth aspect of this application provides a storage medium having a computer program stored thereon, which, when executed by a processor, implements the various steps of the USB bus delay monitoring method described above.
[0035] As can be seen from the above technical solution, when the USB bus controller submits a DMA request, this application obtains a first timestamp. The first timestamp reflects the moment the USB bus controller submits the DMA request, i.e., the moment data transmission begins. When the USB bus controller completes the DMA request, it obtains a second timestamp. The second timestamp reflects the moment the USB bus controller completes the DMA request, i.e., the moment data transmission is complete. Subtracting the first timestamp from the second timestamp yields a delay value. This delay value reflects the time consumed in data transmission within the USB module. Finally, it is determined whether the delay value exceeds a preset threshold. If it exceeds the threshold, a preset command is sent to a preset takeover module, allowing the takeover module to handle related tasks. This application can measure the USB transmission delay value and, when the delay value exceeds a preset threshold, notify the takeover module to handle related tasks, improving the reliability and safety of the autonomous driving system. Attached Figure Description
[0036] To more clearly illustrate the technical solutions in the embodiments of this application or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of this application. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0037] Figure 1 This is a schematic diagram of the USB bus delay monitoring method disclosed in an embodiment of this application;
[0038] Figure 2 The code instrumentation locations disclosed in the embodiments of this application are illustrated;
[0039] Figure 3 This is a schematic diagram illustrating the saving of each delay value pair as disclosed in an embodiment of this application;
[0040] Figure 4 This is a schematic diagram illustrating the import of various delay values into a database, as disclosed in an embodiment of this application.
[0041] Figure 5 This is a schematic diagram of generating a delay curve based on various delay values as disclosed in an embodiment of this application;
[0042] Figure 6 This is a schematic diagram of the USB bus delay monitoring device disclosed in the embodiments of this application;
[0043] Figure 7 This is a schematic diagram of the USB bus delay monitoring device disclosed in an embodiment of this application. Detailed Implementation
[0044] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of this application, and not all embodiments. Based on the embodiments of this application, all other embodiments obtained by those of ordinary skill in the art without creative effort are within the scope of protection of this application.
[0045] The USB bus latency monitoring method provided in this application is described below. Please refer to [link / reference]. Figure 1 The USB bus latency monitoring method provided in this application embodiment may include the following steps:
[0046] Step S101: When the USB bus controller submits a DMA request, obtain the first timestamp.
[0047] Step S102: When the USB bus controller completes the DMA request, obtain the second timestamp.
[0048] DMA (Direct Memory Access) allows hardware devices of different speeds to communicate without relying on a large interrupt load on the CPU. A complete DMA transfer process must go through the following four steps:
[0049] (1) DMA request: The CPU initializes the DMA controller and sends an operation command to the I / O interface, and the I / O interface makes a DMA request.
[0050] (2) DMA Response: The DMA controller prioritizes and masks DMA requests, and submits a bus request to the bus arbitration logic. The CPU releases bus control after completing the current bus cycle. At this point, the bus arbitration logic outputs a bus acknowledgment, indicating that the DMA has responded, and notifies the I / O interface to begin DMA transfer via the DMA controller.
[0051] (3) DMA Transfer: After the DMA controller gains control of the bus, the CPU is immediately suspended or only performs internal operations. The DMA controller outputs read and write commands to directly control the RAM and I / O interface for DMA transfer. Under the control of the DMA controller, data is transferred directly between the memory and external devices without the participation of the central processing unit. Initially, the starting position and length of the data to be transferred must be provided.
[0052] (4) DMA Completion: After completing the data transfer specified in the DMA request, the DMA controller releases bus control and sends a termination signal to the I / O interface. Upon receiving the termination signal, the I / O interface stops the operation of the I / O device and sends an interrupt request to the CPU, causing the CPU to exit its non-intervention state and execute code to check the correctness of the DMA transfer operation. Finally, it continues executing the original program with the result and status of the operation.
[0053] Therefore, the first timestamp records the moment when the DMA request started, and the second timestamp records the moment when the DMA request ended.
[0054] Step S103: Subtract the first timestamp from the second timestamp to obtain the delay value.
[0055] Understandably, this latency value reflects the time it takes for data to be transferred via the USB module.
[0056] Step S104: Determine whether the delay value exceeds a preset threshold. If so, proceed to step S105.
[0057] In step S105, the preset command is sent to the preset takeover module.
[0058] If the latency exceeds a preset threshold, the USB transmission latency is considered too high, which may pose a safety hazard for autonomous vehicles. Therefore, it is necessary to notify the relevant takeover module to take over the corresponding tasks to ensure the safe operation of the autonomous vehicle.
[0059] This application acquires a first timestamp when the USB bus controller submits a DMA request. The first timestamp reflects the moment the USB bus controller submits the DMA request, i.e., the moment data transmission begins. When the USB bus controller completes the DMA request, a second timestamp is acquired. The second timestamp reflects the moment the USB bus controller completes the DMA request, i.e., the moment data transmission is complete. The delay value is obtained by subtracting the first timestamp from the second timestamp. This delay value reflects the time consumed in data transmission within the USB module. Finally, it is determined whether the delay value exceeds a preset threshold. If it exceeds the threshold, a preset command is sent to a preset takeover module, allowing the takeover module to handle the related tasks. This application can measure the USB transmission delay value and, when the delay value exceeds a preset threshold, notify the takeover module to handle the related tasks, improving the reliability and safety of the autonomous driving system.
[0060] Code instrumentation is a technique that inserts probes into the program under test, and then obtains control flow and data flow information through the execution of these probes to achieve the testing objective. Therefore, based on the timing of probe insertion, it can be divided into target code instrumentation and source code instrumentation. Target code instrumentation requires necessary analysis of the target code to determine the location and content of the instrumentation. While the format of target code is primarily operating system-dependent and independent of the specific programming language and version, its incomplete syntactic and semantic information makes it difficult to perform lexical and syntactic analysis. Source code instrumentation, on the other hand, is performed based on a complete lexical and syntactic analysis of the source file, ensuring high accuracy and specificity in its instrumentation.
[0061] Based on this, in some embodiments of this application, step S101, which involves obtaining the first timestamp when the USB bus controller submits a DMA request, may include:
[0062] When the USB bus controller submits a DMA request, it uses the first probe to obtain the first timestamp.
[0063] The first probe is pre-deployed in the USB bus controller driver in the form of code instrumentation, and the instrumentation position of the first probe is set in the DMA request submission program of the driver.
[0064] Similarly, step S102, the process of obtaining the second timestamp when the USB bus controller completes the DMA request, may include:
[0065] When the USB bus controller completes the DMA request, it uses the second probe to obtain the second timestamp.
[0066] The second probe is pre-deployed in the USB bus controller driver as a code instrumentation, and the instrumentation position of the second probe is set in the DMA request response program of the driver.
[0067] Specifically, please refer to Figure 2 The USB bus controller submits a DMA request at node ① (the socketing position of the first probe). This DMA request is mapped to a circular buffer (TRB, Transfer Request Block), and at node ②, the DMA request is converted into an electronic signal and transmitted to the USB device via the USB cable. The USB device responds to the received electronic signal at node ③. During this process, the USB bus controller updates the data interaction result at node ④, and finally receives the complete response data at node ⑤ (the socketing position of the second probe), thus completing the DMA request.
[0068] In some embodiments of this application, the process of pre-deploying the first probe in the driver of the USB bus controller in the form of code instrumentation may include:
[0069] The first probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology.
[0070] The process of pre-deploying the second probe in the USB bus controller driver in the form of code instrumentation may include:
[0071] The second probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology.
[0072] Kprobe is a consistent debugging technique provided by the operating system kernel, which can flexibly trace the execution of kernel functions without modifying existing code. Specifically, predefined processing functions are associated with corresponding probes. When the kernel function executes to the probe, the corresponding associated function is executed, and after execution, the normal code path continues.
[0073] In some embodiments of this application, please refer to Figure 3 After obtaining the delay value in step S103, the process may further include:
[0074] Step S106: Store the delay value and the first timestamp as a delay value pair in memory.
[0075] Step S107: Periodically save each delay value in memory to a preset file.
[0076] In some embodiments of this application, please refer to Figure 4After periodically saving each delay value pair in memory to a preset file in step S107, the process may further include:
[0077] Step S108: Import the delay values in the file into a preset database in the cloud.
[0078] Step S109: When a data query request is received, the target data is retrieved from the database based on the data query request.
[0079] The target data includes at least one pair of delay values.
[0080] In some embodiments of this application, please refer to Figure 5 After obtaining the target data from the database based on the data query request in step S109, the method may further include:
[0081] Step S110: Generate a delay curve based on the target data.
[0082] The USB bus delay monitoring device provided in the embodiments of this application is described below. The USB bus delay monitoring device described below can be referred to in correspondence with the USB bus delay monitoring method described above.
[0083] Please see Figure 6 The USB bus delay monitoring device provided in this application embodiment may include:
[0084] The starting point acquisition unit 21 is used to acquire the first timestamp when the USB bus controller submits a direct memory access (DMA) request;
[0085] The endpoint acquisition unit 22 is used to acquire a second timestamp when the USB bus controller completes the DMA request;
[0086] Delay calculation unit 23 is used to subtract the first timestamp from the second timestamp to obtain the delay value;
[0087] The takeover judgment module 24 is used to determine whether the delay value exceeds a preset threshold; if so, it sends a preset command to the preset takeover module.
[0088] In some embodiments of this application, the process by which the starting point acquisition unit 21 acquires the first timestamp when the USB bus controller submits a direct memory access (DMA) request may include:
[0089] When the USB bus controller submits a DMA request, the first timestamp is obtained using the first probe.
[0090] The first probe is pre-deployed in the driver of the USB bus controller in the form of code instrumentation, and the instrumentation position of the first probe is set in the DMA request submission procedure of the driver.
[0091] In some embodiments of this application, the process by which the endpoint acquisition unit 22 acquires the second timestamp when the USB bus controller completes the DMA request may include:
[0092] When the USB bus controller completes the DMA request, it uses the second probe to obtain the second timestamp.
[0093] The second probe is pre-deployed in the driver of the USB bus controller in the form of code instrumentation, and the instrumentation position of the second probe is set in the DMA request response program of the driver.
[0094] In some embodiments of this application, the process by which the starting point acquisition unit 21 pre-deploys the first probe in the driver of the USB bus controller in the form of code instrumentation may include:
[0095] The first probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology;
[0096] The process by which the endpoint acquisition unit 22 pre-deploys the second probe in the driver of the USB bus controller in the form of code instrumentation may include:
[0097] The second probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology.
[0098] In some embodiments of this application, after the delay calculation unit 23 obtains the delay value, it may further include:
[0099] The delay value and the first timestamp are stored in memory as delay value pairs, and each delay value pair in memory is periodically saved to a preset file.
[0100] In some embodiments of this application, after periodically saving the delay value pairs in memory to a preset file, the process may further include:
[0101] Import the delay values from the preset file into a preset database in the cloud;
[0102] When a data query request is received, target data is retrieved from the database based on the data query request. The target data includes at least one delayed value pair.
[0103] In some embodiments of this application, after obtaining the target data from the database based on the data query request, the process may further include:
[0104] A delay curve is generated based on the target data.
[0105] The USB bus delay monitoring device provided in this application embodiment can be applied to USB bus delay monitoring devices, such as computers. Optionally, Figure 7 The hardware structure block diagram of the USB bus delay monitoring device is shown below. Figure 7 The hardware structure of the USB bus delay monitoring device may include: at least one processor 31, at least one communication interface 32, at least one memory 33 and at least one communication bus 34.
[0106] In this embodiment, the number of processor 31, communication interface 32, memory 33 and communication bus 34 is at least one, and processor 31, communication interface 32 and memory 33 communicate with each other through communication bus 34;
[0107] The processor 31 may be a central processing unit (CPU), an application-specific integrated circuit (ASIC), or one or more integrated circuits configured to implement the embodiments of this application.
[0108] The memory 33 may include high-speed RAM, and may also include non-volatile memory, such as at least one disk storage device;
[0109] The memory 33 stores a program, and the processor 31 can call the program stored in the memory 33. The program is used for:
[0110] When the USB bus controller submits a direct memory access (DMA) request, obtain the first timestamp;
[0111] When the USB bus controller completes the DMA request, it obtains the second timestamp;
[0112] Subtract the first timestamp from the second timestamp to obtain the delay value;
[0113] Determine whether the delay value exceeds a preset threshold; if so, send a preset command to a preset takeover module.
[0114] Optionally, the refined and extended functions of the program can be found in the description above.
[0115] This application embodiment also provides a storage medium that can store a program suitable for execution by a processor, the program being used for:
[0116] When the USB bus controller submits a direct memory access (DMA) request, obtain the first timestamp;
[0117] When the USB bus controller completes the DMA request, it obtains the second timestamp;
[0118] Subtract the first timestamp from the second timestamp to obtain the delay value;
[0119] Determine whether the delay value exceeds a preset threshold; if so, send a preset command to a preset takeover module.
[0120] Optionally, the refined and extended functions of the program can be found in the description above.
[0121] In summary:
[0122] This application acquires a first timestamp when the USB bus controller submits a DMA request. The first timestamp reflects the moment the USB bus controller submits the DMA request, i.e., the moment data transmission begins. When the USB bus controller completes the DMA request, a second timestamp is acquired. The second timestamp reflects the moment the USB bus controller completes the DMA request, i.e., the moment data transmission is complete. The delay value is obtained by subtracting the first timestamp from the second timestamp. This delay value reflects the time consumed in data transmission within the USB module. Finally, it is determined whether the delay value exceeds a preset threshold. If it exceeds the threshold, a preset command is sent to a preset takeover module, allowing the takeover module to handle the related tasks. This application can measure the USB transmission delay value and, when the delay value exceeds a preset threshold, notify the takeover module to handle the related tasks, improving the reliability and safety of the autonomous driving system.
[0123] Finally, it should be noted that in this document, relational terms such as "first" and "second" are used only to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or apparatus. Without further limitations, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or apparatus that includes said element.
[0124] The various embodiments in this specification are described in a progressive manner. Each embodiment focuses on the differences from other embodiments. The various embodiments can be combined as needed, and the same or similar parts can be referred to each other.
[0125] The above description of the disclosed embodiments enables those skilled in the art to make or use this application. Various modifications to these embodiments will be readily apparent to those skilled in the art, and the general principles defined herein may be implemented in other embodiments without departing from the spirit or scope of this application. Therefore, this application is not to be limited to the embodiments shown herein, but is to be accorded the widest scope consistent with the principles and novel features disclosed herein.
Claims
1. A USB bus delay monitoring method, characterized in that, include: When the USB bus controller submits a direct memory access (DMA) request, obtain the first timestamp; When the USB bus controller completes the DMA request, it obtains the second timestamp; The second timestamp is the moment when the USB bus controller receives the response data returned by the USB device, the response data being formed by the USB device responding to an electronic signal converted from a DMA request mapped to a circular buffer; Subtract the first timestamp from the second timestamp to obtain the delay value; The delay value reflects the time taken for data to be transmitted via the USB module; Determine whether the delay value exceeds a preset threshold; If so, the preset command will be sent to the preset takeover module so that the takeover module can take over the corresponding work.
2. The method according to claim 1, characterized in that, When the USB bus controller submits a Direct Memory Access (DMA) request, the process of obtaining the first timestamp includes: When the USB bus controller submits a DMA request, the first timestamp is obtained using the first probe. The first probe is pre-deployed in the driver of the USB bus controller in the form of code instrumentation, and the instrumentation position of the first probe is set in the DMA request submission procedure of the driver.
3. The method according to claim 2, characterized in that, When the USB bus controller completes the DMA request, the process of obtaining the second timestamp includes: When the USB bus controller completes the DMA request, it uses the second probe to obtain the second timestamp. The second probe is pre-deployed in the driver of the USB bus controller in the form of code instrumentation, and the instrumentation position of the second probe is set in the DMA request response program of the driver.
4. The method according to claim 3, characterized in that, The process of pre-deploying the first probe in the driver of the USB bus controller in the form of code instrumentation includes: The first probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology; The process of pre-deploying the second probe in the driver of the USB bus controller in the form of code instrumentation includes: The second probe is deployed in the USB bus controller driver in the form of code instrumentation based on Kprobe technology.
5. The method according to any one of claims 1 to 3, characterized in that, After obtaining the delay value, the following is also included: The delay value and the first timestamp are stored in memory as delay value pairs, and each delay value pair in memory is periodically saved to a preset file.
6. The method according to claim 5, characterized in that, After periodically saving the various delay values in memory to a preset file, the process also includes: Import the delay values from the preset file into a preset database in the cloud; When a data query request is received, target data is retrieved from the database based on the data query request. The target data includes at least one delayed value pair.
7. The method according to claim 6, characterized in that, After retrieving the target data from the database based on the data query request, the process further includes: A delay curve is generated based on the target data.
8. A USB bus delay monitoring device, characterized in that, include: The start point acquisition unit is used to acquire the first timestamp when the USB bus controller submits a direct memory access (DMA) request; The endpoint acquisition unit is used to acquire a second timestamp when the USB bus controller completes the DMA request; The second timestamp is the moment when the USB bus controller receives the response data returned by the USB device, the response data being formed by the USB device responding to an electronic signal converted from a DMA request mapped to a circular buffer; The delay calculation unit is used to subtract the first timestamp from the second timestamp to obtain the delay value; The delay value reflects the time taken for data to be transmitted via the USB module; The takeover judgment module is used to determine whether the delay value exceeds a preset threshold; If so, the preset command will be sent to the preset takeover module so that the takeover module can take over the corresponding work.
9. A USB bus delay monitoring device, characterized in that, include: Memory and processor; The memory is used to store programs; The processor is used to execute the program to implement each step of the USB bus delay monitoring method as described in any one of claims 1 to 7.
10. A storage medium having a computer program stored thereon, characterized in that, When the computer program is executed by the processor, it implements each step of the USB bus delay monitoring method as described in any one of claims 1 to 7.
Citation Information
Patent Citations
Automobile instrument system, working method and storage medium
CN114771249A
Data transmission delay time calculation method in network type control system
JP2005094204A