Data interaction method, host, system and readable storage medium

By using read and write pointers in the host to determine the data to be read and filling verification data in the storage unit, the problem of data errors caused by disorder is solved, and correct data interaction and performance improvement are achieved.

CN120723531APending Publication Date: 2025-09-30LOONGSON TECH CORP
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202510677995.3
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-05-23
Publication Date
2025-09-30

AI Technical Summary

Technical Problem

In the prior art, since the order in which multiple requests are received is likely to be inconsistent with the order in which they are sent, disorderly processing may occur, which may result in reduced host performance.

Method used

By receiving the interrupt trigger request sent by the device, the read pointer and write pointer of the preset storage area are used to determine the data to be read, and the verification data is filled in the storage unit. The data to be read is compared with the verification data. If they are consistent, it is determined that the data is wrong. The data is re-verified until it is correct and then returned to the device.

Benefits of technology

Ensure the correctness of data interaction, improve system stability and host performance, avoid dependence on hardware mechanisms, and improve system operation quality.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120723531A_ABST
    Figure CN120723531A_ABST
Patent Text Reader

Abstract

The embodiment of the invention provides a data interaction method, a host, a system and a readable storage medium. Relates to the technical field of computers. The method comprises the following steps: receiving an interrupt trigger request sent by equipment, and determining to-be-read data according to a read pointer and a write pointer of a preset storage area; comparing all the determined to-be-read data with the verification data, and if the to-be-read data consistent with the verification data exists, determining that a data error occurs; and when the data error occurs, all the to-be-read data is compared with the verification data again until any one of the to-be-read data is different from the verification data, and all the to-be-read data is returned to the device. The data correctness can be ensured without depending on a hardware mechanism, and the performance of the host is improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of computer technology, and specifically relates to a data interaction method, a host, a system, and a readable storage medium. Background Art

[0002] Connecting a host to external devices enables diverse functional expansion and collaborative processing, further expanding host functionality and improving performance. For example, connecting a graphics card to the host can enhance its graphics processing capabilities. Data exchange between the host and device requires sending, receiving, and responding to multiple requests. Only by obtaining the correct data during this process can the host and device operate normally.

[0003] In related technologies, since the order in which multiple requests are received may be inconsistent with the order in which they are sent, resulting in disorder, an additional hardware mechanism is used to ensure that the host receives the requests in the order in which they are sent, thereby preventing data errors.

[0004] However, the operation of the above hardware mechanism requires additional consumption of hardware resources, which reduces the host performance. Summary of the Invention

[0005] The present application aims to provide a data interaction method, host, system and readable storage medium, which at least solve the problem of ensuring that requests are not out of order based on hardware mechanisms, thereby causing host performance degradation.

[0006] In order to solve the above technical problems, this application is implemented as follows:

[0007] In a first aspect, an embodiment of the present application discloses a data interaction method, which is applied to a host and includes:

[0008] receiving an interrupt trigger request sent by a device, and determining data to be read based on a read pointer and a write pointer of a preset storage area; the preset storage area includes a plurality of storage cells, each storage cell is used to store an item of data, and the storage cell is filled with verification data before data is written; wherein the read pointer points to the storage cell to be read next; and the write pointer points to the storage cell to be written next;

[0009] Comparing all the determined data to be read with the verification data respectively, and if there is data to be read that is consistent with the verification data, determining that a data error occurs;

[0010] In the event of a data error, all data to be read are re-compared with the verification data until any data to be read is different from the verification data, and all data to be read are returned to the device.

[0011] In a second aspect, an embodiment of the present application further discloses a host, comprising:

[0012] a receiving unit, configured to receive an interrupt trigger request from a device and determine data to be read based on a read pointer and a write pointer of a preset storage area; the preset storage area includes a plurality of storage cells, each storage cell is configured to store an item of data, and the storage cell is filled with verification data before data is written; wherein the read pointer points to the storage cell to be read next; and the write pointer points to the storage cell to be written next;

[0013] a comparing unit, configured to compare all the determined data to be read with the verification data respectively, and determine that a data error occurs if there is data to be read that is consistent with the verification data;

[0014] The sending unit is used to re-compare all the data to be read with the verification data respectively when the data error occurs, until any data to be read is different from the verification data, and return all the data to be read to the device.

[0015] In a third aspect, an embodiment of the present application further discloses a data interaction system, which includes a host as described in the second aspect above, and a device, wherein the device is used to send an interrupt trigger request to the host and obtain all data to be read returned by the host.

[0016] In a fourth aspect, an embodiment of the present application further discloses a data interaction system, which includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to be executed by one or more processors to perform the aforementioned data interaction method.

[0017] In a fifth aspect, an embodiment of the present application further discloses a readable storage medium, which, when instructions in the readable storage medium are executed by a processor of a data interaction system, enables the processor to execute the aforementioned data interaction method.

[0018] The embodiments of the present application include the following advantages:

[0019] An embodiment of the present application provides a data interaction method, which determines the data to be read based on the read pointer and write pointer of a preset storage area by receiving an interrupt trigger request sent by a device, and the storage unit is filled with verification data before the data is written, and all the data to be read are compared with the verification data. If there is data to be read that is consistent with the verification data, it means that the verification data is included in the data to be read, and it can be determined that a data error has occurred. In the case of a data error, all the data to be read are compared with the verification data again until any data to be read is different from the verification data. All the data to be read can be returned to the device. By comparing the verification data, even if a disorder problem occurs, it can avoid returning erroneous data to the device, and instead return correct data to the device, which not only ensures the correctness of the data exchanged between the device and the host, improves the stability of the system, but also avoids relying on hardware mechanisms to ensure data correctness, and improves host performance. BRIEF DESCRIPTION OF THE DRAWINGS

[0020] Figure 1 This is a step diagram of a data interaction method provided by an embodiment of the present application;

[0021] Figure 2 This is a schematic diagram of the host and device interaction process provided by an embodiment of the present application;

[0022] Figure 3 This is a step diagram of another data interaction method provided by an embodiment of the present application;

[0023] Figure 4 This is a step diagram of another data interaction method provided in an embodiment of the present application;

[0024] Figure 5 This is a flow chart of data interaction and data verification provided by an embodiment of the present application;

