Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 22 Aug 2019 20:53:49 -0400
From:      Jung-uk Kim <jkim@FreeBSD.org>
To:        Warner Losh <imp@bsdimp.com>, John Baldwin <jhb@freebsd.org>
Cc:        Warner Losh <imp@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   Re: svn commit: r351406 - head/sys/dev/nvme
Message-ID:  <e32060ad-f2bf-7a56-4205-3040ca3253e9@FreeBSD.org>
In-Reply-To: <CANCZdfr4ETsuSmD91EomrPnbi%2B5hX89jq5Uq1%2BbNg9PPCahAaQ@mail.gmail.com>
References:  <201908222112.x7MLCpbt023647@repo.freebsd.org> <bcd7d7cc-a79f-98a1-49b1-8868bfc64818@FreeBSD.org> <CANCZdfr4ETsuSmD91EomrPnbi%2B5hX89jq5Uq1%2BbNg9PPCahAaQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
This is a multi-part message in MIME format.
--------------A5AC9B068D6157EF15B1EC8F
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit

On 19. 8. 22., Warner Losh wrote:
> On Thu, Aug 22, 2019, 3:27 PM John Baldwin <jhb@freebsd.org
> <mailto:jhb@freebsd.org>> wrote:
> 
>     On 8/22/19 2:12 PM, Warner Losh wrote:
>     > Author: imp
>     > Date: Thu Aug 22 21:12:51 2019
>     > New Revision: 351406
>     > URL: https://svnweb.freebsd.org/changeset/base/351406
>     >
>     > Log:
>     >   We need to define version 1 of nvme, not nvme_foo. Otherwise nvd
>     won't
>     >   load and people who pull in nvme/nvd from modules can't load nvd.ko
>     >   since it depends on nvme, not nvme_foo. The duplicate doesn't matter
>     >   since kldxref properly handles that case.
> 
>     I would perhaps have put the MODULE_VERSION for nvme and its dependency
>     on cam into nvme.c instead of duplicating it.  I think that is more
>     consistent
>     with what we have done elsewhere in the tree.
> 
> 
> That can't be true. Doing that doesn't work. We wind up dereferencing
> freed memory, as we discussed on IRC. Each DRIVER_MODULE needs its own
> MODULE_VERSION given the current code. I'd call that a bug, but not one
> I could dig into today... 

FYI, the attached patch works for me.

Jung-uk Kim

--------------A5AC9B068D6157EF15B1EC8F
Content-Type: text/x-patch; charset=UTF-8;
 name="nvme.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment;
 filename="nvme.diff"

Index: sys/dev/nvme/nvme.c
===================================================================
--- sys/dev/nvme/nvme.c	(revision 351406)
+++ sys/dev/nvme/nvme.c	(working copy)
@@ -57,6 +57,9 @@ MALLOC_DEFINE(M_NVME, "nvme", "nvme(4) memory allo
 
 devclass_t nvme_devclass;
 
+MODULE_VERSION(nvme, 1);
+MODULE_DEPEND(nvme, cam, 1, 1, 1);
+
 static void
 nvme_init(void)
 {
Index: sys/dev/nvme/nvme_ahci.c
===================================================================
--- sys/dev/nvme/nvme_ahci.c	(revision 351406)
+++ sys/dev/nvme/nvme_ahci.c	(working copy)
@@ -54,9 +54,9 @@ static driver_t nvme_ahci_driver = {
 	sizeof(struct nvme_controller),
 };
 
-DRIVER_MODULE(nvme, ahci, nvme_ahci_driver, nvme_devclass, NULL, 0);
-MODULE_VERSION(nvme, 1);
-MODULE_DEPEND(nvme, cam, 1, 1, 1);
+DRIVER_MODULE(nvme_ahci, ahci, nvme_ahci_driver, nvme_devclass, NULL, 0);
+MODULE_VERSION(nvme_ahci, 1);
+MODULE_DEPEND(nvme_ahci, nvme, 1, 1, 1);
 
 static int
 nvme_ahci_probe (device_t device)
Index: sys/dev/nvme/nvme_pci.c
===================================================================
--- sys/dev/nvme/nvme_pci.c	(revision 351406)
+++ sys/dev/nvme/nvme_pci.c	(working copy)
@@ -61,9 +61,9 @@ static driver_t nvme_pci_driver = {
 	sizeof(struct nvme_controller),
 };
 
-DRIVER_MODULE(nvme, pci, nvme_pci_driver, nvme_devclass, NULL, 0);
-MODULE_VERSION(nvme, 1);
-MODULE_DEPEND(nvme, cam, 1, 1, 1);
+DRIVER_MODULE(nvme_pci, pci, nvme_pci_driver, nvme_devclass, NULL, 0);
+MODULE_VERSION(nvme_pci, 1);
+MODULE_DEPEND(nvme_pci, nvme, 1, 1, 1);
 
 static struct _pcsid
 {

--------------A5AC9B068D6157EF15B1EC8F--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?e32060ad-f2bf-7a56-4205-3040ca3253e9>