get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/1.1/patches/2221593/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2221593,
    "url": "http://patchwork.ozlabs.org/api/1.1/patches/2221593/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260409215232.399350-1-decui@microsoft.com/",
    "project": {
        "id": 28,
        "url": "http://patchwork.ozlabs.org/api/1.1/projects/28/?format=api",
        "name": "Linux PCI development",
        "link_name": "linux-pci",
        "list_id": "linux-pci.vger.kernel.org",
        "list_email": "linux-pci@vger.kernel.org",
        "web_url": null,
        "scm_url": null,
        "webscm_url": null
    },
    "msgid": "<20260409215232.399350-1-decui@microsoft.com>",
    "date": "2026-04-09T21:52:32",
    "name": "Drivers: hv: vmbus: Export hv_vmbus_exists() and use it in pci-hyperv",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "474eda5b6735a5166280d3f3bf08581f61e3ddea",
    "submitter": {
        "id": 64601,
        "url": "http://patchwork.ozlabs.org/api/1.1/people/64601/?format=api",
        "name": "Dexuan Cui",
        "email": "decui@microsoft.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/linux-pci/patch/20260409215232.399350-1-decui@microsoft.com/mbox/",
    "series": [
        {
            "id": 499363,
            "url": "http://patchwork.ozlabs.org/api/1.1/series/499363/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/linux-pci/list/?series=499363",
            "date": "2026-04-09T21:52:32",
            "name": "Drivers: hv: vmbus: Export hv_vmbus_exists() and use it in pci-hyperv",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/499363/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2221593/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2221593/checks/",
    "tags": {},
    "headers": {
        "Return-Path": "\n <linux-pci+bounces-52234-incoming=patchwork.ozlabs.org@vger.kernel.org>",
        "X-Original-To": [
            "incoming@patchwork.ozlabs.org",
            "linux-pci@vger.kernel.org"
        ],
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=vger.kernel.org\n (client-ip=2600:3c04:e001:36c::12fc:5321; helo=tor.lore.kernel.org;\n envelope-from=linux-pci+bounces-52234-incoming=patchwork.ozlabs.org@vger.kernel.org;\n receiver=patchwork.ozlabs.org)",
            "smtp.subspace.kernel.org;\n arc=none smtp.client-ip=13.77.154.182",
            "smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=microsoft.com",
            "smtp.subspace.kernel.org;\n spf=pass smtp.mailfrom=linux.microsoft.com"
        ],
        "Received": [
            "from tor.lore.kernel.org (tor.lore.kernel.org\n [IPv6:2600:3c04:e001:36c::12fc:5321])\n\t(using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)\n\t key-exchange x25519 server-signature ECDSA (secp384r1) server-digest SHA384)\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fsDFk3Bszz1yCv\n\tfor <incoming@patchwork.ozlabs.org>; Fri, 10 Apr 2026 07:53:14 +1000 (AEST)",
            "from smtp.subspace.kernel.org (conduit.subspace.kernel.org\n [100.90.174.1])\n\tby tor.lore.kernel.org (Postfix) with ESMTP id 0ABFA302A1B9\n\tfor <incoming@patchwork.ozlabs.org>; Thu,  9 Apr 2026 21:52:57 +0000 (UTC)",
            "from localhost.localdomain (localhost.localdomain [127.0.0.1])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 7591A35B653;\n\tThu,  9 Apr 2026 21:52:51 +0000 (UTC)",
            "from linux.microsoft.com (linux.microsoft.com [13.77.154.182])\n\tby smtp.subspace.kernel.org (Postfix) with ESMTP id 299CD37C0FE;\n\tThu,  9 Apr 2026 21:52:50 +0000 (UTC)",
            "by linux.microsoft.com (Postfix, from userid 1009)\n\tid EA39620B7129; Thu,  9 Apr 2026 14:52:49 -0700 (PDT)"
        ],
        "ARC-Seal": "i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;\n\tt=1775771571; cv=none;\n b=F5X9wga9rlBQCGFT2b+0NK89dKFaKMfnEyhYTA2A/l3OQk5pYJL7CM0HebYQuGJo38xQR5EcLLABMSPstnVfR0+rjD8Ah1c/Njjl9A2C6Z3Q2FJlLyUOWmeuhfLv/nIJNfrP5Ik6QDstpWOdPvtOBx19MZ0ncPcQ6vyT/Vp0CEI=",
        "ARC-Message-Signature": "i=1; a=rsa-sha256; d=subspace.kernel.org;\n\ts=arc-20240116; t=1775771571; c=relaxed/simple;\n\tbh=tFfRzLm4MwVx6uT8622X3ap+XCSlK+8946afWlhqItQ=;\n\th=From:To:Cc:Subject:Date:Message-ID:MIME-Version;\n b=pT2AnsvUy5S3mACPF/Gun3qwheDcKdbMLJUtRTYrc7oz7brwB/yZ3o8gUCgDDr0zOeAKdHYwALNmb5KZK5/CRj1ygYG2nEd3hhFq6uXG2D9bm5kCe2duP5oYzjFckEWiX9si62L1buMOsqtoT8bxiD/Mz/rhoQgI4iMu8Sw7RDk=",
        "ARC-Authentication-Results": "i=1; smtp.subspace.kernel.org;\n dmarc=pass (p=reject dis=none) header.from=microsoft.com;\n spf=pass smtp.mailfrom=linux.microsoft.com;\n arc=none smtp.client-ip=13.77.154.182",
        "DKIM-Filter": "OpenDKIM Filter v2.11.0 linux.microsoft.com EA39620B7129",
        "From": "Dexuan Cui <decui@microsoft.com>",
        "To": "kys@microsoft.com,\n\thaiyangz@microsoft.com,\n\twei.liu@kernel.org,\n\tdecui@microsoft.com,\n\tlongli@microsoft.com,\n\tlpieralisi@kernel.org,\n\tkwilczynski@kernel.org,\n\tmani@kernel.org,\n\trobh@kernel.org,\n\tbhelgaas@google.com,\n\tlinux-hyperv@vger.kernel.org,\n\tlinux-pci@vger.kernel.org",
        "Cc": "linux-kernel@vger.kernel.org,\n\tMukesh Rathor <mrathor@linux.microsoft.com>",
        "Subject": "[PATCH] Drivers: hv: vmbus: Export hv_vmbus_exists() and use it in\n pci-hyperv",
        "Date": "Thu,  9 Apr 2026 14:52:32 -0700",
        "Message-ID": "<20260409215232.399350-1-decui@microsoft.com>",
        "X-Mailer": "git-send-email 2.43.7",
        "Precedence": "bulk",
        "X-Mailing-List": "linux-pci@vger.kernel.org",
        "List-Id": "<linux-pci.vger.kernel.org>",
        "List-Subscribe": "<mailto:linux-pci+subscribe@vger.kernel.org>",
        "List-Unsubscribe": "<mailto:linux-pci+unsubscribe@vger.kernel.org>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit"
    },
    "content": "With commit f84b21da3624 (\"PCI: hv: Don't load the driver for baremetal root partition\"),\nthe bare metal Linux root partition won't use the pci-hyperv driver, but\nwhen a Linux VM runs on the Linux root partition, pci-hyperv's module_init\nfunction init_hv_pci_drv() can still run, e.g. in the case of\nCONFIG_PCI_HYPERV=y, even if the VMBus driver is not used in such a VM\n(i.e. the hv_vmbus driver's init function returns -ENODEV due to\nvmbus_root_device being NULL).\n\nIn such a Linux VM, init_hv_pci_drv() runs with a side effect: the 3\nhvpci_block_ops callbacks are set to functions that depend on hv_vmbus.\n\nLater, when the MLX driver in such a VM invokes the callbacks, e.g. in\ndrivers/net/ethernet/mellanox/mlx5/core/lib/hv.c:\nmlx5_hv_register_invalidate(), hvpci_block_ops.reg_blk_invalidate() is\nhv_register_block_invalidate() rather than a NULL function pointer, and\nhv_register_block_invalidate() assumes that it can find a struct\nhv_pcibus_device from pdev->bus->sysdata, which is false in such a VM.\n\nConsequently, hv_register_block_invalidate() -> get_pcichild_wslot() ->\nspin_lock_irqsave() may hang since it can be accessing an invalid\nspinlock pointer.\n\nFix the issue by exporting hv_vmbus_exists() and using it in pci-hyperv:\n\n    hv_root_partition() is true and hv_nested is false ==>\n\thv_vmbus_exists() is false.\n\n    hv_root_partition() is true and hv_nested is true ==>\n\thv_vmbus_exists() is true.\n\n    hv_root_partition() is false ==> hv_vmbus_exists() is true.\n\nWhile at it, rename vmbus_exists() to hv_vmbus_exists() to follow the\nconvention that all public functions have the hv_ prefix; also change\nthe return value's type from int to bool to make the code more readable;\nalso move the two pr_info() calls.\n\nReported-by: Mukesh Rathor <mrathor@linux.microsoft.com>\nSigned-off-by: Dexuan Cui <decui@microsoft.com>\n---\n drivers/hv/vmbus_drv.c              | 20 ++++++++------------\n drivers/pci/controller/pci-hyperv.c |  2 +-\n include/linux/hyperv.h              |  2 ++\n 3 files changed, 11 insertions(+), 13 deletions(-)",
    "diff": "diff --git a/drivers/hv/vmbus_drv.c b/drivers/hv/vmbus_drv.c\nindex bc4fc1951ae1..2c8936efc8d1 100644\n--- a/drivers/hv/vmbus_drv.c\n+++ b/drivers/hv/vmbus_drv.c\n@@ -101,13 +101,11 @@ struct device *hv_get_vmbus_root_device(void)\n }\n EXPORT_SYMBOL_GPL(hv_get_vmbus_root_device);\n \n-static int vmbus_exists(void)\n+bool hv_vmbus_exists(void)\n {\n-\tif (vmbus_root_device == NULL)\n-\t\treturn -ENODEV;\n-\n-\treturn 0;\n+\treturn vmbus_root_device != NULL;\n }\n+EXPORT_SYMBOL_GPL(hv_vmbus_exists);\n \n static u8 channel_monitor_group(const struct vmbus_channel *channel)\n {\n@@ -1582,11 +1580,10 @@ int __vmbus_driver_register(struct hv_driver *hv_driver, struct module *owner, c\n {\n \tint ret;\n \n-\tpr_info(\"registering driver %s\\n\", hv_driver->name);\n+\tif (!hv_vmbus_exists())\n+\t\treturn -ENODEV;\n \n-\tret = vmbus_exists();\n-\tif (ret < 0)\n-\t\treturn ret;\n+\tpr_info(\"registering driver %s\\n\", hv_driver->name);\n \n \thv_driver->driver.name = hv_driver->name;\n \thv_driver->driver.owner = owner;\n@@ -1612,9 +1609,8 @@ EXPORT_SYMBOL_GPL(__vmbus_driver_register);\n  */\n void vmbus_driver_unregister(struct hv_driver *hv_driver)\n {\n-\tpr_info(\"unregistering driver %s\\n\", hv_driver->name);\n-\n-\tif (!vmbus_exists()) {\n+\tif (hv_vmbus_exists()) {\n+\t\tpr_info(\"unregistering driver %s\\n\", hv_driver->name);\n \t\tdriver_unregister(&hv_driver->driver);\n \t\tvmbus_free_dynids(hv_driver);\n \t}\ndiff --git a/drivers/pci/controller/pci-hyperv.c b/drivers/pci/controller/pci-hyperv.c\nindex 2c7a406b4ba8..226b8bb802f3 100644\n--- a/drivers/pci/controller/pci-hyperv.c\n+++ b/drivers/pci/controller/pci-hyperv.c\n@@ -4166,7 +4166,7 @@ static int __init init_hv_pci_drv(void)\n \tif (!hv_is_hyperv_initialized())\n \t\treturn -ENODEV;\n \n-\tif (hv_root_partition() && !hv_nested)\n+\tif (!hv_vmbus_exists())\n \t\treturn -ENODEV;\n \n \tret = hv_pci_irqchip_init();\ndiff --git a/include/linux/hyperv.h b/include/linux/hyperv.h\nindex dfc516c1c719..5459e776ec17 100644\n--- a/include/linux/hyperv.h\n+++ b/include/linux/hyperv.h\n@@ -1304,6 +1304,8 @@ static inline void *hv_get_drvdata(struct hv_device *dev)\n \n struct device *hv_get_vmbus_root_device(void);\n \n+bool hv_vmbus_exists(void);\n+\n struct hv_ring_buffer_debug_info {\n \tu32 current_interrupt_mask;\n \tu32 current_read_index;\n",
    "prefixes": []
}