linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Gavin Shan <shangw@linux.vnet.ibm.com>, linuxppc-dev@ozlabs.org
Subject: Re: [PATCH] powerpc/iommu: Don't detach device without IOMMU group
Date: Mon, 13 Jan 2014 15:54:11 +1100	[thread overview]
Message-ID: <52D37173.7030907@ozlabs.ru> (raw)
In-Reply-To: <1389584182-6349-1-git-send-email-shangw@linux.vnet.ibm.com>

On 01/13/2014 02:36 PM, Gavin Shan wrote:
> Some devices, for example PCI root port, don't have IOMMU table and
> group. We needn't detach them from their IOMMU group. Otherwise, it
> potentially incurs kernel crash because of referring NULL IOMMU group
> as following backtrace indicates:
> 
>   .iommu_group_remove_device+0x74/0x1b0
>   .iommu_bus_notifier+0x94/0xb4
>   .notifier_call_chain+0x78/0xe8
>   .__blocking_notifier_call_chain+0x7c/0xbc
>   .blocking_notifier_call_chain+0x38/0x48
>   .device_del+0x50/0x234
>   .pci_remove_bus_device+0x88/0x138
>   .pci_stop_and_remove_bus_device+0x2c/0x40
>   .pcibios_remove_pci_devices+0xcc/0xfc
>   .pcibios_remove_pci_devices+0x3c/0xfc
> 
> Signed-off-by: Gavin Shan <shangw@linux.vnet.ibm.com>

Thanks! I never tested the unplug case...

Reviewed-by: Alexey Kardashevskiy <aik@ozlabs.ru>



> ---
>  arch/powerpc/kernel/iommu.c |   11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/powerpc/kernel/iommu.c b/arch/powerpc/kernel/iommu.c
> index 572bb5b..8a49424 100644
> --- a/arch/powerpc/kernel/iommu.c
> +++ b/arch/powerpc/kernel/iommu.c
> @@ -1137,6 +1137,17 @@ static int iommu_add_device(struct device *dev)
>  
>  static void iommu_del_device(struct device *dev)
>  {
> +	/*
> +	 * Some devices might not have IOMMU table and group
> +	 * and we needn't detach them from the associated
> +	 * IOMMU groups
> +	 */
> +	if (!dev->iommu_group) {
> +		pr_debug("iommu_tce: skipping device %s with no tbl\n",
> +			 dev_name(dev));
> +		return;
> +	}
> +
>  	iommu_group_remove_device(dev);
>  }
>  
> 


-- 
Alexey

      reply	other threads:[~2014-01-13  4:54 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-13  3:36 [PATCH] powerpc/iommu: Don't detach device without IOMMU group Gavin Shan
2014-01-13  4:54 ` Alexey Kardashevskiy [this message]

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=52D37173.7030907@ozlabs.ru \
    --to=aik@ozlabs.ru \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=shangw@linux.vnet.ibm.com \
    /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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).