mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Wu. JackBB (GSM)" <JackBB_Wu@compal.com>
To: Brian Norris <briannorris@chromium.org>
Cc: Loic Poulain <loic.poulain@oss.qualcomm.com>,
	Sergey Ryazanov <ryazanov.s.a@gmail.com>,
	Johannes Berg <johannes@sipsolutions.net>,
	"Andrew Lunn" <andrew+netdev@lunn.ch>,
	"David S. Miller" <davem@davemloft.net>,
	"Eric Dumazet" <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
	Wen-Zhi Huang <wen-zhi.huang@mediatek.com>,
	Shi-Wei Yeh <shi-wei.yeh@mediatek.com>,
	Minano Tseng <Minano.tseng@mediatek.com>,
	Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>,
	Simon Horman <horms@kernel.org>, Jonathan Corbet <corbet@lwn.net>,
	Shuah Khan <skhan@linuxfoundation.org>,
	"Yu. Robert (GSM)" <robert_yu@compal.com>,
	"Chang. Jeff (GSM)" <Jeff_Chang@compal.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"netdev@vger.kernel.org" <netdev@vger.kernel.org>,
	"linux-arm-kernel@lists.infradead.org"
	<linux-arm-kernel@lists.infradead.org>,
	"linux-mediatek@lists.infradead.org"
	<linux-mediatek@lists.infradead.org>,
	"linux-doc@vger.kernel.org" <linux-doc@vger.kernel.org>
Subject: Re: [PATCH v11 1/6] net: wwan: t9xx: Add PCIe core
Date: Fri, 13 Nov 2026 06:36:13 +0000	[thread overview]
Message-ID: <3e19cff16c1145ee8801c18a24c1c0f3@compal.com> (raw)
In-Reply-To: <avY4pfjYOoJGh4en@google.com>

Hi Brian,

Thanks for the review.

On Fri, Nov 13, 2026 at 6:07 AM Brian Norris <briannorris@chromium.org> wrote:
> On Thu, Nov 05, 2026 at 03:56:27PM +0800, Jack Wu wrote:
[...]
> > +     ret = pci_save_state(pdev);
> > +     if (ret) {
> > +             dev_err(mdev->dev, "Failed to save PCI state: %d\n", ret);
> > +             goto free_irq;
> > +     }
>
> I'm a bit skeptical of drivers that stash an extra copy of PCI state.
> There are times where it's legitimate, but often it means you'll
> introduce bugs of your own.

Agreed, v12 will drop the copy. remove() will call pci_save_state() right
before the modem reset and pci_restore_state() right after it, the way
t7xx_reset_device() does, and probe() will no longer save anything.

The restore itself is still needed: the reset returns the endpoint to
its power-on defaults, with the BARs and the command register cleared,
so config space has to be written back for the next driver that binds
to the device.

[...]
> > +     /* Without this a runtime-PM suspend after unbind would snapshot the
> > +      * reset state over our copy, and whoever binds next finds BARs the
> > +      * device does not decode.
> > +      */
>
> I'm confused about this explanation. You don't ever call
> pm_runtime_put() or similar, so this device can never actually
> runtime-suspend. Are you talking about some code that's not included in
> this patch series?
>
> https://docs.kernel.org/power/pci.html#device-runtime-power-management

You're right, the comment is wrong. The driver does not use runtime PM,
and the save and restore are needed only because of the reset above.
The comment will be removed in v12.

> Anyway, if you *did* have a problem here ... I expect the answer is to
> properly get() a reference on the way out, so that runtime_suspend is no
> longer possible after a reset, until the next probe().

With both the save and the restore inside remove(), the reference the
PCI core already holds across ->remove() keeps the device active between
them, and config space is back in place before remove() returns. So v12
will not need a reference of its own.

> You also have a slightly different description from the cover letter:
>
> """
>   - mtk_pci_remove() calls pci_restore_state() and pci_clear_master()
>     after pci_load_and_free_saved_state(): the reset leaves the device
>     at power-on defaults and the state was saved after pci_set_master()
> """

You're right, the code no longer matches that description. In v12 the
save will happen after pci_clear_master() and pci_disable_device(), right
before the reset, so the restored command register has bus mastering
off, and the v12 changelog will describe it that way.

> In any case, something seems fishy here.

Agreed. In v12 it will be a single save and restore around the reset.

Thanks,
Jack

  reply	other threads:[~2026-11-13  6:36 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-05  7:56 [PATCH v11 0/6] net: wwan: t9xx: Add MediaTek T9XX WWAN driver Jack Wu via B4 Relay
2026-11-05  7:56 ` [PATCH v11 1/6] net: wwan: t9xx: Add PCIe core Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:54     ` Wu. JackBB (GSM)
2026-11-12 22:07   ` Brian Norris
2026-11-13  6:36     ` Wu. JackBB (GSM) [this message]
2026-11-05  7:56 ` [PATCH v11 2/6] net: wwan: t9xx: Add control plane transaction layer framework Jack Wu via B4 Relay
2026-11-05  7:56 ` [PATCH v11 3/6] net: wwan: t9xx: Add control DMA interface Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:56     ` Wu. JackBB (GSM)
2026-11-05  7:56 ` [PATCH v11 4/6] net: wwan: t9xx: Add control port Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:57     ` Wu. JackBB (GSM)
2026-11-05  7:56 ` [PATCH v11 5/6] net: wwan: t9xx: Add FSM thread Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:57     ` Wu. JackBB (GSM)
2026-11-05  7:56 ` [PATCH v11 6/6] net: wwan: t9xx: Add AT & MBIM WWAN ports Jack Wu via B4 Relay
2026-11-10 11:03   ` netdev-bot+sashiko
2026-11-11  8:58     ` Wu. JackBB (GSM)

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=3e19cff16c1145ee8801c18a24c1c0f3@compal.com \
    --to=jackbb_wu@compal.com \
    --cc=Jeff_Chang@compal.com \
    --cc=Minano.tseng@mediatek.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=briannorris@chromium.org \
    --cc=corbet@lwn.net \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=johannes@sipsolutions.net \
    --cc=kuba@kernel.org \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=loic.poulain@oss.qualcomm.com \
    --cc=matthias.bgg@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=robert_yu@compal.com \
    --cc=ryazanov.s.a@gmail.com \
    --cc=shi-wei.yeh@mediatek.com \
    --cc=skhan@linuxfoundation.org \
    --cc=wen-zhi.huang@mediatek.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

all inboxes | Powered by JetHome®