Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp783586ybc; Fri, 22 Nov 2019 13:06:12 -0800 (PST) X-Google-Smtp-Source: APXvYqzMDk+uY3J40KHVEWRZMo2zsJQz7ktilpmZ5LNcRUIFnzWne188n6ru6sTuGNrId58KDOS6 X-Received: by 2002:a17:906:b289:: with SMTP id q9mr24267293ejz.183.1574456772465; Fri, 22 Nov 2019 13:06:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574456772; cv=none; d=google.com; s=arc-20160816; b=PckPUBgRrrCyWS/HRqW06k3p2nY6R+DGAHMsiSxRYnOcy9SZV2PFjYBxHGsHuDkTSc vL0znE6WQdcoaH2BfQW8mrToj+4bQKWsdQzHdBZND2Sql59ZprmY4o45pVktXTo/HLN0 xF8eJk4nWVOwpMQmqyu9xdUya17V5Sm1a6SampTGAEZNPWFZb/T4uoK1E6SxSVBAt1kR sk7Pief1MQpk1U830/6UtJM6TJaj6BLALpw4OtakXMdRhn5a/q4NYYEaxKJzk+wbqIP9 gNmA55CTcIMteCS6fHOucOY9NPquO9Gyp1r+xz5rPs0YgwiSSaQoRIRC5wNtveBQPFQ5 OOQw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=ILSZGGm7QSx3PdU1qLsdt69tl8AFDunS479DgX6F4Bo=; b=lRHtY8jtoHqx5FfznDu0pNNUpm8Ip9Iq38uiLOzk9/cED7MPsQGwxUdlGsFVkL2p31 HBlQkW6hrl86R+e/5EZ5qH0Me4A3OYCdCC0l79A92wDDr/BpDoeilOiX1QcdLO6vwgIW Xg+1lYSZyzxxV29wr/09MsFkIRwDWHM8lm+BtoGuI4HebiSSnQCqfniEMzUNA258C+HA x0M2JMhUKes0CkqgsLCXkZwgvKQZ0UaiVZF2+0MAU6vj0gvapbjgAOeQqN8sEjPe/Ovs zSmFgT8pOIheMpJ1YCoxO8j1DFrZcbZYgV5clpINH+lCurNllx2+ZAEHaQH9kUZ+mkYM 6d7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="kh80/zLj"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j8si5858770eds.146.2019.11.22.13.05.23; Fri, 22 Nov 2019 13:06:12 -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; dkim=pass header.i=@intel-com.20150623.gappssmtp.com header.s=20150623 header.b="kh80/zLj"; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726690AbfKVVBW (ORCPT + 99 others); Fri, 22 Nov 2019 16:01:22 -0500 Received: from mail-oi1-f194.google.com ([209.85.167.194]:41252 "EHLO mail-oi1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726546AbfKVVBV (ORCPT ); Fri, 22 Nov 2019 16:01:21 -0500 Received: by mail-oi1-f194.google.com with SMTP id e9so7729481oif.8 for ; Fri, 22 Nov 2019 13:01:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=intel-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ILSZGGm7QSx3PdU1qLsdt69tl8AFDunS479DgX6F4Bo=; b=kh80/zLjvg/MndD6Asgkf+9hVicNjw851+U/2dwR7L1ah4TyiU5XqUgbWHuv53l4ID 0xEcah08GvOf3iVDWzlMHd704BRqZh8WMGG8ywjM3ldpt+XF6AvLKjIxoRp6ydktNRaq 6q/jc5Zp0gAHGoR8TPJxoDM/ds4k5S7PZBpWxAqki9ryxU5kEG1i4olKYYk9bOkSQXBw gbeu6O3bMW7Z1IPNmtHGBMneAq+Pcw2D4dA1osFcjt4X6YKmIsvMyYRDs1ew5Fwpl65R +vS43E4dmdb97gHjr3UACfB6cOmOiU4BGPpMZgXZc1njFAppePN7l6PTqY/pH9NcKGEK l76A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ILSZGGm7QSx3PdU1qLsdt69tl8AFDunS479DgX6F4Bo=; b=LmkMAxwGckU/pINvHHK3RM1zosc4sgOwc9zhv9VeRP+hgfCeOfOMqQAiB3u/rjrd7d fW4++feZXW4y3Z8QDPiX79yI9fls5nMazFc0clmwi3pAEDZNO8SlBqTC5FYPxcrUqZV+ tFC3lohf/heyGlgp9BpSyax6IneE+fgjyDBZ9G79rOChU4RbyksFbxsBHWSCfo3D+rFq FtII4by9UEtEoApbDcn20Ap49Oc/5/qeOdqEYrr3tVl5iyqjhNSxCIENTc9SOwiwtMPv NCm6b/wZlv+H4kkl34i83ny8sijuKd4++Gp+ZtFxnPjL9gaqGd75tSRrx4entrnOuHe4 iCPw== X-Gm-Message-State: APjAAAXR81hoWZjYhM2Ctfc5qyGVtA/6IeRJxdJggTAohL3JfPax9iAh ODEDJr/874i8bl7aoLIH2fM3GIxD0E3jR44L2s6u2w== X-Received: by 2002:aca:ea57:: with SMTP id i84mr13409682oih.73.1574456479982; Fri, 22 Nov 2019 13:01:19 -0800 (PST) MIME-Version: 1.0 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> In-Reply-To: From: Dan Williams Date: Fri, 22 Nov 2019 13:01:09 -0800 Message-ID: Subject: Re: [PATCH 1/5] dmaengine: Store module owner in dma_device struct To: Logan Gunthorpe Cc: Dave Jiang , Vinod Koul , Linux Kernel Mailing List , dmaengine@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 22, 2019 at 12:56 PM Logan Gunthorpe wrote: > > > > 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. Oh yes, in fact I think it's something that can only reasonably be considered for new consumers. > 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. Yes, the SOC case is not so much my concern as the generic offload use cases, especially if those offloads are in a similar hotplug domain as a cpu.