[0025] Figure 6 This is a block diagram of a host provided in an embodiment of the present application;

[0026] Figure 7 This is a block diagram of a data interaction system provided by an embodiment of the present application;

[0027] Figure 8 This is a hardware structure diagram of a data interaction system provided in an embodiment of the present application. DETAILED DESCRIPTION

[0028] The technical solutions in the embodiments of the present application will be described clearly and completely below in conjunction with the drawings in the embodiments of the present application.

[0029] Figure 1 This is a flowchart of a data interaction method provided by an embodiment of the present application. Figure 1As shown, the method is applied to the host, and the method may include:

[0030] Step 101, receiving an interrupt trigger request sent by a device, and determining the data to be read based on the read pointer and write pointer of a preset storage area; the preset storage area includes a plurality of storage units, each storage unit is used to store an item of data, and the storage unit is filled with verification data before the data is written; wherein, the read pointer points to the storage unit to be read next time; and the write pointer points to the storage unit to be written next time.

[0031] Hosts and devices can communicate based on the high-speed serial computer expansion bus standard (Peripheral Component Interconnect Express (PCIE)), the Industry Standard Architecture (ISA), and other methods. For example, in a PCIE bus system, the requests sent by a device to the host include data write requests, write pointer update requests, and interrupt trigger requests. A data write request indicates that the device needs to write data to the host, a write pointer update request indicates that the device needs to update the host's write pointer, and an interrupt trigger request triggers a host interrupt to enable the host to return relevant data.

[0032] During data exchange, data write requests and interrupt trigger requests can easily become out of order. This means that the order in which they are received and sent differs. For example, if the device sends a data write request, a write pointer update request, and an interrupt trigger request, while the host receives the write pointer update request, an interrupt trigger request, and a data write request, out of order. This out of order can be caused by a variety of factors, including device characteristics, system architecture, and data processing methods. Once out of order occurs, further execution of processes by the host and device will result in unknown errors, leading to various system instabilities and difficulty in locating the issues, resulting in a poor user experience.

[0033] Figure 2 is a schematic diagram of the host device interaction process provided by an embodiment of the present application; Figure 2 The host 10 and the device 20 can communicate with each other via the PCIE bus. The order in which the device 20 sends requests is request 1, request 2, and request 3. Request 1 is a data write request, request 2 is a write pointer update request, and request 3 is an interrupt trigger request. The preset storage area 101 in the host 10 can be an interrupt ring buffer (IRING). The preset storage area 101 can be divided into different storage units 0, 1, and 2, etc. Figure 2The read pointer corresponding to the preset storage area 101 points to storage unit 0, and the write pointer points to storage unit 3. Figure 2 The number of storage units, read pointer, write pointer positions and other specific contents involved are examples and can be adjusted as needed.

[0034] In an embodiment of the present application, an interrupt trigger request may be sent after a device completes a specific operation, such as sending a data write request, wherein the sending of the data write request may be implemented based on direct memory access (DMA). The interrupt trigger request may be notified to the host in the form of a message signaled interrupt (MSI) request, and the interrupt trigger request may carry key information such as an interrupt vector and a device identifier.

[0035] After the host receives the interrupt trigger request sent by the device, it can receive the request through a specific interrupt controller and, based on the information carried in the interrupt trigger request, identify which device issued the request and the specific type of request. It then pauses the currently executing task and executes the interrupt handling function (msi_irq_handler) corresponding to the interrupt. This interrupt handling function can be used to implement subsequent steps such as determining and verifying the data to be read. The interrupt handling function may include the following:

[0036] static irqreturn_t pcie_device_irq_handler(int irq,void*dev_id){

[0037] struct pci_dev*pdev=dev_id;

[0038] / / Handle interrupt events

[0039] return IRQ_HANDLED;

[0040] }

[0041] The above code defines a function named "msi_irq_handler", which is used to handle interrupt trigger requests from PCIE devices. The function parameters include the interrupt number "irq" and the general pointer "dev_id". "dev_id" is a pointer to the "struct PCIE_msi_dev" structure, which represents a PCIE device. The function converts the incoming "dev_id" pointer to the pointer "msi_dev" of the "struct PCIE_msi_dev" type. In the code location where the interrupt event is processed, more processing logic can be added, such as the steps of determining the data to be read and verification in this application. Finally, the function returns "IRQ_HANDLED", indicating that the interrupt has been successfully handled.

[0042] The preset storage area can be used for data interaction between the host and the device, and the preset storage area can be an interrupt ring buffer, a data table, or other types of storage areas. The preset storage area is used to temporarily store data sent by the device to the host. The preset storage area includes several storage units, each of which can store one item of data, for example, "0xDEADBEEF" is one item of data. Each storage unit in the preset storage area can store default initial data, i.e., verification data, so that the entire preset storage area is filled with verification data. The storage space size of each storage unit can be consistent, and the storage space can be a fixed size; or the storage space size of different storage units can be different, and the storage space size corresponding to each storage unit can be adjusted, which is not specifically limited here.

[0043] The read pointer (RPTR) and write pointer (WPTR) are used to manage the writing and reading of data in a preset storage area. The write pointer can be maintained by the device. When the device sends a data write request via DMA data transfer and continues to send write pointer update requests, the write pointer value is updated accordingly to point to the next writable storage unit. For example, if the preset storage area contains storage units 1, 2, 3, and 4, and data has been written to storage units 1, 2, and 3, the write pointer will point to storage unit 4.

[0044] The read pointer can be maintained by the host. The read pointer indicates the storage unit from which the host will read data from the buffer next time. For example, there are storage units 1, 2, 3, and 4 in the preset storage area. When the data in storage units 1, 2, and 3 have been read, the read pointer will point to storage unit 4.

[0045] When processing an interrupt trigger request, the host can determine whether there is new data to read based on the read pointer and write pointer. If the storage location pointed to by the read pointer and write pointer is inconsistent, it means that new data has been written and has not yet been read. The data to be read between the read pointer and write pointer can be determined.

[0046] Step 102 : Compare all the determined data to be read with the verification data respectively. If there is data to be read that is consistent with the verification data, it is determined that a data error occurs.

