From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754302AbdCBBLN (ORCPT ); Wed, 1 Mar 2017 20:11:13 -0500 Received: from ale.deltatee.com ([207.54.116.67]:57647 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754271AbdCBBLI (ORCPT ); Wed, 1 Mar 2017 20:11:08 -0500 To: Jason Gunthorpe References: <1488091997-12843-1-git-send-email-logang@deltatee.com> <20170301214120.GA30451@bhelgaas-glaptop.roam.corp.google.com> <4a867c32-ed29-bc98-c7cb-6315243e664a@deltatee.com> <20170301235854.GF2820@obsidianresearch.com> Cc: Bjorn Helgaas , Keith Busch , Myron Stowe , Greg Kroah-Hartman , Bjorn Helgaas , Geert Uytterhoeven , Jonathan Corbet , "David S. Miller" , Andrew Morton , Emil Velikov , Mauro Carvalho Chehab , Guenter Roeck , Jarkko Sakkinen , Linus Walleij , Ryusuke Konishi , Stefan Berger , Wei Zhang , Kurt Schwemmer , Stephen Bates , linux-pci@vger.kernel.org, linux-doc@vger.kernel.org, linux-nvme@lists.infradead.org, linux-kernel@vger.kernel.org From: Logan Gunthorpe Message-ID: <7d6b3b59-5cec-d73f-b65c-4d685ccc70f8@deltatee.com> Date: Wed, 1 Mar 2017 17:23:38 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Icedove/45.6.0 MIME-Version: 1.0 In-Reply-To: <20170301235854.GF2820@obsidianresearch.com> Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.111 X-SA-Exim-Rcpt-To: linux-kernel@vger.kernel.org, linux-nvme@lists.infradead.org, linux-doc@vger.kernel.org, linux-pci@vger.kernel.org, stephen.bates@microsemi.com, kurt.schwemmer@microsemi.com, wzhang@fb.com, stefanb@linux.vnet.ibm.com, konishi.ryusuke@lab.ntt.co.jp, linus.walleij@linaro.org, jarkko.sakkinen@linux.intel.com, linux@roeck-us.net, mchehab@kernel.org, emil.l.velikov@gmail.com, akpm@linux-foundation.org, davem@davemloft.net, corbet@lwn.net, geert+renesas@glider.be, bhelgaas@google.com, gregkh@linuxfoundation.org, myron.stowe@gmail.com, keith.busch@intel.com, helgaas@kernel.org, jgunthorpe@obsidianresearch.com X-SA-Exim-Mail-From: logang@deltatee.com Subject: Re: [PATCH v5 0/4] New Microsemi PCI Switch Management Driver X-SA-Exim-Version: 4.2.1 (built Mon, 26 Dec 2011 16:24:06 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/03/17 04:58 PM, Jason Gunthorpe wrote: > On Wed, Mar 01, 2017 at 03:49:04PM -0700, Logan Gunthorpe wrote: > >> Seems to me like an elegant solution would be to implement a 'cdev_kill' >> function which could kill all the processes using a cdev. Thus, during >> an unbind, a driver could call it and be sure that there are no users >> left and it can safely allow the devres unwind to continue. Then no >> difficult and racy 'alive' flags would be necessary and it would be much >> easier on drivers. > > That could help, but this would mean cdev would have to insert a shim > to grab locks around the various file ops. Hmm, I was hoping something more along the lines of actually killing the processes instead of just shimming away fops. > AFAIK TPM is correct and has been robustly tested now. We have a 'vtpm' > driver that agressively uses hot-unplug. Ah, thanks for the explanation of how that works. I didn't notice the semaphore usage. Switchtec is a bit more tricky because a) there's no upper level driver to handle things and b) userspace may be inside a wait_for_completion (via read or poll) that needs to be completed. If a so called 'cdev_kill' could actually just kill these processes it would be a bit easier. Currently, in the Switchtec code, there's a timeout if the interrupt doesn't fire (which occurs if the pci device has been torn down) and the code will check an alive bit (under mutex protection) and error out if it's not alive. Because of how poll works, I don't see how I can just hold a semaphore inside every fops call like the tpm code does. Logan