Queue management method and queue manager implemented in UFS equipment
By using hardware to implement a queue management method for multiple command queues and linked list structures in UFS devices, the problems of poor parallelism and large hardware overhead caused by queue mode in the prior art are solved, and higher command execution parallelism and smaller firmware design difficulty are achieved.
Patent Information
- Application Number
- CN202311797644.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2023-12-25
- Publication Date
- 2025-06-27
AI Technical Summary
In existing UFS devices, the shared queue mode causes poor parallelism between command executions between different logical units, and in the case of queue blocking, it may block commands of all logical units, resulting in performance degradation; while the single logical unit queue mode can provide better performance, since each logical unit has its own command queue, the hardware overhead becomes larger and the area increases.
A new queue management method is proposed, using hardware to implement multiple command queues and multiple storage units. By building multiple linked lists on the storage unit, each linked list corresponds to a logical unit number, and using multiple hardware queues to store the first pointer, tail pointer and S pointer of multiple linked lists, data incoming and dequeuing operations are realized, and sorting and dispatching are performed according to command attributes and priorities.
This method achieves the effect of multi-queue mode management when the hardware resource overhead is slightly greater than that of single-queue mode, improves the parallelism of command execution among different logical units, reduces the design difficulty of firmware, and is compatible with two queue modes.
Smart Images

