All of lore.kernel.org
 help / color / mirror / Atom feed
From: Baolu Lu <baolu.lu@linux.intel.com>
To: Yunhui Cui <cuiyunhui@bytedance.com>,
	dwmw2@infradead.org, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com, iommu@lists.linux.dev,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] iommu/vt-d: fix system hang on reboot -f
Date: Mon, 24 Feb 2025 09:02:47 +0800	[thread overview]
Message-ID: <622aa790-6560-4be9-bfb4-736809a249bc@linux.intel.com> (raw)
In-Reply-To: <20250220101511.37602-1-cuiyunhui@bytedance.com>

On 2/20/25 18:15, Yunhui Cui wrote:
> When entering intel_iommu_shutdown, system interrupts are disabled,
> and the reboot process might be scheduled out by down_write(). If the
> scheduled process does not yield (e.g., while(1)), the system will hang.
> 
> Signed-off-by: Yunhui Cui<cuiyunhui@bytedance.com>
> ---
>   drivers/iommu/intel/iommu.c | 3 ++-
>   1 file changed, 2 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/intel/iommu.c b/drivers/iommu/intel/iommu.c
> index cc46098f875b..76a1d83b46bf 100644
> --- a/drivers/iommu/intel/iommu.c
> +++ b/drivers/iommu/intel/iommu.c
> @@ -2871,7 +2871,8 @@ void intel_iommu_shutdown(void)
>   	if (no_iommu || dmar_disabled)
>   		return;
>   
> -	down_write(&dmar_global_lock);
> +	if (!down_write_trylock(&dmar_global_lock))
> +		return;

If system interrupts are disabled here, locking is unnecessary. Hotplug
operations depend on interrupt events, so it's better to remove the
lock. The shutdown helper then appears like this:

void intel_iommu_shutdown(void)
{
         struct dmar_drhd_unit *drhd;
         struct intel_iommu *iommu = NULL;

         if (no_iommu || dmar_disabled)
                 return;

         /*
          * System interrupts are disabled when it reaches here. Locking
          * is unnecessary when iterating the IOMMU list.
          */
         list_for_each_entry(drhd, &dmar_drhd_units, list) {
                 if (drhd->ignored)
                         continue;

                 iommu = drhd->iommu;
                 /* Disable PMRs explicitly here. */
                 iommu_disable_protect_mem_regions(iommu);
                 iommu_disable_translation(iommu);
         }
}

Does it work for you?

Thanks,
baolu

  parent reply	other threads:[~2025-02-24  1:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-20 10:15 [PATCH] iommu/vt-d: fix system hang on reboot -f Yunhui Cui
2025-02-21  8:40 ` Ethan Zhao
2025-02-21  9:46   ` [External] " yunhui cui
2025-02-24  2:53     ` Ethan Zhao
2025-02-24  3:21     ` Ethan Zhao
2025-02-24  1:02 ` Baolu Lu [this message]
2025-02-24  3:42   ` yunhui cui
2025-02-24  5:37   ` Ethan Zhao

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=622aa790-6560-4be9-bfb4-736809a249bc@linux.intel.com \
    --to=baolu.lu@linux.intel.com \
    --cc=cuiyunhui@bytedance.com \
    --cc=dwmw2@infradead.org \
    --cc=iommu@lists.linux.dev \
    --cc=joro@8bytes.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=robin.murphy@arm.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.