mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: "Slark Xiao" <slark_xiao@163.com>
To: "Manivannan Sadhasivam" <manivannan.sadhasivam@oss.qualcomm.com>
Cc: mani@kernel.org, mhi@lists.linux.dev,
	linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re:[PATCH] bus: mhi: host: pci_generic: Fix the physical function check
Date: Wed, 27 May 2026 18:08:23 +0800 (CST)	[thread overview]
Message-ID: <12aa604a.8d99.19e68e81ed2.Coremail.slark_xiao@163.com> (raw)
In-Reply-To: <20260527085220.14139-1-manivannan.sadhasivam@oss.qualcomm.com>

At 2026-05-27 16:52:20, "Manivannan Sadhasivam" <manivannan.sadhasivam@oss.qualcomm.com> wrote:
>Commit b4d01c5b9a9d ("bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID
>for VF's to check status") added the check for physical function by
>checking for 'pdev->is_physfn. But 'pdev->is_physfn' is only set for the
>physical function of a SR-IOV capable device. But for the non-SR-IOV device
>this variable will be 0. So this check ended up breaking the health check
>functionality for all non-SR-IOV devices.
>
>Fix it by checking for '!pdev->is_virtfn' to make sure that the check is
>only skipped for virtual functions.
>
>Reported-by: Slark Xiao <slark_xiao@163.com>
>Fixes: b4d01c5b9a9d ("bus: mhi: host: pci_generic: Read SUBSYSTEM_VENDOR_ID for VF's to check status")
>Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
>---
> drivers/bus/mhi/host/pci_generic.c | 20 ++++++++++----------
> 1 file changed, 10 insertions(+), 10 deletions(-)
>
>diff --git a/drivers/bus/mhi/host/pci_generic.c b/drivers/bus/mhi/host/pci_generic.c
>index 5836ecb0ea32..0d0d9c7ffa4b 100644
>--- a/drivers/bus/mhi/host/pci_generic.c
>+++ b/drivers/bus/mhi/host/pci_generic.c
>@@ -1261,7 +1261,7 @@ static void mhi_pci_recovery_work(struct work_struct *work)
> 
> 	dev_warn(&pdev->dev, "device recovery started\n");
> 
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		timer_delete(&mhi_pdev->health_check_timer);
> 
> 	pm_runtime_forbid(&pdev->dev);
>@@ -1291,7 +1291,7 @@ static void mhi_pci_recovery_work(struct work_struct *work)
> 
> 	set_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status);
> 
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		mod_timer(&mhi_pdev->health_check_timer, jiffies + HEALTH_CHECK_PERIOD);
> 
> 	return;
>@@ -1382,7 +1382,7 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> 		mhi_cntrl_config = info->config;
> 
> 	/* Initialize health check monitor only for Physical functions */
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		timer_setup(&mhi_pdev->health_check_timer, health_check, 0);
> 
> 	mhi_cntrl = &mhi_pdev->mhi_cntrl;
>@@ -1404,7 +1404,7 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> 	mhi_cntrl->mru = info->mru_default;
> 	mhi_cntrl->name = info->name;
> 
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		mhi_pdev->reset_on_remove = info->reset_on_remove;
> 
> 	if (info->edl_trigger)
>@@ -1453,7 +1453,7 @@ static int mhi_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> 	set_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status);
> 
> 	/* start health check */
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		mod_timer(&mhi_pdev->health_check_timer, jiffies + HEALTH_CHECK_PERIOD);
> 
> 	/* Allow runtime suspend only if both PME from D3Hot and M3 are supported */
>@@ -1482,7 +1482,7 @@ static void mhi_pci_remove(struct pci_dev *pdev)
> 	pm_runtime_forbid(&pdev->dev);
> 	pci_disable_sriov(pdev);
> 
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		timer_delete_sync(&mhi_pdev->health_check_timer);
> 	cancel_work_sync(&mhi_pdev->recovery_work);
> 
>@@ -1514,7 +1514,7 @@ static void mhi_pci_reset_prepare(struct pci_dev *pdev)
> 
> 	dev_info(&pdev->dev, "reset\n");
> 
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		timer_delete(&mhi_pdev->health_check_timer);
> 
> 	/* Clean up MHI state */
>@@ -1560,7 +1560,7 @@ static void mhi_pci_reset_done(struct pci_dev *pdev)
> 	}
> 
> 	set_bit(MHI_PCI_DEV_STARTED, &mhi_pdev->status);
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		mod_timer(&mhi_pdev->health_check_timer, jiffies + HEALTH_CHECK_PERIOD);
> }
> 
>@@ -1626,7 +1626,7 @@ static int  __maybe_unused mhi_pci_runtime_suspend(struct device *dev)
> 	if (test_and_set_bit(MHI_PCI_DEV_SUSPENDED, &mhi_pdev->status))
> 		return 0;
> 
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		timer_delete(&mhi_pdev->health_check_timer);
> 
> 	cancel_work_sync(&mhi_pdev->recovery_work);
>@@ -1679,7 +1679,7 @@ static int __maybe_unused mhi_pci_runtime_resume(struct device *dev)
> 	}
> 
> 	/* Resume health check */
>-	if (pdev->is_physfn)
>+	if (!pdev->is_virtfn)
> 		mod_timer(&mhi_pdev->health_check_timer, jiffies + HEALTH_CHECK_PERIOD);
> 
> 	/* It can be a remote wakeup (no mhi runtime_get), update access time */
>-- 
>2.51.0

Tested-by: Slark Xiao <slark_xiao@163.com>

Test result is expected now with these changes.
BTW, shall we add this changes into stable version? Since kernel 6.18 and 7.0  have been affected.

Thanks

  reply	other threads:[~2026-05-27 10:08 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-27  8:52 [PATCH] " Manivannan Sadhasivam
2026-05-27 10:08 ` Slark Xiao [this message]
2026-05-27 15:46   ` Manivannan Sadhasivam

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=12aa604a.8d99.19e68e81ed2.Coremail.slark_xiao@163.com \
    --to=slark_xiao@163.com \
    --cc=linux-arm-msm@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mani@kernel.org \
    --cc=manivannan.sadhasivam@oss.qualcomm.com \
    --cc=mhi@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 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®