devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Lizhi Hou <lizhi.hou@amd.com>
To: Rob Herring <robh@kernel.org>
Cc: <linux-pci@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
	<devicetree@vger.kernel.org>, <linuxppc-dev@lists.ozlabs.org>,
	<kvm-ppc@vger.kernel.org>, Bjorn Helgaas <bhelgaas@google.com>,
	Saravana Kannan <saravanak@google.com>,
	Vaibhav Jain <vaibhav@linux.ibm.com>,
	Nicholas Piggin <npiggin@gmail.com>,
	Michael Ellerman <mpe@ellerman.id.au>,
	Vaidyanathan Srinivasan <svaidy@linux.ibm.com>,
	Kowshik Jois B S <kowsjois@linux.ibm.com>,
	Lukas Wunner <lukas@wunner.de>
Subject: Re: [PATCH v2] PCI: Fix crash during pci_dev hot-unplug on pseries KVM guest
Date: Fri, 26 Jul 2024 11:45:03 -0700	[thread overview]
Message-ID: <0b1be7b7-e65b-8d8e-0659-388dec303039@amd.com> (raw)
In-Reply-To: <CAL_JsqJAuVexFAz6gWWuTtX1Go-FnHe6vJapv0znHBERSCtv+Q@mail.gmail.com>


On 7/26/24 10:52, Rob Herring wrote:
> On Thu, Jul 25, 2024 at 6:06 PM Lizhi Hou <lizhi.hou@amd.com> wrote:
>> Hi Amit,
>>
>>
>> I try to follow the option which add a OF flag. If Rob is ok with this,
>> I would suggest to use it instead of V1 patch
>>
>> diff --git a/drivers/of/dynamic.c b/drivers/of/dynamic.c
>> index dda6092e6d3a..a401ed0463d9 100644
>> --- a/drivers/of/dynamic.c
>> +++ b/drivers/of/dynamic.c
>> @@ -382,6 +382,11 @@ void of_node_release(struct kobject *kobj)
>>                                  __func__, node);
>>           }
>>
>> +       if (of_node_check_flag(node, OF_CREATED_WITH_CSET)) {
>> +               of_changeset_revert(node->data);
>> +               of_changeset_destroy(node->data);
>> +       }
> What happens if multiple nodes are created in the changeset?
Ok. multiple nodes will not work.
>
>> +
>>           if (node->child)
>>                   pr_err("ERROR: %s() unexpected children for %pOF/%s\n",
>>                           __func__, node->parent, node->full_name);
>> @@ -507,6 +512,7 @@ struct device_node *of_changeset_create_node(struct
>> of_changeset *ocs,
>>           np = __of_node_dup(NULL, full_name);
>>           if (!np)
>>                   return NULL;
>> +       of_node_set_flag(np, OF_CREATED_WITH_CSET);
> This should be set where the data ptr is set.

Ok. It sounds the fix could be simplified to 3 lines change.


diff --git a/drivers/pci/of.c b/drivers/pci/of.c
index 51e3dd0ea5ab..0b3ba1e1b18c 100644
--- a/drivers/pci/of.c
+++ b/drivers/pci/of.c
@@ -613,7 +613,7 @@ void of_pci_remove_node(struct pci_dev *pdev)
         struct device_node *np;

         np = pci_device_to_OF_node(pdev);
-       if (!np || !of_node_check_flag(np, OF_DYNAMIC))
+       if (!np || !of_node_check_flag(np, OF_CREATED_WITH_CSET))
                 return;
         pdev->dev.of_node = NULL;

@@ -672,6 +672,7 @@ void of_pci_make_dev_node(struct pci_dev *pdev)
         if (ret)
                 goto out_free_node;

+       of_node_set_flag(np, OF_CREATED_WITH_CSET);
         np->data = cset;
         pdev->dev.of_node = np;
         kfree(name);
diff --git a/include/linux/of.h b/include/linux/of.h
index a0bedd038a05..a46317f6626e 100644
--- a/include/linux/of.h
+++ b/include/linux/of.h
@@ -153,6 +153,7 @@ extern struct device_node *of_stdout;
  #define OF_POPULATED_BUS       4 /* platform bus created for children */
  #define OF_OVERLAY             5 /* allocated for an overlay */
  #define OF_OVERLAY_FREE_CSET   6 /* in overlay cset being freed */
+#define OF_CREATED_WITH_CSET    7 /* created by of_changeset_create_node */

  #define OF_BAD_ADDR    ((u64)-1)


Lizhi

>
> Rob

  reply	other threads:[~2024-07-26 18:45 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-07-15  8:07 [PATCH v2] PCI: Fix crash during pci_dev hot-unplug on pseries KVM guest Amit Machhiwal
2024-07-15 16:20 ` Lizhi Hou
2024-07-15 17:23   ` Bjorn Helgaas
2024-07-15 20:35     ` Lizhi Hou
2024-07-15 18:55 ` Rob Herring
2024-07-15 20:52   ` Lizhi Hou
2024-07-23 16:21     ` Rob Herring
2024-07-23 18:21       ` Lizhi Hou
2024-07-23 19:54         ` Rob Herring
2024-07-23 21:08           ` Lizhi Hou
2024-07-25 17:45             ` Amit Machhiwal
2024-07-25 20:55               ` Bjorn Helgaas
2024-07-26  5:49                 ` Amit Machhiwal
2024-07-26 12:49                   ` Michael Ellerman
2024-07-25 23:06               ` Lizhi Hou
2024-07-26 17:52                 ` Rob Herring
2024-07-26 18:45                   ` Lizhi Hou [this message]
2024-07-29 11:13                     ` Amit Machhiwal
2024-07-29 16:47                       ` Lizhi Hou
2024-07-29 16:55                         ` Amit Machhiwal
2024-07-29 18:19                           ` Lizhi Hou
2024-07-26 11:37               ` Rob Herring
2024-07-29 13:27                 ` Stefan Bader
2024-08-02 16:55                   ` Amit Machhiwal

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=0b1be7b7-e65b-8d8e-0659-388dec303039@amd.com \
    --to=lizhi.hou@amd.com \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=kowsjois@linux.ibm.com \
    --cc=kvm-ppc@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linuxppc-dev@lists.ozlabs.org \
    --cc=lukas@wunner.de \
    --cc=mpe@ellerman.id.au \
    --cc=npiggin@gmail.com \
    --cc=robh@kernel.org \
    --cc=saravanak@google.com \
    --cc=svaidy@linux.ibm.com \
    --cc=vaibhav@linux.ibm.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;
as well as URLs for NNTP newsgroup(s).