Vmd pch rootbus#3
Conversation
e6e2d3d to
893f31f
Compare
mtkaczyk
left a comment
There was a problem hiding this comment.
patch 1 review
for title I suggest to remove reference to Intel CPU code number (not needed here):
PCI: vmd: Clean up vmd_enable_domain function
This function is too long and needs to be shortened to make it more readable.
This clean up is a prework for enablement additional VMD bus range. It doesn't change
Functional behavior of vmd_enable_domain().
Suggested-by: Nirmal Patel <nirmal.patel@linux.intel.com>
Signed-off-by: Szymon Durawa <szymon.durawa@linux.intel.com>
typo beahvior
| VMD_RESOURCE_COUNT | ||
| }; | ||
|
|
||
| enum vmd_rootbus { VMD_ROOTBUS_0 = 0, VMD_ROOTBUS_COUNT }; |
There was a problem hiding this comment.
I've never seen something like that before, probably visual formatting.
| { | ||
| u16 bus, max_buses = resource_size(&vmd->resources[0]); | ||
| u16 bus, | ||
| max_buses = resource_size(&vmd->resources[VMD_RESOURCE_CFGBAR]); |
There was a problem hiding this comment.
not acceptable:
| max_buses = resource_size(&vmd->resources[VMD_RESOURCE_CFGBAR]); | |
| u16 bus; | |
| u16 max_buses = resource_size(&vmd->resources[VMD_RESOURCE_CFGBAR]); |
| vmd->dev->resource[VMD_MEMBAR1].child = &vmd->resources[1]; | ||
| vmd->dev->resource[VMD_MEMBAR2].child = &vmd->resources[2]; | ||
| vmd->dev->resource[VMD_MEMBAR1].child = | ||
| &vmd->resources[VMD_RESOURCE_MEMBAR_1]; |
There was a problem hiding this comment.
For sure, it is badly formatted.
| &vmd->resources[VMD_RESOURCE_MEMBAR_1]; | |
| struct x *vmd_membar1_res=&vmd->dev->resource[VMD_MEMBAR1]; | |
| struct x *vmd_membar2_res =&vmd->dev->resource[VMD_MEMBAR2]; | |
| vmd_membar1_res->child =&vmd->dev->resource[VMD_MEMBAR1]; | |
| vmd_membar2_res->child =&vmd->dev->resource[VMD_MEMBAR2]; |
| static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features) | ||
| static void vmd_configure_cfgbar(struct vmd_dev *vmd) | ||
| { | ||
| struct resource *res; |
There was a problem hiding this comment.
| struct resource *res; | |
| struct resource *res = &vmd->dev->resource[VMD_CFGBAR]; |
| * @membar_number: type of the MemBAR | ||
| * @start_offset: 4K aligned offset applied to start of VMD’s MEMBAR MMIO space | ||
| * @end_offset: 4K aligned offset applied to end of VMD’s MEMBAR MMIO space | ||
| * @parent: parent resource assigned to resource to be filled in |
| * to MMIO address assigned by the OS or BIOS. | ||
| * @vmd: the VMD device | ||
| * @resource_number: resource buffer number to be filled in | ||
| * @membar_number: type of the MemBAR |
| snprintf(name, sizeof(name), "VMD MEMBAR%d", membar_number/2); | ||
|
|
||
| if (!parent) | ||
| parent = res; |
There was a problem hiding this comment.
generally overwriting income parameter is bad practice, maybe better. use inline if?
.parent = parent ? parent : res;
| pci_add_resource_offset(&resources, &vmd->resources[2], offset[1]); | ||
| pci_add_resource(&resources, &vmd->resources[VMD_RESOURCE_CFGBAR]); | ||
| pci_add_resource_offset( | ||
| &resources, &vmd->resources[VMD_RESOURCE_MEMBAR_1], offset[0]); |
There was a problem hiding this comment.
looks like bad formatting to me, please look into kernel, how they solve this :)
| vmd->bus = pci_create_root_bus(&vmd->dev->dev, vmd->busn_start, | ||
| &vmd_ops, sd, &resources); | ||
| if (!vmd->bus) { | ||
| vmd->bus[VMD_ROOTBUS_0] = pci_create_root_bus( |
| char __iomem *base; | ||
|
|
||
| if (vmd_has_pch_rootbus(vmd)) | ||
| max_buses += resource_size( |
| case 3: | ||
| if (!(features & VMD_FEAT_HAS_PCH_ROOTBUS)) { | ||
| pci_err(dev, | ||
| "VMD Bus Restriction detected type %d, but PCH Rootbus is not supported, aborting.\n", |
There was a problem hiding this comment.
You can move it up to previous line, lgtm anyway
| * PCI_REG_BUSRANGE0 register. | ||
| */ | ||
| vmd->resources[VMD_RESOURCE_CFGBAR].start = | ||
| VMD_ROOTBUS_RANGE_START(ioc_bus_range); |
There was a problem hiding this comment.
I'm not sure if this is correct in kernel coding style :(
| &vmd->resources[VMD_RESOURCE_MEMBAR_1]); | ||
| vmd_configure_membar(vmd, VMD_RESOURCE_PCH_MEMBAR_2, | ||
| VMD_MEMBAR2, | ||
| membar2_offset + pch_membar2_offset, 0, |
There was a problem hiding this comment.
consider shorter naming for variables.
| * which is stored in vmd->busn_start[VMD_ROOTBUS_1]. | ||
| */ | ||
| bus_number = (bus->number == VMD_PRIMARY_PCH_BUS) ? | ||
| vmd->busn_start[VMD_ROOTBUS_1] : |
893f31f to
c4ede08
Compare
This function is too long and needs to be shortened to make it more readable. Certain VMD devices like Intel Arrow Lake has two bus ranges, current implementation supports only one range. This clean up is a prework for enablement additional VMD bus range. It doesn't change functional behavior of vmd_enable_domain(). Suggested-by: Nirmal Patel <nirmal.patel@linux.intel.com> Reviewed-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Szymon Durawa <szymon.durawa@linux.intel.com>
Starting from Intel Arrow Lake VMD enhacement introduces separate rotbus for PCH. It means that all 3 MMIO BARs exposed by VMD are shared now between CPU IOC and PCH. This patch adds PCH bus enumeration and MMIO management for devices with VMD enhancement support. Suggested-by: Nirmal Patel <nirmal.patel@linux.intel.com> Reviewed-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Szymon Durawa <szymon.durawa@linux.intel.com>
VMD PCH rootbus primary number is 0x80 and pci_scan_bridge_extend() cannot assign it as "hard-wired to 0" and marks setup as broken. To avoid this, PCH bus number has to be the same as PCH primary number. Suggested-by: Nirmal Patel <nirmal.patel@linux.intel.com> Reviewed-by: Mariusz Tkaczyk <mariusz.tkaczyk@linux.intel.com> Signed-off-by: Szymon Durawa <szymon.durawa@linux.intel.com>
| * @membar_number: type of the MemBAR | ||
| * @start_offset: 4K aligned offset applied to start of VMD’s MEMBAR MMIO space | ||
| * @end_offset: 4K aligned offset applied to end of VMD’s MEMBAR MMIO space | ||
| * @parent: parent resource assigned to resource to be filled in |
| pci_add_resource_offset(&resources_pch, | ||
| &vmd->resources[VMD_RES_PCH_MEMBAR_2], offset[1]); | ||
|
|
||
| vmd->bus[VMD_ROOTBUS_1] = pci_create_root_bus( |
VMD PCH rootbus implementation