[0047] In an embodiment of the present application, since the storage units in the preset storage area store verification data by default, after data is written, the verification data of the relevant storage units will be replaced by the new data written. When data is not written, the relevant storage units still store the default verification data.

[0048] Since the read pointer and the write pointer are inconsistent, it means that new data has been written and not read. Then, the data to be read can be determined based on the read pointer and the write pointer. This situation means that theoretically new data has been written to the preset storage area.

[0049] At the same time, the data to be read determined based on the read pointer and write pointer is theoretically the new data that has been written, not the default verification data. Therefore, all the data to be read are compared with the verification data. If there is data to be read that is consistent with the verification data, it means that the data has not been written correctly, resulting in the default verification data still existing. In this case, it can be considered that a data error has occurred. The function to implement verification can include the following:

[0050]

[0051] The above function is used to check whether there is data consistent with the check data (check_data) in the data list to be read (read_data_list). If there is data consistent with the check data, it returns True to indicate that a data error has occurred. Otherwise, it returns False.

[0052] Among them, it can be understood that the reason for the data error is the above-mentioned disorder problem. The host receives a write pointer update request and updates the write pointer, resulting in the read pointer and write pointer being inconsistent when the host receives an interrupt trigger request. At this time, the data to be read can be determined based on the read pointer and write pointer, but the host has not actually received a data write request, resulting in no new data being written in the preset storage area. Therefore, in the preset storage area, the data to be read determined based on the read pointer and write pointer is actually still the default verification data.

[0053] In addition, the specific number of data to be read that is consistent with the verification data may be uncertain. If all the data to be read is consistent with the verification data, it means that the host has not written any new data at all. If the number of data to be read that is consistent with the verification data only accounts for a part of all the data to be read, it means that the host may be writing new data but has not yet completely written it.

[0054] Step 103 : When the data error occurs, all the data to be read are re-compared with the verification data until any data to be read is different from the verification data, and all the data to be read are returned to the device.

[0055] In an embodiment of the present application, when it is determined that a data error has occurred, the data to be read can be re-determined based on the read pointer and the write pointer, and all the data to be read can be re-compared with the verification data until any of the data to be read is different from the verification data, indicating that the host has completely written the new data to be written. At this time, the data is correct, and all the data to be read can be returned to the device. The process of repeating the verification until the data is correct can be implemented by the following function:

[0056]

[0057]

[0058] The above function is used to re-compare all the data to be read in the data list to be read (param read_data_list) with the check data (param check_data) in the event of a data error. This function will continue until all the data to be read in the data list to be read differs from the check data. The re-checked data to be read is then returned to the device.

[0059] Although the host updates the write pointer first and receives an interrupt trigger request due to the disorder, it can still continue to receive data write requests and write data. Therefore, the host can continuously re-determine the data to be read based on the read pointer and write pointer, and continue to compare them. At a certain moment, after the host receives the data write request and completes the data writing, it can determine that the host has completely written the required data by comparing the checksum data.

[0060] In summary, the embodiment of the present application determines the data to be read according to the read pointer and write pointer of the preset storage area by receiving the interrupt trigger request sent by the device, and the storage unit is filled with verification data before the data is written, and all the data to be read are compared with the verification data. If there is data to be read that is consistent with the verification data, it means that the verification data is included in the data to be read, and it can be determined that a data error has occurred. In the case of a data error, all the data to be read are compared with the verification data again until any data to be read is different from the verification data. All the data to be read can be returned to the device. By comparing the verification data, it is possible to avoid returning erroneous data to the device, so that the data returned to the device is correct data, ensuring that the device can obtain the correct data, so that it can operate stably, improve system stability, improve product quality, do not need to rely on hardware mechanisms to ensure data correctness, and improve host performance.

[0061] Each method step of the embodiment of the present application can be implemented in the driver. By writing the code of hardware-related operations or management functions in the driver, the operating system can call the methods in the driver to control the hardware in the host to work.

[0062] Figure 3 This is another data interaction method provided by the embodiment of the present application. Figure 3 include:

[0063] Step 303: Receive an interrupt trigger request sent by a device and determine the data to be read based on a read pointer and a write pointer of a preset storage area; the preset storage area includes a plurality of storage cells, each storage cell is used to store an item of data, and the storage cell is filled with verification data before data is written; wherein the read pointer points to the storage cell to be read next; and the write pointer points to the storage cell to be written next;

[0064] Step 304: Compare all the determined data to be read with the verification data respectively. If there is data to be read that is consistent with the verification data, it is determined that a data error has occurred.

[0065] Step 305 : When the data error occurs, all the data to be read are re-compared with the verification data until any data to be read is different from the verification data, and all the data to be read are returned to the device.

[0066] For details of steps 303-305, please refer to Figure 1 The contents of the embodiment will not be repeated here.

[0067] Optionally, after determining that a data error occurs in step 304, and re-comparing all the data to be read with the verification data in step 305 until any data to be read is different from the verification data, the method further includes:

[0068] Step A1, receiving a data write request sent by the device, and determining the data to be written carried in the data write request;

[0069] Step A2, determining the starting storage unit corresponding to the data to be written according to the read pointer, and determining the ending storage unit corresponding to the data to be written according to the write pointer;

[0070] Step A3: writing the data to be written into the preset storage area in sequence from the starting storage unit to the ending storage unit.

[0071] In the embodiment of the present application, according to the normal data exchange process, the host should first receive the data write request, then update the write pointer and receive the interrupt trigger request. However, regardless of whether out-of-order occurs, that is, regardless of whether the data write request is received later than the interrupt trigger request or earlier than the interrupt trigger request, the host can still write data based on the received data write request.

[0072] Therefore, after determining that a data error has occurred and re-comparing all the data to be read with the verification data, until any of the data to be read is different from the verification data, the host can receive a data write request and parse the request data packet according to the corresponding protocol specification to extract the data to be written. After obtaining the data to be written, since the read pointer indicates the storage unit to be read next time, and the write pointer points to the storage unit to be written next time, the storage area between the read pointer and the write pointer is the storage area for the data to be written this time. Therefore, the host can determine the starting storage unit corresponding to the data to be written based on the read pointer, and determine the ending storage unit corresponding to the data to be written based on the write pointer.

[0073] The starting storage unit is the storage unit currently pointed to by the read pointer, and the ending storage unit can be the storage unit immediately preceding the storage unit currently pointed to by the write pointer. For example, if the preset storage area includes 1 to 10 storage units, and the read pointer points to storage unit 1, then the starting storage unit is storage unit 1, and data can be written from storage unit 1. If the write pointer points to storage unit 6, then the ending storage unit is storage unit 5. This process allows the data to be written to be reasonably allocated continuous storage space in the storage area, facilitating subsequent data access and management.

[0074] After determining the starting and ending storage units for the data to be written, the host writes the multiple data to be written sequentially into each storage unit from the starting storage unit to the ending storage unit in the preset storage area according to the original order of the data. Alternatively, the starting and ending storage units can be determined directly based on the read pointer and the amount of data to be written. Similarly, the read pointer directly points to the starting storage unit, and the ending storage unit can be calculated based on the amount of data to be written so that the storage area between the starting and ending storage units is sufficient to store the data to be written. Alternatively, the ending storage unit can be determined without determining the ending storage unit, and data can be written directly from the starting storage unit directly pointed to by the read pointer. The writing process is not specifically limited here.

[0075] Optionally, before step 303 of receiving the interrupt trigger request sent by the device, the method further includes:

[0076] Step 301: receiving a write pointer update request sent by the device, and determining a write pointer update value carried in the write pointer update request; the write pointer update value is determined by the device according to the size of the data to be written;

[0077] Step 302: Update the storage unit pointed to by the write pointer based on the write pointer update value.

[0078] In an embodiment of the present application, the write pointer is maintained by the device, so the write pointer update value can be determined by the device. The write pointer needs to point to the storage unit to be written next time, and the device can determine the write pointer update value based on the data size of the data to be written.

[0079] For example, if there are five items of data to be written, the write pointer update value can be 5. The write pointer update value can also be the original value of the write pointer plus the amount of data to be written. For example, if the write pointer value before the data is written is 1, indicating that the write pointer points to storage unit 1, and there are five items of data to be written, the write pointer update value is 6.

[0080] The device transmits a write pointer update request (e.g., a DMA-WPTR packet) to the host, which then modifies the write pointer based on the write pointer update value, thereby updating the memory location pointed to by the write pointer. If the write pointer update value matches the amount of data to be written, the original write pointer value is added to the write pointer update value. If the write pointer update value matches the amount of data to be written plus the original write pointer value, the write pointer value is set directly based on the write pointer update value.

[0081] Optionally, before step 303 of receiving the interrupt trigger request sent by the device, the method further includes:

[0082] Step B1: comparing preset verification data with a preset data set; the preset data set includes historical data of the host and the device during historical interactions;

[0083] Step B2: if the preset verification data is different from any data in the preset data set, determining the preset verification data as final verification data;

[0084] Step B3: writing the final verification data into each storage unit in the preset storage area.

[0085] In an embodiment of the present application, the preset data set contains historical data from the host and device during historical interactions. The historical data can reflect various data situations that have occurred in historical interactions. Comparing the preset verification data with the preset data set can avoid using verification data that has already appeared, may have problems, or is not representative. If the preset verification data is repeated with the historical data, it may be impossible to accurately detect errors in data transmission when the verification data is subsequently used for verification.

[0086] The preset verification data can be randomly generated or user-specified. When the preset verification data is compared with a preset data set, if it differs from any data in the preset data set, it indicates that the verification data is unique and can adapt to the current data interaction scenario. Based on this preset verification data, errors that may occur during data transmission can be more effectively identified, while preventing misjudgment of correct data in normal data interaction. The final verification data determined through this comparison provides a more reliable basis for subsequent data verification, which can improve the accuracy and reliability of data interaction.

[0087] After determining that the final verification data is, for example, "0xDEADBEEF" or "0x00000000" or other verification data, the verification data may be written into each storage unit of the preset storage area to fill the preset storage area, which will not be described in detail here.

[0088] Furthermore, multiple types of verification data can be used, that is, the verification data can be different, and each type of verification data can be used to effectively identify errors that may occur during data transmission, thereby preventing misjudgment of correct data in normal data exchange. Therefore, verification data is written to each storage cell in a preset storage area, and when filling the storage area, multiple types of verification data can be used to fill the area, for example, filling a portion of storage cells with verification data A and another portion of storage cells with verification data B. As another embodiment, verification data A can also be used to fill all storage cells in the preset storage area.

[0089] It is understood that in the event of out-of-order requests, one or more data errors are avoided based on the embodiments of the present application, and after one or more data exchanges are performed normally, the data pages during these data exchanges can be used as historical data to obtain an updated historical data set. Furthermore, new verification data can be determined by comparison based on the updated historical data set, which will not be further described here.

[0090] In the embodiments of the present application, by comparing the preset verification data with a preset data set comprising historical data of historical interactions between the host and the device, if the preset verification data differs from any data in the preset data set, the preset verification data is determined to be the final verification data, and the verification data is written to each storage unit in the preset storage area. This allows invalid data not involved in the interaction process between the host and the device to be filtered out as verification data, reducing the probability of misjudging correct data, providing a more reliable basis for subsequent data verification, and improving the accuracy of data verification.

[0091] Optionally, after step 305 of returning all the to-be-read data to the device, the method further includes:

[0092] Step 306: Update the read pointer based on the value of the write pointer so that the read pointer and the write pointer point to the same storage unit;

[0093] Step 307, determining, in the preset storage area, a target storage unit corresponding to the to-be-read data that has been returned to the device;

[0094] Step 308: Write the verification data into the target storage unit.

[0095] In an embodiment of the present application, after all the data to be read is returned to the device, indicating that the written data has been read, the read pointer can be updated based on the value of the write pointer, that is, the value of the read pointer is updated to the same value as the write pointer, so that the write pointer and the read pointer point to the same storage unit.

[0096] For example, the preset storage area includes storage cells 1-10. The read pointer points to storage cell 3, indicating that storage cells 1 and 2 have been read and the next read starts from storage cell 3. At the same time, the write pointer points to storage cell 6. Since the write pointer points to the next writable storage cell, the next storage cells to be read are 3-5. After storage cells 3-5 are read, the read pointer is updated to point to storage cell 6. After subsequent data is written, the write pointer continues to be updated. After data is read, the read pointer is updated based on the value of the write pointer, and the cycle continues.

