Skip to content

Commit 0a61ec9

Browse files
yishaihrleon
authored andcommitted
PCI/TPH: Expose pcie_tph_get_st_table_size()
Expose pcie_tph_get_st_table_size() to be used by drivers as will be done in the next patch from the series. Signed-off-by: Yishai Hadas <[email protected]> Acked-by: Bjorn Helgaas <[email protected]> Link: https://patch.msgid.link/9ae851e0ee42cc56d2a30276e116b65091030ceb.1752752567.git.leon@kernel.org Signed-off-by: Leon Romanovsky <[email protected]>
1 parent 9a0048e commit 0a61ec9

File tree

2 files changed

+7
-5
lines changed

2 files changed

+7
-5
lines changed

drivers/pci/tph.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ static u32 get_st_table_loc(struct pci_dev *pdev)
168168
* Return the size of ST table. If ST table is not in TPH Requester Extended
169169
* Capability space, return 0. Otherwise return the ST Table Size + 1.
170170
*/
171-
static u16 get_st_table_size(struct pci_dev *pdev)
171+
u16 pcie_tph_get_st_table_size(struct pci_dev *pdev)
172172
{
173173
u32 reg;
174174
u32 loc;
@@ -185,6 +185,7 @@ static u16 get_st_table_size(struct pci_dev *pdev)
185185

186186
return FIELD_GET(PCI_TPH_CAP_ST_MASK, reg) + 1;
187187
}
188+
EXPORT_SYMBOL(pcie_tph_get_st_table_size);
188189

189190
/* Return device's Root Port completer capability */
190191
static u8 get_rp_completer_type(struct pci_dev *pdev)
@@ -211,7 +212,7 @@ static int write_tag_to_st_table(struct pci_dev *pdev, int index, u16 tag)
211212
int offset;
212213

213214
/* Check if index is out of bound */
214-
st_table_size = get_st_table_size(pdev);
215+
st_table_size = pcie_tph_get_st_table_size(pdev);
215216
if (index >= st_table_size)
216217
return -ENXIO;
217218

@@ -443,7 +444,7 @@ void pci_restore_tph_state(struct pci_dev *pdev)
443444
pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++);
444445
st_entry = (u16 *)cap;
445446
offset = PCI_TPH_BASE_SIZEOF;
446-
num_entries = get_st_table_size(pdev);
447+
num_entries = pcie_tph_get_st_table_size(pdev);
447448
for (i = 0; i < num_entries; i++) {
448449
pci_write_config_word(pdev, pdev->tph_cap + offset,
449450
*st_entry++);
@@ -475,7 +476,7 @@ void pci_save_tph_state(struct pci_dev *pdev)
475476
/* Save all ST entries in extended capability structure */
476477
st_entry = (u16 *)cap;
477478
offset = PCI_TPH_BASE_SIZEOF;
478-
num_entries = get_st_table_size(pdev);
479+
num_entries = pcie_tph_get_st_table_size(pdev);
479480
for (i = 0; i < num_entries; i++) {
480481
pci_read_config_word(pdev, pdev->tph_cap + offset,
481482
st_entry++);
@@ -499,7 +500,7 @@ void pci_tph_init(struct pci_dev *pdev)
499500
if (!pdev->tph_cap)
500501
return;
501502

502-
num_entries = get_st_table_size(pdev);
503+
num_entries = pcie_tph_get_st_table_size(pdev);
503504
save_size = sizeof(u32) + num_entries * sizeof(u16);
504505
pci_add_ext_cap_save_buffer(pdev, PCI_EXT_CAP_ID_TPH, save_size);
505506
}

include/linux/pci-tph.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ int pcie_tph_get_cpu_st(struct pci_dev *dev,
2828
unsigned int cpu_uid, u16 *tag);
2929
void pcie_disable_tph(struct pci_dev *pdev);
3030
int pcie_enable_tph(struct pci_dev *pdev, int mode);
31+
u16 pcie_tph_get_st_table_size(struct pci_dev *pdev);
3132
#else
3233
static inline int pcie_tph_set_st_entry(struct pci_dev *pdev,
3334
unsigned int index, u16 tag)

0 commit comments

Comments
 (0)