Lines Matching +full:locality +full:- +full:specific

1 // SPDX-License-Identifier: GPL-2.0
10 #include <linux/pci-acpi.h>
13 #include <linux/pci-tph.h>
17 /* System-wide TPH disabled */
24 * Locality TPH Features"), as specified in the approved ECN for PCI Firmware
25 * Spec and available at https://members.pcisig.com/wg/PCI-SIG/document/15470.
27 * @vm_st_valid: 8-bit ST for volatile memory is valid
28 * @vm_xst_valid: 16-bit extended ST for volatile memory is valid
30 * @vm_st: 8-bit ST for volatile mem
31 * @vm_xst: 16-bit extended ST for volatile mem
32 * @pm_st_valid: 8-bit ST for persistent memory is valid
33 * @pm_xst_valid: 16-bit extended ST for persistent memory is valid
35 * @pm_st: 8-bit ST for persistent mem
36 * @pm_xst: 16-bit extended ST for persistent mem
60 case PCI_TPH_REQ_TPH_ONLY: /* 8-bit tag */ in tph_extract_tag()
63 if (info->vm_st_valid) in tph_extract_tag()
64 return info->vm_st; in tph_extract_tag()
67 if (info->pm_st_valid) in tph_extract_tag()
68 return info->pm_st; in tph_extract_tag()
72 case PCI_TPH_REQ_EXT_TPH: /* 16-bit tag */ in tph_extract_tag()
75 if (info->vm_xst_valid) in tph_extract_tag()
76 return info->vm_xst; in tph_extract_tag()
79 if (info->pm_xst_valid) in tph_extract_tag()
80 return info->pm_xst; in tph_extract_tag()
122 if (out_obj->type != ACPI_TYPE_BUFFER) { in tph_invoke_dsm()
127 st_out->value = *((u64 *)(out_obj->buffer.pointer)); in tph_invoke_dsm()
140 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, &reg); in set_ctrl_reg_req_en()
145 pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); in set_ctrl_reg_req_en()
152 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, &reg); in get_st_modes()
159 * pcie_tph_get_st_table_loc - Return the device's ST table location
163 * PCI_TPH_LOC_NONE - Not present
164 * PCI_TPH_LOC_CAP - Located in the TPH Requester Extended Capability
165 * PCI_TPH_LOC_MSIX - Located in the MSI-X Table
171 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, &reg); in pcie_tph_get_st_table_loc()
194 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, &reg); in pcie_tph_get_st_table_size()
218 /* Write tag to ST table - Return 0 if OK, otherwise -errno */
227 return -ENXIO; in write_tag_to_st_table()
229 offset = pdev->tph_cap + PCI_TPH_BASE_SIZEOF + index * sizeof(u16); in write_tag_to_st_table()
235 * pcie_tph_get_cpu_st() - Retrieve Steering Tag for a target memory associated
236 * with a specific CPU
243 * specific CPU as indicated by cpu_uid.
245 * Return: 0 if success, otherwise negative value (-errno)
256 if (!rp || !rp->bus || !rp->bus->bridge) in pcie_tph_get_cpu_st()
257 return -ENODEV; in pcie_tph_get_cpu_st()
259 rp_acpi_handle = ACPI_HANDLE(rp->bus->bridge); in pcie_tph_get_cpu_st()
263 return -EINVAL; in pcie_tph_get_cpu_st()
266 *tag = tph_extract_tag(mem_type, pdev->tph_req_type, &info); in pcie_tph_get_cpu_st()
274 return -ENODEV; in pcie_tph_get_cpu_st()
280 * pcie_tph_set_st_entry() - Set Steering Tag in the ST table entry
285 * Figure out the proper location of ST table, either in the MSI-X table or
289 * Return: 0 if success, otherwise negative value (-errno)
296 if (!pdev->tph_cap) in pcie_tph_set_st_entry()
297 return -EINVAL; in pcie_tph_set_st_entry()
299 if (!pdev->tph_enabled) in pcie_tph_set_st_entry()
300 return -EINVAL; in pcie_tph_set_st_entry()
303 if (pdev->tph_mode == PCI_TPH_ST_NS_MODE) in pcie_tph_set_st_entry()
324 err = -EINVAL; in pcie_tph_set_st_entry()
332 set_ctrl_reg_req_en(pdev, pdev->tph_req_type); in pcie_tph_set_st_entry()
335 (loc == PCI_TPH_LOC_MSIX) ? "MSI-X" : "ST", index, tag); in pcie_tph_set_st_entry()
342 * pcie_disable_tph - Turn off TPH support for device
349 if (!pdev->tph_cap) in pcie_disable_tph()
352 if (!pdev->tph_enabled) in pcie_disable_tph()
355 pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, 0); in pcie_disable_tph()
357 pdev->tph_mode = 0; in pcie_disable_tph()
358 pdev->tph_req_type = 0; in pcie_disable_tph()
359 pdev->tph_enabled = 0; in pcie_disable_tph()
364 * pcie_enable_tph - Enable TPH support for device using a specific ST mode
368 * - PCI_TPH_ST_NS_MODE: NO ST Mode
369 * - PCI_TPH_ST_IV_MODE: Interrupt Vector Mode
370 * - PCI_TPH_ST_DS_MODE: Device Specific Mode
377 * Return: 0 on success, otherwise negative value (-errno)
387 return -EINVAL; in pcie_enable_tph()
389 if (!pdev->tph_cap) in pcie_enable_tph()
390 return -EINVAL; in pcie_enable_tph()
392 if (pdev->tph_enabled) in pcie_enable_tph()
393 return -EBUSY; in pcie_enable_tph()
399 return -EINVAL; in pcie_enable_tph()
401 pdev->tph_mode = mode; in pcie_enable_tph()
404 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, &reg); in pcie_enable_tph()
406 pdev->tph_req_type = PCI_TPH_REQ_EXT_TPH; in pcie_enable_tph()
408 pdev->tph_req_type = PCI_TPH_REQ_TPH_ONLY; in pcie_enable_tph()
413 pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type); in pcie_enable_tph()
415 if (pdev->tph_req_type == PCI_TPH_REQ_DISABLE) in pcie_enable_tph()
416 return -EINVAL; in pcie_enable_tph()
419 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, &reg); in pcie_enable_tph()
422 reg |= FIELD_PREP(PCI_TPH_CTRL_MODE_SEL_MASK, pdev->tph_mode); in pcie_enable_tph()
425 reg |= FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, pdev->tph_req_type); in pcie_enable_tph()
427 pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); in pcie_enable_tph()
429 pdev->tph_enabled = 1; in pcie_enable_tph()
442 if (!pdev->tph_cap) in pci_restore_tph_state()
445 if (!pdev->tph_enabled) in pci_restore_tph_state()
453 cap = &save_state->cap.data[0]; in pci_restore_tph_state()
454 pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++); in pci_restore_tph_state()
459 pci_write_config_word(pdev, pdev->tph_cap + offset, in pci_restore_tph_state()
472 if (!pdev->tph_cap) in pci_save_tph_state()
475 if (!pdev->tph_enabled) in pci_save_tph_state()
483 cap = &save_state->cap.data[0]; in pci_save_tph_state()
484 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, cap++); in pci_save_tph_state()
491 pci_read_config_word(pdev, pdev->tph_cap + offset, in pci_save_tph_state()
509 pdev->tph_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_TPH); in pci_tph_init()
510 if (!pdev->tph_cap) in pci_tph_init()