Hot plug control method and device of PCIE (Peripheral Component Interface Express) equipment, PCIE controller and storage medium
By simulating the PRSNT pin through GPIO pins and combining it with the management and link status of the PCIe controller, the hot-plugging interruption problem caused by PRSNT pin damage or lack of design was solved, and safe plugging and unplugging management of PCIe devices was realized.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-08
- Publication Date
- 2026-04-03
AI Technical Summary
Existing PCIe hot-plugging solutions rely on PRSNT pin detection. If the chip is damaged or the PRSNT pin is not designed, the hot-plugging interrupt cannot be triggered, making safe plugging and unplugging impossible.
By simulating the PRSNT pin through GPIO pins and combining the management status and link status of the PCIe controller, the interrupt trigger condition is determined, and hot-plug commands are sent to the user to realize the hot-plug management of PCIe devices.
In the event that the PRSNT pin is damaged or not designed, the PRSNT pin is simulated by GPIO pins, enabling hot-swapping of PCIe devices and ensuring normal system operation.
Smart Images

Figure CN121785972A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of computer technology, and more specifically, to a method, apparatus, PCIe controller, and storage medium for hot-plugging control of PCIe devices. Background Technology
[0002] Hot-swapping, also known as live plugging or unplugging, refers to the process of inserting or removing Peripheral Component Interconnect Express (PCIe) devices from a computing device without turning off the power, thus ensuring the normal operation of the computer system. Because hot-swapping technology improves the ease of maintenance of computing devices, it is widely used in the computer industry.
[0003] The existing general solution for PCIe hot-plugging uses dedicated sideband signals (PRSNT1# and PRSNT2#) to detect the insertion or removal status of the device, and combines hardware registers with software to achieve safe insertion and removal.
[0004] However, when the PRSNT pin of the chip is damaged or the chip is not designed with a PRSNT pin, the hot-plug interrupt cannot be triggered. Summary of the Invention
[0005] The purpose of this application is to address the shortcomings of the prior art by providing a method, apparatus, PCIe controller, and storage medium for hot-plugging control of PCIe devices, so as to simulate PCIe hot-plugging interruption through input / output ports and realize hot-plugging of PCIe devices.
[0006] To achieve the above objectives, the technical solutions adopted in the embodiments of this application are as follows: In a first aspect, embodiments of this application provide a hot-plug control method for a PCIe device, applied to a PCIe controller, the method comprising: Determine whether the input / output pins meet the interrupt trigger conditions; If the input / output pins meet the interrupt triggering condition, a hot-plug command is sent to the user according to the management status and link status of the PCIe controller, so that the user can hot-plug the PCIe device according to the hot-plug command. After the user completes the hot-plug operation, the PCIe device and slot are managed for hot-plugging.
[0007] In one possible implementation, determining whether the input / output pins meet the interrupt triggering conditions includes: Obtain the preset interrupt trigger conditions of the input / output pins, as well as the interrupt trigger information input by the user; Based on the interrupt trigger information, determine whether the input / output pin currently meets the interrupt trigger condition.
[0008] In one possible implementation, if the input / output pins meet the interrupt triggering condition, a hot-plug command is sent to the user based on the management state and link state of the PCIe controller, including: Obtain the PCIe slot information and the interrupt number of the input / output pin; If the input / output pins meet the interrupt triggering condition, the interrupt handling function is called and executed according to the interrupt number; Based on the PCIe slot information, obtain the management status and link status of the PCIe controller; Based on the management status and link status of the PCIe controller, hot-plug commands are sent to the user.
[0009] In one possible implementation, sending a hot-plug command to the user based on the management state and link state of the PCIe controller includes: If the management state of the PCIe controller is off and the link state is idle, a hot-plug card command is sent to the user so that the user can insert the PCIe device.
[0010] In one possible implementation, the hot-plug management of the PCIe device and slot after the user completes the hot-plug operation includes: After the user completes the hot-plug card operation, it is determined whether the link status of the PCIe controller is a stable link status; If the link status of the PCIe controller is stable, allocate resources to the PCIe device, load the driver, and create a device node.
[0011] In one possible implementation, sending a hot-plug command to the user based on the management state and link state of the PCIe controller includes: If the PCIe controller is in an enabled state and the link is in a stable connection state, a hot-swap command is sent to the user so that the user can unplug the PCIe device.
[0012] In one possible implementation, if the input / output pins satisfy the interrupt triggering condition, the method further includes: Obtain and save the space configuration information of the PCIe controller; The hot-plug management of the PCIe device and slot after the user completes the hot-plug operation includes: After the user completes the hot-swap card operation, the space configuration information of the PCIe controller is rewritten, and the driver and device node of the PCIe device are uninstalled.
[0013] In one possible implementation, after the user completes the hot-swap card operation, the method further includes: Set the management status of the PCIe controller to the off state.
[0014] Secondly, embodiments of this application also provide a hot-plug control device for a PCIe device, applied to a PCIe controller, the device comprising: The interrupt triggering judgment module is used to determine whether the input / output pins meet the interrupt triggering conditions; A hot-swap instruction sending module is used to send a hot-swap instruction to the user based on the management status and link status of the PCIe controller if the input / output pins meet the interrupt triggering conditions, so that the user can hot-swap the PCIe device according to the hot-swap instruction; The hot-swap management module is used to manage the hot-swap of the PCIe device and slot after the user completes the hot-swap operation.
[0015] In one possible implementation, the interrupt triggering judgment module is specifically used to obtain the preset interrupt triggering conditions of the input / output pin and the interrupt triggering information input by the user; and to determine whether the input / output pin currently meets the interrupt triggering conditions based on the interrupt triggering information.
[0016] In one possible implementation, the hot-swap card instruction sending module is specifically used to obtain PCIe slot information and the interrupt number of the input / output pin; if the input / output pin meets the interrupt triggering condition, the interrupt handling function is called and executed according to the interrupt number; the management status and link status of the PCIe controller are obtained according to the PCIe slot information; and the hot-swap instruction is sent to the user according to the management status and link status of the PCIe controller.
[0017] In one possible implementation, the hot-swap card instruction sending module is specifically used to send a hot-swap card instruction to the user if the management state of the PCIe controller is off and the link state is idle, so that the user can insert the PCIe device.
[0018] In one possible implementation, the hot-swap management module is specifically used to determine whether the link status of the PCIe controller is a stable link state after the user completes the hot-swap card operation; if the link status of the PCIe controller is a stable link state, it allocates resources to the PCIe device, loads the driver, and creates a device node.
[0019] In one possible implementation, the hot-swap management module is specifically used to send a hot-swap card command to the user if the management state of the PCIe controller is enabled and the link state is a stable connection state, so that the user can unplug the PCIe device.
[0020] In one possible implementation, if the input / output pins satisfy the interrupt triggering condition, the device further includes: The information acquisition module is used to acquire and save the space configuration information of the PCIe controller; The hot-swap management module is specifically used to rewrite the space configuration information of the PCIe controller and uninstall the driver and device node of the PCIe device after the user completes the hot-swap card operation.
[0021] In one possible implementation, after the user completes the hot-swap card operation, the hot-swap management module is further configured to set the management status of the PCIe controller to the off state.
[0022] Thirdly, embodiments of this application also provide a PCIe controller, including: a processor, a storage medium and a bus, wherein the storage medium stores program instructions executable by the processor, and when the PCIe controller is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of the hot-plug control method for the PCIe device as described in any of the first aspects.
[0023] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, which, when executed by a processor, performs the steps of the hot-plug control method for a PCIe device as described in any of the first aspects.
[0024] The beneficial effects of this application are: The hot-swap card control method, device, PCIe controller, and storage medium provided in this application, when the input / output pins meet the interrupt triggering conditions, instruct the user to hot-swap the PCIe device according to the management state and link state of the PCIe controller. After the hot-swap is completed, hot-swap management is performed. When the PRSNT pin is unusable or not designed, or when the bit corresponding to the slot status register cannot be triggered to be set due to the change of pin level, the hot-swap of the PCIe device can also be simulated through GPIO pins. Attached Figure Description
[0025] To more clearly illustrate the technical solutions of the embodiments of this application, the accompanying drawings used in the embodiments will be briefly introduced below. It should be understood that the following drawings only show some embodiments of this application and should not be regarded as a limitation of the scope. For those skilled in the art, other related drawings can be obtained based on these drawings without creative effort.
[0026] Figure 1 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 1 ; Figure 2 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 2 ; Figure 3 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 3 ; Figure 4 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 4 ; Figure 5 A flowchart illustrating the hot-plug control process for a PCIe device provided in an embodiment of this application; Figure 6 A schematic diagram of the structure of the hot-plug control device for a PCIe device provided in an embodiment of this application; Figure 7 This is a schematic diagram of a PCIe controller provided in an embodiment of this application. Detailed Implementation
[0027] To make the objectives, technical solutions, and advantages of the embodiments of this application clearer, the technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are some embodiments of this application, but not all embodiments.
[0028] Therefore, the following detailed description of the embodiments of this application provided in the accompanying drawings is not intended to limit the scope of the claimed application, but merely to illustrate selected embodiments of the application. All other embodiments obtained by those skilled in the art based on the embodiments of this application without inventive effort are within the scope of protection of this application.
[0029] Furthermore, the terms "first," "second," etc., used in the specification, claims, and accompanying drawings of this application are used to distinguish similar objects and are not necessarily used to describe a specific order or sequence. It should be understood that such data can be interchanged where appropriate so that the embodiments of this application described herein can be implemented in orders other than those illustrated or described herein. Additionally, the terms "comprising" and "having," and any variations thereof, are intended to cover a non-exclusive inclusion; for example, a process, method, system, product, or apparatus that comprises a series of steps or units is not necessarily limited to those steps or units explicitly listed, but may include other steps or units not explicitly listed or inherent to such processes, methods, products, or apparatus.
[0030] It should be noted that, where there is no conflict, the features in the embodiments of this application can be combined with each other.
[0031] The existing common PCIe hot-swapping scheme detects device insertion or removal status using dedicated sideband signals (PRSNT1# and PRSNT2#). Specifically, PRSNT1# of the PCIe slot is grounded, and PRSNT2# is pulled up to a high level. When no device is inserted into the PCIe slot, PRSNT1# is grounded (low), and PRSNT2# is pulled up (high). PRSNT1# and PRSNT2# have different levels. When a PCIe device is inserted into the PCIe slot, PRSNT1# and PRSNT2# are short-circuited, causing PRSNT2# to be pulled low. When the PCIe device is removed from the PCIe slot, PRSNT2# returns to a high level. Thus, the PCIe controller, by detecting the level change of the PRSNT pin, triggers an interrupt signal to the Central Processing Unit (CPU) and controls the corresponding bit in the Slot Control / Status Register to be set. Upon receiving the interrupt signal, the CPU, based on the Slot Control / Status Register... The set state of the Register determines whether a device is inserted or removed. For a device insertion event, the PCIe device is powered on and configured. For a device removal event, the PCIe slot is powered off and the PCIe device is physically removed.
[0032] However, hot-plugging cannot be achieved if the PRSNT pin of the chip is damaged, the chip is not designed with a PRSNT pin, or the corresponding bit in the Slot Control / Status Register cannot be set due to a change in status.
[0033] Based on the problems existing in the prior art, this application proposes to provide a hot-plug control method, device, PCIe controller, and storage medium for PCIe devices. When the input / output pins meet the interrupt triggering conditions, the user is instructed to hot-plug the PCIe device according to the management status and link status of the PCIe controller. After the hot-plug is completed, hot-plug management is performed. When the PRSNT pin is unusable or not designed, or when the bit corresponding to the slot status register cannot be triggered to be set due to the change of pin level, the hot-plug of the PCIe device can also be simulated through GPIO pins.
[0034] The hot-plug control method for PCIe devices provided in this application is applied to a PCIe controller. The PCIe controller can communicate with the host, the central processing unit, and the PCIe devices. The specific implementation of the hot-plug control method for PCIe devices is described below with reference to embodiments.
[0035] Figure 1 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 1 ,like Figure 1 As shown, the method may include: S101. Determine whether the input / output pins meet the interrupt triggering conditions.
[0036] In this embodiment, the General Purpose Input / Output (GPIO) pin can be a general-purpose signal pin connected to the host CPU. The interrupt triggering condition of the GPIO pin can be determined based on its signal state. The interrupt triggering of the GPIO pin is initiated by the user through a preset control. This preset control can be a PCIe device hot-plug / hot-plug control on a web interface or a preset management tool. Clicking the preset control triggers the GPIO pin interrupt.
[0037] S102. If the input / output pins meet the interrupt triggering conditions, a hot-plug command is sent to the user according to the management status and link status of the PCIe controller, so that the user can hot-plug the PCIe device according to the hot-plug command.
[0038] In this embodiment, if the signal status of the GPIO pin indicates that the GPIO pin meets the interrupt triggering condition, the interrupt handling function is called, the interrupt handling function is executed, and the interrupt handling process is entered.
[0039] Upon entering the interrupt handling process, the management status and link status of the PCIe controller are obtained. The management status of the PCIe controller is used to indicate the management status of the PCIe slot by the PCIe controller, indicating whether a PCIe device is inserted into the PCIe slot. The link status of the PCIe controller is used to indicate the communication status of the physical link between the PCIe controller and the PCIe slot.
[0040] Based on the management and link status of the PCIe controller, it can be determined whether a PCIe device is inserted into the PCIe slot. Therefore, based on whether a PCIe device is inserted into the PCIe slot, the hot-plug command to be sent to the user can be determined.
[0041] Specifically, if a PCIe device is inserted into the PCIe slot, a hot-swap card command can be sent to the user. After receiving the hot-swap card command, the user can remove the PCIe device from the PCIe slot. If no PCIe device is inserted into the PCIe slot, a hot-swap card command can be sent to the user. After receiving the hot-swap card command, the user can insert the PCIe device into the PCIe slot.
[0042] It should be noted that although the management status of the PCIe controller itself indicates whether a PCIe device is inserted into the PCIe slot, determining whether a PCIe device is inserted into the PCIe slot by combining the management status of the PCIe controller and the link status is more accurate than determining whether a PCIe device is inserted into the PCIe slot solely by the management status of the PCIe controller.
[0043] S103. After the user completes the hot-plug operation, hot-plug management is performed on the PCIe device and slot.
[0044] In this embodiment, after the user completes the hot-plugging operation of the PCIe device, it is necessary to manage the hot-plugging of the PCIe device and the slot. Specifically, if the user inserts the PCIe device into the PCIe slot, the PCIe slot can be powered on and reset, the PCIe link speed, bandwidth and other resources can be configured for the PCIe device, the PCIe devices can be enumerated, the type of the PCIe device can be determined, and the device driver can be loaded for the PCIe device according to the type of the PCIe device, so that the PCIe device is ready for use.
[0045] If a user removes a PCIe device from its PCIe slot, they can uninstall the device driver and disconnect the power to the PCIe slot.
[0046] The hot-plug control method for PCIe devices provided in the above embodiments, when the input / output pins meet the interrupt triggering conditions, instructs the user to hot-plug the PCIe device according to the management status and link status of the PCIe controller. After hot-plugging is completed, hot-plug management is performed. In the case where the PRSNT pin is unusable or not designed, or when the bit corresponding to the slot status register cannot be triggered to be set due to the change of pin level, the hot-plugging of the PCIe device can also be realized through GPIO pin simulation.
[0047] In one possible implementation, Figure 2 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 2 ,like Figure 2 As shown, the process of S101 determining whether the input / output pins meet the interrupt triggering conditions may include: S201. Obtain the preset interrupt trigger conditions of the input / output pins and the interrupt trigger information input by the user.
[0048] S202. Based on the interrupt trigger information, determine whether the input / output pins currently meet the interrupt trigger conditions.
[0049] In this embodiment, interrupt triggering conditions for GPIO pins are pre-configured. The interrupt triggering condition can be a signal identifier for interrupt triggering. After obtaining the interrupt triggering conditions of the GPIO pin and the interrupt triggering information input by the user, it is determined whether the interrupt triggering information is consistent with the signal identifier in the interrupt triggering conditions. If the interrupt triggering information is consistent with the signal identifier in the interrupt triggering conditions, it is determined that the GPIO pin meets the interrupt triggering conditions. If the interrupt triggering information is inconsistent with the signal identifier in the interrupt triggering conditions, it is determined that the GPIO pin does not meet the interrupt triggering conditions.
[0050] The hot-plug control method for PCIe devices provided in the above embodiments determines whether the GPIO pin meets the interrupt triggering condition based on the interrupt triggering condition of the GPIO pin. Even when the PRSNT pin cannot be used or the PRSNT pin is not designed, interrupt triggering can still be performed, thereby realizing the hot-plugging of PCIe devices.
[0051] In one possible implementation, Figure 3 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 3 ,like Figure 3 As shown, the process of sending a hot-plug command to the user in S102, if the input / output pins meet the interrupt triggering conditions, based on the management state and link state of the PCIe controller, may include: S301, Obtain PCIe slot information and interrupt numbers for input / output pins.
[0052] S302. If the input / output pins meet the interrupt triggering conditions, the interrupt handling function is called and executed according to the interrupt number.
[0053] S303. Based on the PCIe slot information, obtain the management status and link status of the PCIe controller.
[0054] S304. Based on the management status and link status of the PCIe controller, send hot-plug commands to the user.
[0055] In this embodiment, the host can have multiple slots, and the PCIe controller can manage multiple slots. Among the multiple slots, there may be PCIe slots for plugging and unplugging PCIe devices. The PCIe slot information may include the slot identifier of the PCIe slot. The host's running program includes various types of interrupt handling functions for various scenarios. Each interrupt handling function has a corresponding call identifier. In order to call the interrupt handling function for hot-plugging PCIe devices, interrupt numbers are pre-set for GPIO pins.
[0056] By parsing the device tree, the PCIe slot information, GPIO pin interrupt number, and interrupt trigger condition can be obtained. After receiving the interrupt trigger information input by the user, it is determined whether the interrupt trigger information meets the interrupt trigger condition. If the interrupt trigger condition is met, the interrupt handling function for hot-plugging PCIe devices can be obtained based on the GPIO pin interrupt number.
[0057] The interrupt handler for hot-plugging PCIe devices is executed. Based on the slot identifier of the PCIe slot, the management status and link status of the PCIe controller for the PCIe slot corresponding to the slot identifier are obtained. Based on the management status and link status of the PCIe controller, it can be determined whether a PCIe device is inserted into the PCIe slot. Therefore, based on whether a PCIe device is inserted into the PCIe slot, the hot-plug command to be sent to the user can be determined.
[0058] The hot-plug control method for PCIe devices provided in the above embodiments instructs the user to hot-plug the PCIe device according to the management status and link status of the PCIe controller. After the hot-plug is completed, hot-plug management is performed. Hot-plugging of PCIe devices can also be achieved when the PRSNT pin is unusable or not designed.
[0059] In one possible implementation, the process of S304 sending a hot-plug command to the user based on the management state and link state of the PCIe controller may include: If the PCIe controller's management status is off and the link status is idle, a hot-plug card command is sent to the user so that the user can insert a PCIe device.
[0060] In this embodiment, the management status ctrl-status of the PCIe controller includes an ON_STATUS state and an OFF_STATUS state. The ON_STATUS state indicates that a PCIe device is inserted into the PCIe slot, and the OFF_STATUS state indicates that no PCIe device is inserted into the PCIe slot. The link status of the PCIe device includes an Idle state detect and a Stable Link state L0. The Idle state indicates that no physical link has been established between the PCIe controller and the PCIe slot, and the Stable Link state indicates that a stable physical link has been established between the PCIe controller and the PCIe slot.
[0061] If the PCIe controller's management status is off and the link status is idle, and it is determined that no PCIe device is inserted into the PCIe slot, a hot-swap card command can be sent to the user so that the user can insert a PCIe device into the PCIe slot.
[0062] In some embodiments, the link state between the PCIe controller and the PCIe device can be determined based on the Link Training and Status State Machine (LTSSM).
[0063] Furthermore, Figure 4 A flowchart illustrating the hot-plug control method for PCIe devices provided in this application embodiment. Figure 4 ,like Figure 4 As shown, the process of managing the hot-swapping of PCIe devices and slots after the user completes the hot-swapping operation in S103 may include: S401. After the user completes the hot-plug card operation, determine whether the link status of the PCIe controller is a stable link status.
[0064] S402. If the link status of the PCIe controller is stable, allocate resources to the PCIe device, load the driver, and create the device node.
[0065] In this embodiment, after the user inserts a PCIe device into the PCIe slot, the PCIe controller detects the link status of the physical link between itself and the PCIe device. Once the link status indicates a stable physical link between the PCIe controller and the PCIe device, the PCIe slot can be powered on and reset. The controller then configures the PCIe link's speed, bandwidth, and other resources for the PCIe device, enumerates the PCIe devices, determines their type, loads the device driver for each device based on its type, and creates a device node for the PCIe device, allowing access or calls to the device. After this, the PCIe device is ready for use.
[0066] In some embodiments, if the link status is unstable or abnormal, it is necessary to wait for the physical link status to stabilize. After the link status is stable, resources are allocated to the PCIe device, the driver is loaded, and the device node is created.
[0067] The hot-plug control method for PCIe devices provided in the above embodiments sends a hot-plug card command to the user when the management state of the PCIe controller is off and the link state is idle, so that the user can insert the PCIe device and realize the hot-plugging of the PCIe device.
[0068] In one possible implementation, the process of S304 sending a hot-plug command to the user based on the management state and link state of the PCIe controller may include: If the PCIe device is in an enabled management state and the link is in a stable connection state, a hot-swap command is sent to the user so that the user can remove the PCIe device.
[0069] In this embodiment, if the management status of the PCIe device is enabled and the link status is stable, it is determined that a PCIe device is inserted into the PCIe slot. At this time, a hot-swap card command can be sent to the user so that the user can remove the PCIe device from the PCIe slot.
[0070] Furthermore, if the input / output pins meet the interrupt triggering conditions, the method may also include: Get and save the space configuration information of the PCIe controller; The process of managing the hot-swapping of PCIe devices and slots after the user completes the hot-swapping operation, as described in S103 above, may include: After the user completes the hot-swap operation, the space configuration information of the PCIe controller is rewritten, and the PCIe device driver and device node are uninstalled.
[0071] In this embodiment, before executing the interrupt handling function to determine the management status and link status of the PCIe controller, the space configuration information of the PCIe controller can be obtained and saved first.
[0072] The PCIe controller itself is also a PCIe device with a configuration space. This configuration space is a standardized memory area of the PCIe controller, which stores key information about the PCIe controller, such as the PCIe controller's identifier, managed address range, link status, power status, etc. Before the PCIe device is hot-plugged, the driver will read all the key information in the PCIe controller's space configuration information through the PCIe configuration read / write cycle and save it in the secure memory allocated by the driver.
[0073] After a PCIe device is removed from a PCIe slot, the PCIe link may cause errors. To avoid failures when inserting a PCIe device the next time, the saved configuration information can be rewritten back into the PCIe controller's configuration space after the PCIe device is removed from the PCIe slot.
[0074] In addition to rewriting the space configuration information, it is also necessary to power off the PCIe slot, uninstall the PCIe device driver to prevent other applications or programs from accessing the PCIe device, and uninstall the PCIe device device node so that other applications or programs can no longer access or call the PCIe device through the device node.
[0075] Furthermore, after the user completes the hot-swap card operation, the method may also include: Set the management status of the PCIe controller to the off state.
[0076] In this embodiment, to ensure that the PCIe device can be hot-swapping normally next time, after the PCIe device is removed, the management state of the PCIe controller can be set to OFF_STATUS. This way, after the next interrupt is triggered, the hot-swapping card command can be issued to the user based on the PCIe controller's management state being OFF and the link state being Idle.
[0077] The hot-plug control method for PCIe devices provided in the above embodiments sends a hot-plug card command to the user when the management state of the PCIe controller is enabled and the link state is stable, so that the user can remove the PCIe device and realize the hot-plugging of the PCIe device.
[0078] Example, Figure 5 A flowchart illustrating the hot-plug control process for a PCIe device provided in this application embodiment is shown below. Figure 5As shown, the hot-plug control process for PCIe devices may include: S501: Parse the device tree, obtain the GPIO interrupt number and PCIE slot information, and initialize the PCIE controller.
[0079] S502. Determine whether the GPIO pin meets the interrupt trigger condition. If yes, jump to S503.
[0080] S503, Execute the interrupt handling function.
[0081] S504. Save the space configuration information of the PCIe controller.
[0082] S505. Determine the management status of the PCIe controller. If the management status is OFF_STATUS, proceed to S506. If the management status is ON_STATUS, proceed to S510.
[0083] S506. Determine the connection status of the PCIe controller. If the connection status is "detect" (unloaded), then jump to S507.
[0084] S507 sends a hot-swap card command to the user, enabling the user to insert a PCIe device card.
[0085] S508. Determine the connection status of the PCIe controller. If the connection status is stable connection status L0, then jump to S509.
[0086] S509: Allocate resources for PCIe devices, load drivers, and create device nodes.
[0087] S510. Determine the connection status of the PCIe controller. If the connection status is stable connection status L0, then jump to S511.
[0088] S511: Send a hot-swap command to the user so that the user can remove the PCIe device card.
[0089] S512, Write back the space configuration information of the PCIe controller.
[0090] S513, Uninstall the PCIe device driver and device node.
[0091] S514. Set the management status of the PCIe controller to the off state.
[0092] Based on the above method embodiments, this application also provides a hot-swap control device for PCIe devices, applied to a PCIe controller. Figure 6 This is a schematic diagram of the structure of the hot-plug control device for a PCIe device provided in an embodiment of this application, as shown below. Figure 6As shown, the device may include: The interrupt trigger judgment module 601 is used to determine whether the input / output pins meet the interrupt trigger conditions. The hot-swap card instruction sending module 602 is used to send a hot-swap instruction to the user according to the management status and link status of the PCIe controller if the input / output pins meet the interrupt triggering conditions, so that the user can hot-swap the PCIe device according to the hot-swap instruction. The hot-swap management module 603 is used to manage the hot-swap of PCIe devices and slots after the user has completed the hot-swap operation.
[0093] In one possible implementation, the interrupt trigger judgment module 601 is specifically used to obtain the preset interrupt trigger conditions of the input / output pins and the interrupt trigger information input by the user; based on the interrupt trigger information, it determines whether the input / output pins currently meet the interrupt trigger conditions.
[0094] In one possible implementation, the hot-swap card instruction sending module 602 is specifically used to obtain PCIe slot information and interrupt numbers of input / output pins; if the input / output pins meet the interrupt triggering conditions, the interrupt handling function is called and executed according to the interrupt number; the management status and link status of the PCIe controller are obtained according to the PCIe slot information; and the hot-swap instruction is sent to the user according to the management status and link status of the PCIe controller.
[0095] In one possible implementation, the hot-swap card instruction sending module 602 is specifically used to send a hot-swap card instruction to the user if the management state of the PCIe controller is off and the link state is idle, so that the user can insert the PCIe device.
[0096] In one possible implementation, the hot-swap management module 603 is specifically used to determine whether the link status of the PCIe controller is a stable link state after the user completes the hot-swap card operation; if the link status of the PCIe controller is a stable link state, it allocates resources to the PCIe device, loads the driver, and creates the device node.
[0097] In one possible implementation, the hot-swap management module 603 is specifically used to send a hot-swap card command to the user if the management state of the PCIe controller is enabled and the link state is stable, so that the user can remove the PCIe device.
[0098] In one possible implementation, if the input / output pins meet the interrupt triggering condition, the device may further include: The information acquisition module is used to acquire and save the space configuration information of the PCIe controller; The hot-swap management module 603 is specifically used to rewrite the space configuration information of the PCIe controller and uninstall the PCIe device driver and device node after the user completes the hot-swap card operation.
[0099] In one possible implementation, after the user completes the hot-swap card operation, the hot-swap management module 603 is also used to set the management state of the PCIe controller to the off state.
[0100] The above-described device is used to execute the method provided in the foregoing embodiments, and its implementation principle and technical effect are similar, so they will not be described again here.
[0101] These modules can be one or more integrated circuits configured to implement the above methods, such as one or more Application Specific Integrated Circuits (ASICs), one or more microprocessors, or one or more Field Programmable Gate Arrays (FPGAs). Alternatively, when a module is implemented using processing element scheduler code, the processing element can be a general-purpose processor, such as a Central Processing Unit (CPU) or other processor capable of calling program code. Furthermore, these modules can be integrated together as a system-on-a-chip (SOC).
[0102] Figure 7 A schematic diagram of a PCIe controller provided in an embodiment of this application is shown below. Figure 7 As shown, the PCIe controller 700 may include a processor 701, a storage medium 702, and a bus. The storage medium 702 stores program instructions executable by the processor 701. When the PCIe controller 700 is running, the processor 701 communicates with the storage medium 702 via the bus, and the processor 701 executes the program instructions to perform the above-described method embodiment. The specific implementation and technical effects are similar and will not be described in detail here.
[0103] Optionally, this application also provides a computer-readable storage medium storing a computer program, which is executed by a processor to perform the above-described method embodiments.
[0104] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative; for instance, the division of units is only a logical functional division, and in actual implementation, there may be other division methods. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed. Furthermore, the coupling or direct coupling or communication connection shown or discussed may be through some interfaces; the indirect coupling or communication connection between apparatuses or units may be electrical, mechanical, or other forms.
[0105] The units described as separate components may or may not be physically separate. The components shown as units may or may not be physical units; that is, they may be located in one place or distributed across multiple network units. Some or all of the units can be selected to achieve the purpose of this embodiment according to actual needs.
[0106] Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit. The integrated unit can be implemented in hardware or in a combination of hardware and software functional units.
[0107] The integrated units implemented as software functional units described above can be stored in a computer-readable storage medium. These software functional units, stored in a storage medium, include several instructions to cause a computer device (which may be a personal computer, server, or network device, etc.) or processor to execute some steps of the methods described in the various embodiments of this application. The aforementioned 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.
[0108] The above are merely specific embodiments of this application, but the scope of protection of this application is not limited thereto. Any variations or substitutions that can be easily conceived by those skilled in the art within the scope of the technology disclosed in this application should be included within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for controlling the hot-swapping of a PCIe device, characterized in that, Applied to a PCIe controller, the method includes: Determine whether the input / output pins meet the interrupt trigger conditions; If the input / output pins meet the interrupt triggering condition, a hot-plug command is sent to the user according to the management status and link status of the PCIe controller, so that the user can hot-plug the PCIe device according to the hot-plug command. After the user completes the hot-plug operation, the PCIe device and slot are managed for hot-plugging.
2. The method as described in claim 1, characterized in that, The determination of whether the input / output pins meet the interrupt triggering conditions includes: Obtain the preset interrupt trigger conditions of the input / output pins, as well as the interrupt trigger information input by the user; Based on the interrupt trigger information, determine whether the input / output pin currently meets the interrupt trigger condition.
3. The method as described in claim 1, characterized in that, If the input / output pins meet the interrupt triggering condition, a hot-plug command is sent to the user based on the management status and link status of the PCIe controller, including: Obtain the PCIe slot information and the interrupt number of the input / output pin; If the input / output pins meet the interrupt triggering condition, the interrupt handling function is called and executed according to the interrupt number; Based on the PCIe slot information, obtain the management status and link status of the PCIe controller; Based on the management status and link status of the PCIe controller, hot-plug commands are sent to the user.
4. The method as described in claim 3, characterized in that, The step of sending hot-plug commands to the user based on the management status and link status of the PCIe controller includes: If the management state of the PCIe controller is off and the link state is idle, a hot-plug card command is sent to the user so that the user can insert the PCIe device.
5. The method as described in claim 4, characterized in that, The hot-plug management of the PCIe device and slot after the user completes the hot-plug operation includes: After the user completes the hot-plug card operation, determine whether the link status of the PCIe controller is a stable link status; If the link status of the PCIe controller is stable, resources are allocated to the PCIe device, the driver is loaded, and a device node is created.
6. The method as described in claim 3, characterized in that, The step of sending hot-plug commands to the user based on the management status and link status of the PCIe controller includes: If the PCIe controller is in an enabled state and the link is in a stable connection state, a hot-swap card command is sent to the user so that the user can unplug the PCIe device.
7. The method as described in claim 6, characterized in that, If the input / output pins meet the interrupt triggering condition, the method further includes: Obtain and save the space configuration information of the PCIe controller; The hot-plug management of the PCIe device and slot after the user completes the hot-plug operation includes: After the user completes the hot-swap card operation, the space configuration information of the PCIe controller is rewritten, and the driver and device node of the PCIe device are uninstalled.
8. The method as described in claim 7, characterized in that, After the user completes the hot-swap card operation, the method further includes: Set the management status of the PCIe controller to the off state.
9. A hot-plug control device for a PCIe device, characterized in that, Applied to a PCIe controller, the device includes: The interrupt triggering judgment module is used to determine whether the input / output pins meet the interrupt triggering conditions; A hot-swap instruction sending module is used to send a hot-swap instruction to the user based on the management status and link status of the PCIe controller if the input / output pins meet the interrupt triggering conditions, so that the user can hot-swap the PCIe device according to the hot-swap instruction; The hot-swap management module is used to manage the hot-swap of the PCIe device and slot after the user completes the hot-swap operation.
10. A PCIe controller, characterized in that, include: The system includes a processor, a storage medium, and a bus, wherein the storage medium stores program instructions executable by the processor, and when the PCIe controller is running, the processor communicates with the storage medium via the bus, and the processor executes the program instructions to perform the steps of the hot-plug control method for a PCIe device as described in any one of claims 1 to 8.
11. A computer-readable storage medium, characterized in that, The storage medium stores a computer program, which, when executed by a processor, performs the steps of the hot-plug control method for a PCIe device as described in any one of claims 1 to 8.