Skip to content

Commit c5a87d4

Browse files
Sainath Grandhiwenlingz
authored andcommitted
HV: Cleanup PCI segment usage from VT-d interfaces
ACRN does not support multiple PCI segments in its current form. But VT-d module uses segment info in its interfaces and hardcodes it to 0. This patch cleans up everything related to segment to avoid ambiguity. Tracked-On: #4134 Signed-off-by: Sainath Grandhi <sainath.grandhi@intel.com> Reviewed-by: Eddie Dong <eddie.dong@intel.com> Reviewed-by: Jason Chen CJ <jason.cj.chen@intel.com>
1 parent 810169a commit c5a87d4

File tree

1 file changed

+10
-15
lines changed

1 file changed

+10
-15
lines changed

hypervisor/arch/x86/vtd.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,7 @@ static inline uint16_t vmid_to_domainid(uint16_t vm_id)
205205
}
206206

207207
static int32_t dmar_register_hrhd(struct dmar_drhd_rt *dmar_unit);
208-
static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8_t devfun);
208+
static struct dmar_drhd_rt *device_to_dmaru(uint8_t bus, uint8_t devfun);
209209
static int32_t register_hrhd_units(void)
210210
{
211211
struct dmar_drhd_rt *drhd_rt;
@@ -553,26 +553,21 @@ static struct dmar_drhd_rt *ioapic_to_dmaru(uint16_t ioapic_id, union pci_bdf *s
553553
return dmar_unit;
554554
}
555555

556-
static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8_t devfun)
556+
static struct dmar_drhd_rt *device_to_dmaru(uint8_t bus, uint8_t devfun)
557557
{
558558
struct dmar_drhd_rt *dmar_unit = NULL;
559559
uint32_t i, j;
560560

561561
for (j = 0U; j < platform_dmar_info->drhd_count; j++) {
562562
dmar_unit = &dmar_drhd_units[j];
563563

564-
if (dmar_unit->drhd->segment != segment) {
565-
continue;
566-
}
567-
568564
for (i = 0U; i < dmar_unit->drhd->dev_cnt; i++) {
569565
if ((dmar_unit->drhd->devices[i].bus == bus) &&
570566
(dmar_unit->drhd->devices[i].devfun == devfun)) {
571567
break;
572568
}
573569
}
574570

575-
/* found exact one or the one which has the same segment number with INCLUDE_PCI_ALL set */
576571
if ((i != dmar_unit->drhd->dev_cnt) || ((dmar_unit->drhd->flags & DRHD_FLAG_INCLUDE_PCI_ALL_MASK) != 0U)) {
577572
break;
578573
}
@@ -1049,7 +1044,7 @@ static void dmar_resume(struct dmar_drhd_rt *dmar_unit)
10491044
dmar_enable_intr_remapping(dmar_unit);
10501045
}
10511046

1052-
static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, uint8_t bus, uint8_t devfun)
1047+
static int32_t add_iommu_device(struct iommu_domain *domain, uint8_t bus, uint8_t devfun)
10531048
{
10541049
struct dmar_drhd_rt *dmar_unit;
10551050
struct dmar_entry *root_table;
@@ -1066,7 +1061,7 @@ static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, u
10661061
sid.fields.bus = bus;
10671062
sid.fields.devfun = devfun;
10681063

1069-
dmar_unit = device_to_dmaru(segment, bus, devfun);
1064+
dmar_unit = device_to_dmaru(bus, devfun);
10701065
if (dmar_unit == NULL) {
10711066
pr_err("no dmar unit found for device: %x:%x.%x", bus, sid.bits.d, sid.bits.f);
10721067
ret = -EINVAL;
@@ -1164,7 +1159,7 @@ static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, u
11641159
return ret;
11651160
}
11661161

1167-
static int32_t remove_iommu_device(const struct iommu_domain *domain, uint16_t segment, uint8_t bus, uint8_t devfun)
1162+
static int32_t remove_iommu_device(const struct iommu_domain *domain, uint8_t bus, uint8_t devfun)
11681163
{
11691164
struct dmar_drhd_rt *dmar_unit;
11701165
struct dmar_entry *root_table;
@@ -1176,7 +1171,7 @@ static int32_t remove_iommu_device(const struct iommu_domain *domain, uint16_t s
11761171
union pci_bdf sid;
11771172
int32_t ret = 0;
11781173

1179-
dmar_unit = device_to_dmaru(segment, bus, devfun);
1174+
dmar_unit = device_to_dmaru(bus, devfun);
11801175

11811176
sid.fields.bus = bus;
11821177
sid.fields.devfun = devfun;
@@ -1302,11 +1297,11 @@ int32_t move_pt_device(const struct iommu_domain *from_domain, struct iommu_doma
13021297

13031298
if (bus_local < CONFIG_IOMMU_BUS_NUM) {
13041299
if (from_domain != NULL) {
1305-
status = remove_iommu_device(from_domain, 0U, bus, devfun);
1300+
status = remove_iommu_device(from_domain, bus, devfun);
13061301
}
13071302

13081303
if ((status == 0) && (to_domain != NULL)) {
1309-
status = add_iommu_device(to_domain, 0U, bus, devfun);
1304+
status = add_iommu_device(to_domain, bus, devfun);
13101305
}
13111306
} else {
13121307
status = -EINVAL;
@@ -1373,7 +1368,7 @@ int32_t dmar_assign_irte(struct intr_source intr_src, union dmar_ir_entry irte,
13731368
int32_t ret = 0;
13741369

13751370
if (intr_src.is_msi) {
1376-
dmar_unit = device_to_dmaru(0U, (uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
1371+
dmar_unit = device_to_dmaru((uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
13771372
sid.value = intr_src.src.msi.value;
13781373
trigger_mode = 0x0UL;
13791374
} else {
@@ -1417,7 +1412,7 @@ void dmar_free_irte(struct intr_source intr_src, uint16_t index)
14171412
union pci_bdf sid;
14181413

14191414
if (intr_src.is_msi) {
1420-
dmar_unit = device_to_dmaru(0U, (uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
1415+
dmar_unit = device_to_dmaru((uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
14211416
} else {
14221417
dmar_unit = ioapic_to_dmaru(intr_src.src.ioapic_id, &sid);
14231418
}

0 commit comments

Comments
 (0)