mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-21 21:19:35 +00:00
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>
This commit is contained in:
parent
fe20fc1451
commit
7928e21d07
@ -205,7 +205,7 @@ static inline uint16_t vmid_to_domainid(uint16_t vm_id)
|
|||||||
}
|
}
|
||||||
|
|
||||||
static int32_t dmar_register_hrhd(struct dmar_drhd_rt *dmar_unit);
|
static int32_t dmar_register_hrhd(struct dmar_drhd_rt *dmar_unit);
|
||||||
static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8_t devfun);
|
static struct dmar_drhd_rt *device_to_dmaru(uint8_t bus, uint8_t devfun);
|
||||||
static int32_t register_hrhd_units(void)
|
static int32_t register_hrhd_units(void)
|
||||||
{
|
{
|
||||||
struct dmar_drhd_rt *drhd_rt;
|
struct dmar_drhd_rt *drhd_rt;
|
||||||
@ -553,7 +553,7 @@ static struct dmar_drhd_rt *ioapic_to_dmaru(uint16_t ioapic_id, union pci_bdf *s
|
|||||||
return dmar_unit;
|
return dmar_unit;
|
||||||
}
|
}
|
||||||
|
|
||||||
static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8_t devfun)
|
static struct dmar_drhd_rt *device_to_dmaru(uint8_t bus, uint8_t devfun)
|
||||||
{
|
{
|
||||||
struct dmar_drhd_rt *dmar_unit = NULL;
|
struct dmar_drhd_rt *dmar_unit = NULL;
|
||||||
uint32_t i, j;
|
uint32_t i, j;
|
||||||
@ -561,10 +561,6 @@ static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8
|
|||||||
for (j = 0U; j < platform_dmar_info->drhd_count; j++) {
|
for (j = 0U; j < platform_dmar_info->drhd_count; j++) {
|
||||||
dmar_unit = &dmar_drhd_units[j];
|
dmar_unit = &dmar_drhd_units[j];
|
||||||
|
|
||||||
if (dmar_unit->drhd->segment != segment) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0U; i < dmar_unit->drhd->dev_cnt; i++) {
|
for (i = 0U; i < dmar_unit->drhd->dev_cnt; i++) {
|
||||||
if ((dmar_unit->drhd->devices[i].bus == bus) &&
|
if ((dmar_unit->drhd->devices[i].bus == bus) &&
|
||||||
(dmar_unit->drhd->devices[i].devfun == devfun)) {
|
(dmar_unit->drhd->devices[i].devfun == devfun)) {
|
||||||
@ -572,7 +568,6 @@ static struct dmar_drhd_rt *device_to_dmaru(uint16_t segment, uint8_t bus, uint8
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* found exact one or the one which has the same segment number with INCLUDE_PCI_ALL set */
|
|
||||||
if ((i != dmar_unit->drhd->dev_cnt) || ((dmar_unit->drhd->flags & DRHD_FLAG_INCLUDE_PCI_ALL_MASK) != 0U)) {
|
if ((i != dmar_unit->drhd->dev_cnt) || ((dmar_unit->drhd->flags & DRHD_FLAG_INCLUDE_PCI_ALL_MASK) != 0U)) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1049,7 +1044,7 @@ static void dmar_resume(struct dmar_drhd_rt *dmar_unit)
|
|||||||
dmar_enable_intr_remapping(dmar_unit);
|
dmar_enable_intr_remapping(dmar_unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, uint8_t bus, uint8_t devfun)
|
static int32_t add_iommu_device(struct iommu_domain *domain, uint8_t bus, uint8_t devfun)
|
||||||
{
|
{
|
||||||
struct dmar_drhd_rt *dmar_unit;
|
struct dmar_drhd_rt *dmar_unit;
|
||||||
struct dmar_entry *root_table;
|
struct dmar_entry *root_table;
|
||||||
@ -1066,7 +1061,7 @@ static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, u
|
|||||||
sid.fields.bus = bus;
|
sid.fields.bus = bus;
|
||||||
sid.fields.devfun = devfun;
|
sid.fields.devfun = devfun;
|
||||||
|
|
||||||
dmar_unit = device_to_dmaru(segment, bus, devfun);
|
dmar_unit = device_to_dmaru(bus, devfun);
|
||||||
if (dmar_unit == NULL) {
|
if (dmar_unit == NULL) {
|
||||||
pr_err("no dmar unit found for device: %x:%x.%x", bus, sid.bits.d, sid.bits.f);
|
pr_err("no dmar unit found for device: %x:%x.%x", bus, sid.bits.d, sid.bits.f);
|
||||||
ret = -EINVAL;
|
ret = -EINVAL;
|
||||||
@ -1164,7 +1159,7 @@ static int32_t add_iommu_device(struct iommu_domain *domain, uint16_t segment, u
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int32_t remove_iommu_device(const struct iommu_domain *domain, uint16_t segment, uint8_t bus, uint8_t devfun)
|
static int32_t remove_iommu_device(const struct iommu_domain *domain, uint8_t bus, uint8_t devfun)
|
||||||
{
|
{
|
||||||
struct dmar_drhd_rt *dmar_unit;
|
struct dmar_drhd_rt *dmar_unit;
|
||||||
struct dmar_entry *root_table;
|
struct dmar_entry *root_table;
|
||||||
@ -1176,7 +1171,7 @@ static int32_t remove_iommu_device(const struct iommu_domain *domain, uint16_t s
|
|||||||
union pci_bdf sid;
|
union pci_bdf sid;
|
||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
|
||||||
dmar_unit = device_to_dmaru(segment, bus, devfun);
|
dmar_unit = device_to_dmaru(bus, devfun);
|
||||||
|
|
||||||
sid.fields.bus = bus;
|
sid.fields.bus = bus;
|
||||||
sid.fields.devfun = devfun;
|
sid.fields.devfun = devfun;
|
||||||
@ -1302,11 +1297,11 @@ int32_t move_pt_device(const struct iommu_domain *from_domain, struct iommu_doma
|
|||||||
|
|
||||||
if (bus_local < CONFIG_IOMMU_BUS_NUM) {
|
if (bus_local < CONFIG_IOMMU_BUS_NUM) {
|
||||||
if (from_domain != NULL) {
|
if (from_domain != NULL) {
|
||||||
status = remove_iommu_device(from_domain, 0U, bus, devfun);
|
status = remove_iommu_device(from_domain, bus, devfun);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((status == 0) && (to_domain != NULL)) {
|
if ((status == 0) && (to_domain != NULL)) {
|
||||||
status = add_iommu_device(to_domain, 0U, bus, devfun);
|
status = add_iommu_device(to_domain, bus, devfun);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
status = -EINVAL;
|
status = -EINVAL;
|
||||||
@ -1373,7 +1368,7 @@ int32_t dmar_assign_irte(struct intr_source intr_src, union dmar_ir_entry irte,
|
|||||||
int32_t ret = 0;
|
int32_t ret = 0;
|
||||||
|
|
||||||
if (intr_src.is_msi) {
|
if (intr_src.is_msi) {
|
||||||
dmar_unit = device_to_dmaru(0U, (uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
|
dmar_unit = device_to_dmaru((uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
|
||||||
sid.value = intr_src.src.msi.value;
|
sid.value = intr_src.src.msi.value;
|
||||||
trigger_mode = 0x0UL;
|
trigger_mode = 0x0UL;
|
||||||
} else {
|
} else {
|
||||||
@ -1417,7 +1412,7 @@ void dmar_free_irte(struct intr_source intr_src, uint16_t index)
|
|||||||
union pci_bdf sid;
|
union pci_bdf sid;
|
||||||
|
|
||||||
if (intr_src.is_msi) {
|
if (intr_src.is_msi) {
|
||||||
dmar_unit = device_to_dmaru(0U, (uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
|
dmar_unit = device_to_dmaru((uint8_t)intr_src.src.msi.bits.b, intr_src.src.msi.fields.devfun);
|
||||||
} else {
|
} else {
|
||||||
dmar_unit = ioapic_to_dmaru(intr_src.src.ioapic_id, &sid);
|
dmar_unit = ioapic_to_dmaru(intr_src.src.ioapic_id, &sid);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user