[0097] In addition, since the data to be read has been returned to the device, these data are no longer needed. The target storage units corresponding to the data to be read that have been returned to the device can be determined in the preset storage area, and verification data can be rewritten in these target storage units for verification of the next written data.

[0098] Similarly, the rewritten verification data may be the same data as the verification data filled last time, that is, there is only one type of verification data, or may be verification data different from the verification data filled last time, that is, there are multiple types of verification data.

[0099] In an embodiment of the present application, the read pointer is updated based on the value of the write pointer so that the read pointer and the write pointer point to the same storage unit. In a preset storage area, the target storage unit corresponding to the to-be-read data returned to the device is determined, and verification data is written in the target storage unit. After the data is returned to the device, the read pointer can be adjusted and the verification data can be rewritten in the target storage unit corresponding to the returned data. The rewritten verification data can be used for the next verification on the one hand, and on the other hand, it avoids the old data that has been read being returned to the device as new data in subsequent readings, thereby preparing for the subsequent data interaction process and improving the efficiency of data interaction.

[0100] Optionally, the step 303 of determining the data to be read according to the read pointer and the write pointer of the preset storage area includes:

[0101] Sub-step 3031: Determine that the data stored from the storage unit pointed to by the read pointer to the storage unit pointed to by the write pointer is the data to be read.

[0102] In an embodiment of the present application, the storage unit pointed to by the read pointer is the storage unit to be read next. For example, the preset storage area includes 1 to 5 storage units, and the storage unit initially pointed to by the read pointer is storage unit 1, indicating that the next reading starts from storage unit 1. After reading storage units 1 to 2, the read pointer points to storage unit 3, indicating that the next reading starts from storage unit 3.

[0103] Similarly, the write pointer points to the next storage unit to be written. The storage unit before the write pointer points to the data that has already been written. For example, if the preset storage area includes 1 to 5 storage units, and the write pointer points to storage unit 1, it means that the next write starts from storage unit 1. Since storage unit 1 is the first storage unit, no data has been written yet. If the write pointer points to storage unit 4, it means that the next write starts from storage unit 4, and storage units 1 to 3 store the write data.

[0104] Therefore, the storage unit where the data to be read is located is within the range defined by the read pointer and the write pointer. The host can determine the length of the interval for storing the data to be read based on the difference between the read pointer and the write pointer. The read pointer and the write pointer indicate the location of the interval for storing the data to be read in the preset storage area.

[0105] For example, the preset storage area includes 1 to 10 storage units, the read pointer points to storage unit 1, and the write pointer points to storage unit 6. The length of the interval used to store the data to be read is 5, and the storage units used to store the data to be read are 1 to 5.

[0106] In summary, the embodiment of the present application determines the data to be read based on the read pointer and write pointer of the preset storage area by receiving the interrupt trigger request sent by the device, and the storage unit is filled with verification data before the data is written, and all the data to be read are compared with the verification data. If there is data to be read that is consistent with the verification data, it means that the verification data is included in the data to be read, and it can be determined that a data error has occurred. In the case of a data error, all the data to be read are compared with the verification data again until any data to be read is different from the verification data. All the data to be read can be returned to the device. By comparing the verification data, it is possible to avoid returning erroneous data to the device, so that the data returned to the device is correct, thereby avoiding relying on hardware mechanisms to ensure data correctness and improving host performance.

[0107] Figure 4 This is a step diagram of another data interaction method provided in an embodiment of the present application. The method is applied to a device and includes:

[0108] Step 403: Send an interrupt trigger request to the host; the host is used to receive the interrupt trigger request and determine the data to be read based on the read pointer and write pointer of the preset storage area; the preset storage area includes a plurality of storage units, each storage unit is used to store an item of data, and the storage unit is filled with verification data before the data is written; wherein, the read pointer points to the storage unit to be read next; the write pointer points to the storage unit to be written next; the host is further used to compare all the determined data to be read with the verification data respectively, and if there is data to be read that is consistent with the verification data, it is determined that a data error has occurred; the host is further used to re-compare all the data to be read with the verification data respectively in the event of the data error until any data to be read is different from the verification data, and return all the data to be read to the device;

[0109] Step 404: Acquire all the to-be-read data returned by the host to complete data interaction.

[0110] The details of steps 403 to 404 can be found in the Figures 1 to 3 The embodiments of the present invention will not be described in detail.

[0111] Optionally, before step 403 of sending the interrupt trigger request to the host, the method further includes:

[0112] Step 401, sending a data write request carrying the data to be written to the host; the host is used to receive the data write request and determine the data to be written carried in the data write request; the host is also used to determine the starting storage unit and the ending storage unit corresponding to the data to be written based on the write pointer and the data size of the data to be written; the host is also used to write the data to be written into the storage units from the starting storage unit to the ending storage unit in the preset storage area in sequence.

[0113] Step 402: determine a write pointer update value based on the data size of the data to be written, and send a write pointer update request carrying the write pointer update value to the host; the host is used to receive the write pointer update request and determine the write pointer update value carried in the write pointer update request; the host is also used to update the storage unit pointed to by the write pointer based on the write pointer update value.

[0114] In the embodiment of the present application, it is understood that the order of requests sent by the device to the host is usually not out of order, that is, the order in which the device sends requests is usually data write request, write pointer update request and interrupt trigger request. The out of order problem mainly refers to the inconsistency between the order in which the host receives the requests and the order in which the device sends the requests. For other content, please refer to the above Figures 1 to 3 The embodiments of the present invention will not be described in detail.

[0115] In summary, the embodiment of the present application determines the data to be read based on the read pointer and write pointer of the preset storage area by receiving the interrupt trigger request sent by the device, and the storage unit is filled with verification data before the data is written, and all the data to be read are compared with the verification data. If there is data to be read that is consistent with the verification data, it means that the verification data is included in the data to be read, and it can be determined that a data error has occurred. In the case of a data error, all the data to be read are compared with the verification data again until any data to be read is different from the verification data. All the data to be read can be returned to the device. By comparing the verification data, it is possible to avoid returning erroneous data to the device, so that the data returned to the device is correct, thereby avoiding relying on hardware mechanisms to ensure data correctness and improving host performance.

