Skip to contentSkip to conversation

PCI: Add DOE support for endpoint

PATCH Superseded Aksh Garg 2 participants 7 messages May 22

Subsystems (3)

v4 of 6 Superseded Latest is v6 →

lore
Share & tools
lore

Aksh Garg

author
#0 lore raw

v4 cover PCI: Add DOE support for endpoint

This patch series introduces the framework for supporting the Data Object Exchange (DOE) feature for PCIe endpoint devices. Please refer to the documentation added in patch 4 for details on the feature and implementation architecture.

The implementation provides a common framework for all PCIe endpoint controllers, not specific to any particular SoC vendor.

The changes since v1 are documented in the respective patch descriptions.

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1 (RFC): https://lore.kernel.org/all/[email protected]/

Below is a code demonstration showing the integration of DOE-EP APIs with EPC drivers.

Note: The provided code is just to show how an EPC driver is expected to
utilize the pci_ep_doe_process_request() and pci_ep_doe_abort() APIs, and might not cover all the corner cases. The below implementation also expects the EPC hardware to have some memory buffer to store the data from(for) write_mailbox(read_mailbox) DOE capability registers.

============================================================================

/* ========== DOE Completion Callback (invoked by DOE-EP core) ========== */

static void doe_completion_cb(struct pci_epc *epc, u8 func_no, u16 cap_offset,
int status, u16 vendor, u8 type, void *response_pl, size_t response_pl_sz)

{
	struct epc_driver *drv = epc_get_drvdata(epc);
	u32 *response = (u32 *)response_pl;
	u32 header1, header2;
	int payload_dw, i;

	if (status < 0) {
		/* Error: set ERROR bit in DOE Status register */
		writel(1 << DOE_STATUS_ERROR,
		       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));
		goto free;
	}

	if (readl(drv->base + PF_DOE_CTRL_REG(func_no, cap_offset)) & DOE_CTRL_ABORT) {
		/* Aborted: do not send response */
		goto free;
	}

	/* Success: write DOE headers first, then response to the read memory */

	/* Header 1: Vendor ID (bits 15:0) | Type (bits 23:16) */
	header1 = (type << 16) | vendor;
	writel(header1, drv->base + PF_DOE_RD_MEMORY_WR_REG(func_no, cap_offset));

	/* Header 2: Length in DW (including 2 DW of headers + payload) */
	payload_dw = DIV_ROUND_UP(response_pl_sz, sizeof(u32));
	header2 = 2 + payload_dw;  /* 2 header DWs + payload */
	writel(header2, drv->base + PF_DOE_RD_MEMORY_WR_REG(func_no, cap_offset));
	
	/* Set READY bit to signal response ready */
	writel(1 << DOE_STATUS_READY,
	       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));

	/* Write response payload DWORDs to Read memory */
	for (i = 0; i < payload_dw; i++)
		writel(response[i],
		       drv->base + PF_DOE_RD_MEMORY_WR_REG(func_no, cap_offset));

	/* Wait for the memory to empty before clearing the READY bit */
	while (!RD_MEMORY_EMPTY()) {/* wait */}

	writel(0 << DOE_STATUS_READY,
	       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));
	
	/* unset BUSY bit */
	writel(0 << DOE_STATUS_BUSY,
	       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));
free:
	kfree(response_pl);
}

/* ========== DOE Interrupt Handler (triggered on GO bit from root complex) ========== */

static irqreturn_t doe_interrupt_handler(int irq, void *priv)

{
	struct epc_driver *drv = priv;
	u16 cap_offset = extract_cap_offset_from_irq(irq);
	u8 func_no = extract_func_from_irq(irq);
	u32 header1, header2, length_dw, *request;
	u16 vendor;
	u8 type;
	int i, ret;

	/* Read first header DWORD: Vendor ID (bits 15:0) | Type (bits 23:16) */
	header1 = readl(drv->base + PF_DOE_WR_MEMORY_RD_REG(func_no, cap_offset));
	vendor = header1 & 0xFFFF;
	type = (header1 >> 16) & 0xFF;

	/* Read second header DWORD: Length in DW (includes 2 DW of headers) */
	header2 = readl(drv->base + PF_DOE_WR_MEMORY_RD_REG(func_no, cap_offset));
	length_dw = header2 & 0x3FFFF;  /* Bits 17:0 */

	if (!length_dw)
		length_dw = PCI_DOE_MAX_LENGTH;

	length_dw -= 2;  /* Subtract 2 DW of headers to get payload length */
	/* Allocate buffer for complete request (headers + payload) */
	request = kzalloc(length_dw * sizeof(u32), GFP_ATOMIC);
	if (!request) {
		writel(1 << DOE_STATUS_ERROR,
		       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));
		return IRQ_HANDLED;
	}

	/* Read remaining payload DWORDs from Write memory */
	for (i = 0; i < length_dw; i++) {
		while (WR_MEMORY_EMPTY()) { /* wait */ }
		request[i] = readl(drv->base + PF_DOE_WR_MEMORY_RD_REG(func_no, cap_offset));
	}
	/* Set BUSY bit */
	writel(1 << DOE_STATUS_BUSY,
	       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));

	/* Hand off to DOE-EP core for asynchronous processing */
	ret = pci_ep_doe_process_request(drv->epc, func_no, cap_offset,
					 vendor, type, (void *)request,
					 length_dw * sizeof(u32),
					 doe_completion_cb);
	if (ret) {
		writel(1 << DOE_STATUS_ERROR,
		       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));
		kfree(request);
	}

	return IRQ_HANDLED;
}

/* ========== Abort Handler (triggered on ABORT bit from root complex) ========== */

static irqreturn_t doe_abort_handler(int irq, void *priv)

{
	struct epc_driver *drv = priv;
	u16 cap_offset = extract_cap_offset_from_irq(irq);
	u8 func_no = extract_func_from_irq(irq);

	/* Abort pending/in-flight operations in DOE-EP core */
	pci_ep_doe_abort(drv->epc, func_no, cap_offset);

	/* Discard Write memory contents */
	writel(DOE_WR_MEMORY_CTRL_DISCARD,
	       drv->base + PF_DOE_WR_MEMORY_CTRL_REG(func_no, cap_offset));

	/* Clear status bits */
	writel((0 << DOE_STATUS_ERROR) | (0 << DOE_STATUS_BUSY) |
	       (0 << DOE_STATUS_READY),
	       drv->base + PF_DOE_STATUS_REG(func_no, cap_offset));

	return IRQ_HANDLED;
}

