From: Alistair Popple <apopple@nvidia.com>
To: Stanislav Kinsburskii <skinsburskii@gmail.com>
Cc: akpm@linux-foundation.org, jgg@ziepe.ca, leon@kernel.org,
linux-kernel@vger.kernel.org, linux-mm@kvack.org
Subject: Re: [PATCH] lib: test_hmm: use device devt for coherent device range selection
Date: Mon, 6 Jul 2026 14:29:56 +1000 [thread overview]
Message-ID: <aksu7Baw-Pe4WtuT@nvdebian.thelocal> (raw)
In-Reply-To: <178277581197.172200.16265155329935822153.stgit@skinsburskii>
On 2026-06-30 at 09:30 +1000, Stanislav Kinsburskii <skinsburskii@gmail.com> wrote...
> Commit af69016dab96 ("lib: test_hmm: implement a device release method")
> moved the initial dmirror_allocate_chunk() call before cdev_device_add().
> That means the struct cdev has not been added yet, so cdev_add() has not
> initialized mdevice->cdevice.dev.
>
> The coherent-device range selection uses the device minor to choose between
> spm_addr_dev0 and spm_addr_dev1. Reading MINOR(mdevice->cdevice.dev) before
> cdev_add() therefore always sees an uninitialized dev_t. As a result, both
> coherent devices select the same physical range, and adding the second
> device fails due to the overlapping dev_pagemap range.
>
> Use mdevice->device.devt instead. It is initialized in
> dmirror_device_init() before dmirror_allocate_chunk() is called and is the
> same dev_t later passed to cdev_device_add().
>
> Fixes: af69016dab96 ("lib: test_hmm: implement a device release method")
> Signed-off-by: Stanislav Kinsburskii <skinsburskii@gmail.com>
> ---
> lib/test_hmm.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/lib/test_hmm.c b/lib/test_hmm.c
> index 9c59d1ceb5b5..c4adbf98fac7 100644
> --- a/lib/test_hmm.c
> +++ b/lib/test_hmm.c
> @@ -581,7 +581,7 @@ static int dmirror_allocate_chunk(struct dmirror_device *mdevice,
> devmem->pagemap.type = MEMORY_DEVICE_PRIVATE;
> break;
> case HMM_DMIRROR_MEMORY_DEVICE_COHERENT:
> - devmem->pagemap.range.start = (MINOR(mdevice->cdevice.dev) - 2) ?
> + devmem->pagemap.range.start = (MINOR(mdevice->device.devt) - 2) ?
Makes sense to me. As Andrew mentioned we should cc: stable, but I assume he
will add that so:
Reviewed-by: Alistair Popple <apopple@nvidia.com>
> spm_addr_dev0 :
> spm_addr_dev1;
> devmem->pagemap.range.end = devmem->pagemap.range.start +
>
>
>
prev parent reply other threads:[~2026-07-06 4:30 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-29 23:30 [PATCH] lib: test_hmm: use device devt for coherent device range selection Stanislav Kinsburskii
2026-06-30 0:06 ` Andrew Morton
2026-07-06 4:29 ` Alistair Popple [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aksu7Baw-Pe4WtuT@nvdebian.thelocal \
--to=apopple@nvidia.com \
--cc=akpm@linux-foundation.org \
--cc=jgg@ziepe.ca \
--cc=leon@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mm@kvack.org \
--cc=skinsburskii@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox