Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

cdx: Export Symbols for MCDI RPC and Initialization

The cdx_mcdi_init(), cdx_mcdi_process_cmd(), and cdx_mcdi_rpc() functions are
needed by the VersalNET EDAC module that interact with the MCDI (Management
Controller Direct Interface) framework. These functions facilitate
communication between different hardware components by enabling command
execution and status management.

Signed-off-by: Shubhrajyoti Datta <shubhrajyoti.datta@amd.com>
Signed-off-by: Borislav Petkov (AMD) <bp@alien8.de>
Acked-by: Nikhil Agarwal <nikhil.agarwal@amd.com>
Link: https://lore.kernel.org/20250908115649.22903-1-shubhrajyoti.datta@amd.com

authored by

Shubhrajyoti Datta and committed by
Borislav Petkov (AMD)
8b0d0312 54fd6bd4

+45
+38
drivers/cdx/controller/mcdi.c
··· 100 100 return cdx->mcdi_ops->mcdi_rpc_timeout(cdx, cmd); 101 101 } 102 102 103 + /** 104 + * cdx_mcdi_init - Initialize MCDI (Management Controller Driver Interface) state 105 + * @cdx: Handle to the CDX MCDI structure 106 + * 107 + * This function allocates and initializes internal MCDI structures and resources 108 + * for the CDX device, including the workqueue, locking primitives, and command 109 + * tracking mechanisms. It sets the initial operating mode and prepares the device 110 + * for MCDI operations. 111 + * 112 + * Return: 113 + * * 0 - on success 114 + * * -ENOMEM - if memory allocation or workqueue creation fails 115 + */ 103 116 int cdx_mcdi_init(struct cdx_mcdi *cdx) 104 117 { 105 118 struct cdx_mcdi_iface *mcdi; ··· 142 129 fail: 143 130 return rc; 144 131 } 132 + EXPORT_SYMBOL_GPL(cdx_mcdi_init); 145 133 134 + /** 135 + * cdx_mcdi_finish - Cleanup MCDI (Management Controller Driver Interface) state 136 + * @cdx: Handle to the CDX MCDI structure 137 + * 138 + * This function is responsible for cleaning up the MCDI (Management Controller Driver Interface) 139 + * resources associated with a cdx_mcdi structure. Also destroys the mcdi workqueue. 140 + * 141 + */ 146 142 void cdx_mcdi_finish(struct cdx_mcdi *cdx) 147 143 { 148 144 struct cdx_mcdi_iface *mcdi; ··· 166 144 kfree(cdx->mcdi); 167 145 cdx->mcdi = NULL; 168 146 } 147 + EXPORT_SYMBOL_GPL(cdx_mcdi_finish); 169 148 170 149 static bool cdx_mcdi_flushed(struct cdx_mcdi_iface *mcdi, bool ignore_cleanups) 171 150 { ··· 577 554 cdx_mcdi_cmd_start_or_queue(mcdi, cmd); 578 555 } 579 556 557 + /** 558 + * cdx_mcdi_process_cmd - Process an incoming MCDI response 559 + * @cdx: Handle to the CDX MCDI structure 560 + * @outbuf: Pointer to the response buffer received from the management controller 561 + * @len: Length of the response buffer in bytes 562 + * 563 + * This function handles a response from the management controller. It locates the 564 + * corresponding command using the sequence number embedded in the header, 565 + * completes the command if it is still pending, and initiates any necessary cleanup. 566 + * 567 + * The function assumes that the response buffer is well-formed and at least one 568 + * dword in size. 569 + */ 580 570 void cdx_mcdi_process_cmd(struct cdx_mcdi *cdx, struct cdx_dword *outbuf, int len) 581 571 { 582 572 struct cdx_mcdi_iface *mcdi; ··· 627 591 628 592 cdx_mcdi_process_cleanup_list(mcdi->cdx, &cleanup_list); 629 593 } 594 + EXPORT_SYMBOL_GPL(cdx_mcdi_process_cmd); 630 595 631 596 static void cdx_mcdi_cmd_work(struct work_struct *context) 632 597 { ··· 795 758 return cdx_mcdi_rpc_sync(cdx, cmd, inbuf, inlen, outbuf, outlen, 796 759 outlen_actual, false); 797 760 } 761 + EXPORT_SYMBOL_GPL(cdx_mcdi_rpc); 798 762 799 763 /** 800 764 * cdx_mcdi_rpc_async - Schedule an MCDI command to run asynchronously
+7
include/linux/cdx/mcdi.h
··· 169 169 u32 fn_flags; 170 170 }; 171 171 172 + void cdx_mcdi_finish(struct cdx_mcdi *cdx); 173 + int cdx_mcdi_init(struct cdx_mcdi *cdx); 174 + void cdx_mcdi_process_cmd(struct cdx_mcdi *cdx, struct cdx_dword *outbuf, int len); 175 + int cdx_mcdi_rpc(struct cdx_mcdi *cdx, unsigned int cmd, 176 + const struct cdx_dword *inbuf, size_t inlen, 177 + struct cdx_dword *outbuf, size_t outlen, size_t *outlen_actual); 178 + 172 179 /* 173 180 * We expect that 16- and 32-bit fields in MCDI requests and responses 174 181 * are appropriately aligned, but 64-bit fields are only