====================================================================================

Aksh Garg (4):
PCI/DOE: Move common definitions to the header file
PCI: endpoint: Add DOE mailbox support for endpoint functions
PCI: endpoint: Add support for DOE initialization and setup in EPC
core
Documentation: PCI: Add documentation for DOE endpoint support

 Documentation/PCI/endpoint/index.rst          |   1 +
 .../PCI/endpoint/pci-endpoint-doe.rst         | 329 +++++++++++
 drivers/pci/doe.c                             |  11 -
 drivers/pci/endpoint/Kconfig                  |  14 +
 drivers/pci/endpoint/Makefile                 |   1 +
 drivers/pci/endpoint/pci-ep-doe.c             | 553 ++++++++++++++++++
 drivers/pci/endpoint/pci-epc-core.c           |  92 +++
 drivers/pci/pci.h                             |  48 ++
 include/linux/pci-doe.h                       |   8 +
 include/linux/pci-epc.h                       |   9 +
 10 files changed, 1055 insertions(+), 11 deletions(-)
 create mode 100644 Documentation/PCI/endpoint/pci-endpoint-doe.rst
 create mode 100644 drivers/pci/endpoint/pci-ep-doe.c
Signature · 1 line
2.34.1
author
#1 lore raw

PATCH v4 1/4 PCI/DOE: Move common definitions to the header file

Move common macros and structures from drivers/pci/doe.c to drivers/pci/pci.h to allow reuse across root complex and endpoint DOE implementations.

PCI_DOE_MAX_LENGTH macro can be used outside the PCI core as well, hence move the macro to include/linux/pci-doe.h.

These changes prepare the groundwork for the DOE endpoint implementation that will reuse these common definitions.

---

Changes from v3 to v4:
- None.

Changes from v2 to v3:
- Rebased on 7.1-rc1.

Changes since v1:
- Moved the common macros that need not be visible outside the PCI core to drivers/pci/pci.h instead to include/linux/pci-doe.h as suggested by Lukas Wunner
- Removed the redundant empty inlines guarded with CONFIG_PCI_DOE in include/linux/pci-doe.h.

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

 drivers/pci/doe.c       | 11 -----------
 drivers/pci/pci.h       |  9 +++++++++
 include/linux/pci-doe.h |  3 +++
 3 files changed, 12 insertions(+), 11 deletions(-)
drivers/pci/doe.c +0 -11
index 7b41da4ec11a..e8d9e95644b3 100644
@@ -28,12 +28,6 @@
 #define PCI_DOE_TIMEOUT HZ
 #define PCI_DOE_POLL_INTERVAL	(PCI_DOE_TIMEOUT / 128)
 
-#define PCI_DOE_FLAG_CANCEL	0
-#define PCI_DOE_FLAG_DEAD	1
-
-/* Max data object length is 2^18 dwords */
-#define PCI_DOE_MAX_LENGTH	(1 << 18)
-
 /**
  * struct pci_doe_mb - State for a single DOE mailbox
  *
@@ -63,11 +57,6 @@ struct pci_doe_mb {
 #endif
 };
 
-struct pci_doe_feature {
-	u16 vid;
-	u8 type;
-};
-
 /**
  * struct pci_doe_task - represents a single query/response
  *
drivers/pci/pci.h +9 -0
index 4a14f88e543a..5844deee2b5f 100644
@@ -683,6 +683,15 @@ struct pci_sriov {
 	bool		drivers_autoprobe; /* Auto probing of VFs by driver */
 };
 
+/* DOE Mailbox state flags */
+#define PCI_DOE_FLAG_CANCEL	0
+#define PCI_DOE_FLAG_DEAD	1
+
+struct pci_doe_feature {
+	u16 vid;
+	u8 type;
+};
+
 #ifdef CONFIG_PCI_DOE
 void pci_doe_init(struct pci_dev *pdev);
 void pci_doe_destroy(struct pci_dev *pdev);
include/linux/pci-doe.h +3 -0
index bd4346a7c4e7..abb9b7ae8029 100644
@@ -19,6 +19,9 @@ struct pci_doe_mb;
 #define PCI_DOE_FEATURE_CMA 1
 #define PCI_DOE_FEATURE_SSESSION 2
 
+/* Max data object length is 2^18 dwords */
+#define PCI_DOE_MAX_LENGTH		(1 << 18)
+
 struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor,
 					u8 type);
 
Signature · 1 line
2.34.1
author
#2 lore raw

PATCH v4 2/4 PCI: endpoint: Add DOE mailbox support for endpoint functions

In reply to Aksh Garg

DOE (Data Object Exchange) is a standard PCIe extended capability feature introduced in the Data Object Exchange (DOE) ECN for PCIe r5.0. It provides a communication mechanism primarily used for implementing PCIe security features such as device authentication, and secure link establishment. Think of DOE as a sophisticated mailbox system built into PCIe. The root complex can send structured requests to the endpoint device through DOE mailboxes, and the endpoint device responds with appropriate data.

Add the DOE support for PCIe endpoint devices, enabling endpoint functions to process the DOE requests from the host. The implementation provides framework APIs for EPC core driver and controller drivers to register mailboxes, and request processing with workqueues ensuring sequential handling per mailbox, and parallel handling across mailboxes. The Discovery protocol is handled internally by the DOE core.

This implementation complements the existing DOE implementation for root complex in drivers/pci/doe.c.

---

Changes from v3 to v4:
- Used 'Returns' instead of 'RETURNS' in the function docstrings to comply with kernel-doc format, as suggested by Manivannan Sadhasivam.
- In pci_ep_doe_process_request(), changed the type of request buffer from "const void *" to "void *", as the ownership is transferred to DOE-EP framework, which is responsible to free the buffer.
- Added "struct pci_epc *epc" to typedef "pci_ep_doe_complete_t", to be used by the EPC driver.

Changes from v2 to v3:
- Rebased on 7.1-rc1.

