Skip to content

Vmd pch rootbus#3

Open
sdurawa wants to merge 3 commits into
masterfrom
vmd_pch_rootbus
Open

Vmd pch rootbus#3
sdurawa wants to merge 3 commits into
masterfrom
vmd_pch_rootbus

Conversation

@sdurawa
Copy link
Copy Markdown
Owner

@sdurawa sdurawa commented Oct 21, 2024

VMD PCH rootbus implementation

Copy link
Copy Markdown

@mtkaczyk mtkaczyk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

Comment thread drivers/pci/controller/vmd.c Outdated
VMD_RESOURCE_COUNT
};

enum vmd_rootbus { VMD_ROOTBUS_0 = 0, VMD_ROOTBUS_COUNT };
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've never seen something like that before, probably visual formatting.

Comment thread drivers/pci/controller/vmd.c Outdated
{
u16 bus, max_buses = resource_size(&vmd->resources[0]);
u16 bus,
max_buses = resource_size(&vmd->resources[VMD_RESOURCE_CFGBAR]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not acceptable:

Suggested change
max_buses = resource_size(&vmd->resources[VMD_RESOURCE_CFGBAR]);
u16 bus;
u16 max_buses = resource_size(&vmd->resources[VMD_RESOURCE_CFGBAR]);

Comment thread drivers/pci/controller/vmd.c Outdated
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];
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure, it is badly formatted.

Suggested change
&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];

Comment thread drivers/pci/controller/vmd.c Outdated
static int vmd_enable_domain(struct vmd_dev *vmd, unsigned long features)
static void vmd_configure_cfgbar(struct vmd_dev *vmd)
{
struct resource *res;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Highlight that it can be NULL.

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean @parent lol :)

Comment thread drivers/pci/controller/vmd.c Outdated
* 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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you say type but the name has number

Comment thread drivers/pci/controller/vmd.c Outdated
snprintf(name, sizeof(name), "VMD MEMBAR%d", membar_number/2);

if (!parent)
parent = res;
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

generally overwriting income parameter is bad practice, maybe better. use inline if?

		.parent = parent ? parent : res;

Comment thread drivers/pci/controller/vmd.c Outdated
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]);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad formatting.

Comment thread drivers/pci/controller/vmd.c Outdated
char __iomem *base;

if (vmd_has_pch_rootbus(vmd))
max_buses += resource_size(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bad formating

Comment thread drivers/pci/controller/vmd.c Outdated
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",
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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);
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if this is correct in kernel coding style :(

Comment thread drivers/pci/controller/vmd.c Outdated
&vmd->resources[VMD_RESOURCE_MEMBAR_1]);
vmd_configure_membar(vmd, VMD_RESOURCE_PCH_MEMBAR_2,
VMD_MEMBAR2,
membar2_offset + pch_membar2_offset, 0,
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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] :
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

formating

Szymon Durawa added 3 commits October 22, 2024 17:31
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
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I mean @parent lol :)

pci_add_resource_offset(&resources_pch,
&vmd->resources[VMD_RES_PCH_MEMBAR_2], offset[1]);

vmd->bus[VMD_ROOTBUS_1] = pci_create_root_bus(
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this formatting is bad.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants