Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp776621ybc; Fri, 22 Nov 2019 12:59:49 -0800 (PST) X-Google-Smtp-Source: APXvYqya7xJykIt/JwJN5CXeFDCzBWWmPH49b3dMO21NcLwO0BfP8dB9D60oqP7p3L1UwtX2QbjV X-Received: by 2002:aa7:cac7:: with SMTP id l7mr3678193edt.196.1574456389122; Fri, 22 Nov 2019 12:59:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574456389; cv=none; d=google.com; s=arc-20160816; b=GUxITb3jtk68EcFqSi6M658A7Mb7F7RqH/auMoJcAPfZbzLzSN7Z8WEuymLwuMfoDM 8cZhsyuO40eIBRcNkYKN+CV+SBvqooa7fwodyFKlgaxxja2HGsn+KTXF9qcNHVE6AV5I yi6qaYgdBdNPpNcoufQLxaMWhOXHMV3vUFEVA6CLBY2Ufc5rgYOjMcVInmWVOArKENfg B8FcrKJlgrk7iIeuXMixadM4f9jeKIRUWkN3E5vVdsFdK1eWaWNr9r4J87fV60I7ItLm mLRPWrW/Vx1E6OpuVcPMJCsTR0y0u/Y+YYctb7lBLUIEFfSw+IfLPbrEPq+Nbhtfa4tj nsMQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:subject:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to; bh=9/v7jSznRVKjjeUXHbebXV07Umk7SNOUf7sClFkMK4o=; b=NP4vdzWH2l9phuvey8RU/sTF3ghKnO0qx2MGQIAKyl/LSFjs605NJxbW3pWa/XMouM 412XCArl8KyKTpw7LKgDQ+qDpV1oDjMo+TBtGyw+iGOjqaKCbi/p1tquf1n8aAUZ2PyF o65SqBfvUz8MbqTyxLK5MQr8fKbp24lnu1WfksAVoycecWwHLUyBpQBDYU9BdbtM46R4 ueLd5hJdpHudT8LO5VBscV8F2rwnCZdUzyNlbIt6y9VEl9DHFmcQgkDJfXajoxGWhOdR b2ywXjYcYgBYDA+gQGrT9zGjjHqGwRlWBjiV9bbywqA0B/z6IdjqeL6CmFDVPEgny6Og gE9w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q2si4954298eju.229.2019.11.22.12.59.25; Fri, 22 Nov 2019 12:59:49 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727209AbfKVU4T (ORCPT + 99 others); Fri, 22 Nov 2019 15:56:19 -0500 Received: from ale.deltatee.com ([207.54.116.67]:60378 "EHLO ale.deltatee.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726089AbfKVU4S (ORCPT ); Fri, 22 Nov 2019 15:56:18 -0500 Received: from guinness.priv.deltatee.com ([172.16.1.162]) by ale.deltatee.com with esmtp (Exim 4.92) (envelope-from ) id 1iYFyR-00036v-Tt; Fri, 22 Nov 2019 13:56:17 -0700 To: Dan Williams , Dave Jiang Cc: Vinod Koul , Linux Kernel Mailing List , dmaengine@vger.kernel.org References: <20191022214616.7943-1-logang@deltatee.com> <20191022214616.7943-2-logang@deltatee.com> <20191109171853.GF952516@vkoul-mobl> <3a19f075-6a86-4ace-9184-227f3dc2f2d3@deltatee.com> <20191112055540.GY952516@vkoul-mobl> <5ca7ef5d-dda7-e36c-1d40-ef67612d2ac4@deltatee.com> <20191114045555.GJ952516@vkoul-mobl> <20191122052010.GO82508@vkoul-mobl> <4c03b5c6-6f25-2753-22b9-7cdcb4f8b527@intel.com> From: Logan Gunthorpe Message-ID: Date: Fri, 22 Nov 2019 13:56:15 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-CA Content-Transfer-Encoding: 7bit X-SA-Exim-Connect-IP: 172.16.1.162 X-SA-Exim-Rcpt-To: dmaengine@vger.kernel.org, linux-kernel@vger.kernel.org, vkoul@kernel.org, dave.jiang@intel.com, dan.j.williams@intel.com X-SA-Exim-Mail-From: logang@deltatee.com X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on ale.deltatee.com X-Spam-Level: X-Spam-Status: No, score=-8.7 required=5.0 tests=ALL_TRUSTED,BAYES_00, GREYLIST_ISWHITE,MYRULES_FREE autolearn=ham autolearn_force=no version=3.4.2 Subject: Re: [PATCH 1/5] dmaengine: Store module owner in dma_device struct X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on ale.deltatee.com) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2019-11-22 1:50 p.m., Dan Williams wrote: > On Fri, Nov 22, 2019 at 8:53 AM Dave Jiang wrote: >> >> >> >> On 11/21/19 10:20 PM, Vinod Koul wrote: >>> On 14-11-19, 10:03, Logan Gunthorpe wrote: >>>> >>>> >>>> On 2019-11-13 9:55 p.m., Vinod Koul wrote: >>>>>> But that's the problem. We can't expect our users to be "nice" and not >>>>>> unbind when the driver is in use. Killing the kernel if the user >>>>>> unexpectedly unbinds is not acceptable. >>>>> >>>>> And that is why we review the code and ensure this does not happen and >>>>> behaviour is as expected >>>> >>>> Yes, but the current code can kill the kernel when the driver is unbound. >>>> >>>>>>>> I suspect this is less of an issue for most devices as they wouldn't >>>>>>>> normally be unbound while in use (for example there's really no reason >>>>>>>> to ever unbind IOAT seeing it's built into the system). Though, the fact >>>>>>>> is, the user could unbind these devices at anytime and we don't want to >>>>>>>> panic if they do. >>>>>>> >>>>>>> There are many drivers which do modules so yes I am expecting unbind and >>>>>>> even a bind following that to work >>>>>> >>>>>> Except they will panic if they unbind while in use, so that's a >>>>>> questionable definition of "work". >>>>> >>>>> dmaengine core has module reference so while they are being used they >>>>> won't be removed (unless I complete misread the driver core behaviour) >>>> >>>> Yes, as I mentioned in my other email, holding a module reference does >>>> not prevent the driver from being unbound. Any driver can be unbound by >>>> the user at any time without the module being removed. >>> >>> That sounds okay then. >> >> I'm actually glad Logan is putting some work in addressing this. I also >> ran into the same issue as well dealing with unbinds on my new driver. > > This was an original mistake of the dmaengine implementation that > Vinod inherited. Module pinning is distinct from preventing device > unbind which ultimately can't be prevented. Longer term I think we > need to audit dmaengine consumers to make sure they are prepared for > the driver to be removed similar to how other request based drivers > can gracefully return an error status when the device goes away rather > than crashing. Yes, but that will be a big project because there are a lot of drivers. But I think the dmaengine common code needs to support removal properly, which essentially means changing how all the drivers allocate and free their structures, among other things. The one saving grace is that most of the drivers are for SOCs which can't be physically removed and there's really no use-case for the user to call unbind. Logan