Changes since v1:
- Moved the DOE-EP core file to drivers/pci/endpoint/pci-ep-doe.c, and corresponding Kconfig and Makefile to match the existing naming scheme, as suggested by Niklas Cassel.
- Renamed the config from PCI_DOE_EP to PCI_ENDPOINT_DOE
- Moved the function declarations that need not be visible outside the PCI core to drivers/pci/pci.h instead to include/linux/pci-doe.h as suggested by Lukas Wunner
- Converted from synchronous to asynchronous request processing:
* Removed wait_for_completion() from pci_ep_doe_process_request()
* Function returns immediately after queuing to workqueue, hence removed private data for completion in the task structure
* Added completion callback as an additional argument to pci_ep_doe_process_request(), which takes the response and status parameters as arguments (along with other required arguments), hence removed task_status in the task structure
* Created a typedef pci_ep_doe_complete_t for completion callback
* Removed the pci_ep_doe_task_complete() function, as it would not be required anymore with these changes
* Moved from INIT_WORK_ONSTACK() to INIT_WORK(), to initialize the work on heap instead of stack
* signal_task_complete() now invokes the completion callback, once the protocol handler completes its task
- Changed from dynamic xarray-based protocol registration to static array:
* Removed the register/unregister protocol APIs
* Replaced the dynamic xarray with static array of struct pci_doe_protocol
* Added discovery protocol to static array, instead of treating it specially, hence removed the special handling for Discovery protocol in doe_ep_task_work()
* Updated pci_ep_doe_handle_discovery() and pci_ep_doe_find_protocol() accordingly.
- Memory Management:
* DOE core frees request buffer in signal_task_complete()
or during error handling
* pci_ep_doe_process_request() defines response_pl and response_pl_sz as NULL and 0 respectively, whose pointer is passed to the protocol handler, hence removed the arguments void **response, size_t *response_sz to this function.
- Task structure refactoring:
* Response buffer: void **response_pl to void *response_pl
* Response size: size_t *response_pl_sz to size_t response_pl_sz
* Changed the completion callback to type pci_ep_doe_complete_t
* Removed void *private and int task_status
- Updated documentation comments of the functions according to the changes

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: https://lore.kernel.org/all/[email protected]/

 drivers/pci/endpoint/Kconfig      |  14 +
 drivers/pci/endpoint/Makefile     |   1 +
 drivers/pci/endpoint/pci-ep-doe.c | 553 ++++++++++++++++++++++++++++++
 drivers/pci/pci.h                 |  39 +++
 include/linux/pci-doe.h           |   5 +
 include/linux/pci-epc.h           |   3 +
 6 files changed, 615 insertions(+)
 create mode 100644 drivers/pci/endpoint/pci-ep-doe.c
drivers/pci/endpoint/Kconfig +14 -0
index 8dad291be8b8..15ae16aaa58f 100644
@@ -36,6 +36,20 @@ config PCI_ENDPOINT_MSI_DOORBELL
 	  doorbell. The RC can trigger doorbell in EP by writing data to a
 	  dedicated BAR, which the EP maps to the controller's message address.
 
+config PCI_ENDPOINT_DOE
+	bool "PCI Endpoint Data Object Exchange (DOE) support"
+	depends on PCI_ENDPOINT
+	help
+	  This enables support for Data Object Exchange (DOE) protocol
+	  on PCI Endpoint controllers. It provides a communication
+	  mechanism through mailboxes, primarily used for PCIe security
+	  features.
+
+	  Say Y here if you want be able to communicate using PCIe DOE
+	  mailboxes.
+
+	  If unsure, say N.
+
 source "drivers/pci/endpoint/functions/Kconfig"
 
 endmenu
drivers/pci/endpoint/Makefile +1 -0
index b4869d52053a..1fa176b6792b 100644
@@ -7,3 +7,4 @@ obj-$(CONFIG_PCI_ENDPOINT_CONFIGFS)	+= pci-ep-cfs.o
 obj-$(CONFIG_PCI_ENDPOINT)		+= pci-epc-core.o pci-epf-core.o\
 					   pci-epc-mem.o functions/
 obj-$(CONFIG_PCI_ENDPOINT_MSI_DOORBELL)	+= pci-ep-msi.o
+obj-$(CONFIG_PCI_ENDPOINT_DOE)		+= pci-ep-doe.o
drivers/pci/endpoint/pci-ep-doe.c new file +553 -0

553 lines not on this page · raw message

drivers/pci/pci.h +39 -0
index 5844deee2b5f..c4a0e25625e3 100644
@@ -692,6 +692,13 @@ struct pci_doe_feature {
 	u8 type;
 };
 
+struct pci_epc;
+
+typedef void (*pci_ep_doe_complete_t)(struct pci_epc *epc, u8 func_no,
+				      u16 cap_offset, int status,
+				      u16 vendor, u8 type,
+				      void *response_pl, size_t response_pl_sz);
+
 #ifdef CONFIG_PCI_DOE
 void pci_doe_init(struct pci_dev *pdev);
 void pci_doe_destroy(struct pci_dev *pdev);
@@ -702,6 +709,38 @@ static inline void pci_doe_destroy(struct pci_dev *pdev) { }
 static inline void pci_doe_disconnected(struct pci_dev *pdev) { }
 #endif
 
+#ifdef CONFIG_PCI_ENDPOINT_DOE
+int pci_ep_doe_init(struct pci_epc *epc);
+int pci_ep_doe_add_mailbox(struct pci_epc *epc, u8 func_no, u16 cap_offset);
+int pci_ep_doe_process_request(struct pci_epc *epc, u8 func_no, u16 cap_offset,
+			       u16 vendor, u8 type, void *request,
+			       size_t request_sz, pci_ep_doe_complete_t complete);
+int pci_ep_doe_abort(struct pci_epc *epc, u8 func_no, u16 cap_offset);
+void pci_ep_doe_destroy(struct pci_epc *epc);
+#else
+static inline int pci_ep_doe_init(struct pci_epc *epc) { return -EOPNOTSUPP; }
+static inline int pci_ep_doe_add_mailbox(struct pci_epc *epc, u8 func_no,
+					 u16 cap_offset)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int pci_ep_doe_process_request(struct pci_epc *epc, u8 func_no,
+					     u16 cap_offset, u16 vendor, u8 type,
+					     void *request, size_t request_sz,
+					     pci_ep_doe_complete_t complete)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline int pci_ep_doe_abort(struct pci_epc *epc, u8 func_no, u16 cap_offset)
+{
+	return -EOPNOTSUPP;
+}
+
+static inline void pci_ep_doe_destroy(struct pci_epc *epc) { }
+#endif
+
 #ifdef CONFIG_PCI_NPEM
 void pci_npem_create(struct pci_dev *dev);
 void pci_npem_remove(struct pci_dev *dev);
include/linux/pci-doe.h +5 -0
index abb9b7ae8029..c46e42f3ce78 100644
@@ -22,6 +22,11 @@ struct pci_doe_mb;
 /* Max data object length is 2^18 dwords */
 #define PCI_DOE_MAX_LENGTH		(1 << 18)
 
