The present invention relates to a host device coupled to a flash memory controller.
In a conventional flash memory controller that complies with Universal Flash Storage (UFS) standard, in order to test the performance of the flash memory controller when processing multiple commands, the host device will send multiple commands to the flash memory controller to observe the characteristics of the flash memory controller when processing these commands. However, since the current software architecture of the host device cannot quickly transmit a large number of commands to the flash memory controller, it cannot effectively test the limits of the flash memory controller in processing multiple commands.
Therefore, the present invention proposes a command processing method that allows the host device to quickly send a large number of commands to the flash memory controller for processing, so as to solve the problems described in the prior art.
According to one embodiment of the present invention, a host device coupled to a memory device is disclosed. The memory device comprises a flash memory controller and a flash memory module, and the host device comprises a processor, and the processor is configured to perform the steps of: (a) configuring a plurality of transport request descriptors in a memory; (b) writing a plurality of command descriptors into the memory in sequence, wherein a number of the plurality of command descriptors is greater than a number of the plurality of transport request descriptors; (c) selecting a transport request descriptor from the plurality of transport request descriptors sequentially and repeatedly, and determine a command descriptor sequentially without repetition; (d) modifying the transport request descriptor according to the command descriptor; (e) reading the transport request descriptor to send a command in the command descriptor to the memory device; and (f) determining whether a last command descriptor of the plurality of command descriptors has been processed, if not, going back to step (c), and executing steps (c)-(f) in sequence.
According to one embodiment of the present invention, an electronic device, comprising a memory device and a host device is disclosed. The memory device comprises a flash memory controller and a flash memory module. The host device is coupled to the memory device, wherein the host device comprises a processor, and the processor is configured to perform the steps of: (a) configuring a plurality of transport request descriptors in a memory; (b) writing a plurality of command descriptors into the memory in sequence, wherein a number of the plurality of command descriptors is greater than a number of the plurality of transport request descriptors; (c) selecting a transport request descriptor from the plurality of transport request descriptors sequentially and repeatedly, and determine a command descriptor sequentially without repetition; (d) modifying the transport request descriptor according to the command descriptor; (e) reading the transport request descriptor to send a command in the command descriptor to the memory device; and (f) determining whether a last command descriptor of the plurality of command descriptors has been processed, if not, going back to step (c), and executing steps (c)-(f) in sequence.
These and other objectives of the present invention will no doubt become obvious to those of ordinary skill in the art after reading the following detailed description of the preferred embodiment that is illustrated in the various figures and drawings.
As shown in
In addition, the host device 50 further includes an interface transmission circuit 56 coupled to the memory device 100. The memory transmission circuit 56 includes a UFS controller 132, a UniPro layer 134 and an M-PHY circuit 136 that complies with specifications of MIPI Alliance.
In this embodiment, the host device 50 can transmit multiple commands to the flash memory controller 110, and the flash memory controller 110 will perform read operations or write operations on the flash memory module 120 based on these commands from the host device 50.
In this embodiment, in order to test the performance and limit of the memory device 100 in processing multiple commands, the host device 50 will continuously send many commands, for example, about 10,000 to 50,000 commands to the memory device 100. As mentioned in the prior art, the conventional host device architecture cannot quickly transmit a large number of commands to the memory device 100, thus resulting in a low efficiency in testing the memory device 100. Therefore, this embodiment proposes a method for testing the memory device 100, where the command processing method performed in the command processing method allows the host device 50 to quickly send a large number of commands to the flash memory controller 110 for processing.
Specifically, referring to
The processor 52 in the host device 50 also configures a plurality of UTP command descriptors (UCD) 220_1-220_M in the DRAM 54. The number of UCDs 220_1-220_M can be determined according to the number of test commands that the host device 50 needs to send to the memory device 100. For example, if the host device 50 needs to send 10,000 commands to the memory device 100 for testing, then the number of UCDs 220_1-220_M is 10,000 (that is, M is equal to 10,000). In this embodiment, each of the UCDs 220_1-220_M has the same size, and each of UCDs 220_1-220_M includes a command UPIU, a response UPIU and a PRDT, wherein the command UPIU refers to a command packaged in a UPIU packet, the response UPIU refers to a response message packaged in a UPIU packet from the memory device 100, and the PRDT describes address information that points to one or more data buffers. In one embodiment, the UCDs 220_1-220_M have consecutive addresses in the DRAM 54, but the invention is not limited thereto.
In addition, multiple doorbell registers (DBR) 202_1-202_N will be provided inside the UFS controller 132, where the DBRs 202_1-202_N correspond to the UTRDs 210_1-210_N, respectively, and each DBR is used to indicate whether the corresponding UTRD is in a state that can transmit a command. For example, if the value of the DBR 202_1 is “0”, it means that the UTRD 210_1 is currently unable to transmit commands; and if the value of the DBR 202_1 is “1”, it means that the UTRD 210_1 is in a state that can transmit a command. In this embodiment, only one of the DBRs 202_1-202_N has the value “1”, while the rest of the DBRs are all “0”, and the DBRs 202_1-202_N are sequentially and repeatedly has the value “1”. In addition, in this embodiment, a DBR is defined as a bit, but this definition is not a limitation of the present invention. In other embodiments, multiple bits can be regarded as a doorbell register, for example, 32 bits can be regarded as a doorbell register, and each bit corresponds to a UTRD, that is, at this time the symbol “DBR” shown in
In the operation of the host device 50, first, the processor 52 can generate multiple command UPIUs in sequence, where these commands can include various different types of commands, such as inquiry commands of UFS based on Small Computer System Interface (SCSI), mode selection commands, pre-fetch commands, security protocol commands, commands, read write commands, verify command, . . . etc. The read commands and the write commands are regarded as commands that require user data transfer, the security protocol commands will transmit security-related user data or set data in the protection region, the inquiry commands and the mode selection commands transfers non-user data, and the remaining commands can be regarded as commands that do not require data transfer. At this time, the processor 52 sets the DBR 202_1 to “1”, and modifies the content of the UTRD 210_1 corresponding to the DBR 202_1 to describe the information of the UCD 220_1. For example, since each of the UCDs 220_1-220_M has the same size, and the sizes/lengths of the command UPIU, response UPIU, and PRDT are known, the processor 52 can modify the content of the UTRD 210_1 to describe the starting address of the UCD 220_1, response UPIU offset, response UPIU length, PRDT offset, PRDT length, . . . and so on. In addition, the UCDs 220_1-220_M serves as a software sequence, and the processor 52 writes the first command UPIU to the first field of UCD 220_1, and if this command UPIU is not a read command or a write command, the PRDT in the UCD 220_1 can remain blank or not point to any meaningful data buffer because this command does not require data transfer; and if this command UPIU is a read command or a write command, since this command requires data transfer, the PRDT in the UCD 220_1 will point to a data buffer in DRAM 54, where the data buffer includes the data that needs to be written to the memory device 100, or the data buffer is used to store data read from the memory device 100. It is noted that at this time, the response UPIU in the UCD 220_1 is blank or does not include any valid data.
In addition, at the same time, the processor 52 sequentially writes the subsequent command UPIUs into the subsequent UCD 220_2-220_M. Similarly, if this command UPIU is not a read command or a write command, the PRDT in the corresponding UCD can remain blank or not point to any meaningful data buffer because this command does not require data transfer; and if this command UPIU is a read command or a write command, since this command requires data transfer, the PRDT in the corresponding UCD will point to a data buffer in DRAM 54, where the data buffer includes the data that needs to be written to the memory device 100, or the data buffer is used to store data read from the memory device 100.
After the processor 52 completes the writing/modification of the UTRD 210_1 and the UCD 220_1, a direct memory access (DMA) circuit in the host device 50 will read the UTRD 210_1, and transmit the command UPIU in the UCD 220_1 to the memory device 100 based on the content of the UTRD 210_1. In addition, after the command UPIU in UCD 220_1 is transmitted to the memory device 100, the flash memory controller 110 in the memory device 100 will execute the command UPIU, and send a response message to the host device 50 based on whether the command UPIU is successfully executed, and at this time the response message will be written to the response UPIU within the UCD 220_1.
In this embodiment, in order to improve the speed of the host device 50 sending commands to the memory device 100, after the processor 52 knows that the command UPIU in the UCD 220_1 is sent to the memory device 100 through the DMA circuit, regardless of whether a response message is received from the memory device 100, the processor 52 will set the DBR 202_1 to “0”, set the DBR 202_2 to “1”, and modify the UTRD 210_2 corresponding to the DBR 202_2 to describe the information of the UCD 220_2. For example, since each of the UCDs 220_1-220_M has the same size, and the sizes/lengths of the command UPIU, response UPIU, and PRDT are known, the processor 52 can modify the content of the UTRD 210_2 to describe the starting address of the UCD 220_2, response UPIU offset, response UPIU length, PRDT offset, PRDT length, . . . and so on.
After the processor 52 completes the writing/modification of the UTRD 210_2 and the UCD 220_2, the DMA circuit in the host device 50 will read the UTRD 210_2, and transmit the command UPIU in the UCD 220_2 to the memory device 100 based on the content of the UTRD 210_2. In addition, after the command UPIU in UCD 220_2 is transmitted to the memory device 100, the flash memory controller 110 in the memory device 100 will execute the command UPIU, and send a response message to the host device 50 based on whether the command UPIU is successfully executed, and at this time the response message will be written to the response UPIU within the UCD 220_2.
Similarly, after the processor 52 knows that the command UPIU in the UCD 220_2 is sent to the memory device 100 through the DMA circuit, regardless of whether a response message is received from the memory device 100, the processor 52 will set the DBR 202_2 to “0”, set the DBR 202_3 to “1”, and modify the UTRD 210_3 corresponding to the DBR 202_3 to describe the information of the UCD 220_3.
Based on similar operations, the processor 52 sequentially modifies the contents of the UTRDs 210_4-210_32, and transmits the corresponding command UPIUs to the memory device 100 in sequence. Then, the processor 52 returns to the first UTRD 210_1 for processing, but does not return to the first UCD 220_1, that is, the processor 52 continues to sequentially start processing the UCD 220_33. Specifically, the processor 52 sets the DBR 202_1 to “1” and modifies the content of the UTRD 210_1 corresponding to the DBR 202_1 to describe the information of the UCD 220_33. At this time, the processor 52 writes the command UPIU to the first field of UCD 220_33. Afterwards, the DMA circuit reads the UTRD 210_33 and transmits the command UPIU in the UCD 220_33 to the memory device 100 according to the content of the UTRD 210_33.
Then, based on similar operations, the processor 52 sequentially modifies the contents of the UTRDs 210_2-210_32, and transmits the corresponding command UPIUs stored in the UCDs 220_34-220_64 to the memory device 100 in sequence.
Similarly, the processor 52 modifies the UTRDs 210_1-210_32 sequentially and repeatedly, and writes data to the remaining UCDs sequentially without repetition, until the command UPIU of the last UCD 220_M is transmitted to the memory device 100.
As mentioned above, since the processor 52 does not need to consider whether each command UPIU can be successfully executed by the flash memory controller 110 when transmitting the command UPIU to the memory device 100, that is, there is no need to read the response UPIU of each UCD, the processor 52 can quickly transmit many command UPIUs to the memory device 100 to improve the efficiency of command testing.
In addition, after all the command UPIUs generated by the processor 52 are transmitted to the memory device 100, the processor 52 begins to obtain the response UPIUs in the UCD 220_1-220_M to determine which one of UCD 220_1-220_M has a command execution error, so that the engineers can analyze the results of these command tests.
It should be noted that the UTRD and UCD in the UFS specification are used as explanations in the above embodiment, but the present invention is not limited thereto. In other embodiments, the UTRD may be replaced by a transport request descriptor corresponding to other flash memory specifications, and the UCD may be replaced by a command descriptor corresponding to other flash memory specifications.
Step 300: the flow starts.
Step 302: configure a plurality of transport request descriptors in a memory.
Step 303: write a plurality of command descriptors into the memory in sequence, wherein a number of the plurality of command descriptors is greater than a number of the plurality of transport request descriptors.
Step 304: select a transport request descriptor from the plurality of transport request descriptors sequentially and repeatedly, and determine a command descriptor sequentially without repetition.
Step 306: modify the transport request descriptor according to the command descriptor.
Step 308: read the transport request descriptor to send a command in the command descriptor to a memory device, and after executing the command, the memory device sends a response message and writes the response message to the command descriptor.
Step 310: determine whether a last command descriptor has been processed. If yes, the flow enters Step 312; and if not, the flow goes back to Step 302.
Step 312: start to read the response messages in all command descriptors for analysis.
Those skilled in the art will readily observe that numerous modifications and alterations of the device and method may be made while retaining the teachings of the invention. Accordingly, the above disclosure should be construed as limited only by the metes and bounds of the appended claims.
Number | Date | Country | Kind |
---|---|---|---|
112135977 | Sep 2023 | TW | national |