PCI/IDE: Add Address Association Register setup for downstream MMIO
PATCH v2 1/1 PCI/IDE: Add Address Association Register setup for downstream MMIO
Add Address Association Register setup for downstream MMIO
The address ranges for RP side Address Association Registers should cover memory addresses for all PFs/VFs/downstream devices of the DSM device. A simple solution is to get the aggregated memory range and prefetchable-memory range from directly connected downstream port (either an RP or a switch port) and set into 2 Address Association Register blocks.
Just like RID association, address associations will be set by default if hardware sets 'Number of Address Association Register Blocks' in the 'Selective IDE Stream Capability Register' to a non-zero value. Alternatively, TSM drivers can opt-out of the settings by zero'ing out the probed region.
If the directly connected downstream port provides both memory range and prefetchable-memory range but the platform only provides 1 Address Association Register block then setup the former first. This follows the PCI bridge specification precedent where memory is mandatory and prefetchable-memory is optional. Priortize the mandatory one. If the platform can't fit into the default setup, TSM drivers can always change the setting before setup. E.g. zero'ing out the memory range so that prefetchable-memory range could be setup.
The Address Association Register setup for Endpoint Side is still uncertain so isn't supported in this patch.
--- include/linux/ioport.h | 6 +++ include/linux/pci-ide.h | 27 ++++++++++ include/linux/pci.h | 5 ++ drivers/pci/ide.c | 115 ++++++++++++++++++++++++++++++++++++---- 4 files changed, 144 insertions(+), 9 deletions(-)
include/linux/ioport.h +6 -0
@@ -336,6 +336,12 @@ static inline bool resource_union(const struct resource *r1, const struct resourreturn true; } +/* Check if this resource is added to a resource tree or detached. */ +static inline bool resource_assigned (struct resource *res) +{ +return res->parent; +} +int find_resource_space (struct resource *root,struct resource *new,resource_size_t size,struct resource_constraint *constraint);
include/linux/pci-ide.h +27 -0
@@ -24,6 +24,9 @@ enum pci_ide_partner_select {* @rid_start: Partner Port Requester ID range start * @rid_start: Partner Port Requester ID range end * @stream_index: Selective IDE Stream Register Block selection +* @mem_assoc: PCI bus memory address association for targeting peer partner +* @pref_assoc: (optional) PCI bus prefetchable memory address association for +* targeting peer partner * @default_stream: Endpoint uses this stream for all upstream TLPs regardless of * address and RID association registers * @setup: flag to track whether to run pci_ide_stream_teardown() for this
@@ -34,11 +37,35 @@ struct pci_ide_partner {u16 rid_start;u16 rid_end;u8 stream_index; +struct pci_bus_region mem_assoc; +struct pci_bus_region pref_assoc; unsigned int default_stream:1; unsigned int setup:1; unsigned int enable:1; }; +/** +* struct pci_ide_regs - Hardware register association settings for Selective +* IDE Streams +* @rid_1: IDE RID Association Register 1 +* @rid_2: IDE RID Association Register 2 +* @addr: Up to two address association blocks (IDE Address Association Register +* 1 through 3) for MMIO and prefetchable MMIO +* @nr_addr: Number of address association blocks initialized +* +* See pci_ide_stream_to_regs() +*/ +struct pci_ide_regs { +u32 rid_1; +u32 rid_2; +struct { +u32 assoc1; +u32 assoc2; +u32 assoc3; + } addr[2 ]; +int nr_addr; +}; +/** * struct pci_ide - PCIe Selective IDE Stream descriptor * @pdev: PCIe Endpoint in the pci_ide_partner pair
include/linux/pci.h +5 -0
@@ -877,6 +877,11 @@ struct pci_bus_region {pci_bus_addr_t end; }; +static inline pci_bus_addr_t pci_bus_region_size (const struct pci_bus_region *region) +{ +return region->end - region->start +1 ; +} +struct pci_dynids {spinlock_t lock;/* Protects list, index */ struct list_head list;/* For IDs added at runtime */
drivers/pci/ide.c +106 -9
172 lines not on this page · raw message
Signature · 1 line
2.25.1
Quoted 24 lines · Xu Yilun
Add Address Association Register setup for downstream MMIO
The address ranges for RP side Address Association Registers should cover memory addresses for all PFs/VFs/downstream devices of the DSM device. A simple solution is to get the aggregated memory range and prefetchable-memory range from directly connected downstream port (either an RP or a switch port) and set into 2 Address Association Register blocks.
Just like RID association, address associations will be set by default if hardware sets 'Number of Address Association Register Blocks' in the 'Selective IDE Stream Capability Register' to a non-zero value. Alternatively, TSM drivers can opt-out of the settings by zero'ing out the probed region.
If the directly connected downstream port provides both memory range and prefetchable-memory range but the platform only provides 1 Address Association Register block then setup the former first. This follows the PCI bridge specification precedent where memory is mandatory and prefetchable-memory is optional. Priortize the mandatory one. If the platform can't fit into the default setup, TSM drivers can always change the setting before setup. E.g. zero'ing out the memory range so that prefetchable-memory range could be setup.
Quoted 2 lines
The Address Association Register setup for Endpoint Side is still uncertain so isn't supported in this patch.
This looks good Yilun. I will append it to the end of the v7 posting of the PCI/TSM base series.
I will likely split the resource_assigned() introduction to its own patch with a Link: to the rationale provided by Ilpo, and perform some other small fixups. Like I notice I defined the rid registers as rid_X and the address association registers as assocX, so I'll drop the "_".