mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-02-17 20:40:33 -05:00
devm_cxl_add_dport_by_dev() outside of cxl_test is done through PCI hierarchy. However with cxl_test, it needs to be done through the platform device hierarchy. Add the mock function for devm_cxl_add_dport_by_dev(). When cxl_core calls a cxl_core exported function and that function is mocked by cxl_test, the call chain causes a circular dependency issue. Dan provided a workaround to avoid this issue. Apply the method to changes from the late dport allocation changes in order to enable cxl-test. In cxl_core they are defined with "__" added in front of the function. A macro is used to define the original function names for when non-test version of the kernel is built. A bit of macros and typedefs are used to allow mocking of those functions in cxl_test. Co-developed-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com> Reviewed-by: Li Ming <ming.li@zohomail.com> Tested-by: Alison Schofield <alison.schofield@intel.com> Tested-by: Robert Richter <rrichter@amd.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com>
34 lines
1.3 KiB
C
34 lines
1.3 KiB
C
/* SPDX-License-Identifier: GPL-2.0 */
|
|
|
|
#include <linux/list.h>
|
|
#include <linux/acpi.h>
|
|
#include <cxl.h>
|
|
|
|
struct cxl_mock_ops {
|
|
struct list_head list;
|
|
bool (*is_mock_adev)(struct acpi_device *dev);
|
|
int (*acpi_table_parse_cedt)(enum acpi_cedt_type id,
|
|
acpi_tbl_entry_handler_arg handler_arg,
|
|
void *arg);
|
|
bool (*is_mock_bridge)(struct device *dev);
|
|
acpi_status (*acpi_evaluate_integer)(acpi_handle handle,
|
|
acpi_string pathname,
|
|
struct acpi_object_list *arguments,
|
|
unsigned long long *data);
|
|
struct acpi_pci_root *(*acpi_pci_find_root)(acpi_handle handle);
|
|
bool (*is_mock_bus)(struct pci_bus *bus);
|
|
bool (*is_mock_port)(struct device *dev);
|
|
bool (*is_mock_dev)(struct device *dev);
|
|
int (*devm_cxl_port_enumerate_dports)(struct cxl_port *port);
|
|
int (*devm_cxl_switch_port_decoders_setup)(struct cxl_port *port);
|
|
int (*devm_cxl_endpoint_decoders_setup)(struct cxl_port *port);
|
|
void (*cxl_endpoint_parse_cdat)(struct cxl_port *port);
|
|
struct cxl_dport *(*devm_cxl_add_dport_by_dev)(struct cxl_port *port,
|
|
struct device *dport_dev);
|
|
};
|
|
|
|
void register_cxl_mock_ops(struct cxl_mock_ops *ops);
|
|
void unregister_cxl_mock_ops(struct cxl_mock_ops *ops);
|
|
struct cxl_mock_ops *get_cxl_mock_ops(int *index);
|
|
void put_cxl_mock_ops(int index);
|