All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Omar Elghoul" <oelghoul@linux.ibm.com>
Cc: "Vasily Gorbik" <gor@linux.ibm.com>,
	kvm@vger.kernel.org, linux-s390@vger.kernel.org,
	"Heiko Carstens" <hca@linux.ibm.com>,
	"Alexander Gordeev" <agordeev@linux.ibm.com>
Subject: Re: [PATCH v5 2/4] s390/pci: Preserve FMB state in device re-enablement
Date: Fri, 26 Jun 2026 18:06:05 +0000	[thread overview]
Message-ID: <20260626180606.2EF961F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260626175525.37370-3-oelghoul@linux.ibm.com>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] This problem wasn't introduced by this patch, but there is a missing resource cleanup in `zpci_reenable_device()` on the `zpci_set_irq()` error path. If `zpci_set_irq()` fails, the function returns immediately without calling `zpci_disable_device()`, unlike the subsequent IOMMU registration error path. This leaves the device enabled in an inconsistent state.
--

commit 94bfdcea02e7e7dca9c322a0dc40fac61a9fb275
Author: Omar Elghoul <oelghoul@linux.ibm.com>

s390/pci: Preserve FMB state in device re-enablement

This commit introduces zpci_fmb_reenable_device() to check the FMB state and
ensure it is enabled. It resets the counters and handles re-enabling if the
FMB was already active.

> diff --git a/arch/s390/pci/pci.c b/arch/s390/pci/pci.c
> index 2910d4038d39c..1eb6aa772eb3f 100644
> --- a/arch/s390/pci/pci.c
> +++ b/arch/s390/pci/pci.c
[ ... ]
> @@ -737,9 +765,13 @@ int zpci_reenable_device(struct zpci_dev *zdev)
>  	}
>  
>  	rc = zpci_iommu_register_ioat(zdev, &status);
> -	if (rc)
> +	if (rc) {
>  		zpci_disable_device(zdev);
> +		return rc;
> +	}

[Severity: High]
This isn't a bug introduced by this patch, but there is a pre-existing issue
with resource cleanup in zpci_reenable_device().

If zpci_set_irq() fails earlier in this function:

        if (zdev->msi_nr_irqs > 0) {
                rc = zpci_set_irq(zdev);
                if (rc)
                        return rc;
        }

It returns immediately without calling zpci_disable_device(), unlike the
subsequent zpci_iommu_register_ioat() error path. Does this leave the device
enabled in the firmware but failed in Linux, rendering it unusable and
leaking its enabled state?

>  
> +	guard(mutex)(&zdev->fmb_lock);
> +	zpci_fmb_reenable_device(zdev);
>  	return rc;
>  }

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260626175525.37370-1-oelghoul@linux.ibm.com?part=2

  reply	other threads:[~2026-06-26 18:06 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-06-26 17:55 [PATCH v5 0/4] vfio-pci/zdev: Improved zPCI Function Measurement Support Omar Elghoul
2026-06-26 17:55 ` [PATCH v5 1/4] s390/pci: Hold fmb_lock when enabling or disabling PCI devices Omar Elghoul
2026-06-26 18:12   ` sashiko-bot
2026-06-26 17:55 ` [PATCH v5 2/4] s390/pci: Preserve FMB state in device re-enablement Omar Elghoul
2026-06-26 18:06   ` sashiko-bot [this message]
2026-07-01  8:34   ` Niklas Schnelle
2026-06-26 17:55 ` [PATCH v5 3/4] s390/pci: Fence FMB enable/disable via debugfs for passthrough devices Omar Elghoul
2026-06-26 17:55 ` [PATCH v5 4/4] vfio-pci/zdev: Add VFIO FMB device features Omar Elghoul

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=20260626180606.2EF961F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=agordeev@linux.ibm.com \
    --cc=gor@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=linux-s390@vger.kernel.org \
    --cc=oelghoul@linux.ibm.com \
    --cc=sashiko-reviews@lists.linux.dev \
    /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.