Message ID | 20210223163607.76266-2-andrea.righi@canonical.com |
---|---|
State | New |
Headers | show |
Series | aws: revert change to support instance types > 255 cpu cores | expand |
On Tue, Feb 23, 2021 at 1:36 PM Andrea Righi <andrea.righi@canonical.com> wrote: > > BugLink: https://bugs.launchpad.net/bugs/1913739 > > This reverts commit 561ef22a7d396289a1c5a1d18057ccdf9bb59826. > > It seems that this patch is addressing the problem correctly only with > kernels >4.4. For now it is probably safer to simply drop this patch and > revert this change in 4.4 to avoid introducing potential regressions. > > Signed-off-by: Andrea Righi <andrea.righi@canonical.com> > --- > drivers/iommu/dmar.c | 45 ++++++++++++++------------------------------ > 1 file changed, 14 insertions(+), 31 deletions(-) > > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c > index 78174f2f9fafb..00169c9eb3eed 100644 > --- a/drivers/iommu/dmar.c > +++ b/drivers/iommu/dmar.c > @@ -1012,8 +1012,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) > { > struct intel_iommu *iommu; > u32 ver, sts; > - int agaw = -1; > - int msagaw = -1; > + int agaw = 0; > + int msagaw = 0; > int err; > > if (!drhd->reg_base_addr) { > @@ -1038,28 +1038,17 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) > } > > err = -EINVAL; > - if (cap_sagaw(iommu->cap) == 0) { > - pr_info("%s: No supported address widths. Not attempting DMA translation.\n", > - iommu->name); > - drhd->ignored = 1; > + agaw = iommu_calculate_agaw(iommu); > + if (agaw < 0) { > + pr_err("Cannot get a valid agaw for iommu (seq_id = %d)\n", > + iommu->seq_id); > + goto err_unmap; > } > - > - if (!drhd->ignored) { > - agaw = iommu_calculate_agaw(iommu); > - if (agaw < 0) { > - pr_err("Cannot get a valid agaw for iommu (seq_id = %d)\n", > - iommu->seq_id); > - drhd->ignored = 1; > - } > - } > - if (!drhd->ignored) { > - msagaw = iommu_calculate_max_sagaw(iommu); > - if (msagaw < 0) { > - pr_err("Cannot get a valid max agaw for iommu (seq_id = %d)\n", > - iommu->seq_id); > - drhd->ignored = 1; > - agaw = -1; > - } > + msagaw = iommu_calculate_max_sagaw(iommu); > + if (msagaw < 0) { > + pr_err("Cannot get a valid max agaw for iommu (seq_id = %d)\n", > + iommu->seq_id); > + goto err_unmap; > } > iommu->agaw = agaw; > iommu->msagaw = msagaw; > @@ -1088,12 +1077,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) > > drhd->iommu = iommu; > > - /* > - * This is only for hotplug; at boot time intel_iommu_enabled won't > - * be set yet. When intel_iommu_init() runs, it registers the units > - * present at boot time, then sets intel_iommu_enabled. > - */ > - if (intel_iommu_enabled && !drhd->ignored) > + if (intel_iommu_enabled) > iommu->iommu_dev = iommu_device_create(NULL, iommu, > intel_iommu_groups, > "%s", iommu->name); > @@ -1111,8 +1095,7 @@ error: > > static void free_iommu(struct intel_iommu *iommu) > { > - if (intel_iommu_enabled && iommu->iommu_dev) > - iommu_device_destroy(iommu->iommu_dev); > + iommu_device_destroy(iommu->iommu_dev); > > if (iommu->irq) { > if (iommu->pr_irq) { > -- > 2.30.0 > Thanks Andrea, a clean patch, with reasonable justification. Acked-by: Guilherme G. Piccoli <gpiccoli@canonical.com>
On 23/02/2021 16:36, Andrea Righi wrote: > BugLink: https://bugs.launchpad.net/bugs/1913739 > > This reverts commit 561ef22a7d396289a1c5a1d18057ccdf9bb59826. > > It seems that this patch is addressing the problem correctly only with > kernels >4.4. For now it is probably safer to simply drop this patch and > revert this change in 4.4 to avoid introducing potential regressions. > > Signed-off-by: Andrea Righi <andrea.righi@canonical.com> > --- > drivers/iommu/dmar.c | 45 ++++++++++++++------------------------------ > 1 file changed, 14 insertions(+), 31 deletions(-) > > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c > index 78174f2f9fafb..00169c9eb3eed 100644 > --- a/drivers/iommu/dmar.c > +++ b/drivers/iommu/dmar.c > @@ -1012,8 +1012,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) > { > struct intel_iommu *iommu; > u32 ver, sts; > - int agaw = -1; > - int msagaw = -1; > + int agaw = 0; > + int msagaw = 0; > int err; > > if (!drhd->reg_base_addr) { > @@ -1038,28 +1038,17 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) > } > > err = -EINVAL; > - if (cap_sagaw(iommu->cap) == 0) { > - pr_info("%s: No supported address widths. Not attempting DMA translation.\n", > - iommu->name); > - drhd->ignored = 1; > + agaw = iommu_calculate_agaw(iommu); > + if (agaw < 0) { > + pr_err("Cannot get a valid agaw for iommu (seq_id = %d)\n", > + iommu->seq_id); > + goto err_unmap; > } > - > - if (!drhd->ignored) { > - agaw = iommu_calculate_agaw(iommu); > - if (agaw < 0) { > - pr_err("Cannot get a valid agaw for iommu (seq_id = %d)\n", > - iommu->seq_id); > - drhd->ignored = 1; > - } > - } > - if (!drhd->ignored) { > - msagaw = iommu_calculate_max_sagaw(iommu); > - if (msagaw < 0) { > - pr_err("Cannot get a valid max agaw for iommu (seq_id = %d)\n", > - iommu->seq_id); > - drhd->ignored = 1; > - agaw = -1; > - } > + msagaw = iommu_calculate_max_sagaw(iommu); > + if (msagaw < 0) { > + pr_err("Cannot get a valid max agaw for iommu (seq_id = %d)\n", > + iommu->seq_id); > + goto err_unmap; > } > iommu->agaw = agaw; > iommu->msagaw = msagaw; > @@ -1088,12 +1077,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) > > drhd->iommu = iommu; > > - /* > - * This is only for hotplug; at boot time intel_iommu_enabled won't > - * be set yet. When intel_iommu_init() runs, it registers the units > - * present at boot time, then sets intel_iommu_enabled. > - */ > - if (intel_iommu_enabled && !drhd->ignored) > + if (intel_iommu_enabled) > iommu->iommu_dev = iommu_device_create(NULL, iommu, > intel_iommu_groups, > "%s", iommu->name); > @@ -1111,8 +1095,7 @@ error: > > static void free_iommu(struct intel_iommu *iommu) > { > - if (intel_iommu_enabled && iommu->iommu_dev) > - iommu_device_destroy(iommu->iommu_dev); > + iommu_device_destroy(iommu->iommu_dev); > > if (iommu->irq) { > if (iommu->pr_irq) { > This makes sense. Thanks Andrea. Acked-by: Colin Ian King <colin.king@canonical.com>
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 78174f2f9fafb..00169c9eb3eed 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -1012,8 +1012,8 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) { struct intel_iommu *iommu; u32 ver, sts; - int agaw = -1; - int msagaw = -1; + int agaw = 0; + int msagaw = 0; int err; if (!drhd->reg_base_addr) { @@ -1038,28 +1038,17 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) } err = -EINVAL; - if (cap_sagaw(iommu->cap) == 0) { - pr_info("%s: No supported address widths. Not attempting DMA translation.\n", - iommu->name); - drhd->ignored = 1; + agaw = iommu_calculate_agaw(iommu); + if (agaw < 0) { + pr_err("Cannot get a valid agaw for iommu (seq_id = %d)\n", + iommu->seq_id); + goto err_unmap; } - - if (!drhd->ignored) { - agaw = iommu_calculate_agaw(iommu); - if (agaw < 0) { - pr_err("Cannot get a valid agaw for iommu (seq_id = %d)\n", - iommu->seq_id); - drhd->ignored = 1; - } - } - if (!drhd->ignored) { - msagaw = iommu_calculate_max_sagaw(iommu); - if (msagaw < 0) { - pr_err("Cannot get a valid max agaw for iommu (seq_id = %d)\n", - iommu->seq_id); - drhd->ignored = 1; - agaw = -1; - } + msagaw = iommu_calculate_max_sagaw(iommu); + if (msagaw < 0) { + pr_err("Cannot get a valid max agaw for iommu (seq_id = %d)\n", + iommu->seq_id); + goto err_unmap; } iommu->agaw = agaw; iommu->msagaw = msagaw; @@ -1088,12 +1077,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd) drhd->iommu = iommu; - /* - * This is only for hotplug; at boot time intel_iommu_enabled won't - * be set yet. When intel_iommu_init() runs, it registers the units - * present at boot time, then sets intel_iommu_enabled. - */ - if (intel_iommu_enabled && !drhd->ignored) + if (intel_iommu_enabled) iommu->iommu_dev = iommu_device_create(NULL, iommu, intel_iommu_groups, "%s", iommu->name); @@ -1111,8 +1095,7 @@ error: static void free_iommu(struct intel_iommu *iommu) { - if (intel_iommu_enabled && iommu->iommu_dev) - iommu_device_destroy(iommu->iommu_dev); + iommu_device_destroy(iommu->iommu_dev); if (iommu->irq) { if (iommu->pr_irq) {
BugLink: https://bugs.launchpad.net/bugs/1913739 This reverts commit 561ef22a7d396289a1c5a1d18057ccdf9bb59826. It seems that this patch is addressing the problem correctly only with kernels >4.4. For now it is probably safer to simply drop this patch and revert this change in 4.4 to avoid introducing potential regressions. Signed-off-by: Andrea Righi <andrea.righi@canonical.com> --- drivers/iommu/dmar.c | 45 ++++++++++++++------------------------------ 1 file changed, 14 insertions(+), 31 deletions(-)