Figure CN120216151A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the field of integrated circuit technologies, and more particularly, to a queue management method and a queue manager implemented in a UFS device. Background Art
[0002] The Universal Flash Storage (UFS) is a high-performance flash storage standard mainly used in devices such as mobile devices and digital cameras. The Universal Flash Storage standard supports command queue technology. Devices that adopt the Universal Flash Storage standard are referred to as UFS devices in this article. Based on the command queue technology, a UFS device can receive multiple commands and store them in a command queue. The UFS device can select the optimal command execution order according to its own capabilities and resources. In this way, the UFS device can process multiple commands simultaneously instead of waiting for one command to complete before processing the next command.
[0003] The Universal Flash Storage standard provides two queue modes: a shared queue and a per-logical unit queue. In the shared queue mode, theoretically, there is only one command queue in the hardware, and all logical units (LUs) can use this queue. The main advantage of this queue is that the resource overhead is relatively small. However, the disadvantage is that since all logical units are competing for the same queue, the command execution parallelism between different logical units is poor. Moreover, when the queue is blocked, it may block the commands of all logical units, resulting in a performance degradation in the actual usage scenario. Additionally, if the priority sorting between commands needs to be considered, this will increase the difficulty of hardware or firmware design. In the per-logical unit queue mode, each logical unit has its own queue. The main advantage of this mode is that it can provide better performance and higher efficiency because each logical unit has its own queue, making it easier to implement the instruction sorting in each queue, and commands can be processed in parallel between different queues. However, this may also cause some problems, such as an increase in hardware overhead due to each logical unit having its own command queue, and further resulting in an increase in the area of the UFS device. Summary of the Invention
[0004] In view of this, embodiments of the present disclosure propose a queue management method and a queue manager implemented in a UFS device. The queue management method adopts a new queue management mode that has the respective advantages of the two queue management modes of UFS and at least alleviates the problems of the existing two queue modes.
[0005] According to a first aspect of the present invention, there is provided a queue management method implemented in a UFS device, the UFS device including a plurality of command queues implemented in hardware and a plurality of storage units implemented in hardware, the plurality of command queues being used to store the head pointers and tail pointers of a plurality of linked lists constructed on the plurality of storage units respectively, the plurality of linked lists corresponding to a plurality of logical unit numbers respectively,
[0006] The queue management method includes a data enqueue operation and a data dequeue operation, and the data enqueue operation includes the following steps:
[0007] Receive a command UPIU;
[0008] Parse the command UPIU to obtain the command information of the command UPIU;
[0009] Assign a unique identifier to the command UPIU;
[0010] Determine the storage location of the command UPIU in a first linked list among the plurality of linked lists, and link the storage unit storing the unique identifier of the command UPIU to the first linked list according to the storage location; and
[0011] Modify the relevant pointers of the first command queue corresponding to the first linked list.
[0012] In some embodiments, the data dequeue operation includes:
[0013] Determine the priority sorting of the plurality of command queues;
[0014] Dispatch commands from the corresponding command queues according to the priority sorting and blocking situation.
[0015] In some embodiments, the determining the priority sorting of the plurality of command queues includes:
[0016] Determine the priority sorting of the plurality of command queues based on the priority sorting of the logical units corresponding to the plurality of logical unit numbers;
[0017] For the same priority, sorting is achieved through arbitration.
[0018] In some embodiments, the determining the storage location of the command UPIU in a first linked list among the plurality of linked lists includes:
[0019] Determine a first command queue based on the logical unit number obtained from the command information;
[0020] Locate the first linked list among the plurality of linked lists based on the head pointer in the first command queue; and
[0021] Determine the storage location of the command UPIU in the first linked list according to the command information.
[0022] In some embodiments, determining the storage location of the command UPIU in the first linked list includes:
[0023] If the command attribute parsed from the command UPIU is Header of Queue, insert the corresponding unique identifier at the head of the linked list;
[0024] If the command attribute parsed from the command UPIU is Simple and the priority is equal to 0, or the command attribute is Ordered, or the command is a blocking command, then insert the corresponding unique identifier at the tail of the linked list;
[0025] If the command attribute parsed from the command UPIU is Simple and the priority is equal to 1, insert the corresponding unique identifier after the latest command whose attribute is Header of Queue, Ordered, Simple and the priority is equal to 1 or a blocking command.
[0026] In some embodiments, an S pointer is also stored in the command queue, and the S pointer is used for sorting commands with the attribute of Simple and the priority equal to 1.
[0027] In some embodiments, it further includes: storing the command information of the command UPIU in a memory.
[0028] In some embodiments, the multiple storage units implemented by hardware form an array, the unique identifier of the command UPIU is an index of the array, and the unique identifier of the command UPIU is stored in the storage unit corresponding to the index.
[0029] According to a second aspect of the present invention, there is provided a queue manager implemented in a UFS device. The UFS device includes an array implemented by hardware and multiple command queues. The array and the multiple command queues are each composed of a fixed number of storage units. The multiple command queues are used to store the head pointers and tail pointers of multiple linked lists constructed on the array respectively. The multiple linked lists respectively correspond to multiple logical unit numbers. The queue manager includes:
[0030] A command receiving module, configured to receive, cache, and allocate a unique identifier for the command UPIU, and store the command information parsed from the command UPIU in an external memory;
[0031] A queue management module, which is configured to take out the head pointer from the first command queue among the multiple command queues according to the logical unit number of the command UPIU, determine the storage location of the command UPIU in the first linked list among the multiple linked lists based on the head pointer and the command information, link the storage unit storing the unique identifier of the command UPIU to the first linked list according to the storage location, and modify the relevant pointers of the first command queue;
[0032] A command dispatching module, which is configured to determine the priority sorting of the multiple command queues and dispatch commands from the corresponding command queues according to the priority sorting and blocking situation.
[0033] In some embodiments, it further includes: a state machine, which is configured to control the startup and stop of each module.
[0034] In some embodiments, the command dispatching module first determines the priority sorting of the multiple command queues according to the priority sorting of the logical units corresponding to the multiple logical unit numbers, and for the same priority, the sorting is achieved through arbitration.
[0035] In some embodiments, the queue management module includes:
[0036] Locate the first linked list among the multiple linked lists based on the head pointer; and
[0037] Determine the storage location of the command UPIU in the first linked list.
[0038] In some embodiments, the determining the storage location of the command UPIU in the first linked list includes:
[0039] If the command attribute parsed from the command UPIU is Header of Queue, insert the corresponding unique identifier at the head of the linked list;
[0040] If the command attribute parsed from the command UPIU is Simple and the priority is equal to 0, or the command attribute is Ordered, or the command is a blocking command, then insert the corresponding unique identifier at the tail of the linked list;
[0041] If the command attribute parsed from the command UPIU is Simple and the priority is equal to 1, then insert the corresponding unique identifier after the latest command with the command attributes of Header of Queue, Ordered, Simple and the priority equal to 1 or a blocking command.
[0042] In some embodiments, an S pointer is further stored in the command queue, and the S pointer is used for sorting commands with the attribute of Simple and the priority equal to 1.
[0043] In some embodiments, the unique identifier of the command UPIU is an index of the array, and the unique identifier of the command UPIU is stored in the storage unit corresponding to the index.
[0044] According to a third aspect of the present invention, a UFS device is provided, including the queue manager described in any one of the above.
[0045] The queue management method proposed in the embodiments of the present disclosure creates multiple linked lists on a hardware-implemented storage unit. Each linked list stores the unique identifier of the command UPIU with a set logical unit number, and the head pointer, tail pointer, and S pointer of multiple linked lists are respectively stored through multiple hardware queues. When receiving a command UPIU, the unique identifier of the command UPIU is stored in an appropriate position of the corresponding linked list according to these pointers and command information. This mode uses slightly more hardware resource overhead than the single-queue mode to achieve the purpose of multi-queue mode management, and improves the parallelism of command execution between different logical units. BRIEF DESCRIPTION OF THE DRAWINGS
[0046] Through the following description of the embodiments of the present invention with reference to the drawings, the above and other objects, features, and advantages of the present invention will become clearer. In the drawings:
[0047] Figure 1 is a structural diagram of a storage system;
[0048] Figure 2 is a flowchart of the data enqueue operation in the queue management method implemented in a UFS device provided by an embodiment of the present invention;
[0049] Figure 3 is a flowchart of the data dequeue operation in the queue management method implemented in a UFS device provided by an embodiment of the present invention;
[0050] Figure 4 is a schematic structural diagram of a queue manager implemented in a UFS device provided by an embodiment of the present invention;
[0051] Figure 5 is an example diagram of the storage of an array and command queues provided by an embodiment of the present invention. DETAILED DESCRIPTION OF THE EMBODIMENTS
[0052] The following describes the present invention based on embodiments. Many specific details of the present invention are described below to understand the present invention more clearly. However, as those skilled in the art can understand, the present invention can be implemented without these specific details, that is, the present invention is not limited to these embodiments. To avoid confusing the essence of the present invention, well-known methods, processes, flows, chip devices, and chip circuits are not described in detail.
[0053] Like chip devices are represented by like reference numerals in the various figures. In addition, those of ordinary skill in the art should understand that the figures provided herein are for illustrative purposes only and are not necessarily drawn to scale.
[0054] Before introducing the exemplary embodiments of the present application, for the convenience of those skilled in the art to better understand the present application, the relevant knowledge of UFS is described.
[0055] LUN (Logic Unit Number), UFS inherits the concept of logical units in SCSI, that is, the physical storage space is divided into several logical spaces, and each logical space is uniquely identified by a unique LUN. When the host issues a command or request, it specifies which LUN to send to, and then the device addresses according to the LUN.
[0056] UPIU (UFS Protocol Information Units) is a data packet with a fixed format, used to transmit commands, data, and status information between UFS devices and the host. UPIU consists of multiple parts such as Header and Payload. The Header provides information such as the interaction type, length, and attributes of the UPIU. Depending on the type of UPIU, the Payload may contain commands, data, or status information.
[0057] Table 1 shows the basic structure of the Header of the UPIU of UFS3.1. There are differences between the Headers of the UPIU of UFS4.0 and UFS3.1.
[0058] Table 1
[0059]
[0060] Referring to Table 1, the interaction type of the UPIU can be parsed from the Header, and based on the interaction type, the UPIU can be determined to be one of types such as commands, query requests, task management requests, etc.
[0061] The "flags" in Table 1 are only useful for command UPIUs (UPIUs with an interaction type of command) and their response UPIUs, indicating the attributes of the command.
[0062] Table 2 shows the value information of the flags of the command UPIU of UFS3.1.
[0063] Table 2
[0064]
[0065] Table 3 shows the value information of the command attributes (ATTR in Table 2) of UFS3.1.
[0066] Table 3
[0067] Command Attribute (ATTR) Bit 1 Bit 0 Simple 0 0 Ordered 0 1 Header of Queue 1 0 Not Used 1 1
[0068] Referring to Tables 2 and 3, in the command UPIU, when the command attribute (ATTR) is Simple, it means that the device does not need to perform special processing when receiving such a command. Generally, the one that arrives first is executed first. When the command attribute (ATTR) is Ordered, it means that when the device receives such a command, it should process all the commands before this command before processing the current command. When the command attribute (ATTR) is Headof Queue command, it means that after the device receives this command, it is placed at the head of the command queue and executed immediately.
[0069] Furthermore, if it is determined that the command is a blocking command based on the command information parsed from the command UPIU, the blocking command is used to ensure data consistency and integrity. When the host sends a write command to the storage device, this command will ensure that all relevant data has been written to the storage device before the device continues to execute the next command.
[0070] Task Tag: UFS supports command queues, and the host can send many commands to the device simultaneously. To distinguish these commands or requests, for UFS3.1, the host needs to label each command. Then, the data UPIU and status UPIU related to this command or request have the same label as this command UPIU.
[0071] Replay Protected Memory Block (RPMB): As a way to securely store encrypted data, it can only be accessed through authentication (belonging to one of the four Well known LUNs).
[0072] Figure 1 It is the structural diagram of the storage system. As shown in the figure, the storage system includes a host 130 and a UFS device 100.
[0073] In this example, the UFS device 100 and the host 130 transfer data through the UFS interface. This interface is a bidirectional serial interface, including a data line and a clock line. The data line is used to transmit data, and the clock line is used for synchronization. UFS communication adopts a "client - server" or master - slave command architecture. The host 130 sends commands or requests (Request) to the UFS device (server, Target) 100 through the UFS interface, and then the UFS device 100 executes the command and returns the command status (Response).
[0074] The UFS device 100 includes a controller 102, a cache unit 103, a flash memory controller 101, and a storage medium 104. The controller 102 parses the received commands and performs read and write operations. The cache unit 103 can use SRAM and / or DRAM, and can load and run the program instructions of the flash translation layer (FTL). The cache unit 103 can also cache some intermediate data, such as the data read from the flash memory medium 104 and to be transmitted to the host 130, or the data received from the host 130 and to be stored in the storage medium 104. The flash memory controller 101 is used to control the reading and writing of data to and from the storage medium 104.
[0075] The storage medium 104 is, for example, a flash memory chip array. To improve the data read and write performance, the flash memory controller 101 can read and write the flash memory chips of the storage medium 104 via multiple channels (such as CH0 and CH2), and each channel is connected to a group of flash memory chips. Based on UFS, the physical space provided by the storage medium 110 can be divided into several logical spaces, and each logical space is identified by a unique LUN. When the host 130 issues a command or request, it specifies which LU to send to, and then the device performs addressing based on the LUN.
[0076] Figure 2 It is a flowchart of the data enqueue operation in the queue management method implemented in the UFS device provided in this embodiment. In the UFS device, there is a hardware-implemented array and multiple command queues. Both the array and the command queues are composed of a fixed number of storage units. The multiple command queues share the array to implement a singly linked list. That is, multiple linked lists are constructed on the array, and the constructed linked lists correspond to the queues one by one, and the queues also correspond to the logical units one by one. The information of the linked list is stored in each command queue. For example, each command queue stores the head pointer and the tail pointer of its corresponding linked list. When no linked list is initially formed in the storage unit, the head pointer and the tail pointer stored in the command queue can be set to null pointers.
[0077] This queue management method includes a data enqueue operation and a data dequeue operation. Refer to Figure 2 As shown, the data enqueue operation includes the following steps.
[0078] As shown in the figure, the data enqueue operation includes steps S201 to S204.
[0079] In step S201, the command UPIU is received.
[0080] In step S202, the command UPIU is parsed, a unique identifier is assigned, and the unique identifier and the command information of the command UPIU are stored in the memory correspondingly.
[0081] In step S203, determine the storage location of the command UPIU in the first linked list among multiple linked lists, and link the storage unit storing the unique identifier of the command UPIU to the first linked list according to the storage location.
[0082] In step S204, modify the relevant pointers in the first command queue corresponding to the first linked list.
[0083] The command UPIU refers to the UPIU whose interaction type parsed from the header of the UPIU is Command (see the description of the command UPIU above). Based on this embodiment, first receive the command UPIU from the host, parse the command UPIU, allocate a unique identifier to the command, store the unique identifier and the complete command information in the memory, then obtain the logical unit number from the command information, determine the first command queue among multiple command queues according to the logical unit number obtained from the command information, take out information such as the head pointer and the tail pointer from it, and locate to the first linked list among multiple linked lists according to the relevant pointer information (if the head pointer is a null pointer, the command ID serves as the head node of the first linked list), then determine the storage location of the command UPIU in the first linked list among multiple linked lists in combination with the command information parsed from the command UPIU, and then link the storage unit storing the unique identifier of the command UPIU to this storage location in the first linked list. For example, if the newly allocated unique identifier is to be inserted into the head of the first linked list, modify the pointer in the storage unit so that the storage unit links to the original head of the first linked list. If it is inserted at a certain position in the middle of the linked list, not only modify the pointer in the storage unit, but also modify the pointer in the storage unit before this position so that the storage unit links to this position.
[0084] In this embodiment, step S203 realizes the command sorting in each linked list. Referring to Tables 2 and 3 above, if the command attribute parsed from the command UPIU is Header of Queue, the corresponding command ID is inserted at the head; if the command attribute parsed from the command UPIU is Simple and the priority is equal to 0, or the command attribute is Ordered, or it is a blocking command, the corresponding command ID is inserted at the end of the queue; if the command attribute parsed from the command UPIU is Simple and the priority is equal to 1, the corresponding command ID is inserted immediately after the command with the command attribute of Header of Queue, Ordered, Simple and the priority equal to 1 or the Barrier command. If there is no such command in the command queue, it means that all the instructions in the queue are simple and the priority is equal to 0, then the command is inserted at the head. In addition, if the first pointer in the linked list points to a command with the attribute of Header of Queue and a new Header of Queue command is received, although the UFS protocol does not clearly indicate, the common practice is to place the command at the head for priority execution. In addition, it should be noted that since the UPIU format definitions in different versions of UFS are different, in practice, the above operations need to be adjusted according to the UFS version adopted.
[0085] After the data enqueue operation is completed, as shown in step S204, the relevant pointers in the first command queue corresponding to the first linked list are modified. For example, if a new identifier is inserted at the end of the linked list, the tail pointer of the corresponding linked list needs to be modified.
[0086] In some embodiments, for enqueue sorting, in addition to the head pointer and the tail pointer, each command queue also stores an S pointer. How to use the head pointer, the tail pointer and the S pointer will be described in detail below.
[0087] Meaning of the first pointer: The ID of the first command in the corresponding linked list.
[0088] Meaning of the S pointer: The position indication where the next Simple (CP = 1) command is to be inserted (only used for the data enqueue operation, and also represents the position of the last Head attribute command / Order attribute command / blocking command / Simple (CP = 1) command in the corresponding linked list).
[0089] Meaning of the tail pointer: The position of the last command in the corresponding linked list, corresponding to a certain index position in the linked list.
[0090] The Head (Header of Queue) attribute command is inserted at the head of the linked list, and the head pointer points to the ID allocated by the Head attribute command. If all three current pointers are ff (ff indicates a null pointer, meaning there are no commands in the corresponding linked list), then the ID of this Head attribute command will be assigned to the head pointer, S pointer, and tail pointer simultaneously. Since there is only this one command in the corresponding linked list at this time, the head pointer is equal to the tail pointer. According to the above definition, the S pointer represents the position of the last Head / Order / Barrier / Simple (CP = 1) command in the linked list, so the S pointer also needs to be updated. If the current linked list is not empty, then the ID of the Head attribute command is assigned to the head pointer, and the ID of this Head attribute command is linked to the original head ID.
[0091] The Order attribute command, barrier command, and Simple (CP = 0) attribute command are inserted at the tail of the linked list. It can be considered that these three commands have the lowest priority. Similarly, if the current linked list is empty, the ID of the command is assigned to the head pointer and tail pointer simultaneously. If the current command is an Order attribute command / barrier command, then the S pointer is also updated. If not, the S pointer continues to remain a null pointer, indicating that there are no Head attribute commands / Order attribute commands / barrier commands / Simple (CP = 1) commands in the current queue. If the linked list is not empty, then the tail pointer points to the ID of this command, and the next ID of this command is updated to itself.
[0092] The Simple (CP = 1) attribute command is inserted at the S pointer. If the corresponding linked list is empty, then the ID of the command is assigned to the head pointer, S pointer, and tail pointer simultaneously. If the corresponding linked list is not empty and the S pointer is a null pointer, it means that although the corresponding linked list is not empty, there are no Head attribute commands / Order attribute commands / barrier commands / Simple (CP = 1) commands, that is, the corresponding linked list is full of Simple (CP = 0) commands. Then, the head pointer and S pointer are updated to the ID of this Simple (CP = 1) command and linked to the original head ID. If the corresponding linked list is not empty and the S pointer is not a null pointer, it means that there are already Head attribute commands / Order attribute commands / barrier commands / Simple (CP = 1) commands in the corresponding linked list. Then, this Simple (CP = 1) command needs to be arranged after the existing Head attribute commands / Order attribute commands / barrier commands / Simple (CP = 1) commands. This position is the S pointer. The S pointer points to the ID corresponding to this Simple (CP = 1) command, and the ID of the original S pointer is linked to the ID of this Simple (CP = 1) command, while the ID of this Simple (CP = 1) command is linked to the ID after the original S pointer.
[0093] In some embodiments, assigning a unique identifier to the command UPIU in step S202 is to assign an index of an array to the command UPIU. For example, an array is constructed using 32 registers, and the index of each register is one of 0 to 31. Then, when enqueuing, an unused index value from 0 to 31 is assigned to the command UPIU as the unique identifier according to a certain strategy. In this way, the ID assigned to the command UPIU is consistent with the index of the register it uses in the array.
[0094] UFS specifies a maximum of 32 normal LUNs and 4 W-LUNs, corresponding to 32 normal LUs and 4 W-LUs respectively. One high-priority LUN can also be defined among the 32 LUNs. The W-LUNs are divided into four types, namely REPORT, DEVICE, BOOT LUN, and RPMB. The protocol specifically stipulates that the RPMB LUN can be configured with a separate queue depth regardless of whether it is in the per-logic unit queue or shared queue mode. Then, in the embodiments of the present invention, a reasonable queue architecture can be: 32 ordinary queues (including one high-priority queue among the 32 ordinary queues) and one well-known LUN (all W-LUNs except RPMB) queue, and one RPMB LUN queue. The sum of the queue depths of each queue is the total queue depth defined by the UFS device.
[0095] Figure 3 It is a flowchart of the data dequeue operation in the queue management method implemented in the UFS device provided in this embodiment.
[0096] In step S301, multiple command queues are sorted.
[0097] Specifically, for the scenario where there are multiple non-empty queues at the same time, first, the priority sorting of multiple command queues is determined by sorting according to the priorities of the logical units corresponding to the logical unit numbers in each command request, and then arbitration is performed on the command queues with the same priority. For example, if the queue architecture of 32 ordinary queues (including one high-priority queue among the 32 ordinary queues), one well-known LUN (except RPMB) queue, and one RPMB LUN queue described above is adopted, the priority judgment during dequeueing is: RPMB queue > well-known LUN (except RPMB) queue > high-priority queue > polling arbitration for the remaining 31 ordinary queues.
[0098] In step S302, commands are dispatched from the corresponding command queues according to the priority sorting and blocking situation.
[0099] For example, if, according to the sorting result, the first command to dequeue is the first command in queue 1, the unique identifier ID of this command is pushed from the command queue to the firmware 320 or the hardware execution unit 310. The firmware 320 or the hardware execution unit 310 performs corresponding processing according to the unique identifier ID. During the execution process, the firmware 320 or the hardware execution unit 310 can obtain the command information from the memory according to this ID. If there is a queue blockage in each queue, when the blockage occurs, the commands in this queue cannot dequeue until all the previous commands of this LUN are completed. The blockage situations can be the following: 1. The first command is an Order attribute; 2. The first command is a Barrier command; 3. There is a correlation problem between the first command and the read / write command being executed by this LUN; 4. Some user-defined configurations. The advantage of this blockage behavior is that the queue priority sorting can be implemented by hardware, greatly reducing the design difficulty of the firmware. The blockage behavior only occurs within a single LUN and does not affect other LUNs, increasing the command execution parallelism between different LUNs. In addition, some user-defined configuration registers can be easily added to implement the blockage or exclusive execution of certain commands.
[0100] In addition, the pointer in the corresponding command queue needs to be modified after each data dequeue operation. Refer to Figure 5 As shown, in this example, the index is the ID of the command. At the same time, the next ID it links to is stored in the storage unit corresponding to the index. If ID = 1 is taken away, the head pointer is updated from 1 to 0 because ID = 1 links to ID = 0 in the linked list. Then ID = 0 is taken away, and the head pointer is updated to ff because 0 links to 0 (itself) in the linked list, indicating that 0 is the last one, so it is updated to ff (null pointer).
[0101] It should be noted that the queue management method proposed in the embodiments of the present invention can adapt to the queue modes of UFS: shared queue and per-logical unit queue. For the per-logical unit queue mode, each queue has a TASK SET FULL (signal indicating the queue is full). When inserting a command into each queue (corresponding to the linked list in the above text), if the number of commands has already reached the queue depth of the queue, then TASK SET FULL is at a high level, indicating that the queue is full. For the shared queue, all queues share a TASK SET FULL (flag indicating the queue is full). For any command queue, as long as the total number of commands in all queues is equal to the queue depth of the hardware queue, then TASK SET FULL is at a high level, indicating that the queue is full. Such an adjustment of the processing logic can be easily carried out, for example, by using a register switch to control the switching between the two modes.
[0102] The queue management method provided by the embodiments of the present invention has relatively low resource overhead, realizes the command priority sorting based on the UFS protocol, greatly improves the parallelism of command execution between different LUNs, and also reduces the design difficulty of the firmware.
[0103] Figure 4 It is a schematic structural diagram of a queue manager implemented in a UFS device provided by an embodiment of the present invention. The UFS device includes a plurality of command queues implemented in hardware and a plurality of storage units implemented in hardware. The plurality of command queues are used to store the head pointers and tail pointers of a plurality of linked lists constructed on the plurality of storage units respectively, and the plurality of linked lists respectively correspond to a plurality of logical unit numbers. The queue manager 400 includes the following modules implemented in hardware.
[0104] The command receiving module 401 is used to receive, cache, and assign a unique identifier to the command UPIU, and store the command information parsed from the command UPIU into an external memory.
[0105] The queue management module 402 is used to retrieve relevant pointers from the first command queue among the plurality of command queues according to the logical unit number of the command UPIU, determine the storage position of the command UPIU in the first linked list among the plurality of linked lists based on the pointers and the command information, link the storage unit storing the unique identifier of the command UPIU to the first linked list according to the storage position, and modify the relevant pointers of the first command queue.
[0106] In some embodiments, the queue management module 402 may maintain three pointers in each queue: a head pointer, a tail pointer, and an S pointer. It may also maintain empty / full flags in each queue. By maintaining a counter for each queue, incrementing it when a command enters the queue and decrementing it when a command exits the queue, and determining that the queue is empty when the count is 0, it can determine whether the queue is empty or full. The queue management module 402 may also maintain the number of in-flight commands (the number of commands that have exited the queue but have not been executed completely) and a blocking flag in each queue to facilitate subsequent command dispatching. The blocking flag applies to multiple scenarios. For example, if the command corresponding to the current head pointer is a blocking command or an Order attribute command, the queue dispatch is blocked until the number of in-flight commands in the queue is cleared.
[0107] The command dispatching module 403 is configured to determine the priority sorting of multiple command queues and dispatch commands from the multiple command queues according to the priority sorting and queue blocking status.
[0108] In some embodiments, a state machine 404 is used to control the startup and stop of each module. The state machine 404 receives the enqueue request from the command receiving module 401 and the dequeue request from the command dispatching module 404 respectively, and then controllably sends enqueue / dequeue requests to the queue management module 402. Therefore, for the queue management module 403, enqueueing and dequeueing do not occur simultaneously.
[0109] In some embodiments, in the queue manager, multiple hardware-implemented storage units form an array. The command receiving module 401 assigns a unique identifier to the command UPIU by allocating an index of the array to the command UPIU, and then stores the unique identifier of the command UPIU in the storage unit corresponding to the index.
[0110] In summary, the queue management method and queue manager of the embodiments of the present invention have the following advantages:
[0111] 1. Use a singly linked list to maintain the command queues of all logical units. Each command queue only maintains information such as its own pointers, empty / full flags, the number of in-flight commands, and queue blocking flags, reducing the hardware resource overhead.
[0112] 2. Realize the independent management of each command queue, avoid the situation where a certain command blocks the entire command queue, and improve the parallelism of command execution between different logical units. In actual use, the scenario is relatively complex, and there are various priority and data correlation problems. At this time, high parallelism means high performance.
[0113] 3. Hardware realizes the sorting and blocking of queues and the priority arbitration between queues. Cooperating with other hardware, it can also realize the check of data correlation and the queue blocking caused by the failure of the correlation check, with hardware acceleration, reducing the participation of firmware, which is beneficial to reducing the design difficulty of the firmware.
[0114] 4. While not affecting performance and with relatively low additional hardware overhead, support two different queue modes simultaneously to enhance compatibility.
[0115] As described above in the embodiments of the present invention, these embodiments do not elaborate on all the details, nor do they limit the invention to the specific embodiments described. Obviously, based on the above description, many modifications and variations can be made. These embodiments are selected and specifically described in this specification to better explain the principles and practical applications of the present invention, so that those skilled in the relevant technical field can make good use of the present invention and its modified applications based on the present invention.
Claims
1. A queue management method implemented in a UFS device, the UFS device including an array and multiple command queues implemented in hardware, the array and the multiple command queues each consisting of a fixed number of storage units, the multiple command queues being used to store the head pointers and tail pointers of multiple linked lists constructed on the array respectively, the multiple linked lists corresponding to multiple logical unit numbers respectively, The queue management method includes a data enqueue operation and a data dequeue operation. The data enqueue operation includes the following steps: Receive a command UPIU; Parse the command UPIU to obtain the command information of the command UPIU; Assign a unique identifier to the command UPIU; Determine the storage position of the command UPIU in the first linked list, and link the storage unit storing the unique identifier of the command UPIU to the first linked list according to the storage position; And Modify the relevant pointers in the first command queue corresponding to the first linked list.
2. The queue management method according to claim 1, wherein, The data dequeue operation includes: Determine the priority sorting of the multiple command queues; Dispatch commands from the corresponding command queues according to the priority sorting and blocking situation.
3. The queue management method according to claim 2, wherein, The determining the priority sorting of the multiple command queues includes: Determine the priority sorting of the multiple command queues based on the priority sorting of the logical units corresponding to the multiple logical unit numbers; For the same priority, sorting is achieved through arbitration.
4. The queue management method according to claim 1, wherein The determining the storage position of the command UPIU in the first linked list includes: Determine the first command queue based on the logical unit number obtained from the command information; Locate the first linked list among the multiple linked lists based on the head pointer in the first command queue; and Determine the storage position of the command UPIU in the first linked list according to the command information.
5. The queue management method according to claim 4, wherein, The determining the storage position of the command UPIU in the first linked list includes: If the command attribute parsed from the command UPIU is Header of Queue, insert the corresponding unique identifier at the head of the linked list; If the command attribute parsed from the command UPIU is Simple and the priority is equal to 0, or the command attribute is Ordered, or the command is a blocking command, then insert the corresponding unique identifier at the tail of the linked list; If the command attribute parsed from the command UPIU is Simple and the priority is equal to 1, then insert the corresponding unique identifier after the latest command with the command attributes of Header of Queue, Ordered, Simple and the priority equal to 1 or a blocking command.
6. The queue management method according to claim 5, wherein, An S pointer is also stored in the command queue, and the S pointer is used for sorting commands with the attribute of Simple and the priority equal to 1.
7. The queue management method according to claim 1 further includes: Store the command information of the command UPIU in a memory.
8. The queue management method according to any one of claims 1 to 7, wherein, The unique identifier of the command UPIU is an index of the array, and the unique identifier of the command UPIU is stored in the storage unit corresponding to the index.
9. A queue manager implemented in a UFS device, the UFS device including an array and multiple command queues implemented in hardware, the array and the multiple command queues each consisting of a fixed number of storage units, the multiple command queues being used to store the head pointers and tail pointers of multiple linked lists constructed on the array respectively, the multiple linked lists corresponding to multiple logical unit numbers respectively, The queue manager includes: A command receiving module, configured to receive, cache, and assign a unique identifier to a command UPIU, and store the command information parsed from the command UPIU into an external memory; A queue management module, configured to take out the head pointer from a first command queue among the multiple command queues according to the logical unit number of the command UPIU, determine the storage position of the command UPIU in a first linked list among the multiple linked lists based on the head pointer and the command information, and link the storage unit storing the unique identifier of the command UPIU to the first linked list according to the storage position, and modify relevant pointers within the first command queue; A command dispatching module, configured to determine the priority sorting of the multiple command queues, and dispatch commands from corresponding command queues according to the priority sorting and blocking situation.
10. The queue manager according to claim 9 further includes: A state machine, configured to control the startup and stop of each module.
11. The queue manager according to claim 9, wherein, The command dispatching module first determines the priority sorting of the multiple command queues according to the priority sorting of the logical units corresponding to the multiple logical unit numbers, and for the same priority, sorting is achieved through arbitration.
12. The queue manager according to claim 9, wherein, The queue management module includes: Locating the first linked list among the multiple linked lists based on the head pointer; and Determining the storage position of the command UPIU in the first linked list.
13. The queue manager according to claim 12, wherein, The determining the storage position of the command UPIU in the first linked list includes: If the command attribute parsed from the command UPIU is Header of Queue, inserting the corresponding unique identifier at the head of the linked list; If the command attribute parsed from the command UPIU is Simple and the priority is equal to 0, or the command attribute is Ordered, or the command is a blocking command, then inserting the corresponding unique identifier at the tail of the linked list; If the command attribute parsed from the command UPIU is Simple and the priority is equal to 1, then inserting the corresponding unique identifier after the latest command whose attribute is Header of Queue, Ordered, Simple and the priority is equal to 1 or a blocking command.
14. The queue manager according to claim 13, wherein, An S pointer is also stored in the command queue, and the S pointer is used for sorting commands whose attribute is Simple and the priority is equal to 1.
15. The queue manager according to any one of claims 9 to 14, wherein The multiple storage units implemented in hardware form an array, the unique identifier of the command UPIU is an index of the array, and the unique identifier of the command UPIU is stored in the storage unit corresponding to the index.
16. A UFS device, including the queue manager according to any one of claims 9 to 15.
Citation Information
Cited By
Cluster operation and maintenance instruction execution method and device, electronic device and storage medium
CN120474915A