Commit 74e491e5 authored by Lukas Wunner's avatar Lukas Wunner Committed by Dan Williams

PCI/DOE: Make mailbox creation API private

The PCI core has just been amended to create a pci_doe_mb struct for
every DOE instance on device enumeration.  CXL (the only in-tree DOE
user so far) has been migrated to use those mailboxes instead of
creating its own.

That leaves pcim_doe_create_mb() and pci_doe_for_each_off() without any
callers, so drop them.

pci_doe_supports_prot() is now only used internally, so declare it
static.

pci_doe_destroy_mb() is no longer used as callback for
devm_add_action(), so refactor it to accept a struct pci_doe_mb pointer
instead of a generic void pointer.

Because pci_doe_create_mb() is only called on device enumeration, i.e.
before driver binding, the workqueue name never contains a driver name.
So replace dev_driver_string() with dev_bus_name() when generating the
workqueue name.
Tested-by: default avatarIra Weiny <ira.weiny@intel.com>
Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
Reviewed-by: default avatarMing Li <ming4.li@intel.com>
Reviewed-by: default avatarIra Weiny <ira.weiny@intel.com>
Reviewed-by: default avatarJonathan Cameron <Jonathan.Cameron@huawei.com>
Acked-by: default avatarBjorn Helgaas <bhelgaas@google.com>
Link: https://lore.kernel.org/r/64f614b6584982986c55d2c6229b4ee2b276dd59.1678543498.git.lukas@wunner.deSigned-off-by: default avatarDan Williams <dan.j.williams@intel.com>
parent af0a6c35
...@@ -520,7 +520,6 @@ ForEachMacros: ...@@ -520,7 +520,6 @@ ForEachMacros:
- 'of_property_for_each_string' - 'of_property_for_each_string'
- 'of_property_for_each_u32' - 'of_property_for_each_u32'
- 'pci_bus_for_each_resource' - 'pci_bus_for_each_resource'
- 'pci_doe_for_each_off'
- 'pcl_for_each_chunk' - 'pcl_for_each_chunk'
- 'pcl_for_each_segment' - 'pcl_for_each_segment'
- 'pcm_for_each_format' - 'pcm_for_each_format'
......
...@@ -455,7 +455,7 @@ static struct pci_doe_mb *pci_doe_create_mb(struct pci_dev *pdev, ...@@ -455,7 +455,7 @@ static struct pci_doe_mb *pci_doe_create_mb(struct pci_dev *pdev,
xa_init(&doe_mb->prots); xa_init(&doe_mb->prots);
doe_mb->work_queue = alloc_ordered_workqueue("%s %s DOE [%x]", 0, doe_mb->work_queue = alloc_ordered_workqueue("%s %s DOE [%x]", 0,
dev_driver_string(&pdev->dev), dev_bus_name(&pdev->dev),
pci_name(pdev), pci_name(pdev),
doe_mb->cap_offset); doe_mb->cap_offset);
if (!doe_mb->work_queue) { if (!doe_mb->work_queue) {
...@@ -499,50 +499,18 @@ static struct pci_doe_mb *pci_doe_create_mb(struct pci_dev *pdev, ...@@ -499,50 +499,18 @@ static struct pci_doe_mb *pci_doe_create_mb(struct pci_dev *pdev,
/** /**
* pci_doe_destroy_mb() - Destroy a DOE mailbox object * pci_doe_destroy_mb() - Destroy a DOE mailbox object
* *
* @ptr: Pointer to DOE mailbox * @doe_mb: DOE mailbox
* *
* Destroy all internal data structures created for the DOE mailbox. * Destroy all internal data structures created for the DOE mailbox.
*/ */
static void pci_doe_destroy_mb(void *ptr) static void pci_doe_destroy_mb(struct pci_doe_mb *doe_mb)
{ {
struct pci_doe_mb *doe_mb = ptr;
pci_doe_cancel_tasks(doe_mb); pci_doe_cancel_tasks(doe_mb);
xa_destroy(&doe_mb->prots); xa_destroy(&doe_mb->prots);
destroy_workqueue(doe_mb->work_queue); destroy_workqueue(doe_mb->work_queue);
kfree(doe_mb); kfree(doe_mb);
} }
/**
* pcim_doe_create_mb() - Create a DOE mailbox object
*
* @pdev: PCI device to create the DOE mailbox for
* @cap_offset: Offset of the DOE mailbox
*
* Create a single mailbox object to manage the mailbox protocol at the
* cap_offset specified. The mailbox will automatically be destroyed on
* driver unbinding from @pdev.
*
* RETURNS: created mailbox object on success
* ERR_PTR(-errno) on failure
*/
struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset)
{
struct pci_doe_mb *doe_mb;
int rc;
doe_mb = pci_doe_create_mb(pdev, cap_offset);
if (IS_ERR(doe_mb))
return doe_mb;
rc = devm_add_action_or_reset(&pdev->dev, pci_doe_destroy_mb, doe_mb);
if (rc)
return ERR_PTR(rc);
return doe_mb;
}
EXPORT_SYMBOL_GPL(pcim_doe_create_mb);
/** /**
* pci_doe_supports_prot() - Return if the DOE instance supports the given * pci_doe_supports_prot() - Return if the DOE instance supports the given
* protocol * protocol
...@@ -552,7 +520,7 @@ EXPORT_SYMBOL_GPL(pcim_doe_create_mb); ...@@ -552,7 +520,7 @@ EXPORT_SYMBOL_GPL(pcim_doe_create_mb);
* *
* RETURNS: True if the DOE mailbox supports the protocol specified * RETURNS: True if the DOE mailbox supports the protocol specified
*/ */
bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type) static bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type)
{ {
unsigned long index; unsigned long index;
void *entry; void *entry;
...@@ -567,7 +535,6 @@ bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type) ...@@ -567,7 +535,6 @@ bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type)
return false; return false;
} }
EXPORT_SYMBOL_GPL(pci_doe_supports_prot);
/** /**
* pci_doe_submit_task() - Submit a task to be processed by the state machine * pci_doe_submit_task() - Submit a task to be processed by the state machine
......
...@@ -15,20 +15,6 @@ ...@@ -15,20 +15,6 @@
struct pci_doe_mb; struct pci_doe_mb;
/**
* pci_doe_for_each_off - Iterate each DOE capability
* @pdev: struct pci_dev to iterate
* @off: u16 of config space offset of each mailbox capability found
*/
#define pci_doe_for_each_off(pdev, off) \
for (off = pci_find_next_ext_capability(pdev, off, \
PCI_EXT_CAP_ID_DOE); \
off > 0; \
off = pci_find_next_ext_capability(pdev, off, \
PCI_EXT_CAP_ID_DOE))
struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset);
bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type);
struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor, struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor,
u8 type); u8 type);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment