Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796043649; b=mCFgixR/RP6L2Jo7j7HpKBwP7i+Y3mKkj5+ip9E1TxydRKmtx58GZe4uoWeWoq5F/m6U n6/lH23bV6wtyFsDTkA+E9piMoY0IqJ9jq9tFApEtZM7p8iRVQJfR5PAfcOp1ZTGOTH1y aRuZ+guxP5TSZgFnHGMxya9q140FEGP0drMq/cVB85aQ/M7mp28CTaVioh8DKtWBWH/V6 BYH8I+Ysp/i7GT+GSW5Chj1TGF4QPdGFOqPV4+Rm+qEMPu1VWubX+JnYFQYSEPkJuh4U+ L/4JbRTiu9GkEHl07L544L25tDWT5EP0TbxJXal4YMnzDcQp9I4SZmmh41d3Ic/C/Kw== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796043649; h=DMARC-Filter:DKIM-Signature:Received:X-MC-Unique: X-Mimecast-MFC-AGG-ID:Received:DKIM-Signature:X-Google-DKIM-Signature: X-Forwarded-Encrypted:X-Gm-Message-State:X-Gm-Gg:X-Received: X-Received:Received:Message-ID:Subject:From:To:Cc:Date:In-Reply-To: References:Content-Type:Content-Transfer-Encoding:User-Agent: MIME-Version; bh=s7V+j7bNJs5ySvqqWRXzDeJmbOO59apX7neOt2StHOM=; b=SkzBHjTryj1DOZ4JRBBOzdTuWSBw6VDGV1mTpInbdmR7l38S8xIWWdD8GAiycdgqJ8hM FBbWMV9BgfyBCT4bOWB010xISL6ufKEixucYGviPm93Ot7DvWNqRKSIkes94DcPrM3n9z w38TSRnILfq/zMXcMlxt0OTjT/uDycx/nP3sSVHpKiox+kOC7lSIZlDkxszUYXOl3RQTA vbD1m2hjCEksVQE+T/fy3hPKGEWD2FLrOL6qUE3/N8KK0uS8CGuD6zf3pKod4cgG5dBAv 38tqivg9Sk/jzfYyrCNgmncTCkhAYHt+x1/V6zHwIY973pIcMTww5v4C3zhOvevyYqw== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HyWERdMf; dkim=pass header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Dqek5eLe; arc=none smtp.remote-ip=170.10.129.124 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 29E99606A31C for ; Mon, 30 Nov 2026 13:00:48 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 29E99606A31C Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=HyWERdMf; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=google header.b=Dqek5eLe DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1796043648; 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: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=s7V+j7bNJs5ySvqqWRXzDeJmbOO59apX7neOt2StHOM=; b=HyWERdMfT5qxCVXKD5ZeKMzJq9SMGTCODaeWr8P4YvRzmihD/+toazpGfIJFdHPjZnrXGA ER2damY6URxoD8ZvsRp39TaxT3PwDdXd1dOjJTMSJK2BvMl+b5U6zVv4WWYq9XIkF64Dfc MP67Oi0EWvI+IjhpPRFhkkh+bAiFgG8= Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-635-EXVM27v-O_2f0ujHdrrLRg-1; Mon, 30 Nov 2026 13:00:45 +0000 X-MC-Unique: EXVM27v-O_2f0ujHdrrLRg-1 X-Mimecast-MFC-AGG-ID: EXVM27v-O_2f0ujHdrrLRg_1796043644 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-490c1867460so5662648f8f.2 for ; Mon, 30 Nov 2026 05:00:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1796043644; x=1796648444; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:from:to :cc:subject:date:message-id:reply-to:content-type; bh=s7V+j7bNJs5ySvqqWRXzDeJmbOO59apX7neOt2StHOM=; b=Dqek5eLevFODs3okKZ7b7GMZ0PHXJbxORxs9vLFSoPGtzREJtovIBeT0S0yISugYnM H8UPNAhQ9ygaycUBPPInY8fQ8Zyarx23IQ5rgb9RjTdkDf73OE8HaA2QN3JiNMe/8Qvt i/FvcpChVFPamfKgAa/29CYcphxRFW3cSAZm1ECpcToJJhuZPompg65520iBiflv92CO e/+6Vbp6tZMWDYvbDnBSSoBGs2Kaha91tLRoyfOE+2dsZPZSNg1c3MOWKwjqp7chy6hd gIrF05S/r+xSFs3PzmJp2CiJoW1K3o+vQTWkpplcP0mwlIuIINU0Dcoicb6Cz1ocHmtk d6QA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1796043644; x=1796648444; h=mime-version:user-agent:content-transfer-encoding:content-type :references:in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=s7V+j7bNJs5ySvqqWRXzDeJmbOO59apX7neOt2StHOM=; b=jCFlRa/rEEHcPAK4jOV3BGPcSsYe6iEScDZZurfq2g0l/GpZhenuyYsC/hJJS1qZNB mrMOlwayS0F9LQxGZCAdQVCmN0ra4cQ/inAV02AKvFt9rWPXMIAfFNHD82pUbdmcEEmf C2mM1NkHcpDDOnaZ0lQ5Jlak6hl/Q2MTWx2IDBlhahggfzq4hV/Dymu4j3C/7MLT6sGC Dy1Htm9bGkJwi3wSVrJ1AZlmEqKTZiHNOZuyCoSIELIS44CENGy14ettigmnUB+4EDz7 mY1Vurv/iszISU63mZ8CuiorVybDDwYANivcBJVpW+Tx+3iXZ0yQknGMZuSN7jx43J9C dGNw== X-Forwarded-Encrypted: i=1; AL+hErFIg7nEV9jGrXSPdzhfNhWoS4eOURNpLjr2kVfnLnSr6KsJr1H1zY8bWl4TSXHAUTwv8Al8w4k=@vger.kernel.org X-Gm-Message-State: APuU4Z+ELzrm8FtmVLiOdt8MjeTXPrer2pRlOfwkbBZuHjdaXOizQx/l ixK+hMP+DmlUablIfh8utBySUXZXdTpjpknebzlMQ2g0ak19e6LclqJPOiN8h9c5VR/4zv29Bs9 DCrz2Gahvh4eAC2N5t+gY7mbJZ9nDWiWEJzTFfvrHIqx77nI5GtZ56wvvrQ== X-Gm-Gg: AZFdTZeD1/MmCr99J2QLaGyF8QtxXSOSMxSqsHSeDdAJv0fNPA07K1sTJhR2I2daFwP Wm2kVVwB0+yGfGIhjXCwBQhXd2GTVaraYSQRfbBWRZ0xQgBE3exS7Ws29VVIDs0uIGzsJoa4FVi yozbQErvPcHgXhgbGbfHMsmhgkTyKzFT7d7ZlGcpQjzL3WlfA+NO4zSIbSP6XJOYDMfCDMlCwT6 szxa30ch2eF5N3uiUs6QKkwuuwl/G4ou4HsP9iBcr8UMl6m9lafcfwKsy7nLPPxVFSfA1JcsSMs 6wHVrfw1xf/z7rAZ7fPDuvB49JxCUCWtObRtqrKStsWs+J4payUJ/U0O0oaZ/A6YszwR96OgTsx P3p+4iR0H3Qmt5Hsa5tHHWSinowyK1EXC+LljWy7AQTaH/6dFT621geUOfr11yMPUyAfkFSyAYE LJ X-Received: by 2002:a05:6000:4541:b0:4aa:d196:f329 with SMTP id ffacd0b85a97d-4abb4c7afc6mr44741651f8f.27.1796043644427; Mon, 30 Nov 2026 05:00:44 -0800 (PST) X-Received: by 2002:a05:6000:4541:b0:4aa:d196:f329 with SMTP id ffacd0b85a97d-4abb4c7afc6mr44741577f8f.27.1796043643889; Mon, 30 Nov 2026 05:00:43 -0800 (PST) Received: from [10.200.69.177] (nat-pool-muc-u.redhat.com. [149.14.88.27]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4ab6c340df4sm73726048f8f.55.2026.11.30.05.00.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 30 Nov 2026 05:00:43 -0800 (PST) Message-ID: <022e98e0c153e1e306fd06bf9198c25f32645389.camel@redhat.com> Subject: Re: [PATCH] ata: libata-core: Do not use pcim_enable_device() on PCI resume From: "pstanner@redhat.com" To: weidongw@illinois.edu, Damien Le Moal , Niklas Cassel Cc: linux-ide@vger.kernel.org, Bjorn Helgaas , Krzysztof =?UTF-8?Q?Wilczy=C5=84ski?= , linux-kernel@vger.kernel.org, stable@vger.kernel.org Date: Mon, 30 Nov 2026 14:00:42 +0100 In-Reply-To: <20261128-kbug-l080-v1-1-90f7309990ea@illinois.edu> References: <20261128-kbug-l080-v1-1-90f7309990ea@illinois.edu> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-3.fc44) X-Mailing-List: stable@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Hi, thx for the patch. On Sat, 2026-11-28 at 21:11 -0600, Weidong Wang via B4 Relay wrote: > From: Weidong Wang >=20 [=E2=80=A6] >=20 > The fix and this changelog were drafted with AI assistance (Claude Code, > with a second review by OpenAI Codex), then reviewed by the submitter. That's evident from the *very* verbose commit message, which I think should be slimmed down a bit :) >=20 > Fixes: f748a07a0b64 ("PCI: Remove legacy pcim_release()") > Cc: stable@vger.kernel.org > Signed-off-by: Weidong Wang > --- > The case of a detach while the device is still disabled (failed resume) > is left out, see the commit message: it would need a pci_is_enabled() > check in pcim_disable_device(). I can send that as a separate patch if > the PCI side agrees. That's not a good idea. This intertwining makes the API inconsistent. Instead, pcim_disable_device() should not exist / should be deprecated. See below. >=20 > pata_mpiix never enables the device at probe but uses these helpers; > that older imbalance is not touched here. >=20 > Testing: > - Compile-tested on x86_64 (allmodconfig, W=3D1): > =C2=A0 drivers/ata/libata-core.o drivers/ata/pata_cs5520.o; no new warnin= gs. > - checkpatch.pl --strict: no errors or warnings. > --- > =C2=A0drivers/ata/libata-core.c |=C2=A0 8 +++++++- > =C2=A0drivers/ata/pata_cs5520.c | 12 ++++++++---- > =C2=A02 files changed, 15 insertions(+), 5 deletions(-) >=20 > diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c > index f41ab71fc9e2..587a393d2753 100644 > --- a/drivers/ata/libata-core.c > +++ b/drivers/ata/libata-core.c > @@ -6622,7 +6622,13 @@ int ata_pci_device_do_resume(struct pci_dev *pdev) > =C2=A0 pci_set_power_state(pdev, PCI_D0); > =C2=A0 pci_restore_state(pdev); > =C2=A0 > - rc =3D pcim_enable_device(pdev); > + /* > + * Balance the pci_disable_device() done on suspend. The devres action > + * registered by pcim_enable_device() at probe time is still in place, > + * so do not use pcim_enable_device() here or one more disable action > + * would be added on every resume. > + */ > + rc =3D pci_enable_device(pdev); So will pcim_enable_device() still be called somewhere else? I have thought about the pcim_ API a while ago, and my opinion by now is that drivers must either fully use pcim_, never undoing the actions, or should *only* use the pci_ functions. IOW, who wants unmanaged behavior should not use the managed functions. Especially, functions like pcim_disable_device() should not exist IMO. If you want to disable the device at any other point in time than driver unbind, then use pci_enable_device() + pci_disable_device(). > =C2=A0 if (rc) { > =C2=A0 dev_err(&pdev->dev, > =C2=A0 "failed to enable device after resume (%d)\n", rc); > diff --git a/drivers/ata/pata_cs5520.c b/drivers/ata/pata_cs5520.c > index 3163c8d9cef5..4337db7f9359 100644 > --- a/drivers/ata/pata_cs5520.c > +++ b/drivers/ata/pata_cs5520.c ata_pci_device_do_resume() is used in 28 files. Will the parties other than cs5520 be affected by this change? That seems quite likely. > @@ -225,11 +225,15 @@ static int cs5520_reinit_one(struct pci_dev *pdev) > =C2=A0{ > =C2=A0 struct ata_host *host =3D pci_get_drvdata(pdev); > =C2=A0 u8 pcicfg; > - int rc; > =C2=A0 > - rc =3D ata_pci_device_do_resume(pdev); > - if (rc) > - return rc; > + /* > + * The device was not disabled on suspend, so do not enable it again > + * as ata_pci_device_do_resume() would: that would leave the enable > + * count unbalanced. > + */ > + pci_set_power_state(pdev, PCI_D0); > + pci_restore_state(pdev); > + pci_set_master(pdev); That change looks suspicious. I would expect it to be unnecessary if all that were changed in ATA were replacing the pcim_ functions with the pci_ ones. Regards P.