[0116] Figure 5 This is a flow chart of data interaction and data verification provided by an embodiment of the present application;

[0117] Step 501, determining verification data;

[0118] Step 502: Create a preset storage area and fill it with verification data;

[0119] Step 503: receiving an interrupt trigger request sent by a device;

[0120] Step 504: Compare the verification data to determine whether it passes. If not, re-verify.

[0121] Step 505: If the verification is successful, the data is returned to the device;

[0122] Step 506 , refill the verification data and proceed to step 503 .

[0123] The implementation process of step 502 may include the host software driver first determining the size of the preset storage area, which can be determined based on specific application requirements, such as the amount of data to be stored. The software driver then requests the operating system to apply for memory space of a corresponding size to create the preset storage area. The operating system determines whether there is sufficient free memory to meet the driver's request based on the current system's memory usage. If so, the memory is allocated to the driver. Finally, the host software driver accesses the storage cells within the storage area and writes verification data to each storage cell.

[0124] Figure 6 This is a block diagram of a host provided in an embodiment of the present application; the host 600 includes:

[0125] A receiving unit 601 is configured to receive an interrupt trigger request from a device and determine data to be read based on a read pointer and a write pointer of a preset storage area; the preset storage area includes a plurality of storage cells, each storage cell is configured to store an item of data, and the storage cell is filled with verification data before data is written; wherein the read pointer points to the storage cell to be read next; and the write pointer points to the storage cell to be written next;

[0126] A comparison unit 602 is configured to compare all the determined data to be read with the verification data, and determine that a data error occurs if there is data to be read that is consistent with the verification data;

[0127] The sending unit 603 is configured to re-compare all the data to be read with the verification data respectively when the data error occurs, until any data to be read is different from the verification data, and return all the data to be read to the device.

[0128] Optionally, the receiving unit 601 is further configured to receive a write pointer update request sent by the device before receiving the interrupt trigger request sent by the device, and determine a write pointer update value carried in the write pointer update request; the write pointer update value is determined by the device according to the data size of the data to be written;

[0129] The host 600 further includes:

[0130] A write pointer updating unit is configured to update the storage unit pointed to by the write pointer based on the write pointer update value.

[0131] Optionally, the host 600 further includes:

[0132] a data comparison unit, configured to compare the preset verification data with a preset data set; the preset data set including historical data of the host and the device during historical interactions;

[0133] a verification data determining unit, configured to determine, when the preset verification data is different from any data in the preset data set, that the preset verification data is final verification data;

[0134] The verification data filling unit is used to write the final verification data into each storage unit in the preset storage area.

[0135] Optionally, the host 600 further includes:

[0136] a read pointer updating unit, configured to update the read pointer based on a value of the write pointer so that the read pointer and the write pointer point to the same storage unit;

[0137] a verification data rewriting positioning unit, configured to determine, in the preset storage area, a target storage unit corresponding to the to-be-read data that has been returned to the device;

[0138] The verification data rewriting unit is used to write the verification data into the target storage unit.

[0139] Optionally, the host 600 further includes:

[0140] The receiving unit 601 is further configured to receive a data write request sent by the device and determine the data to be written carried in the data write request;

[0141] The host 600 further includes:

[0142] a write positioning unit, configured to determine a starting storage unit corresponding to the data to be written according to the read pointer, and to determine an ending storage unit corresponding to the data to be written according to the write pointer;

[0143] The data writing unit is used to write the data to be written into the storage units from the starting storage unit to the ending storage unit in the preset storage area in sequence.

[0144] Optionally, the receiving unit 601 includes:

[0145] The determination subunit is used to determine that the data stored from the storage unit pointed to by the read pointer to the storage unit pointed to by the write pointer is the data to be read.

[0146] The host in the embodiment of the present application can implement each process of the above-mentioned data interaction method embodiment and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0147] Figure 7 This is a block diagram of a data interaction system provided by an embodiment of the present application. Figure 7 As shown, the system 700 includes: a host 701 and a device 702; the device 702 is used to send an interrupt trigger request to the host 701 and obtain all to-be-read data returned by the host 701.

[0148] The host 702 and device 702 of the data interaction system provided in the embodiment of the present application can realize Figures 1 to 5 To avoid repetition, each process in the method embodiment will not be described here.

[0149] The device 702 in the embodiment of the present application may be a graphics card or other external device.

[0150] The data interaction system in the embodiments of the present application can be a mobile electronic device or a non-mobile electronic device. For example, the mobile electronic device can be a mobile phone, a tablet computer, a laptop computer, a PDA, an in-vehicle electronic device, a wearable device, an ultra-mobile personal computer (UMPC), a netbook, or a personal digital assistant (PDA), etc. The non-mobile electronic device can be a server, a network attached storage (NAS), a personal computer (PC), a television (TV), an ATM, or an kiosks, etc., and the embodiments of the present application do not specifically limit this.

[0151] Optionally, an embodiment of the present application also provides a data interaction system, which includes a memory and one or more programs, wherein the one or more programs are stored in the memory and are configured to implement the various processes of the above-mentioned data interaction method embodiment when executed by one or more processors, and can achieve the same technical effect. To avoid repetition, they will not be repeated here.

[0152] Figure 8 A schematic diagram of the hardware structure of a data interaction system 1000 for implementing an embodiment of the present application.

[0153] The data interaction system 1000 includes but is not limited to: a radio frequency unit 1001, a network module 1002, an audio output unit 1003, an input unit 1004, a sensor 1005, a display unit 1006, a user input unit 1007, an interface unit 1008, a memory 1009, and a processor 1010 and other components.

[0154] Those skilled in the art will understand that the data interaction system 1000 may also include a power source (such as a battery) to power each component. The power source may be logically connected to the processor 1010 through a power management system, thereby implementing functions such as charging, discharging, and power consumption management through the power management system. Figure 7 The data interaction system structure shown in the figure does not constitute a limitation on the data interaction system. The data interaction system may include more or fewer components than shown in the figure, or combine certain components, or arrange the components differently, which will not be repeated here.

