From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jeremy Fitzhardinge Subject: Re: [PATCH 2/6] Provide a mechanism to register domain owner of a PCI device. Date: Wed, 09 Dec 2009 15:33:40 -0800 Message-ID: <4B2033D4.5020700@goop.org> References: <4B20131E.4080801@goop.org> <1260398597-11468-1-git-send-email-konrad.wilk@oracle.com> <1260398597-11468-2-git-send-email-konrad.wilk@oracle.com> <1260398597-11468-3-git-send-email-konrad.wilk@oracle.com> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <1260398597-11468-3-git-send-email-konrad.wilk@oracle.com> List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Sender: xen-devel-bounces@lists.xensource.com Errors-To: xen-devel-bounces@lists.xensource.com To: Konrad Rzeszutek Wilk Cc: xen-devel@lists.xensource.com List-Id: xen-devel@lists.xenproject.org On 12/09/09 14:43, Konrad Rzeszutek Wilk wrote: > . and also to find the domain owner based on the PCI device and > to unregister a domain owner of a PCI device. > Could you fix this up a bit? > +int xen_register_device_domain_owner(struct pci_dev *dev, domid_t domain) > +{ > + struct xen_device_domain_owner *owner; > + unsigned long flags; > + int rc = 0; > + > + spin_lock_irqsave(&dev_domain_list_spinlock, flags); > Are you expecting interrupt routines could also hold the lock? > + if (find_device(dev)) { > + rc = -EEXIST; > + goto out; > + } > + owner = kzalloc(sizeof(struct xen_device_domain_owner), GFP_KERNEL); > This can block, so you can't do it while holding the lock. Its probably best to allocate it first on the assumption that it will be used (it seems probable that duplicate registrations are at least unlikely, and possibly a bug). Thanks, J