Skip to content

Commit

Permalink
PCI/DOE: Support discovery version 2
Browse files Browse the repository at this point in the history
PCIe r6.1, sec 6.30.1.1 defines a "DOE Discovery Version" field in
the DOE Discovery Request Data Object Contents (3rd DW) as:

15:8 DOE Discovery Version – must be 02h if the Capability Version in
the Data Object Exchange Extended Capability is 02h or greater.

Add support for the version on devices with the DOE v2 capability.

Signed-off-by: Alexey Kardashevskiy <aik@amd.com>
---
Changes:
v3:
* updated subject line
* dropped "DISCOVER_" from the new field macro

v2:
* added the section number to the commit log
  • Loading branch information
aik committed Apr 16, 2024
1 parent d0f29ec commit be8cd8c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions drivers/pci/doe.c
Original file line number Diff line number Diff line change
Expand Up @@ -381,11 +381,13 @@ static void pci_doe_task_complete(struct pci_doe_task *task)
complete(task->private);
}

static int pci_doe_discovery(struct pci_doe_mb *doe_mb, u8 *index, u16 *vid,
static int pci_doe_discovery(struct pci_doe_mb *doe_mb, u8 capver, u8 *index, u16 *vid,
u8 *protocol)
{
u32 request_pl = FIELD_PREP(PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX,
*index);
*index) |
FIELD_PREP(PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER,
(capver >= 2) ? 2 : 0);
__le32 request_pl_le = cpu_to_le32(request_pl);
__le32 response_pl_le;
u32 response_pl;
Expand Down Expand Up @@ -419,13 +421,16 @@ static int pci_doe_cache_protocols(struct pci_doe_mb *doe_mb)
{
u8 index = 0;
u8 xa_idx = 0;
u32 hdr = 0;

pci_read_config_dword(doe_mb->pdev, doe_mb->cap_offset, &hdr);

do {
int rc;
u16 vid;
u8 prot;

rc = pci_doe_discovery(doe_mb, &index, &vid, &prot);
rc = pci_doe_discovery(doe_mb, PCI_EXT_CAP_VER(hdr), &index, &vid, &prot);
if (rc)
return rc;

Expand Down
1 change: 1 addition & 0 deletions include/uapi/linux/pci_regs.h
Original file line number Diff line number Diff line change
Expand Up @@ -1144,6 +1144,7 @@
#define PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH 0x0003ffff

#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX 0x000000ff
#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER 0x0000ff00
#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID 0x0000ffff
#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000
#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000
Expand Down

0 comments on commit be8cd8c

Please sign in to comment.