+typedef int (*pci_doe_protocol_handler_t)(const void *request,
+					  size_t request_sz,
+					  void **response,
+					  size_t *response_sz);
+
 struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor,
 					u8 type);
 
include/linux/pci-epc.h +3 -0
index 1eca1264815b..dd26294c8175 100644
@@ -182,6 +182,9 @@ struct pci_epc {
 	unsigned long			function_num_map;
 	int				domain_nr;
 	bool				init_complete;
+#ifdef CONFIG_PCI_ENDPOINT_DOE
+	struct xarray			doe_mbs;
+#endif
 };
 
 /**
Signature · 1 line
2.34.1
#3 lore raw

Re: [PATCH v4 2/4] PCI: endpoint: Add DOE mailbox support for endpoint functions

Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider: - [High] `pci_ep_doe_process_request()` uses `GFP_KERNEL` for memory allocation, which can sleep and is…

Thank you for your contribution! Sashiko AI review found 8 potential issue(s) to consider:
- [High] pci_ep_doe_process_request() uses GFP_KERNEL for memory allocation, which can sleep and is unsafe to call from hard IRQ contexts.
- [High] pci_ep_doe_abort() calls flush_workqueue(), which blocks and sleeps, leading to kernel panics or deadlocks.
- [High] Returning -EINVAL for an out-of-bounds index in the DOE Discovery protocol violates the PCIe Base Specification.
- [High] Missing pci_ep_doe_remove_mailbox() API leads to memory leaks, Use-After-Free panics, and -EBUSY errors upon module unbind.
- [High] Lack of lifetime protection for doe_mb and unsafe iteration in pci_ep_doe_destroy() leads to Use-After-Free vulnerabilities.
- [Medium] The protocol handler signature lacks context parameters, and supported protocols are hardcoded in a global static array.
- [Medium] task->request_pl is freed before the completion callback fires, violating the documented API contract.
- [Medium] Unratelimited logging in the DOE task worker allows a malicious Root Complex to flood kernel logs.
--

commit 0c1884caaad038c32cdf6616156028f360cc90e8
Author: Aksh Garg <[email protected]>

PCI: endpoint: Add DOE mailbox support for endpoint functions

This commit adds Data Object Exchange (DOE) support for PCIe endpoint devices. It introduces framework APIs to register mailboxes, handle requests using workqueues, and process the internal Discovery protocol.

drivers/pci/endpoint/pci-ep-doe.c new file +0 -0
new file mode 100644
index 0000000000000..63a5c1b8753a0
@@ -0,0 +1,553 @@

[ ... ]

Quoted 5 lines
(quoted diff) +5 -0
+struct pci_doe_protocol {
+	u16 vid;
+	u8 type;
+	pci_doe_protocol_handler_t handler;
+};

[ ... ]

Review

Quoted 7 lines
(quoted diff) +7 -0
+static const struct pci_doe_protocol pci_doe_protocols[] = {
+	{
+		.vid = PCI_VENDOR_ID_PCI_SIG,
+		.type = PCI_DOE_FEATURE_DISCOVERY,
+		.handler = pci_ep_doe_handle_discovery,
+	},
+};

[Severity: Medium]
Is a global static array sufficient for endpoint capabilities?

Because the array is global, all endpoint functions will advertise the exact same DOE protocols. Does this prevent multi-function setups that require unique DOE capabilities per physical function?

Additionally, without endpoint context (such as epc, func_no, or a private pointer) in the handler signature, how can handlers access device-specific state like cryptographic keys?

[ ... ]

Review

Quoted 3 lines
(quoted diff) +3 -0
+int pci_ep_doe_add_mailbox(struct pci_epc *epc, u8 func_no, u16 cap_offset)
+{
+	struct pci_ep_doe_mb *doe_mb;

[Severity: High]
Is there a missing pci_ep_doe_remove_mailbox() API for symmetry?

Endpoint function drivers are typically dynamic modules. If an endpoint function is unbound, the mailbox appears to leak in the doe_mbs xarray. A subsequent bind to the same function number will fail with -EBUSY on xa_insert().

Also, if the driver is removed while a DOE request is pending, could the background worker execute the completion callback into unmapped module memory and cause a panic?

[ ... ]

Quoted 8 lines
(quoted diff) +8 -0
+static int pci_ep_doe_handle_discovery(const void *request, size_t request_sz,
+				       void **response, size_t *response_sz)
+{
+	struct pci_doe_protocol protocol;
+	u8 requested_index, next_index;
+	u32 *response_pl;
+	u32 request_pl;
+	u16 vendor;

Review

Quoted 10 lines
(quoted diff) +10 -0
+	u8 type;
+
+	if (request_sz != sizeof(u32))
+		return -EINVAL;
+
+	request_pl = *(u32 *)request;
+	requested_index = FIELD_GET(PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX, request_pl);
+
+	if (requested_index >= PCI_DOE_PROTOCOL_COUNT)
+		return -EINVAL;

[Severity: High]
Does returning -EINVAL here violate the PCIe Base Specification?

The specification requires that when the Root Complex queries an index greater than or equal to the supported protocols, the endpoint should return a valid DOE Discovery Response with Vendor ID 0000h, Type 00h, and Next Index 00h to signal the end of the protocol list. Failing the request might break the host discovery loop.

[ ... ]

Review

Quoted 9 lines
(quoted diff) +9 -0
+static void signal_task_complete(struct pci_ep_doe_task *task, int status)
+{
+	kfree(task->request_pl);
+	task->complete(task->doe_mb->epc, task->doe_mb->func_no,
+		       task->doe_mb->cap_offset, status,
+		       task->feat.vid, task->feat.type,
+		       task->response_pl, task->response_pl_sz);
+	kfree(task);
+}

[Severity: Medium]
Will this trigger a use-after-free if the controller driver inspects the request buffer in its completion callback?

The kernel documentation for pci_ep_doe_process_request() states that the framework frees the buffer "after the completion callback fires." However, the payload is freed just prior to the invocation here.

[ ... ]

Quoted 7 lines
(quoted diff) +7 -0
+static void doe_ep_task_work(struct work_struct *work)
+{
+	struct pci_ep_doe_task *task = container_of(work, struct pci_ep_doe_task,
+						    work);
+	struct pci_ep_doe_mb *doe_mb = task->doe_mb;
+	pci_doe_protocol_handler_t handler;
+	int rc;

[ ... ]

Review

Quoted 10 lines
(quoted diff) +10 -0
+	/* Find protocol handler in the array */
+	handler = pci_ep_doe_find_protocol(task->feat.vid, task->feat.type);
+	if (!handler) {
+		dev_warn(doe_mb->epc->dev.parent,
+			 "[%d:%x] Unsupported protocol VID=%04x TYPE=%02x\n",
+			 doe_mb->func_no, doe_mb->cap_offset,
+			 task->feat.vid, task->feat.type);
+		signal_task_complete(task, -EOPNOTSUPP);
+		return;
+	}

