Received: by 2002:ab2:1149:0:b0:1f3:1f8c:d0c6 with SMTP id z9csp895222lqz; Sun, 31 Mar 2024 04:20:48 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCWG1jrTJ31MSjx60xVP75qpKf6DAFOYxMawmgwpDTL5KAY5qX4F8rW849EHV9Ob0vkgMT+KsC/Jtqwwv4qoGIzGPGl+2B/CVRdcFmz2Hg== X-Google-Smtp-Source: AGHT+IEBE4cSC09j+yUk1vUEEI/Fut2R2VfriGDx7eBS5tYTUq5RhzCYGArfgk4yoDCtYqnzPo3L X-Received: by 2002:ac2:5ecf:0:b0:516:a6b2:f9eb with SMTP id d15-20020ac25ecf000000b00516a6b2f9ebmr1012906lfq.69.1711884047863; Sun, 31 Mar 2024 04:20:47 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1711884047; cv=pass; d=google.com; s=arc-20160816; b=D4EYNCr/RzOQyeQBuGLKva6Nfwa5S9REUu5TxzcafCPJnB7AXMDk576u6t0k7y9wk/ 8eDr8fqWxNonsPlqt3HP9eNUcTPy25TqSZmmT8CdztgjOAOz34Ocj8Gf9avXM0HAevta y3kcxhRXsaopftreqBgNhMHG39UvlEXpLWxYD9pCdaWPxw2kmLP86+iyMG8ZbFYAb2ob 4kVE9rM+pipF9ZPM7HvBDY/dTd/7UbeAwg1Ctj5y9znNx9Aq9tmVyZyI2vBEjiFNnqwV 0pwVJjj78cxDidKt7zM3pUORn8WEiVaJUGLI0+SLkdtnnumUSlWb4pzcDNBzsAu5XEJc VDZw== 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=ZAFJ+0SeTqdsqNS6GC0N4AccV7yeFgGXHpRB2cwbNo4=; fh=eDeukJVnssaCjhucOD5c9+JYhEpScTZ58W4/+JxapNk=; b=0C76qecLz38NpX36u04DBskSc9grY2Bf0YJTI0h+z6M4tc+VVvqPcnRE4UbOWlT1ag rUvel9f/1CFyISsSAUocPX+Uy9IQbuHl2xpSmoETXn+oD+Cybx26lXBt0PMKk0l3j095 LGXLXy9yCZat0IWLjHdeiobe0/3Jqb8hsWrNEyOatZ8Fu3vKlndnKmySYXviOosg+9c8 6xouI+JFDdSz/B6+hHRKrVSMdBINEIXAZGQVL/kb2kFHujbZm3xoF3Ps5Ni/CCYiyfDq hCGC9geKDRH1zRZP3bvHPFvFslWp9+HH89zKqyTrAA2uUgl8QolA1qb4jsk++eR22DHR rryw==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c7i9IAHs; 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-wireless+bounces-5669-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5669-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id ga36-20020a1709070c2400b00a4e15c6dc6esi3720735ejc.394.2024.03.31.04.20.47 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Mar 2024 04:20:47 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless+bounces-5669-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=c7i9IAHs; 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-wireless+bounces-5669-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-5669-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 am.mirrors.kernel.org (Postfix) with ESMTPS id 41AB71F2192A for ; Sun, 31 Mar 2024 11:20:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 17A6E1448C7; Sun, 31 Mar 2024 11:20:42 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="c7i9IAHs" X-Original-To: linux-wireless@vger.kernel.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 E2B2C144305 for ; Sun, 31 Mar 2024 11:20:39 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711884041; cv=none; b=SbSsPbwjJwxzebpOCosHTcMvrp8GKATIeK7OFf1dFDo+wvNLhXTF8GbOW6U/QihwTb9/Aq+xqugJpsFs1Mz0trscgpJfwjHQnbomcXNMIbX9jbQEpTAsn8WLztubzJsJ7huCmv9m7Ei1Y7wR2b02mRJagUnC6QLOarqPp4+FMXk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1711884041; c=relaxed/simple; bh=HA92dRzVt3vZdgr5pQJY02em2UTWtsR+GLFyMiGbHw4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=Z+bIvAM7zEp10fEy9KXQ02RUwUGMZEf6Q5L5WAtVANwx+XG39iT3ghfrgfKSE6u4o4y8YEH2qj5R7oIurAcI/aGiU4AI8M+wPe17hbJqrvysif5qeYJQ1U8eOpgc/vBAcSsFV5lH0AUEf11J5FnDNfRYb3wj3U4WHToQBarrs0o= 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=c7i9IAHs; arc=none smtp.client-ip=170.10.133.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=1711884038; 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=ZAFJ+0SeTqdsqNS6GC0N4AccV7yeFgGXHpRB2cwbNo4=; b=c7i9IAHsKuupMX+QQPKbD7KgxC0UmvECMDPWeIvRD1pNKLUFH4axWG4pdtxcuX1LmGnPO3 gM2r3MOoObjgNNk0gWim29dzL+FITCqjEbrZuABlRIdOhAzG92Y5aSzV59s9BLlwdbVclF t6IoszosnTZQ9ptY4RWIPTQb15+RIGE= Received: from mail-wm1-f71.google.com (mail-wm1-f71.google.com [209.85.128.71]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-290-zmi87mKyNkqL8R4U6VYK-g-1; Sun, 31 Mar 2024 07:20:36 -0400 X-MC-Unique: zmi87mKyNkqL8R4U6VYK-g-1 Received: by mail-wm1-f71.google.com with SMTP id 5b1f17b1804b1-41481ad9364so21227115e9.0 for ; Sun, 31 Mar 2024 04:20:35 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1711884035; x=1712488835; 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=ZAFJ+0SeTqdsqNS6GC0N4AccV7yeFgGXHpRB2cwbNo4=; b=r5LhL8Lc5XSRPmBj0dI60dho2etBjB55fBNe4WldPPR/sLdEPaL2SxWmRINdJKlCQ3 FgMp4jZIgBvoBv1Eh+X1YIU7U4dsYxXpmDMub8B6SlAouG/jsMzOuygEh59NO7tZjpQT pfRWSzpeSltm3Ze/7Dyhhx36VE0E35+H9ZFrOgOpNTlfIvuUZF5daKIZqba4JNAa8jLq 1DZ7tKKjpFBd/Iugpj5N0rKpD/8c3Wq5AXCvExq269Y1r3GOgZDnaQqwsZ1sTMdN13y6 BhoXZIkeBw1cXGlXyIlltgKW55paLvCjY+4D49DvAQdi9qkYQtvp7zioVGVXSNuf5N+8 2SRA== X-Forwarded-Encrypted: i=1; AJvYcCXVYRL5SZlEue05/ubPdnL4Vr8lWWdWkZBxzPVNlcJybna3BO0JcT/1LKCXlLt4poyvDNL6xc95sR9LciuEtrGcH3bMTW2mImmamciTg8s= X-Gm-Message-State: AOJu0YwVceWrvsBjgaOtbwBnN3yA0Z7Evxl3qyyLPOgabazZX58LeSzt QDtvMe2S8R6d67UVRDxRUEBN0c1Mc7AWmhUDMcJzz9UPzReRJWlrodozW3ncpPMRjNFyUWBWtIn hC8q+9THv3L+n64Sw8BNI+xEqKX52A9F5B2jHmyrpgtd3zBj1oLE2U0BlC4i0OPKJ X-Received: by 2002:a05:600c:220f:b0:413:e19:337f with SMTP id z15-20020a05600c220f00b004130e19337fmr6115872wml.22.1711884034573; Sun, 31 Mar 2024 04:20:34 -0700 (PDT) X-Received: by 2002:a05:600c:220f:b0:413:e19:337f with SMTP id z15-20020a05600c220f00b004130e19337fmr6115845wml.22.1711884033951; Sun, 31 Mar 2024 04:20:33 -0700 (PDT) Received: from redhat.com ([2a02:14f:173:c52c:ce6f:ec9c:ca7c:7200]) by smtp.gmail.com with ESMTPSA id u22-20020a05600c139600b004148d7b889asm14465567wmf.8.2024.03.31.04.20.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 31 Mar 2024 04:20:33 -0700 (PDT) Date: Sun, 31 Mar 2024 07:20:24 -0400 From: "Michael S. Tsirkin" To: Krzysztof Kozlowski Cc: 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: <20240331071546-mutt-send-email-mst@kernel.org> 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-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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 This makes sense. So this will be: Fixes: 3cfc88380413 ("i2c: virtio: add a virtio i2c frontend driver") Cc: "Jie Deng" and I think I will pick this patch for this cycle to fix the bug. The cleanups can go in the next cycle. > --- > 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; > + > 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