From mboxrd@z Thu Jan 1 00:00:00 1970 From: Jacob Pan Subject: Re: [PATCH V4 05/18] iommu/ioasid: Redefine IOASID set and allocation APIs Date: Mon, 10 May 2021 15:28:54 -0700 Message-ID: <20210510152854.793ee594@jacob-builder> References: <20210505180023.GJ1370958@nvidia.com> <20210505130446.3ee2fccd@jacob-builder> <20210506122730.GQ1370958@nvidia.com> <20210506163240.GA9058@otc-nc-03> <20210510123729.GA1002214@nvidia.com> <20210510152502.GA90095@otc-nc-03> <20210510153111.GB1002214@nvidia.com> <20210510162212.GB90095@otc-nc-03> <20210510163956.GD1002214@nvidia.com> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20210510163956.GD1002214-DDmLM1+adcrQT0dZR+AlfA@public.gmane.org> List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Sender: "iommu" To: Jason Gunthorpe Cc: Jean-Philippe Brucker , "Tian, Kevin" , "Jiang, Dave" , "Raj, Ashok" , Jonathan Corbet , Jean-Philippe Brucker , LKML , "iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org" , Alex Williamson , Johannes Weiner , Tejun Heo , "cgroups-u79uwXL29TY76Z2rM5mHXA@public.gmane.org" , "Wu, Hao" , David Woodhouse Hi Jason, On Mon, 10 May 2021 13:39:56 -0300, Jason Gunthorpe wrote: > I still think it is smarter to push a group of RID's into a global > allocation group and accept there are potential downsides with that > than to try to force a global allocation group on every RID and then > try to fix the mess that makes for non-ENQCMD devices. The proposed ioasid_set change in this set has a token for each set of IOASIDs. /** * struct ioasid_set - Meta data about ioasid_set * @nh: List of notifiers private to that set * @xa: XArray to store ioasid_set private IDs, can be used for * guest-host IOASID mapping, or just a private IOASID namespace. * @token: Unique to identify an IOASID set * @type: Token types * @quota: Max number of IOASIDs can be allocated within the set * @nr_ioasids: Number of IOASIDs currently allocated in the set * @id: ID of the set */ struct ioasid_set { struct atomic_notifier_head nh; struct xarray xa; void *token; int type; int quota; atomic_t nr_ioasids; int id; struct rcu_head rcu; struct misc_cg *misc_cg; /* For misc cgroup accounting */ }; To satisfy your "give me a PASID for this RID" proposal, can we just use the RID's struct device as the token? Also add a type field to explicitly indicate global vs per-set(per-RID). i.e. ioasid_t ioasid_alloc(struct ioasid_set *set, ioasid_t min, ioasid_t max, int type, void *private) Where flags can be: enum ioasid_hwid_type { IOASID_HWID_GLOBAL, IOASID_HWID_PER_SET, }; We are really talking about the HW IOASID, just a reminder. Thanks, Jacob