All of lore.kernel.org
 help / color / mirror / Atom feed
From: Christian Borntraeger <borntraeger@linux.ibm.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Yuho Choi <oss.patchbox@gmail.com>,
	Eric Farman <farman@linux.ibm.com>,
	Matthew Rosato <mjrosato@linux.ibm.com>,
	Halil Pasic <pasic@linux.ibm.com>,
	Heiko Carstens <hca@linux.ibm.com>,
	Vasily Gorbik <gor@linux.ibm.com>,
	Alexander Gordeev <agordeev@linux.ibm.com>,
	Sven Schnelle <svens@linux.ibm.com>,
	Vineeth Vijayan <vneethv@linux.ibm.com>,
	Peter Oberparleiter <oberpar@linux.ibm.com>,
	Alex Williamson <alex@shazbot.org>,
	linux-s390@vger.kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH v2] vfio/ccw: Flush notoper_work before returning from reset
Date: Mon, 9 Nov 2026 20:40:10 +0100	[thread overview]
Message-ID: <de7b6808-9f9e-4fcd-a0b2-335369dd7eac@linux.ibm.com> (raw)
In-Reply-To: <20261109144953.GN663069@ziepe.ca>



Am 09.11.26 um 15:49 schrieb Jason Gunthorpe:
> On Mon, Nov 09, 2026 at 01:38:44PM +0100, Christian Borntraeger wrote:
>> Am 06.11.26 um 20:10 schrieb Yuho Choi:
>>> vfio_ccw_dma_unmap() is the DMA invalidation callback, which must unpin
>>> the pages covering the range before it returns.  It calls
>>> vfio_ccw_mdev_reset(), which raises a CLOSE event.
>>>
>>> On the normal path fsm_close() calls cp_free() itself, so the pages are
>>> unpinned synchronously.  But if the subchannel cannot be disabled or
>>> quiesced, fsm_close() falls through to a NOT_OPER event.  Since commit
>>> 0c11f61a876e ("s390/vfio_ccw: Move cp cleanup out of not operational"),
>>> fsm_notoper() only queues notoper_work, which is where cp_free() then
>>> runs.  That commit flushes the work in vfio_ccw_mdev_close_device() and
>>> vfio_ccw_mdev_release_dev(), but nothing waits for it on the reset
>>> path, so the callback returns with the pages still pinned.
>>>
>>> Because notoper_work runs asynchronously, vfio_dma_do_unmap() can exhaust
>>> its 10 retries before cp_free() completes, hitting BUG_ON(++retries > 10)
>>> and taking the host down.  A further CLOSE cannot help either, as both
>>> CLOSE and OPEN are fsm_nop in the NOT_OPER state.
>>
>> Does the the iommufd backend have the same problem?
>> iopt_unmap_iova_range() keeps calling the unmap callback and gives up with
>> WARN_ON(tries > 100) and -EDEADLOCK. So that path is also fixed, I
>> guess.
> 
> Drivers are not allowed to refuse the shootdown, it is broken if
> someone has done this.

Agreed, but isnt that what the patch fixes? when CLOSE fails, vfio-ccw
currently returns from the unmap callback with the pages still pinned
and leaves the unpin to notoper_work. With the flush the pages are
unpinned before the callback returns, so the driver keeps the
contract on both backends.

  > Jason


  reply	other threads:[~2026-11-09 19:40 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-06 19:10 [PATCH v2] vfio/ccw: Flush notoper_work before returning from reset Yuho Choi
2026-11-06 19:21 ` sashiko-bot
2026-11-09 12:38 ` Christian Borntraeger
2026-11-09 14:49   ` Jason Gunthorpe
2026-11-09 19:40     ` Christian Borntraeger [this message]
2026-11-09 18:15   ` Yuho Choi

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=de7b6808-9f9e-4fcd-a0b2-335369dd7eac@linux.ibm.com \
    --to=borntraeger@linux.ibm.com \
    --cc=agordeev@linux.ibm.com \
    --cc=alex@shazbot.org \
    --cc=farman@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=jgg@ziepe.ca \
    --cc=kvm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=mjrosato@linux.ibm.com \
    --cc=oberpar@linux.ibm.com \
    --cc=oss.patchbox@gmail.com \
    --cc=pasic@linux.ibm.com \
    --cc=svens@linux.ibm.com \
    --cc=vneethv@linux.ibm.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.