Skip to content

Commit 0821ff8

Browse files
l1kdjbw
authored andcommitted
PCI/DOE: Make asynchronous API private
A synchronous API for DOE has just been introduced. CXL (the only in-tree DOE user so far) was converted to use it instead of the asynchronous API. Consequently, pci_doe_submit_task() as well as the pci_doe_task struct are only used internally, so make them private. Tested-by: Ira Weiny <ira.weiny@intel.com> Signed-off-by: Lukas Wunner <lukas@wunner.de> Reviewed-by: Ming Li <ming4.li@intel.com> Reviewed-by: Ira Weiny <ira.weiny@intel.com> Reviewed-by: Jonathan Cameron <Jonathan.Cameron@huawei.com> Acked-by: Bjorn Helgaas <bhelgaas@google.com> Link: https://lore.kernel.org/r/cc19544068483681e91dfe27545c2180cd09f931.1678543498.git.lukas@wunner.de Signed-off-by: Dan Williams <dan.j.williams@intel.com>
1 parent 58709b9 commit 0821ff8

2 files changed

Lines changed: 43 additions & 50 deletions

File tree

drivers/pci/doe.c

Lines changed: 43 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,47 @@ struct pci_doe_mb {
5656
unsigned long flags;
5757
};
5858

59+
struct pci_doe_protocol {
60+
u16 vid;
61+
u8 type;
62+
};
63+
64+
/**
65+
* struct pci_doe_task - represents a single query/response
66+
*
67+
* @prot: DOE Protocol
68+
* @request_pl: The request payload
69+
* @request_pl_sz: Size of the request payload (bytes)
70+
* @response_pl: The response payload
71+
* @response_pl_sz: Size of the response payload (bytes)
72+
* @rv: Return value. Length of received response or error (bytes)
73+
* @complete: Called when task is complete
74+
* @private: Private data for the consumer
75+
* @work: Used internally by the mailbox
76+
* @doe_mb: Used internally by the mailbox
77+
*
78+
* The payload sizes and rv are specified in bytes with the following
79+
* restrictions concerning the protocol.
80+
*
81+
* 1) The request_pl_sz must be a multiple of double words (4 bytes)
82+
* 2) The response_pl_sz must be >= a single double word (4 bytes)
83+
* 3) rv is returned as bytes but it will be a multiple of double words
84+
*/
85+
struct pci_doe_task {
86+
struct pci_doe_protocol prot;
87+
const __le32 *request_pl;
88+
size_t request_pl_sz;
89+
__le32 *response_pl;
90+
size_t response_pl_sz;
91+
int rv;
92+
void (*complete)(struct pci_doe_task *task);
93+
void *private;
94+
95+
/* initialized by pci_doe_submit_task() */
96+
struct work_struct work;
97+
struct pci_doe_mb *doe_mb;
98+
};
99+
59100
static int pci_doe_wait(struct pci_doe_mb *doe_mb, unsigned long timeout)
60101
{
61102
if (wait_event_timeout(doe_mb->wq,
@@ -519,7 +560,8 @@ EXPORT_SYMBOL_GPL(pci_doe_supports_prot);
519560
*
520561
* RETURNS: 0 when task has been successfully queued, -ERRNO on error
521562
*/
522-
int pci_doe_submit_task(struct pci_doe_mb *doe_mb, struct pci_doe_task *task)
563+
static int pci_doe_submit_task(struct pci_doe_mb *doe_mb,
564+
struct pci_doe_task *task)
523565
{
524566
if (!pci_doe_supports_prot(doe_mb, task->prot.vid, task->prot.type))
525567
return -EINVAL;
@@ -540,7 +582,6 @@ int pci_doe_submit_task(struct pci_doe_mb *doe_mb, struct pci_doe_task *task)
540582
queue_work(doe_mb->work_queue, &task->work);
541583
return 0;
542584
}
543-
EXPORT_SYMBOL_GPL(pci_doe_submit_task);
544585

545586
/**
546587
* pci_doe() - Perform Data Object Exchange

include/linux/pci-doe.h

Lines changed: 0 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -13,55 +13,8 @@
1313
#ifndef LINUX_PCI_DOE_H
1414
#define LINUX_PCI_DOE_H
1515

16-
struct pci_doe_protocol {
17-
u16 vid;
18-
u8 type;
19-
};
20-
2116
struct pci_doe_mb;
2217

23-
/**
24-
* struct pci_doe_task - represents a single query/response
25-
*
26-
* @prot: DOE Protocol
27-
* @request_pl: The request payload
28-
* @request_pl_sz: Size of the request payload (bytes)
29-
* @response_pl: The response payload
30-
* @response_pl_sz: Size of the response payload (bytes)
31-
* @rv: Return value. Length of received response or error (bytes)
32-
* @complete: Called when task is complete
33-
* @private: Private data for the consumer
34-
* @work: Used internally by the mailbox
35-
* @doe_mb: Used internally by the mailbox
36-
*
37-
* Payloads are treated as opaque byte streams which are transmitted verbatim,
38-
* without byte-swapping. If payloads contain little-endian register values,
39-
* the caller is responsible for conversion with cpu_to_le32() / le32_to_cpu().
40-
*
41-
* The payload sizes and rv are specified in bytes with the following
42-
* restrictions concerning the protocol.
43-
*
44-
* 1) The request_pl_sz must be a multiple of double words (4 bytes)
45-
* 2) The response_pl_sz must be >= a single double word (4 bytes)
46-
* 3) rv is returned as bytes but it will be a multiple of double words
47-
*
48-
* NOTE there is no need for the caller to initialize work or doe_mb.
49-
*/
50-
struct pci_doe_task {
51-
struct pci_doe_protocol prot;
52-
const __le32 *request_pl;
53-
size_t request_pl_sz;
54-
__le32 *response_pl;
55-
size_t response_pl_sz;
56-
int rv;
57-
void (*complete)(struct pci_doe_task *task);
58-
void *private;
59-
60-
/* No need for the user to initialize these fields */
61-
struct work_struct work;
62-
struct pci_doe_mb *doe_mb;
63-
};
64-
6518
/**
6619
* pci_doe_for_each_off - Iterate each DOE capability
6720
* @pdev: struct pci_dev to iterate
@@ -76,7 +29,6 @@ struct pci_doe_task {
7629

7730
struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset);
7831
bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type);
79-
int pci_doe_submit_task(struct pci_doe_mb *doe_mb, struct pci_doe_task *task);
8032

8133
int pci_doe(struct pci_doe_mb *doe_mb, u16 vendor, u8 type,
8234
const void *request, size_t request_sz,

0 commit comments

Comments
 (0)