Test method, device and electronic equipment for solid state disk
By directly reading the control register address of the solid-state drive at the Linux application layer and executing test commands according to protocol rules, the problems of poor performance and high cost of existing testing methods are solved, and efficient and low-cost solid-state drive testing is achieved.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- JIANGSU XINSHENG INTELLIGENT TECH CO LTD
- Filing Date
- 2021-10-22
- Publication Date
- 2026-05-01
AI Technical Summary
Existing solid-state drive (SSD) testing methods suffer from poor test results or high testing costs. In particular, the use of ioctl function tools is not effective, while developing drivers to replace the pre-packaged drivers at the Linux application layer increases testing costs.
By reading the memory address of the control register stored in the target register of the solid-state drive, a virtual address is requested from the motherboard, and test operation commands are written to the physical address according to preset protocol rules. The test commands are then executed through the control register, bypassing the ioctl function, thus enabling direct testing of the solid-state drive by the Linux application layer.
It improves the testing results of solid-state drives (SSDs), reduces testing costs, and enables efficient testing of SSDs at the Linux application layer.
Smart Images

Figure CN113948146B_ABST
Abstract
Description
Testing methods, apparatus and electronic equipment for solid-state drives Technical Field
[0001] This application relates to the field of storage technology, and in particular to a testing method, apparatus, and electronic device for solid-state drives. Background Technology
[0002] Existing solid-state drives (SSDs) need to follow protocols to send commands during operation, and SSD testing must cover protocol testing scenarios. Currently, protocol testing is primarily conducted at the Linux application layer, with two main testing methods: The first method uses tools like smartctl and haarm, which utilize SSD-encapsulated ioctl functions, to send commands for testing. This is the simplest, fastest, and most common method. However, many features of this method are modified or intercepted by the kernel. The second method involves developing a driver to replace the pre-packaged driver at the Linux application layer. This method overcomes the shortcomings of the first method but requires purchasing a separate motherboard and developing a driver specifically for disk platter testing, increasing testing costs. In summary, existing SSDs suffer from either poor testing performance or high testing costs. Summary of the Invention
[0003] To address the aforementioned technical problems, embodiments of this application provide a testing method, apparatus, and electronic device for solid-state drives.
[0004] In a first aspect, embodiments of this application provide a testing method for a solid-state drive, the method comprising:
[0005] Read the memory address of the control register stored in the target register of the solid-state drive;
[0006] Request a first virtual address from the motherboard, and write test operation commands for the solid-state drive into the first virtual address;
[0007] The first physical address corresponding to the first virtual address is determined according to the pre-configured physical page document, and the test operation command is written into the first physical address according to the preset protocol rules;
[0008] Write the first physical address into the memory address of the control register;
[0009] The test operation command is executed through the control register to obtain the test command execution result.
[0010] Optionally, before reading the memory address of the control register stored in the target register of the solid-state drive, the method further includes:
[0011] Read the configuration information of the configuration space of the solid-state drive;
[0012] The type of the solid-state drive is determined based on the configuration information, and the solid-state drive is either a non-volatile solid-state drive or a serial ATA hard drive.
[0013] When the solid-state drive is a non-volatile solid-state drive, the bar1 register and bar2 register in the configuration space are determined as the target registers;
[0014] When the solid-state drive is of type serial ATA hard drive, the bar5 register in the configuration space is determined as the target register.
[0015] Optionally, after requesting the first virtual address from the motherboard, the method further includes:
[0016] Request a second virtual address from the motherboard;
[0017] The second physical address corresponding to the second virtual address is determined based on the pre-configured physical page document;
[0018] Write the result of the test command execution to the second physical address.
[0019] Optionally, the test operation command is a read command, which includes the data storage address of the data to be read. Executing the test operation command through the control register to obtain the test command execution result includes:
[0020] The data stored at the data storage address is read through the control register.
[0021] Optionally, the solid-state drive is a non-volatile solid-state drive, and the method further includes:
[0022] Read the memory address of the Doorbell register stored in the target register;
[0023] Configure the memory address of the Doorbell register to prompt the control register to initiate the execution of the test operation command.
[0024] Optionally, the type is a non-volatile solid-state drive, and the step of writing the test operation command into the first physical address according to a preset protocol rule includes:
[0025] The test operation command is written to the first physical address in accordance with the non-volatile solid-state drive protocol rules.
[0026] Optionally, the type is a serial hard drive type, and writing the test operation command into the first physical address according to preset protocol rules includes:
[0027] The test operation command is written to the first physical address according to the serial hard disk protocol rules.
[0028] Secondly, embodiments of this application provide a testing device for a solid-state drive (SSD), wherein the SSD is connected to a motherboard, and the device includes:
[0029] The read module is used to read the memory address of the control register stored in the target register of the solid-state drive;
[0030] The processing module is used to request a first virtual address from the motherboard and write test operation commands for the solid-state drive into the first virtual address;
[0031] The determination module is used to determine the first physical address corresponding to the first virtual address based on the pre-configured physical page document, and write the test operation command into the first physical address according to the preset protocol rules;
[0032] A write module is used to write the first physical address to the memory address of the control register;
[0033] The execution module is used to execute the test operation command through the control register and obtain the test command execution result.
[0034] Thirdly, embodiments of this application provide an electronic device, including a memory and a processor, wherein the memory is used to store a computer program, and the computer program executes the solid-state drive testing method provided in the first aspect when the processor is running.
[0035] Fourthly, embodiments of this application provide a computer-readable storage medium storing a computer program that, when run on a processor, executes the solid-state drive testing method provided in the first aspect.
[0036] The solid-state drive (SSD) testing method provided in this application reads the memory address of the control register stored in the target register of the SSD; requests a first virtual address from the motherboard, and writes a test operation command for the SSD into the first virtual address; determines the first physical address corresponding to the first virtual address according to a pre-configured physical page document, and writes the test operation command into the first physical address according to a preset protocol rule; writes the first physical address into the memory address of the control register; and executes the test operation command through the control register to obtain the test command execution result. In this way, by avoiding the use of encapsulated ioctl functions, test operation commands can be sent from the Linux application layer to the SSD, improving the testing effect and reducing the testing cost of the SSD. Attached Figure Description
[0037] To more clearly illustrate the technical solutions of this application, the accompanying drawings used in the embodiments will be briefly described below. It should be understood that the following drawings only show some embodiments of this application and should not be considered as a limitation on the scope of protection of this application. In the various drawings, similar components are numbered similarly.
[0038] Figure 1 shows a flowchart of a testing method for a solid-state drive provided in an embodiment of this application;
[0039] Figure 2 shows another flowchart of the solid-state drive testing method provided in the embodiments of this application;
[0040] Figure 3 shows a schematic diagram of a solid-state drive testing device provided in an embodiment of this application. Detailed Implementation
[0041] The technical solutions of the present invention will be clearly and completely described below with reference to the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments.
[0042] The components of the embodiments of the invention described and illustrated herein can typically be arranged and designed in various different configurations. Therefore, the following detailed description of the embodiments of the invention provided in the accompanying drawings is not intended to limit the scope of the claimed invention, but merely to illustrate selected embodiments of the invention. All other embodiments obtained by those skilled in the art based on the embodiments of the invention without inventive effort are within the scope of protection of the invention.
[0043] In the following, the terms “comprising,” “having,” and their cognates, which may be used in various embodiments of the invention, are intended only to indicate a particular feature, number, step, operation, element, component, or combination thereof, and should not be construed as excluding, firstly, the presence of one or more other features, numbers, steps, operations, elements, components, or combinations thereof, or adding the possibility of one or more features, numbers, steps, operations, elements, components, or combinations thereof.
[0044] Furthermore, the terms "first," "second," and "third" are used only to distinguish descriptions and should not be interpreted as indicating or implying relative importance.
[0045] Unless otherwise specified, all terms used herein (including technical and scientific terms) shall have the same meaning as commonly understood by one of ordinary skill in the art to which the various embodiments of the invention pertain. Terms (such as those defined in commonly used dictionaries) shall be interpreted as having the same meaning as in their contextual meaning in the relevant technical field and shall not be interpreted as having an idealized or overly formal meaning, unless clearly defined in the various embodiments of the invention.
[0046] Example 1
[0047] This disclosure provides a testing method for solid-state drives.
[0048] In this embodiment, the solid-state drive (SSD) is connected to the motherboard. Please refer to Figure 1. The testing method for the SSD provided in this embodiment includes:
[0049] Step S101: Read the memory address of the control register stored in the target register of the solid-state drive.
[0050] In this embodiment, the solid-state drive (SSD) can be either a non-volatile memory express (NVME) SSD or a serial advanced technology attachment (SATA) SSD. The SSD's configuration space stores configuration information. After the SSD is connected to the motherboard, the configuration information in the configuration space can be read by traversing the data bus, device, and function using the `start_memmap` function. The configuration space has six bar registers, numbered 0-5: bar0, bar1, bar2, bar3, bar4, and bar5. For different types of SSDs, the bar0, bar1, bar2, bar3, bar4, and bar5 registers store the addresses of different control registers. For different types of SSDs, the memory addresses of the control registers stored in the bar0, bar1, bar2, bar3, bar4, and bar5 registers are different.
[0051] For example, in a non-volatile solid-state drive (SSD), the bar1 register stores the memory address of the control register, and the bar2 register stores the memory address of the head / tail Doorbell (DB) register. In a serial ATA (SATA) SSD, the bar5 register stores the memory address of the Host Bus Adapter (HBA) and the Port register.
[0052] The following is the main code for reading the configuration space:
[0053]
[0054]
[0055] In this embodiment, please refer to Figure 2. The testing method for solid-state drives provided in this embodiment of the present disclosure further includes:
[0056] Step S106: Read the configuration information of the configuration space of the solid-state drive;
[0057] Step S107: Determine the type of the solid-state drive based on the configuration information. The solid-state drive is either a non-volatile solid-state drive or a serial ATA hard drive.
[0058] Step S108: When the solid-state drive is a non-volatile solid-state drive, the bar1 register and bar2 register in the configuration space are determined as the target registers.
[0059] Step S109: When the solid-state drive is of type serial hard drive, the bar5 register in the configuration space is determined as the target register.
[0060] In this way, for different types of solid-state drives, the target register can be determined in the configuration space, thereby quickly obtaining the memory address of the control register stored in the target register and improving processing efficiency.
[0061] Step S102: Request a first virtual address from the motherboard and write test operation commands for the solid-state drive into the first virtual address.
[0062] In this embodiment, if the solid-state drive is a non-volatile solid-state drive type, the alloc_pages function is used to request the first virtual address and the second virtual address.
[0063] The following is the main code for applying for a virtual address:
[0064]
[0065]
[0066] Step S103: Determine the first physical address corresponding to the first virtual address according to the pre-configured physical page document, and write the test operation command into the first physical address according to the preset protocol rules.
[0067] In this embodiment, if the solid-state drive is a non-volatile solid-state drive type, the addr_virt2phy function is used to obtain the first physical address corresponding to the first virtual address and the second physical address corresponding to the second virtual address.
[0068] The following is the main code for finding the physical address corresponding to a virtual address:
[0069]
[0070]
[0071] In this embodiment, the type is a non-volatile solid-state drive, and the step of writing the test operation command into the first physical address according to a preset protocol rule includes:
[0072] The test operation command is written to the first physical address in accordance with the non-volatile solid-state drive protocol rules.
[0073] In this embodiment, if the test operation command is an I / O command, a segment of data memory needs to be requested, and the physical address of the requested data memory is filled into the data pointer in the request queue entry (SQ entry). If the test operation command is a write command, the data to be written to the solid-state drive needs to be written to this data memory.
[0074] In this embodiment, the type is a serial port hard drive, and writing the test operation command into the first physical address according to the preset protocol rules includes:
[0075] The test operation command is written to the first physical address according to the serial hard disk protocol rules.
[0076] Step S104: Write the first physical address into the memory address of the control register.
[0077] In this embodiment, if the solid-state drive is a non-volatile solid-state drive type, the first physical address is written to the ASQ control register, and the second physical address is written to the ACQ control register.
[0078] In this embodiment, if the solid-state drive is a serial ATA (SATA) hard drive, the first physical address is written into the PxCLB and PxCLBU registers in the Port register. The PxCLB and PxCLBU registers are used to store the cmd list. Each cmd header in the cmd list is filled, and the cmd header includes the cmd table address. The H2Dfis and IO data addresses are filled into the cmd table address, and the data to be written is placed therein. The second physical address is written into the PxFB and PxFBU registers in the Port register. The PxFB and PxFBU registers are used to store the recv fis.
[0079] Step S105: Execute the test operation command through the control register to obtain the test command execution result.
[0080] In this embodiment, if the solid-state drive is a non-volatile solid-state drive type, the test operation command is executed through the ASQ control register.
[0081] In this embodiment, if the solid-state drive is a serial port hard drive, test operation commands are sent by manipulating the PxCMD register, PxCI register, and PxCSACT register in the Port register.
[0082] In this embodiment, the test operation command is a read command, which includes the data storage address of the data to be read. Step S105 may include:
[0083] The data stored at the data storage address is read through the control register.
[0084] In this embodiment, if the solid-state drive is a non-volatile solid-state drive type, the data read from the IO is obtained by obtaining the IO data address filled in the SQ entry.
[0085] In this embodiment, if the solid-state drive is a serial port hard drive, the data read from the IO is obtained by obtaining the IO data address filled in the cmd header.
[0086] The following is the main code for reading data from the physical address:
[0087]
[0088]
[0089] In this embodiment, the solid-state drive is a non-volatile solid-state drive, and the method further includes:
[0090] Read the memory address of the Doorbell register stored in the target register;
[0091] Configure the memory address of the Doorbell register to prompt the control register to initiate the execution of the test operation command.
[0092] In this embodiment, for non-volatile solid-state drives (SSDs), configuring the memory address of the Doorbell register can prompt the ASQ control register to initiate the execution of the test operation command stored at the first physical address. For example, setting the memory address of the Doorbell register to 1 can prompt the ASQ control register to initiate the execution of the test operation command stored at the first physical address.
[0093] In this embodiment, after step S102, the testing method for the solid-state drive further includes:
[0094] Request a second virtual address from the motherboard;
[0095] The second physical address corresponding to the second virtual address is determined based on the pre-configured physical page document;
[0096] Write the result of the test command execution to the second physical address.
[0097] In this embodiment, if the solid-state drive is a non-volatile solid-state drive type, the second physical address is written to the ACQ control register. By reading the ACQ control register, the test command execution result obtained after the test operation command in the first physical address is executed can be obtained.
[0098] In this embodiment, if the solid-state drive is a serial hard drive type, the test command execution result is written into recv fis. By reading the data in recv fis and combining it with the PxIS register and PxSERR register, the overall execution result of the test operation command is comprehensively judged.
[0099] The solid-state drive (SSD) testing method provided in this application reads the memory address of the control register stored in the target register of the SSD; requests a first virtual address from the motherboard, and writes a test operation command for the SSD into the first virtual address; determines the first physical address corresponding to the first virtual address according to a pre-configured physical page document, and writes the test operation command into the first physical address according to a preset protocol rule; writes the first physical address into the memory address of the control register; and executes the test operation command through the control register to obtain the test command execution result. In this way, by avoiding the use of encapsulated ioctl functions, test operation commands can be sent from the Linux application layer to the SSD, improving the testing effect and reducing the testing cost of the SSD.
[0100] Example 2
[0101] This disclosure provides a testing apparatus for solid-state drives.
[0102] Specifically, please refer to Figure 3. The solid-state drive (SSD) testing device 300 provided in this embodiment of the present disclosure is connected to the motherboard. The SSD testing device 300 includes:
[0103] The reading module 301 is used to read the memory address of the control register stored in the target register of the solid-state drive;
[0104] The processing module 302 is used to request a first virtual address from the motherboard and write test operation commands for the solid-state drive into the first virtual address;
[0105] The determination module 303 is used to determine the first physical address corresponding to the first virtual address according to the pre-configured physical page document, and write the test operation command into the first physical address according to the preset protocol rules;
[0106] The write module 304 is used to write the first physical address to the memory address of the control register;
[0107] The execution module 305 is used to execute the test operation command through the control register and obtain the test command execution result.
[0108] In this embodiment, the reading module 301 is also used to read the configuration information of the configuration space of the solid-state drive;
[0109] The type of the solid-state drive is determined based on the configuration information, and the solid-state drive is either a non-volatile solid-state drive or a serial ATA hard drive.
[0110] When the solid-state drive is a non-volatile solid-state drive, the bar1 register and bar2 register in the configuration space are determined as the target registers;
[0111] When the solid-state drive is of type serial ATA hard drive, the bar5 register in the configuration space is determined as the target register.
[0112] In this embodiment, the processing module 302 is further configured to request a second virtual address from the motherboard;
[0113] The second physical address corresponding to the second virtual address is determined based on the pre-configured physical page document;
[0114] Write the result of the test command execution to the second physical address.
[0115] In this embodiment, the test operation command is a read command, which includes the data storage address of the data to be read. The execution module 305 is also used to read the data stored in the data storage address through the control register.
[0116] In this embodiment, the solid-state drive is a non-volatile solid-state drive, and the solid-state drive testing device 300 further includes:
[0117] The configuration module is used to read the memory address of the Doorbell register stored in the target register;
[0118] Configure the memory address of the Doorbell register to prompt the control register to initiate the execution of the test operation command.
[0119] In this embodiment, the type is a non-volatile solid-state drive (SSD). The determining module 303 is further configured to write the test operation command to the first physical address according to the non-volatile SSD protocol rules.
[0120] In this embodiment, the type is a serial hard disk type. The determining module 303 is also used to write the test operation command to the first physical address according to the serial hard disk protocol rules.
[0121] The solid-state drive (SSD) testing apparatus provided in this application reads the memory address of the control register stored in the target register of the SSD; requests a first virtual address from the motherboard, and writes test operation commands for the SSD into the first virtual address; determines the first physical address corresponding to the first virtual address according to a pre-configured physical page document, and writes the test operation commands into the first physical address according to a preset protocol rule; writes the first physical address into the memory address of the control register; and executes the test operation commands through the control register to obtain the test command execution result. In this way, by avoiding the use of encapsulated ioctl functions, test operation commands can be sent from the Linux application layer to the SSD, improving the testing effect of the SSD and reducing the testing cost.
[0122] Example 3
[0123] Furthermore, this disclosure provides an electronic device, including a memory and a processor, wherein the memory stores a computer program, and the computer program executes the solid-state drive testing method provided in Embodiment 1 above when running on the processor.
[0124] It should be understood that the electronic device provided in this embodiment can implement the solid-state drive testing method provided in Embodiment 1. For relevant descriptions, please refer to the content of Embodiment 1. To avoid repetition, it will not be repeated here.
[0125] Example 4
[0126] Furthermore, this disclosure provides a computer-readable storage medium, including a memory and a processor, wherein the memory stores a computer program, and the computer program executes the solid-state drive testing method provided in Embodiment 1 above when it is run on the processor.
[0127] It should be understood that the computer-readable storage medium provided in this embodiment can implement the test method of the solid-state drive provided in Embodiment 1. For relevant descriptions, please refer to the content of Embodiment 1. To avoid repetition, it will not be repeated here.
[0128] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can also be implemented in other ways. The apparatus embodiments described above are merely illustrative; for example, the flowcharts and block diagrams in the accompanying drawings illustrate the architecture, functionality, and operation of possible implementations of apparatus, methods, and computer program products according to various embodiments of the present invention. In this regard, each block in a flowchart or block diagram may represent a module, segment, or portion of code containing one or more executable instructions for implementing a specified logical function. It should also be noted that, as an alternative implementation, the functions marked in the blocks may occur in a different order than those marked in the drawings. For example, two consecutive blocks may actually be executed substantially in parallel, and they may sometimes be executed in reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented using a dedicated hardware-based system that performs the specified function or action, or using a combination of dedicated hardware and computer instructions.
[0129] In addition, the functional modules or units in the various embodiments of the present invention can be integrated together to form an independent part, or each module can exist independently, or two or more modules can be integrated to form an independent part.
[0130] If the aforementioned functions are implemented as software functional modules and sold or used as independent products, they can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of this invention, or the part that contributes to the prior art, or a portion of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a smartphone, personal computer, server, or network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this invention. The aforementioned computer-readable storage medium includes various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0131] The above description is merely a specific embodiment of the present invention, but the scope of protection of the present invention is not limited thereto. Any changes or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in the present invention should be included within the scope of protection of the present invention.
Claims
1. A testing method for a solid-state drive, characterized in that, The method for connecting a solid-state drive (SSD) to a motherboard includes: reading the memory address of a control register stored in the target register of the SSD; requesting a first virtual address from the motherboard and writing a test operation command for the SSD into the first virtual address; determining a first physical address corresponding to the first virtual address according to a pre-configured physical page document and writing the test operation command into the first physical address according to a preset protocol rule; writing the first physical address into the memory address of the control register; and executing the test operation command through the control register to obtain the test command execution result.
2. The method according to claim 1, characterized in that, Before reading the memory address of the control register stored in the target register of the solid-state drive, the method further includes: reading the configuration information of the configuration space of the solid-state drive; determining the type of the solid-state drive based on the configuration information, wherein the solid-state drive type is a non-volatile solid-state drive or a serial ATA hard drive; when the solid-state drive type is a non-volatile solid-state drive, determining the bar1 register and bar2 register in the configuration space as the target register; when the solid-state drive type is a serial ATA hard drive, determining the bar5 register in the configuration space as the target register.
3. The method according to claim 1, characterized in that, After requesting a first virtual address from the motherboard, the method further includes: requesting a second virtual address from the motherboard; determining a second physical address corresponding to the second virtual address based on the pre-configured physical page document; and writing the test command execution result into the second physical address.
4. The method according to claim 1, characterized in that, The test operation command is a read command, which includes the data storage address of the data to be read. Executing the test operation command through the control register to obtain the test command execution result includes: reading the data stored in the data storage address through the control register.
5. The method according to claim 2, characterized in that, The solid-state drive is a non-volatile solid-state drive. The method further includes: reading the memory address of the Doorbell register stored in the target register; configuring the memory address of the Doorbell register to prompt the control register to start executing the test operation command.
6. The method according to claim 2, characterized in that, The type is a non-volatile solid-state drive, and the step of writing the test operation command into the first physical address according to the preset protocol rules includes: writing the test operation command into the first physical address according to the non-volatile solid-state drive protocol rules.
7. The method according to claim 2, characterized in that, The type is a serial hard drive, and writing the test operation command into the first physical address according to the preset protocol rules includes: writing the test operation command into the first physical address according to the serial hard drive protocol rules.
8. A testing device for solid-state drives, characterized in that, The solid-state drive (SSD) is connected to the motherboard. The device includes: a reading module for reading the memory address of the control register stored in the target register of the SSD; a processing module for requesting a first virtual address from the motherboard and writing a test operation command for the SSD into the first virtual address; a determining module for determining a first physical address corresponding to the first virtual address based on a pre-configured physical page document and writing the test operation command into the first physical address according to a preset protocol rule; a writing module for writing the first physical address into the memory address of the control register; and an execution module for executing the test operation command through the control register to obtain the test command execution result.
9. An electronic device, characterized in that, The device includes a memory and a processor, wherein the memory stores a computer program that executes the test method for the solid-state drive according to any one of claims 1 to 7 when the processor is running.
10. A computer-readable storage medium, characterized in that, It stores a computer program that, when run on a processor, executes the test method of the solid-state drive according to any one of claims 1 to 7.
Citation Information
Patent Citations
Offline debugging method and device for semiconductor memory aging test
CN112527690A
Dedicated testability design path for memory subsystem controller
CN113326216A