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, ®); 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, ®); in get_st_modes()
162 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); in get_st_table_loc()
184 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); in get_st_table_size()
207 /* Write ST to MSI-X vector control reg - Return 0 if OK, otherwise -errno */
216 msi_lock_descs(&pdev->dev); in write_tag_to_msix()
219 msi_for_each_desc(msi_desc, &pdev->dev, MSI_DESC_ASSOCIATED) { in write_tag_to_msix()
220 if (msi_desc->msi_index == msix_idx) in write_tag_to_msix()
225 err = -ENXIO; in write_tag_to_msix()
230 vec_ctrl = pdev->msix_base + msix_idx * PCI_MSIX_ENTRY_SIZE; in write_tag_to_msix()
242 msi_unlock_descs(&pdev->dev); in write_tag_to_msix()
245 return -ENODEV; in write_tag_to_msix()
249 /* Write tag to ST table - Return 0 if OK, otherwise -errno */
258 return -ENXIO; in write_tag_to_st_table()
260 offset = pdev->tph_cap + PCI_TPH_BASE_SIZEOF + index * sizeof(u16); in write_tag_to_st_table()
266 * pcie_tph_get_cpu_st() - Retrieve Steering Tag for a target memory associated
267 * with a specific CPU
274 * specific CPU as indicated by cpu_uid.
276 * Return: 0 if success, otherwise negative value (-errno)
287 if (!rp || !rp->bus || !rp->bus->bridge) in pcie_tph_get_cpu_st()
288 return -ENODEV; in pcie_tph_get_cpu_st()
290 rp_acpi_handle = ACPI_HANDLE(rp->bus->bridge); in pcie_tph_get_cpu_st()
294 return -EINVAL; in pcie_tph_get_cpu_st()
297 *tag = tph_extract_tag(mem_type, pdev->tph_req_type, &info); in pcie_tph_get_cpu_st()
305 return -ENODEV; in pcie_tph_get_cpu_st()
311 * pcie_tph_set_st_entry() - Set Steering Tag in the ST table entry
316 * Figure out the proper location of ST table, either in the MSI-X table or
320 * Return: 0 if success, otherwise negative value (-errno)
327 if (!pdev->tph_cap) in pcie_tph_set_st_entry()
328 return -EINVAL; in pcie_tph_set_st_entry()
330 if (!pdev->tph_enabled) in pcie_tph_set_st_entry()
331 return -EINVAL; in pcie_tph_set_st_entry()
334 if (pdev->tph_mode == PCI_TPH_ST_NS_MODE) in pcie_tph_set_st_entry()
355 err = -EINVAL; in pcie_tph_set_st_entry()
363 set_ctrl_reg_req_en(pdev, pdev->tph_req_type); in pcie_tph_set_st_entry()
366 (loc == PCI_TPH_LOC_MSIX) ? "MSI-X" : "ST", index, tag); in pcie_tph_set_st_entry()
373 * pcie_disable_tph - Turn off TPH support for device
380 if (!pdev->tph_cap) in pcie_disable_tph()
383 if (!pdev->tph_enabled) in pcie_disable_tph()
386 pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, 0); in pcie_disable_tph()
388 pdev->tph_mode = 0; in pcie_disable_tph()
389 pdev->tph_req_type = 0; in pcie_disable_tph()
390 pdev->tph_enabled = 0; in pcie_disable_tph()
395 * pcie_enable_tph - Enable TPH support for device using a specific ST mode
399 * - PCI_TPH_ST_NS_MODE: NO ST Mode
400 * - PCI_TPH_ST_IV_MODE: Interrupt Vector Mode
401 * - PCI_TPH_ST_DS_MODE: Device Specific Mode
408 * Return: 0 on success, otherwise negative value (-errno)
418 return -EINVAL; in pcie_enable_tph()
420 if (!pdev->tph_cap) in pcie_enable_tph()
421 return -EINVAL; in pcie_enable_tph()
423 if (pdev->tph_enabled) in pcie_enable_tph()
424 return -EBUSY; in pcie_enable_tph()
430 return -EINVAL; in pcie_enable_tph()
432 pdev->tph_mode = mode; in pcie_enable_tph()
435 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CAP, ®); in pcie_enable_tph()
437 pdev->tph_req_type = PCI_TPH_REQ_EXT_TPH; in pcie_enable_tph()
439 pdev->tph_req_type = PCI_TPH_REQ_TPH_ONLY; in pcie_enable_tph()
444 pdev->tph_req_type = min(pdev->tph_req_type, rp_req_type); in pcie_enable_tph()
446 if (pdev->tph_req_type == PCI_TPH_REQ_DISABLE) in pcie_enable_tph()
447 return -EINVAL; in pcie_enable_tph()
450 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, ®); in pcie_enable_tph()
453 reg |= FIELD_PREP(PCI_TPH_CTRL_MODE_SEL_MASK, pdev->tph_mode); in pcie_enable_tph()
456 reg |= FIELD_PREP(PCI_TPH_CTRL_REQ_EN_MASK, pdev->tph_req_type); in pcie_enable_tph()
458 pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, reg); in pcie_enable_tph()
460 pdev->tph_enabled = 1; in pcie_enable_tph()
473 if (!pdev->tph_cap) in pci_restore_tph_state()
476 if (!pdev->tph_enabled) in pci_restore_tph_state()
484 cap = &save_state->cap.data[0]; in pci_restore_tph_state()
485 pci_write_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, *cap++); in pci_restore_tph_state()
490 pci_write_config_word(pdev, pdev->tph_cap + offset, in pci_restore_tph_state()
503 if (!pdev->tph_cap) in pci_save_tph_state()
506 if (!pdev->tph_enabled) in pci_save_tph_state()
514 cap = &save_state->cap.data[0]; in pci_save_tph_state()
515 pci_read_config_dword(pdev, pdev->tph_cap + PCI_TPH_CTRL, cap++); in pci_save_tph_state()
522 pci_read_config_word(pdev, pdev->tph_cap + offset, in pci_save_tph_state()
540 pdev->tph_cap = pci_find_ext_capability(pdev, PCI_EXT_CAP_ID_TPH); in pci_tph_init()
541 if (!pdev->tph_cap) in pci_tph_init()