From: Robin Murphy Subject: Re: [PATCH v9 1/5] driver core: Find an existing link between two devices Date: Wed, 14 Mar 2018 12:14:15 +0000 Message-ID: <11eae0bc-7921-e598-9c01-63498400c85b@arm.com> References: <20180313085534.11650-1-vivek.gautam@codeaurora.org> <2217404.A2W3Iek6du@aspire.rjw.lan> <2705105.V6KYPvoJqj@aspire.rjw.lan> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <2705105.V6KYPvoJqj-yvgW3jdyMHm1GS7QM15AGw@public.gmane.org> Content-Language: en-GB 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: "Rafael J. Wysocki" , Tomasz Figa Cc: Mark Rutland , devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org, Lukas Wunner , linux-arm-msm , Will Deacon , Linux Kernel Mailing List , "open list:IOMMU DRIVERS" , Rob Herring , Greg Kroah-Hartman List-Id: linux-arm-msm@vger.kernel.org Hi Rafael, On 14/03/18 11:57, Rafael J. Wysocki wrote: > On Wednesday, March 14, 2018 12:50:54 PM CET Tomasz Figa wrote: >> On Wed, Mar 14, 2018 at 8:12 PM, Rafael J. Wysocki wrote: >>> On Tuesday, March 13, 2018 12:23:34 PM CET Tomasz Figa wrote: >>>> On Tue, Mar 13, 2018 at 7:34 PM, Vivek Gautam >>>> wrote: >>>>> Hi Tomasz, >>>>> >>>>> On Tue, Mar 13, 2018 at 3:45 PM, Tomasz Figa wrote: >>>>>> Hi Vivek, >>>>>> >>>>>> Thanks for the patch. >>>>>> >>>>>> On Tue, Mar 13, 2018 at 5:55 PM, Vivek Gautam >>>>>> wrote: >>>>>>> The lists managing the device-links can be traversed to >>>>>>> find the link between two devices. The device_link_add() APIs >>>>>>> does traverse these lists to check if there's already a link >>>>>>> setup between the two devices. >>>>>>> So, add a new APIs, device_link_find(), to find an existing >>>>>>> device link between two devices - suppliers and consumers. >>>>>> >>>>>> I'm wondering if this API would be useful for anything else that the >>>>>> problem we're trying to solve with deleting links without storing them >>>>>> anywhere. Perhaps a device_link_del_dev(consumer, supplier) would be a >>>>>> better alternative? >>>>> >>>>> Yea, that sounds simpler i think. Will add this API instead of >>>>> find_link(). Thanks. >>>> >>>> Perhaps let's wait for a moment to see if there are other opinions. :) >>>> >>>> Rafael, Lucas, any thoughts? >>> >>> It is not clear to me what the device_link_del_dev(consumer, supplier) would do. >> >> It would delete a link between consumer and supplier. > > If there's one I suppose. > > I'm wondering if you are somehow trying to address the same problem as the > device links reference counting patch from Lukas that has been queued up for 4.17 > already. Not quite - the issue here is that we have one supplier with an arbitrarily large number of consumers, and would prefer that supplier not to have to spend a whole bunch of memory to store all the struct device_link pointers for the sole reason of having something to give to device_link_del() at the end, given that the device links code is already keeping track of everything internally anyway. The current API would permit doing this: iommu_attach(dev) { ... if (!device_link_add(dev, iommu, IOMMU_LINK_FLAGS)) return -ENODEV; ... } iommu_detach(dev) { ... // Will return the existing link from earlier link = device_link_add(dev, iommu, IOMMU_LINK_FLAGS); device_link_del(link); // Needed once refcounting is in place //device_link_del(link); ... } but it looks so wacky and non-obvious that we'd like to encapsulate the same behaviour into a more formal interface (my personal naming preference would be device_link_remove(consumer, supplier)). Robin.