[Severity: Medium]
Can a malicious or compromised Root Complex flood the kernel log here?

If a stream of unsupported requests is sent, this warning could overwhelm I/O and CPU resources on the endpoint. Would using dev_warn_ratelimited() prevent a potential denial of service?

[ ... ]

Quoted 5 lines
(quoted diff) +5 -0
+int pci_ep_doe_process_request(struct pci_epc *epc, u8 func_no, u16 cap_offset,
+			       u16 vendor, u8 type, void *request, size_t request_sz,
+			       pci_ep_doe_complete_t complete)
+{
+	struct pci_ep_doe_mb *doe_mb;

Review

Quoted 10 lines
(quoted diff) +10 -0
+	struct pci_ep_doe_task *task;
+	int rc;
+
+	doe_mb = pci_ep_doe_get_mailbox(epc, func_no, cap_offset);
+	if (!doe_mb) {
+		kfree(request);
+		return -ENODEV;
+	}
+
+	task = kzalloc_obj(*task, GFP_KERNEL);

[Severity: High]
Is it safe to use GFP_KERNEL here?

Because this function is intended to be called by endpoint controller drivers when receiving DOE requests, it is highly likely to be executing in an atomic context, such as a hardware interrupt handler.

Using GFP_KERNEL might sleep, potentially causing deadlocks or scheduling while atomic bugs. Should this API accept a gfp_t argument instead to allow safe allocation?

[ ... ]

Quoted 4 lines
(quoted diff) +4 -0
+int pci_ep_doe_abort(struct pci_epc *epc, u8 func_no, u16 cap_offset)
+{
+	struct pci_ep_doe_mb *doe_mb;
+

Review

Quoted 10 lines
(quoted diff) +10 -0
+	if (!epc)
+		return -EINVAL;
+
+	doe_mb = pci_ep_doe_get_mailbox(epc, func_no, cap_offset);
+	if (!doe_mb)
+		return -ENODEV;
+
+	/* Set CANCEL flag - worker will abort queued requests */
+	set_bit(PCI_DOE_FLAG_CANCEL, &doe_mb->flags);
+	flush_workqueue(doe_mb->work_queue);

[Severity: High]
Will flush_workqueue() cause a kernel panic or deadlock here?

This function is called when the host triggers a DOE Abort, which typically generates an asynchronous interrupt to the endpoint controller. Because flush_workqueue() blocks until all queued works complete, calling it from an interrupt context will trigger a scheduling while atomic bug.

[ ... ]

Review

Quoted 13 lines
(quoted diff) +13 -0
+void pci_ep_doe_destroy(struct pci_epc *epc)
+{
+	struct pci_ep_doe_mb *doe_mb;
+	unsigned long index;
+
+	if (!epc)
+		return;
+
+	xa_for_each(&epc->doe_mbs, index, doe_mb)
+		pci_ep_doe_destroy_mb(doe_mb);
+
+	xa_destroy(&epc->doe_mbs);
+}

[Severity: High]
Is there a missing lifetime protection on the doe_mb structure?

pci_ep_doe_get_mailbox() retrieves doe_mb via xa_load() and returns an unrefcounted pointer outside of an RCU read lock. If pci_ep_doe_destroy() iterates over the xarray and frees the mailboxes, could a concurrent hardware event call pci_ep_doe_process_request(), retrieve a freed mailbox, and trigger a use-after-free?

Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=2
author
#4 lore raw

PATCH v4 3/4 PCI: endpoint: Add support for DOE initialization and setup in EPC core

In reply to Aksh Garg

Add pci_epc_init_capabilities() in EPC core driver to initialize and setup the capabilities supported by the EPC driver. This calls pci_epc_doe_setup() to setup the DOE framework for an endpoint controller, which discovers the DOE capabilities (extended capability ID 0x2E), and registers each discovered DOE mailbox for all the functions in the endpoint controller.

Add pci_epc_deinit_capabilities() in EPC core driver for cleanup of the resources used by the capabilities of the EPC driver. This calls pci_ep_doe_destroy() to destroy all DOE mailboxes and free associated resources.

---

Changes from v3 to v4:
- Call DOE setup and destroy APIs directly within the EPC core, instead of relying on the EPC drivers to call them individually. EPC drivers do not need to explicitly handle DOE setup, rather the EPC core manages this transparently. (Suggested by Manivannan Sadhasivam).
- Removed pci_epc_doe_destroy() API, which was just calling pci_ep_doe_destroy(). Instead, called pci_ep_doe_destroy() directly during cleanup.
- Called pci_ep_doe_init() before the "!epc->ops->find_ext_capability" check, because if doe-capable=1 and find_ext_capability() op is undefined, this would not initialize the epc->doe_mbs xarray. However during cleanup, the check "!epc->ops->find_ext_capability" would be unnecessary, and it will try to destroy the epc->doe_mbs xarray even when it was not initialized.

Changes from v2 to v3:
- Rebased on 7.1-rc1.

Changes since v1:
- New patch added to v2 (not present in v1)

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/

This patch is introduced based on the feedback provided by Manivannan Sadhasivam at [1].

[1]: https://lore.kernel.org/all/p57x6jleaim5w7t2k3v7tioujnaxuovfpj5euop5ogefvw23se@y5fw3che5p5d/

 drivers/pci/endpoint/pci-epc-core.c | 92 +++++++++++++++++++++++++++++
 include/linux/pci-epc.h             |  6 ++
 2 files changed, 98 insertions(+)
drivers/pci/endpoint/pci-epc-core.c +92 -0
index 6c3c58185fc5..af7889b541c0 100644
@@ -14,6 +14,8 @@
 #include <linux/pci-epf.h>
 #include <linux/pci-ep-cfs.h>
 
+#include "../pci.h"
+
 static const struct class pci_epc_class = {
 	.name = "pci_epc",
 };
@@ -842,6 +844,71 @@ void pci_epc_linkdown(struct pci_epc *epc)
 }
 EXPORT_SYMBOL_GPL(pci_epc_linkdown);
 
+/**
+ * pci_epc_doe_setup() - Discover and setup DOE mailboxes for all functions
+ * @epc: the EPC device on which DOE mailboxes has to be setup
+ *
+ * Discover DOE (Data Object Exchange) capabilities for all physical functions
+ * in the endpoint controller and register DOE mailboxes.
+ *
+ * Returns: 0 on success, -errno on failure
+ */
+static int pci_epc_doe_setup(struct pci_epc *epc)
+{
+	u16 cap_offset = 0;
+	u8 func_no;
+	int ret;
+
+	if (!epc->ops || !epc->ops->find_ext_capability)
+		return -EINVAL;
+
+	/* Discover DOE capabilities for all functions */
+	for (func_no = 0; func_no < epc->max_functions; func_no++) {
+		while ((cap_offset = epc->ops->find_ext_capability(epc, func_no, 0,
+								   cap_offset,
+								   PCI_EXT_CAP_ID_DOE))) {
+			/* Register this DOE mailbox */
+			ret = pci_ep_doe_add_mailbox(epc, func_no, cap_offset);
+			if (ret) {
+				dev_warn(&epc->dev,
+					 "[pf%d:offset %x] failed to add DOE mailbox\n",
+					 func_no, cap_offset);
+			}
+		}
+	}
+
+	dev_dbg(&epc->dev, "DOE mailboxes setup complete\n");
+	return 0;
+}
+
+/**
+ * pci_epc_init_capabilities() - Initialize EPC capabilities
+ * @epc: the EPC device whose capabilities need to be initialized
+ *
+ * Invoke to initialize capabilities supported by the EPC device.
+ */
+static void pci_epc_init_capabilities(struct pci_epc *epc)
+{
+	const struct pci_epc_features *epc_features;
+	int ret;
+
+	epc_features = pci_epc_get_features(epc, 0, 0);
+	if (!epc_features)
+		return;
+
+	if (IS_ENABLED(CONFIG_PCI_ENDPOINT_DOE) && epc_features->doe_capable) {
+		ret = pci_ep_doe_init(epc);
+		if (ret) {
+			dev_warn(&epc->dev, "DOE initialization failed: %d\n", ret);
+			return;
+		}
+
+		ret = pci_epc_doe_setup(epc);
+		if (ret)
+			dev_warn(&epc->dev, "DOE setup failed: %d\n", ret);
+	}
+}
+
 /**
  * pci_epc_init_notify() - Notify the EPF device that EPC device initialization
  *                         is completed.
@@ -857,6 +924,8 @@ void pci_epc_init_notify(struct pci_epc *epc)
 	if (IS_ERR_OR_NULL(epc))
 		return;
 
+	pci_epc_init_capabilities(epc);
+
 	mutex_lock(&epc->list_lock);
 	list_for_each_entry(epf, &epc->pci_epf, list) {
 		mutex_lock(&epf->lock);
@@ -890,6 +959,27 @@ void pci_epc_notify_pending_init(struct pci_epc *epc, struct pci_epf *epf)
 }
 EXPORT_SYMBOL_GPL(pci_epc_notify_pending_init);
 
+/**
+ * pci_epc_deinit_capabilities() - Cleanup EPC capabilities
+ * @epc: the EPC device whose capabilities need to be cleaned up
+ *
+ * Invoke to cleanup capabilities supported by the EPC device,
+ * and free the associated resources.
+ */
+static void pci_epc_deinit_capabilities(struct pci_epc *epc)
+{
+	const struct pci_epc_features *epc_features;
+
+	epc_features = pci_epc_get_features(epc, 0, 0);
+	if (!epc_features)
+		return;
+
+	if (IS_ENABLED(CONFIG_PCI_ENDPOINT_DOE) && epc_features->doe_capable) {
+		pci_ep_doe_destroy(epc);
+		dev_dbg(&epc->dev, "DOE mailboxes destroyed\n");
+	}
+}
+
 /**
  * pci_epc_deinit_notify() - Notify the EPF device about EPC deinitialization
  * @epc: the EPC device whose deinitialization is completed
@@ -903,6 +993,8 @@ void pci_epc_deinit_notify(struct pci_epc *epc)
 	if (IS_ERR_OR_NULL(epc))
 		return;
 
+	pci_epc_deinit_capabilities(epc);
+
 	mutex_lock(&epc->list_lock);
 	list_for_each_entry(epf, &epc->pci_epf, list) {
 		mutex_lock(&epf->lock);
include/linux/pci-epc.h +6 -0
index dd26294c8175..11474e337db3 100644
@@ -84,6 +84,8 @@ struct pci_epc_map {
  * @start: ops to start the PCI link
  * @stop: ops to stop the PCI link
  * @get_features: ops to get the features supported by the EPC
+ * @find_ext_capability: ops to find extended capability offset for a function
+ *			 in endpoint controller
  * @owner: the module owner containing the ops
  */
 struct pci_epc_ops {
@@ -115,6 +117,8 @@ struct pci_epc_ops {
 	void	(*stop)(struct pci_epc *epc);
 	const struct pci_epc_features* (*get_features)(struct pci_epc *epc,
 						       u8 func_no, u8 vfunc_no);
+	u16	(*find_ext_capability)(struct pci_epc *epc, u8 func_no,
+				       u8 vfunc_no, u16 start, u8 cap);
 	struct module *owner;
 };
 
@@ -270,6 +274,7 @@ struct pci_epc_bar_desc {
  * @msi_capable: indicate if the endpoint function has MSI capability
  * @msix_capable: indicate if the endpoint function has MSI-X capability
  * @intx_capable: indicate if the endpoint can raise INTx interrupts
+ * @doe_capable: indicate if the endpoint function has DOE capability
  * @bar: array specifying the hardware description for each BAR
  * @align: alignment size required for BAR buffer allocation
  */
@@ -280,6 +285,7 @@ struct pci_epc_features {
 	unsigned int	msi_capable : 1;
 	unsigned int	msix_capable : 1;
 	unsigned int	intx_capable : 1;
+	unsigned int	doe_capable : 1;
 	struct	pci_epc_bar_desc bar[PCI_STD_NUM_BARS];
 	size_t	align;
 };
Signature · 1 line
2.34.1
#5 lore raw

Re: [PATCH v4 3/4] PCI: endpoint: Add support for DOE initialization and setup in EPC core

Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider: - [Critical] Calling `pci_epc_deinit_notify()` before `pci_epc_init_notify()` triggers a kernel panic when…

Thank you for your contribution! Sashiko AI review found 7 potential issue(s) to consider:
- [Critical] Calling pci_epc_deinit_notify() before pci_epc_init_notify() triggers a kernel panic when destroying an uninitialized xarray.
- [High] Hardcoding Physical Function 0 (PF0) to check capabilities breaks endpoints with asymmetric DOE support.
- [High] The find_ext_capability controller operation is called without holding the required epc->lock.
- [High] Destroying EPC capabilities before notifying EPF drivers creates a Use-After-Free risk.
- [Medium] Repeated invocations of pci_epc_init_notify() silently leak existing DOE mailboxes and corrupt the xarray.
- [Medium] DOE mailboxes on Virtual Functions (VFs) are ignored during discovery and setup.
- [Medium] The cap parameter in the find_ext_capability op is an 8-bit integer, truncating 16-bit PCIe Extended Capability IDs. --

commit 2d1f89c68bd01b16c5b22686d5e612b5c77a0616
Author: Aksh Garg <[email protected]>

PCI: endpoint: Add support for DOE initialization and setup in EPC core

This commit adds pci_epc_init_capabilities() and pci_epc_deinit_capabilities() to the EPC core driver to initialize and tear down DOE capabilities. It discovers DOE mailboxes for physical functions and registers them within the controller.

Quoted 4 lines
drivers/pci/endpoint/pci-epc-core.c +0 -0
index 6c3c58185fc5d..af7889b541c05 100644

[ ... ]

Quoted 15 lines
drivers/pci/endpoint/pci-epc-core.c +11 -0
@@ -842,6 +844,71 @@ void pci_epc_linkdown(struct pci_epc *epc)
 }
 EXPORT_SYMBOL_GPL(pci_epc_linkdown);
 
+/**
+ * pci_epc_doe_setup() - Discover and setup DOE mailboxes for all functions
+ * @epc: the EPC device on which DOE mailboxes has to be setup
+ *
+ * Discover DOE (Data Object Exchange) capabilities for all physical functions
+ * in the endpoint controller and register DOE mailboxes.
+ *
+ * Returns: 0 on success, -errno on failure
+ */
+static int pci_epc_doe_setup(struct pci_epc *epc)
+{

drivers/pci/endpoint/pci-epc-core.c void pci_epc_linkdown(struct pci_epc *epc) · line 867

Quoted 10 lines
drivers/pci/endpoint/pci-epc-core.c +10 -0
+	u16 cap_offset = 0;
+	u8 func_no;
+	int ret;
+
+	if (!epc->ops || !epc->ops->find_ext_capability)
+		return -EINVAL;
+
+	/* Discover DOE capabilities for all functions */
+	for (func_no = 0; func_no < epc->max_functions; func_no++) {
+		while ((cap_offset = epc->ops->find_ext_capability(epc, func_no, 0,

[Severity: Medium]
Does this logic bypass Virtual Functions (VFs)? The loop iterates over physical functions but passes a hardcoded 0 for vfunc_no to find_ext_capability(). Since VFs can also possess extended capabilities, it seems they are excluded from DOE discovery.

[Severity: High]
Is it safe to invoke epc->ops->find_ext_capability() without holding the epc->lock? Other hardware operations in the PCI endpoint core appear to be strictly protected by this lock to prevent concurrent accesses to the shared controller registers.

Quoted 18 lines
drivers/pci/endpoint/pci-epc-core.c +18 -0
+								   cap_offset,
+								   PCI_EXT_CAP_ID_DOE))) {
+			/* Register this DOE mailbox */
+			ret = pci_ep_doe_add_mailbox(epc, func_no, cap_offset);
+			if (ret) {
+				dev_warn(&epc->dev,
+					 "[pf%d:offset %x] failed to add DOE mailbox\n",
+					 func_no, cap_offset);
+			}
+		}
+	}
+
+	dev_dbg(&epc->dev, "DOE mailboxes setup complete\n");
+	return 0;
+}
+
+/**
+ * pci_epc_init_capabilities() - Initialize EPC capabilities

drivers/pci/endpoint/pci-epc-core.c void pci_epc_linkdown(struct pci_epc *epc) · line 895

Quoted 10 lines
drivers/pci/endpoint/pci-epc-core.c +10 -0
+ * @epc: the EPC device whose capabilities need to be initialized
+ *
+ * Invoke to initialize capabilities supported by the EPC device.
+ */
+static void pci_epc_init_capabilities(struct pci_epc *epc)
+{
+	const struct pci_epc_features *epc_features;
+	int ret;
+
+	epc_features = pci_epc_get_features(epc, 0, 0);

[Severity: High]
Could this hardcoded check of Physical Function 0 (PF0) break endpoints that have asymmetric DOE support? If PF0 is not doe_capable, the setup is entirely skipped, even if other physical functions like PF1 support DOE.

Quoted 20 lines
drivers/pci/endpoint/pci-epc-core.c +16 -0
+	if (!epc_features)
+		return;
+
+	if (IS_ENABLED(CONFIG_PCI_ENDPOINT_DOE) && epc_features->doe_capable) {
+		ret = pci_ep_doe_init(epc);
+		if (ret) {
+			dev_warn(&epc->dev, "DOE initialization failed: %d\n", ret);
+			return;
+		}
+
+		ret = pci_epc_doe_setup(epc);
+		if (ret)
+			dev_warn(&epc->dev, "DOE setup failed: %d\n", ret);
+	}
+}
+
 /**
  * pci_epc_init_notify() - Notify the EPF device that EPC device initialization
  *                         is completed.

drivers/pci/endpoint/pci-epc-core.c void pci_epc_init_notify(struct pci_epc *epc) · line 928

Quoted 5 lines
drivers/pci/endpoint/pci-epc-core.c +2 -0
@@ -857,6 +924,8 @@ void pci_epc_init_notify(struct pci_epc *epc)
 	if (IS_ERR_OR_NULL(epc))
 		return;
 
+	pci_epc_init_capabilities(epc);
+

[Severity: Medium]
What happens if pci_epc_init_notify() is invoked multiple times? Without checking if the EPC is already initialized (e.g. epc->init_complete), xa_init(&epc->doe_mbs) is called unconditionally. This would overwrite the xarray head pointer and lock, silently orphaning previously allocated mailbox elements and their workqueues.

Quoted 2 lines
drivers/pci/endpoint/pci-epc-core.c +0 -0
 	mutex_lock(&epc->list_lock);
 	list_for_each_entry(epf, &epc->pci_epf, list) {

[ ... ]

Quoted 6 lines
drivers/pci/endpoint/pci-epc-core.c +2 -0
@@ -890,6 +959,27 @@ void pci_epc_notify_pending_init(struct pci_epc *epc, struct pci_epf *epf)
 }
 EXPORT_SYMBOL_GPL(pci_epc_notify_pending_init);
 
+/**
+ * pci_epc_deinit_capabilities() - Cleanup EPC capabilities

drivers/pci/endpoint/pci-epc-core.c void pci_epc_notify_pending_init(struct pci_epc *epc, struct pci_epf *epf) · line 973

Quoted 10 lines
drivers/pci/endpoint/pci-epc-core.c +10 -0
+ * @epc: the EPC device whose capabilities need to be cleaned up
+ *
+ * Invoke to cleanup capabilities supported by the EPC device,
+ * and free the associated resources.
+ */
+static void pci_epc_deinit_capabilities(struct pci_epc *epc)
+{
+	const struct pci_epc_features *epc_features;
+
+	epc_features = pci_epc_get_features(epc, 0, 0);

[Severity: High]
Similar to the initialization side, is it intentional to hardcode the feature check to PF0 here?

Quoted 13 lines
drivers/pci/endpoint/pci-epc-core.c +9 -0
+	if (!epc_features)
+		return;
+
+	if (IS_ENABLED(CONFIG_PCI_ENDPOINT_DOE) && epc_features->doe_capable) {
+		pci_ep_doe_destroy(epc);
+		dev_dbg(&epc->dev, "DOE mailboxes destroyed\n");
+	}
+}
+
 /**
  * pci_epc_deinit_notify() - Notify the EPF device about EPC deinitialization
  * @epc: the EPC device whose deinitialization is completed

drivers/pci/endpoint/pci-epc-core.c void pci_epc_deinit_notify(struct pci_epc *epc) · line 997

Quoted 5 lines
drivers/pci/endpoint/pci-epc-core.c +2 -0
@@ -903,6 +993,8 @@ void pci_epc_deinit_notify(struct pci_epc *epc)
 	if (IS_ERR_OR_NULL(epc))
 		return;
 
+	pci_epc_deinit_capabilities(epc);
+

[Severity: Critical]
Can this cause a panic if pci_epc_deinit_notify() is called before pci_epc_init_notify()?

Some endpoint drivers (like pcie-qcom-ep) explicitly call the deinit notify on the first PERST deassertion before initialization. Because this unconditionally calls pci_epc_deinit_capabilities(), it will invoke xa_destroy() on an uninitialized xarray, potentially triggering a panic due to bad spinlock magic.

Would it be safer to check epc->init_complete first?

[Severity: High]
Does destroying the EPC capabilities before notifying the EPF drivers create a use-after-free risk? The underlying DOE mailboxes and workqueues are freed here, but the bound EPF drivers are still active and will only be notified to quiesce in the loop below.

Quoted 2 lines
drivers/pci/endpoint/pci-epc-core.c +0 -0
 	mutex_lock(&epc->list_lock);
 	list_for_each_entry(epf, &epc->pci_epf, list) {

[ ... ]

Quoted 4 lines
include/linux/pci-epc.h +0 -0
index dd26294c8175a..11474e337db33 100644

[ ... ]

include/linux/pci-epc.h struct pci_epc_ops { · line 121

Quoted 6 lines
include/linux/pci-epc.h +2 -0
@@ -115,6 +117,8 @@ struct pci_epc_ops {
 	void	(*stop)(struct pci_epc *epc);
 	const struct pci_epc_features* (*get_features)(struct pci_epc *epc,
 						       u8 func_no, u8 vfunc_no);
+	u16	(*find_ext_capability)(struct pci_epc *epc, u8 func_no,
+				       u8 vfunc_no, u16 start, u8 cap);

[Severity: Medium]
Will passing u8 for the cap parameter truncate 16-bit PCIe Extended Capability IDs? While PCI_EXT_CAP_ID_DOE fits in 8 bits, this API contract truncates any future standard or vendor-specific capability IDs > 255. Should the parameter be declared as u16 instead?

Quoted 2 lines
include/linux/pci-epc.h +0 -0
 	struct module *owner;
 };
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=3
author
#6 lore raw

PATCH v4 4/4 Documentation: PCI: Add documentation for DOE endpoint support

In reply to Aksh Garg

Document the architecture and implementation details for the Data Object Exchange (DOE) framework for PCIe Endpoint devices.

---

Changes from v3 to v4:
- Updated the maximum size of the DOE object from 256KB to 1MB, as per PCIe spec.
- Updated the DOE setup and cleanup sections.

Changes from v2 to v3:
- Rebased on 7.1-rc1.

Changes since v1:
- Squashed the patches [1] and [2], and moved the documentation file to Documentation/PCI/endpoint/pci-endpoint-doe.rst to match the existing naming scheme, as suggested by Niklas Cassel
- Updated the documentation as per the design and implementaion changes made to previous patches in this series:
* Updated for static protocol array instead of dynamic registration
* Documented asynchronous callback model
* Updated request/response flow with new callback signature
* Updated memory ownership: DOE core frees request, driver frees response
* Updated initialization and cleanup sections for new APIs

v3: https://lore.kernel.org/all/[email protected]/
v2: https://lore.kernel.org/all/[email protected]/
v1: [1] https://lore.kernel.org/all/[email protected]/

    [2] https://lore.kernel.org/all/[email protected]/
 Documentation/PCI/endpoint/index.rst          |   1 +
 .../PCI/endpoint/pci-endpoint-doe.rst         | 329 ++++++++++++++++++
 2 files changed, 330 insertions(+)
 create mode 100644 Documentation/PCI/endpoint/pci-endpoint-doe.rst
Documentation/PCI/endpoint/index.rst +1 -0
index dd1f62e731c9..7c03d5abd2ef 100644
@@ -9,6 +9,7 @@ PCI Endpoint Framework
 
    pci-endpoint
    pci-endpoint-cfs
+   pci-endpoint-doe
    pci-test-function
    pci-test-howto
    pci-ntb-function
Documentation/PCI/endpoint/pci-endpoint-doe.rst new file +329 -0

329 lines not on this page · raw message

Signature · 1 line
2.34.1