[0155] The processor 1010 is configured to receive an interrupt trigger request sent by a device and determine data to be read based on a read pointer and a write pointer of a preset storage area; the preset storage area includes a plurality of storage cells, each storage cell is configured to store an item of data, and the storage cell is filled with verification data before data is written; the read pointer points to a storage cell to be read next; and the write pointer points to a storage cell to be written next.

[0156] Comparing all the determined data to be read with the verification data respectively, and if there is data to be read that is consistent with the verification data, determining that a data error occurs;

[0157] In the event of a data error, all data to be read are re-compared with the verification data until any data to be read is different from the verification data, and all data to be read are returned to the device.

[0158] Optionally, the processor 1010 is further configured to

[0159] receiving a write pointer update request sent by the device, and determining a write pointer update value carried in the write pointer update request; the write pointer update value is determined by the device according to the size of the data to be written;

[0160] Based on the write pointer update value, the storage unit pointed to by the write pointer is updated.

[0161] Optionally, the processor 1010 is further configured to

[0162] Comparing the preset verification data with a preset data set; the preset data set includes historical data of the host and the device during the historical data interaction process;

[0163] If the preset verification data is different from any data in the preset data set, determining the preset verification data as final verification data;

[0164] The final verification data is written into each storage unit in the preset storage area.

[0165] Optionally, the processor 1010 is further configured to

[0166] Based on the value of the write pointer, updating the read pointer so that the read pointer and the write pointer point to the same storage unit;

[0167] Determining, in the preset storage area, a target storage unit corresponding to the to-be-read data that has been returned to the device;

[0168] The verification data is written into the target storage unit.

[0169] Optionally, the processor 1010 is further configured to

[0170] receiving a data write request sent by the device, and determining the data to be written carried in the data write request;

[0171] Determining a starting storage unit corresponding to the data to be written according to the read pointer, and determining an ending storage unit corresponding to the data to be written according to the write pointer;

[0172] The data to be written is written sequentially into the storage units in the preset storage area from the starting storage unit to the ending storage unit.

[0173] Optionally, the processor 1010 is configured to

[0174] The data stored from the storage unit pointed to by the read pointer to the storage unit pointed to by the write pointer is determined to be the data to be read.

[0175] In summary, the embodiment of the present application determines the data to be read based on the read pointer and write pointer of the preset storage area by receiving the interrupt trigger request sent by the device, and the storage unit is filled with verification data before the data is written, and all the data to be read are compared with the verification data. If there is data to be read that is consistent with the verification data, it means that the verification data is included in the data to be read, and it can be determined that a data error has occurred. In the case of a data error, all the data to be read are compared with the verification data again until any data to be read is different from the verification data. All the data to be read can be returned to the device. By comparing the verification data, it is possible to avoid returning erroneous data to the device, so that the data returned to the device is correct, thereby avoiding relying on hardware mechanisms to ensure data correctness and improving host performance.

[0176] It should be understood that in an embodiment of the present application, the input unit 1004 may include a graphics processing unit (GPU) 10041 and a microphone 10042, and the graphics processor 10041 processes the image data of a static picture or video obtained by an image capture device (such as a camera) in a video capture mode or an image capture mode. The display unit 1006 may include a display panel 10061, and the display panel 10061 may be configured in the form of a liquid crystal display, an organic light emitting diode, etc. The user input unit 1007 includes a touch panel 10071 and at least one of other input devices 10072. The touch panel 10071 is also called a touch screen. The touch panel 10071 may include two parts: a touch detection device and a touch controller. Other input devices 10072 may include, but are not limited to, a physical keyboard, function keys (such as volume control keys, switch keys, etc.), a trackball, a mouse, and an operating stick, which will not be repeated here.

[0177] The memory 1009 can be used to store software programs and various data. The memory 1009 may mainly include a first storage area for storing programs or instructions and a second storage area for storing data, wherein the first storage area may store an operating system, applications or instructions required for at least one function (such as a sound playback function, an image playback function, etc.). In addition, the memory 1009 may include a volatile memory or a non-volatile memory, or the memory 1009 may include both volatile and non-volatile memories. Among them, the non-volatile memory may be a read-only memory (ROM), a programmable read-only memory (PROM), an erasable programmable read-only memory (EPROM), an electrically erasable programmable read-only memory (EEPROM), or a flash memory. The volatile memory may be a random access memory (RAM), a static random access memory (SRAM), a dynamic random access memory (DRAM), a synchronous dynamic random access memory (SDRAM), a double data rate synchronous dynamic random access memory (DDRSDRAM), an enhanced synchronous dynamic random access memory (ESDRAM), a synchronous link dynamic random access memory (SLDRAM), and a direct memory bus random access memory (DRRAM). The memory 1009 in the embodiment of the present application includes but is not limited to these and any other suitable types of memory.

[0178] Processor 1010 may include one or more processing units. Optionally, processor 1010 integrates an application processor and a modem processor. The application processor primarily handles operations related to the operating system, user interface, and application programs, while the modem processor primarily processes wireless communication signals, such as a baseband processor. It is understood that the modem processor may not be integrated into processor 1010.

[0179] An embodiment of the present application also provides a readable storage medium, on which a program or instruction is stored. When the program or instruction is executed by a processor, the various processes of the above-mentioned data interaction method embodiment are implemented and the same technical effect can be achieved. To avoid repetition, it will not be repeated here.

[0180] The processor is the processor in the data interaction system described in the above embodiment. The readable storage medium includes a readable storage medium such as a computer read-only memory (ROM), random access memory (RAM), a magnetic disk or an optical disk.

[0181] An embodiment of the present application further provides a chip, which includes a processor and a communication interface, wherein the communication interface is coupled to the processor, and the processor is used to run programs or instructions to implement the various processes of the above-mentioned data interaction method embodiment, and can achieve the same technical effect. To avoid repetition, it will not be repeated here.

[0182] It should be understood that the chip mentioned in the embodiments of the present application can also be called a system-level chip, a system chip, a chip system or a system-on-chip chip, etc.

