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

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: 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/64f614b6584982986c55d2c6229b4ee2b276dd59.1678543498.git.lukas@wunner.de
Signed-off-by: Dan Williams <dan.j.williams@intel.com>

authored by

Lukas Wunner and committed by
Dan Williams
74e491e5 af0a6c35

+4 -52
-1
.clang-format
··· 520 520 - 'of_property_for_each_string' 521 521 - 'of_property_for_each_u32' 522 522 - 'pci_bus_for_each_resource' 523 - - 'pci_doe_for_each_off' 524 523 - 'pcl_for_each_chunk' 525 524 - 'pcl_for_each_segment' 526 525 - 'pcm_for_each_format'
+4 -37
drivers/pci/doe.c
··· 455 455 xa_init(&doe_mb->prots); 456 456 457 457 doe_mb->work_queue = alloc_ordered_workqueue("%s %s DOE [%x]", 0, 458 - dev_driver_string(&pdev->dev), 458 + dev_bus_name(&pdev->dev), 459 459 pci_name(pdev), 460 460 doe_mb->cap_offset); 461 461 if (!doe_mb->work_queue) { ··· 499 499 /** 500 500 * pci_doe_destroy_mb() - Destroy a DOE mailbox object 501 501 * 502 - * @ptr: Pointer to DOE mailbox 502 + * @doe_mb: DOE mailbox 503 503 * 504 504 * Destroy all internal data structures created for the DOE mailbox. 505 505 */ 506 - static void pci_doe_destroy_mb(void *ptr) 506 + static void pci_doe_destroy_mb(struct pci_doe_mb *doe_mb) 507 507 { 508 - struct pci_doe_mb *doe_mb = ptr; 509 - 510 508 pci_doe_cancel_tasks(doe_mb); 511 509 xa_destroy(&doe_mb->prots); 512 510 destroy_workqueue(doe_mb->work_queue); 513 511 kfree(doe_mb); 514 512 } 515 - 516 - /** 517 - * pcim_doe_create_mb() - Create a DOE mailbox object 518 - * 519 - * @pdev: PCI device to create the DOE mailbox for 520 - * @cap_offset: Offset of the DOE mailbox 521 - * 522 - * Create a single mailbox object to manage the mailbox protocol at the 523 - * cap_offset specified. The mailbox will automatically be destroyed on 524 - * driver unbinding from @pdev. 525 - * 526 - * RETURNS: created mailbox object on success 527 - * ERR_PTR(-errno) on failure 528 - */ 529 - struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset) 530 - { 531 - struct pci_doe_mb *doe_mb; 532 - int rc; 533 - 534 - doe_mb = pci_doe_create_mb(pdev, cap_offset); 535 - if (IS_ERR(doe_mb)) 536 - return doe_mb; 537 - 538 - rc = devm_add_action_or_reset(&pdev->dev, pci_doe_destroy_mb, doe_mb); 539 - if (rc) 540 - return ERR_PTR(rc); 541 - 542 - return doe_mb; 543 - } 544 - EXPORT_SYMBOL_GPL(pcim_doe_create_mb); 545 513 546 514 /** 547 515 * pci_doe_supports_prot() - Return if the DOE instance supports the given ··· 520 552 * 521 553 * RETURNS: True if the DOE mailbox supports the protocol specified 522 554 */ 523 - bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type) 555 + static bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type) 524 556 { 525 557 unsigned long index; 526 558 void *entry; ··· 535 567 536 568 return false; 537 569 } 538 - EXPORT_SYMBOL_GPL(pci_doe_supports_prot); 539 570 540 571 /** 541 572 * pci_doe_submit_task() - Submit a task to be processed by the state machine
-14
include/linux/pci-doe.h
··· 15 15 16 16 struct pci_doe_mb; 17 17 18 - /** 19 - * pci_doe_for_each_off - Iterate each DOE capability 20 - * @pdev: struct pci_dev to iterate 21 - * @off: u16 of config space offset of each mailbox capability found 22 - */ 23 - #define pci_doe_for_each_off(pdev, off) \ 24 - for (off = pci_find_next_ext_capability(pdev, off, \ 25 - PCI_EXT_CAP_ID_DOE); \ 26 - off > 0; \ 27 - off = pci_find_next_ext_capability(pdev, off, \ 28 - PCI_EXT_CAP_ID_DOE)) 29 - 30 - struct pci_doe_mb *pcim_doe_create_mb(struct pci_dev *pdev, u16 cap_offset); 31 - bool pci_doe_supports_prot(struct pci_doe_mb *doe_mb, u16 vid, u8 type); 32 18 struct pci_doe_mb *pci_find_doe_mailbox(struct pci_dev *pdev, u16 vendor, 33 19 u8 type); 34 20