Received: by 2002:ab2:b82:0:b0:1f3:401:3cfb with SMTP id 2csp1011624lqh; Fri, 29 Mar 2024 04:42:28 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWS8jMvDDdoDeXCb7SOUOReR64ObCNJMmxZevuHqGRluiJJMgf+XEc03baw+EXZD/6vyVmnmb9vH9QuHtLfL/JeaQC7NWKEIEmy7DnFFw== X-Google-Smtp-Source: AGHT+IFTo1ZsJg/XCvtS4dwDijY9l68wOXk3SXmZx4+gYlgP6VtwINSZ0PDu7JE103bERNoaGJ2l X-Received: by 2002:a05:620a:1346:b0:78a:72b3:b3e8 with SMTP id c6-20020a05620a134600b0078a72b3b3e8mr2099591qkl.6.1711712547841; Fri, 29 Mar 2024 04:42:27 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711712547; cv=pass; d=google.com; s=arc-20160816; b=1LmoMwoo+oMtUgVdsfqFMKTKI5UCAhOx1TITPBin6i5McmiUhuHX2LzpS2Eh8nkAEG LLakQbCeukLKOuMAm5+YmkElYA9VaKM1BkKYoRR+YoAoED8lMEDY+hXamq1OpDwoNvod gGx6B5bi/Gt+L88cP7dyyZigrsmNwSrlR62A90DGc7ZwWoARLXxNDhb6Au3GSJws5jEE CMNrusL3tZbZMH2Nfwllv+E0JcbtvURegQ7YjWTe4Jps6tHtUPgEPI8Pt1rGjbebu74q 4+ezocy/mh4etgLX0ZFwfboxPFEyiclpxIV6SjvvzdLRt0kPQnzSLY8chU/H0lciP+0M MXaA== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:content-disposition:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:message-id:subject:cc :to:from:date:dkim-signature; bh=+BsDTTyNU5pgUTxWeniUBybyV1pHa+zj3gLQFOaKcJw=; fh=dc9J1D4nNIBQNamS02ha9sYBaZnelzf8ZeXO0ChMFdU=; b=KcuYySYjo0c1M2dUELV/ddjkjgFXkP0KtlLAADNbfGgsZLfOsIwiqbRJKXzIQCfbxP eKYt0piFhouYkqQa3XXCYwNRv3WEHH1GlovA+9Fl2NZEyqPnaW3rPqcPGppdgARKHxZP xtHCJO+vtOjZDZoDGBXBw2DUMu+P2qc00ikDv0cW8BpKT/8//vSZseP07RJLuBZr7JS2 3w+YAigopKZlBxDfDh5p27hJhNBWxniu2r7tAnq47xI1qEg08EU2nUQ9uGgdXLcuwZ3R R32Bhsk8MocAtb9G1WeO1KVOJl3Cb2ga7wGSv4PAQUS+nOYSqR0mrA+54GlnawA+NOsS 9ODQ==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MbfF9mx3; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-crypto+bounces-3073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id dz15-20020a05620a2b8f00b0078bcf0989d9si330007qkb.595.2024.03.29.04.42.27 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 04:42:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto+bounces-3073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=MbfF9mx3; arc=pass (i=1 spf=pass spfdomain=redhat.com dkim=pass dkdomain=redhat.com dmarc=pass fromdomain=redhat.com); spf=pass (google.com: domain of linux-crypto+bounces-3073-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-crypto+bounces-3073-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 847951C21F0F for ; Fri, 29 Mar 2024 11:42:27 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1FC8D6AFAE; Fri, 29 Mar 2024 11:42:22 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="MbfF9mx3" X-Original-To: linux-crypto@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C45CC69E1E for ; Fri, 29 Mar 2024 11:42:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.129.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711712541; cv=none; b=eKqlnwVB2QOPU+WxY9bNzMMPPAe3KNECc8k+cMiIRlGlx+vOZXVAfDH+nfkWu/ISzw1ESl6e5ot2+SBHOlMShMKZ6oiO9WDFQKQxzg7b52qTToXTTun5wwreqvXDMWGXwuvhFFe0Zi5Tg2SfF/imU6Rh51B8LFrM5GiMxzJ72Jg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711712541; c=relaxed/simple; bh=CnPyW/y5UQrILS7vE5ScOzPk56jpnW7Bki+iQBNgkGU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ChwhytNv+h3TqwwZCyApaa4pH+UpcVHHh+XnQF0PV77QOkadIgfSFB6hKWhQVDVG0EHz02IKwY9RIgHRRMeA2JWRsUuZPw1H14p0MpEZlnfC4SSD/qi619Mz2a11r4q/qsCukn0TlBsy49bOf7e1efPwzC5UZ8aOVM2jsIe/Ku8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=MbfF9mx3; arc=none smtp.client-ip=170.10.129.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1711712537; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=+BsDTTyNU5pgUTxWeniUBybyV1pHa+zj3gLQFOaKcJw=; b=MbfF9mx3nMXRUAWUk9UHZVuJmnuw7d+qVPMgVbohXLClfVfNMoJxDTY0dRYjf+3WWn0YM6 pizkDJNu8+1N0A6Lpov4nMsHJWosTP06kpph4by4+quM6tk6xAbXFlqEAipNVVCHg5p9Z0 SbLhGz/QBVG8WKWE0TcDhgvaJCuLRQY= Received: from mail-lj1-f197.google.com (mail-lj1-f197.google.com [209.85.208.197]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-509-RKpW6i3wPl-SrsL2t73ISw-1; Fri, 29 Mar 2024 07:42:16 -0400 X-MC-Unique: RKpW6i3wPl-SrsL2t73ISw-1 Received: by mail-lj1-f197.google.com with SMTP id 38308e7fff4ca-2d6d3815f9bso18645811fa.0 for ; Fri, 29 Mar 2024 04:42:16 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711712535; x=1712317335; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=+BsDTTyNU5pgUTxWeniUBybyV1pHa+zj3gLQFOaKcJw=; b=PJYjIChwwCZbPAWNuCU9HDHU4xRWoBkJtKQJwx4OM0E+PCG7kACBVp4SsMW0/wTaMh Ra/3A+BacnUVE1Z00ixNWd2+F4Z5LvoWagtRVv7aRVoppnp/G24vlI+z6tSB0JeenTlf Nushuv1j97Fl242Mv0Mjz8GdtX7+jHy9nc2j9ubgZ1cJrOWBveVw1Y+2piARQrTvMOXY H9we4T4Ha1mePTi1Q28T0Tqk1zoLeMH7sWwv1u0t3G5D4BYkUqP2zbr5zYTcA5bFJhA7 BVoVM8VlWqEJo57BGg/3bcGnwa5FXSeiQXKkslp3nsoRvJvzubWFG4NMBNUV3Jnkokf2 ZNlw== X-Forwarded-Encrypted: i=1; AJvYcCWie1yN301XVQqE5GOQXM4tiS9jcXt+vlWA1O/+7kIELAQB8hvhMBB/5ylkoOfevtFAurXqSFB1YUoE8Dc/mUcD4qt/aEcIMrku2VCq X-Gm-Message-State: AOJu0YzXtWzkW8ywz1KSsdKJZwf7558a97vLo0wuuo9qGc22xn497Igc vu76vomVpPvBfkjVO94V/BBoWm+b+fiMz8yUdCMxCYKBhF6SoTThoOBxouBnmbWv30wssxuFdmz G/lpGbp+9vMNZsmZRyPQyHuifa0zei6/8qgyuotnyIMosJqC9PhV2FqLPbNsDkQ== X-Received: by 2002:a2e:9659:0:b0:2d6:e148:2463 with SMTP id z25-20020a2e9659000000b002d6e1482463mr1428711ljh.24.1711712535133; Fri, 29 Mar 2024 04:42:15 -0700 (PDT) X-Received: by 2002:a2e:9659:0:b0:2d6:e148:2463 with SMTP id z25-20020a2e9659000000b002d6e1482463mr1428676ljh.24.1711712534737; Fri, 29 Mar 2024 04:42:14 -0700 (PDT) Received: from sgarzare-redhat (host-87-12-25-33.business.telecomitalia.it. [87.12.25.33]) by smtp.gmail.com with ESMTPSA id s7-20020a1709062ec700b00a46abaeeb1csm1837128eji.104.2024.03.29.04.42.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Mar 2024 04:42:14 -0700 (PDT) Date: Fri, 29 Mar 2024 12:42:08 +0100 From: Stefano Garzarella To: Krzysztof Kozlowski Cc: "Michael S. Tsirkin" , Jason Wang , Xuan Zhuo , Richard Weinberger , Anton Ivanov , Johannes Berg , Paolo Bonzini , Stefan Hajnoczi , Jens Axboe , Marcel Holtmann , Luiz Augusto von Dentz , Olivia Mackall , Herbert Xu , Amit Shah , Arnd Bergmann , Greg Kroah-Hartman , Gonglei , "David S. Miller" , Viresh Kumar , Linus Walleij , Bartosz Golaszewski , David Airlie , Gerd Hoffmann , Gurchetan Singh , Chia-I Wu , Jean-Philippe Brucker , Joerg Roedel , Alexander Graf , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Eric Van Hensbergen , Latchesar Ionkov , Dominique Martinet , Christian Schoenebeck , Kalle Valo , Dan Williams , Vishal Verma , Dave Jiang , Ira Weiny , Pankaj Gupta , Bjorn Andersson , Mathieu Poirier , "Martin K. Petersen" , Vivek Goyal , Miklos Szeredi , Anton Yakovlev , Jaroslav Kysela , Takashi Iwai , virtualization@lists.linux.dev, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-um@lists.infradead.org, linux-block@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-crypto@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-gpio@vger.kernel.org, dri-devel@lists.freedesktop.org, iommu@lists.linux.dev, netdev@vger.kernel.org, v9fs@lists.linux.dev, kvm@vger.kernel.org, linux-wireless@vger.kernel.org, nvdimm@lists.linux.dev, linux-remoteproc@vger.kernel.org, linux-scsi@vger.kernel.org, linux-fsdevel@vger.kernel.org, alsa-devel@alsa-project.org, linux-sound@vger.kernel.org Subject: Re: [PATCH 01/22] virtio: store owner from modules with register_virtio_driver() Message-ID: References: <20240327-module-owner-virtio-v1-0-0feffab77d99@linaro.org> <20240327-module-owner-virtio-v1-1-0feffab77d99@linaro.org> Precedence: bulk X-Mailing-List: linux-crypto@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline In-Reply-To: <20240327-module-owner-virtio-v1-1-0feffab77d99@linaro.org> On Wed, Mar 27, 2024 at 01:40:54PM +0100, Krzysztof Kozlowski wrote: >Modules registering driver with register_virtio_driver() might forget to >set .owner field. i2c-virtio.c for example has it missing. The field >is used by some of other kernel parts for reference counting >(try_module_get()), so it is expected that drivers will set it. > >Solve the problem by moving this task away from the drivers to the core >amba bus code, just like we did for platform_driver in >commit 9447057eaff8 ("platform_device: use a macro instead of >platform_driver_register"). > >Signed-off-by: Krzysztof Kozlowski >--- > Documentation/driver-api/virtio/writing_virtio_drivers.rst | 1 - > drivers/virtio/virtio.c | 6 ++++-- > include/linux/virtio.h | 7 +++++-- > 3 files changed, 9 insertions(+), 5 deletions(-) > >diff --git a/Documentation/driver-api/virtio/writing_virtio_drivers.rst b/Documentation/driver-api/virtio/writing_virtio_drivers.rst >index e14c58796d25..e5de6f5d061a 100644 >--- a/Documentation/driver-api/virtio/writing_virtio_drivers.rst >+++ b/Documentation/driver-api/virtio/writing_virtio_drivers.rst >@@ -97,7 +97,6 @@ like this:: > > static struct virtio_driver virtio_dummy_driver = { > .driver.name = KBUILD_MODNAME, >- .driver.owner = THIS_MODULE, > .id_table = id_table, > .probe = virtio_dummy_probe, > .remove = virtio_dummy_remove, >diff --git a/drivers/virtio/virtio.c b/drivers/virtio/virtio.c >index f173587893cb..9510c551dce8 100644 >--- a/drivers/virtio/virtio.c >+++ b/drivers/virtio/virtio.c >@@ -362,14 +362,16 @@ static const struct bus_type virtio_bus = { > .remove = virtio_dev_remove, > }; > >-int register_virtio_driver(struct virtio_driver *driver) >+int __register_virtio_driver(struct virtio_driver *driver, struct module *owner) > { > /* Catch this early. */ > BUG_ON(driver->feature_table_size && !driver->feature_table); > driver->driver.bus = &virtio_bus; >+ driver->driver.owner = owner; >+ `.driver.name = KBUILD_MODNAME` also seems very common, should we put that in the macro as well? > return driver_register(&driver->driver); > } >-EXPORT_SYMBOL_GPL(register_virtio_driver); >+EXPORT_SYMBOL_GPL(__register_virtio_driver); > > void unregister_virtio_driver(struct virtio_driver *driver) > { >diff --git a/include/linux/virtio.h b/include/linux/virtio.h >index b0201747a263..26c4325aa373 100644 >--- a/include/linux/virtio.h >+++ b/include/linux/virtio.h >@@ -170,7 +170,7 @@ size_t virtio_max_dma_size(const struct virtio_device *vdev); > > /** > * struct virtio_driver - operations for a virtio I/O driver >- * @driver: underlying device driver (populate name and owner). >+ * @driver: underlying device driver (populate name). > * @id_table: the ids serviced by this driver. > * @feature_table: an array of feature numbers supported by this driver. > * @feature_table_size: number of entries in the feature table array. >@@ -208,7 +208,10 @@ static inline struct virtio_driver *drv_to_virtio(struct device_driver *drv) > return container_of(drv, struct virtio_driver, driver); > } > >-int register_virtio_driver(struct virtio_driver *drv); >+/* use a macro to avoid include chaining to get THIS_MODULE */ >+#define register_virtio_driver(drv) \ >+ __register_virtio_driver(drv, THIS_MODULE) >+int __register_virtio_driver(struct virtio_driver *drv, struct module *owner); > void unregister_virtio_driver(struct virtio_driver *drv); > > /* module_virtio_driver() - Helper macro for drivers that don't do > >-- >2.34.1 >