[0183] Through the description of the above implementation methods, those skilled in the art can clearly understand that the above-mentioned embodiment methods can be implemented by means of software plus the necessary general hardware platform, and of course can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present application, or the part that contributes to the prior art, can be embodied in the form of a software product, which is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk), and includes a number of instructions for enabling a terminal (which can be a mobile phone, computer, server, air conditioner, or network device, etc.) to execute the methods described in each embodiment of the present application.

[0184] The embodiments of the present application are described above in conjunction with the accompanying drawings, but the present application is not limited to the above-mentioned specific implementation methods. The above-mentioned specific implementation methods are merely illustrative and not restrictive. Under the guidance of this application, ordinary technicians in this field can also make many forms without departing from the purpose of this application and the scope of protection of the claims, all of which are within the protection of this application.

Claims

1. A data interaction method, characterized in that: Applied to a host, the method includes: receiving an interrupt trigger request sent by a device, and determining data to be read based on a read pointer and a write pointer of a preset storage area; the preset storage area includes a plurality of storage cells, each storage cell is used to store an item of data, and the storage cell is filled with verification data before data is written; wherein the read pointer points to the storage cell to be read next; and the write pointer points to the storage cell to be written next; Comparing all the determined data to be read with the verification data respectively, and if there is data to be read that is consistent with the verification data, determining that a data error occurs; In the event of a data error, all data to be read are re-compared with the verification data until any data to be read is different from the verification data, and all data to be read are returned to the device.

2. The method according to claim 1, characterized in that Before the step of receiving the interrupt trigger request sent by the device, the method further includes: receiving a write pointer update request sent by the device, and determining a write pointer update value carried in the write pointer update request; the write pointer update value is determined by the device according to the size of the data to be written; Based on the write pointer update value, the storage unit pointed to by the write pointer is updated.

3. The method according to claim 1, characterized in that Before the step of receiving the interrupt trigger request sent by the device, the method further includes: Comparing the preset verification data with a preset data set; the preset data set includes historical data of the host and the device during historical interactions; If the preset verification data is different from any data in the preset data set, determining the preset verification data as final verification data; The final verification data is written into each storage unit in the preset storage area.

4. The method according to claim 1, wherein After the step of returning all the to-be-read data to the device, the method further includes: Based on the value of the write pointer, updating the read pointer so that the read pointer and the write pointer point to the same storage unit; Determining, in the preset storage area, a target storage unit corresponding to the to-be-read data that has been returned to the device; The verification data is written into the target storage unit.

5. The method according to claim 1, wherein After determining that a data error occurs, and before re-comparing all the data to be read with the verification data until any of the data to be read is different from the verification data, the method further includes: receiving a data write request sent by the device, and determining the data to be written carried in the data write request; Determining a starting storage unit corresponding to the data to be written according to the read pointer, and determining an ending storage unit corresponding to the data to be written according to the write pointer; The data to be written is written sequentially into the storage units in the preset storage area from the starting storage unit to the ending storage unit.

6. The method according to claim 1, characterized in that The step of determining the data to be read according to the read pointer and the write pointer of the preset storage area includes: The data stored from the storage unit pointed to by the read pointer to the storage unit pointed to by the write pointer is determined to be the data to be read.

7. A host, characterized in that: include: A receiving unit, configured to receive an interrupt trigger request from a device and determine data to be read based on a read pointer and a write pointer of a preset storage area; The preset storage area includes a plurality of storage cells, each storage cell is used to store an item of data, and the storage cell is filled with verification data before data is written; wherein the read pointer points to the storage cell to be read next; and the write pointer points to the storage cell to be written next; a comparing unit, configured to compare all the determined data to be read with the verification data respectively, and determine that a data error occurs if there is data to be read that is consistent with the verification data; The sending unit is used to re-compare all the data to be read with the verification data respectively when the data error occurs, until any data to be read is different from the verification data, and return all the data to be read to the device.

8. The host according to claim 7, characterized in that: The receiving unit is further configured to receive a write pointer update request sent by the device before receiving the interrupt trigger request sent by the device, and determine a write pointer update value carried in the write pointer update request; The write pointer update value is determined by the device according to the data size of the data to be written; The host further includes: a write pointer updating unit, configured to update the storage unit pointed to by the write pointer based on the write pointer update value.

9. The host according to claim 7, characterized in that: Also includes: a data comparison unit, configured to compare the preset verification data with a preset data set; the preset data set including historical data of the host and the device during historical interactions; a verification data determining unit, configured to determine, when the preset verification data is different from any data in the preset data set, that the preset verification data is final verification data; The verification data filling unit is used to write the final verification data into each storage unit in the preset storage area.

10. The host according to claim 7, characterized in that: Also includes: a read pointer updating unit, configured to update the read pointer based on a value of the write pointer so that the read pointer and the write pointer point to the same storage unit; a verification data rewriting positioning unit, configured to determine, in the preset storage area, a target storage unit corresponding to the to-be-read data that has been returned to the device; The verification data rewriting unit is used to write the verification data into the target storage unit.

11. The host according to claim 7, characterized in that: The receiving unit is further configured to receive a data write request sent by the device and determine the data to be written carried in the data write request; The host also includes: a write positioning unit, configured to determine a starting storage unit corresponding to the data to be written according to the read pointer, and to determine an ending storage unit corresponding to the data to be written according to the write pointer; The data writing unit is used to write the data to be written into the storage units from the starting storage unit to the ending storage unit in the preset storage area in sequence.

12. The host according to claim 7, characterized in that: The receiving unit includes: The determination subunit is used to determine that the data stored from the storage unit pointed to by the read pointer to the storage unit pointed to by the write pointer is the data to be read.

13. A data interaction system, characterized in that: The system comprises a host according to any one of claims 7 to 12, and a device, wherein the device is configured to send an interrupt trigger request to the host and obtain all to-be-read data returned by the host.

14. A data interaction system, characterized in that: The data interaction system includes a memory and one or more programs, wherein the one or more programs are stored in the memory and configured to execute the data interaction method according to any one of claims 1 to 6 by one or more processors.

15. A readable storage medium, characterized in that When the instructions in the storage medium are executed by a processor of a data interaction system, the processor is enabled to execute the data interaction method according to any one of claims 1 to 6.