From mboxrd@z Thu Jan 1 00:00:00 1970 From: Joerg Roedel Subject: Re: [PATCH v5 02/12] iommu/vt-d: Manage scalalble mode PASID tables Date: Wed, 5 Dec 2018 16:50:12 +0100 Message-ID: <20181205155012.GC16835@8bytes.org> References: <20181128035449.10226-1-baolu.lu@linux.intel.com> <20181128035449.10226-3-baolu.lu@linux.intel.com> <20181203134411.lejlkbnagxml54ro@8bytes.org> <5c81008b-30e8-177d-0182-db366608562f@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: Content-Disposition: inline In-Reply-To: <5c81008b-30e8-177d-0182-db366608562f-VuQAYsv1563Yd54FQh9/CA@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Lu Baolu Cc: "Tian, Kevin" , "Raj, Ashok" , Jean-Philippe Brucker , "Kumar, Sanjay K" , "iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org" , "linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "Sun, Yi Y" , "Pan, Jacob jun" , David Woodhouse List-Id: iommu@lists.linux-foundation.org On Tue, Dec 04, 2018 at 01:58:06PM +0800, Lu Baolu wrote: > This function is called in an unsleepable context. > > spin_lock(&lock) > [...] > if (pasid_table_is_necessary) > allocate_pasid_table(dev) > [...] > spin_unlock(&lock) > > We can move it out of the lock range. > > How about > > if (pasid_table_is_necessary) > pasid_table = allocate_pasid_table(dev) > > spin_lock(&lock) > [...] > if (pasid_table_is_necessary) > set_up_pasid_table(pasid_table) > [...] > spin_unlock(&lock) Hmm, so when the IOMMU is configured in scalable mode we can just allocate a pasid-table for the device when we set it up, right? Scalable mode is a boot-time decision, so we know for sure whether we need a pasid-table on device-setup time. And the device-setup code it preemptable, so I think it this allocation should be outside of any spin-locked section. Joerg