From: Joerg Roedel <joro@8bytes.org>
To: Yijing Wang <wangyijing@huawei.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
Bjorn Helgaas <bhelgaas@google.com>,
David Woodhouse <dwmw2@infradead.org>,
Vinod Koul <vinod.koul@intel.com>,
Dan Williams <dan.j.williams@intel.com>,
dmaengine@vger.kernel.org, iommu@lists.linux-foundation.org,
linux-kernel@vger.kernel.org, Hanjun Guo <guohanjun@huawei.com>
Subject: Re: [PATCH v2] IOMMU: enhance dmar to support device hotplug
Date: Tue, 4 Mar 2014 15:31:58 +0100 [thread overview]
Message-ID: <20140304143158.GC2799@8bytes.org> (raw)
In-Reply-To: <1385022116-228-2-git-send-email-wangyijing@huawei.com>
On Thu, Nov 21, 2013 at 04:21:56PM +0800, Yijing Wang wrote:
> @@ -3641,21 +3681,42 @@ static int device_notifier(struct notifier_block *nb,
> struct device *dev = data;
> struct pci_dev *pdev = to_pci_dev(dev);
> struct dmar_domain *domain;
> + struct dmar_device *dmar_dev;
> + struct dmar_drhd_unit *drhd;
>
> - if (iommu_no_mapping(dev))
> - return 0;
> -
> - domain = find_domain(pdev);
> - if (!domain)
> - return 0;
> + switch (action) {
> + case BUS_NOTIFY_ADD_DEVICE:
> + for_each_drhd_unit(drhd)
> + list_for_each_entry(dmar_dev, &drhd->devices, list)
> + if (dmar_dev->segment == pci_domain_nr(pdev->bus)
> + && dmar_dev->bus == pdev->bus->number
> + && dmar_dev->devfn == pdev->devfn)
> + dmar_dev->pdev = pci_dev_get(pdev);
> + break;
> + case BUS_NOTIFY_DEL_DEVICE:
> + for_each_drhd_unit(drhd)
> + list_for_each_entry(dmar_dev, &drhd->devices, list)
> + if (dmar_dev->pdev == pdev) {
> + pci_dev_put(pdev);
> + dmar_dev->pdev = NULL;
> + }
How is that synchronized with other users of this dmar_dev structure.
Could it happen that you drop the device reference while other parts of
the driver still use it?
Joerg
next prev parent reply other threads:[~2014-03-04 14:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-11-21 8:21 [PATCH v2] Enhance dmar to support device hotplug Yijing Wang
2013-11-21 8:21 ` [PATCH v2] IOMMU: enhance " Yijing Wang
2014-03-04 14:31 ` Joerg Roedel [this message]
2014-03-05 2:53 ` Yijing Wang
2013-12-10 17:03 ` [PATCH v2] Enhance " Don Dutile
2013-12-12 11:46 ` Yijing Wang
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=20140304143158.GC2799@8bytes.org \
--to=joro@8bytes.org \
--cc=alex.williamson@redhat.com \
--cc=bhelgaas@google.com \
--cc=dan.j.williams@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=dwmw2@infradead.org \
--cc=guohanjun@huawei.com \
--cc=iommu@lists.linux-foundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vinod.koul@intel.com \
--cc=wangyijing@huawei.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).