From: Shuai Xue <xueshuai@linux.alibaba.com>
To: Yicong Yang <yangyicong@huawei.com>,
Jonathan Cameron <Jonathan.Cameron@Huawei.com>
Cc: yangyicong@hisilicon.com, chengyou@linux.alibaba.com,
kaishen@linux.alibaba.com, helgaas@kernel.org, will@kernel.org,
baolin.wang@linux.alibaba.com, robin.murphy@arm.com,
linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org,
rdunlap@infradead.org, mark.rutland@arm.com,
zhuo.song@linux.alibaba.com, renyu.zj@linux.alibaba.com
Subject: Re: [PATCH v8 3/4] drivers/perf: add DesignWare PCIe PMU driver
Date: Thu, 19 Oct 2023 20:02:34 +0800 [thread overview]
Message-ID: <dacd7394-c57a-44ee-a506-3ae0aa9870f9@linux.alibaba.com> (raw)
In-Reply-To: <a14fc5c1-522b-ba7b-fabd-55ef8871a3b0@huawei.com>
On 2023/10/19 16:05, Yicong Yang wrote:
> On 2023/10/18 11:33, Shuai Xue wrote:
>>
...
>>
>>>
>>>> + return PTR_ERR(dwc_pcie_pmu_dev);
>>>> + }
>>>> +
>>>> + return 0;
>>>> +}
>>>> +
>>>> +static void __exit dwc_pcie_pmu_exit(void)
>>>> +{
>>>> + platform_device_unregister(dwc_pcie_pmu_dev);
>>>> + platform_driver_unregister(&dwc_pcie_pmu_driver);
>>>> + cpuhp_remove_multi_state(dwc_pcie_pmu_hp_state);
>>>> +
>>>> + if (dwc_pcie_pmu_notify)
>>>
>>> If you have something unusual like this a driver module_exit() it definitely
>>> deserves a comment on why. I'm surprised by this as I'd expect the notifier
>>> to be unregistered in the driver remove so not sure why this is here.
>>> I've lost track of earlier discussions so if this was addressed then all
>>> we need is a comment here for the next person to run into it!
>>
>> All replied above, I will unregistered the notifier by devm_add_action_or_reset().
>>
>> I am curious about that what the difference between unregistered in module_exit()
>> and remove()?
>>
>
> From my understanding, if you register it in probe() then should undo it in remove().
> Otherwise you should register it in module_init(). Just make them coupled to make
> sure cleanup the resources correctly.
>
> This driver is a bit different since device and driver are created in module_init()
> so will works fine in most cases, because the device/driver removal will happens the
> same time when unloading the module. However if manually unbind the driver and device
> without unloading the module, we'll miss to unregister the notifier in the currently
> implementation.
>
I see, thank you for your patient explanation.
Thank you.
Best Regards,
Shuai
next prev parent reply other threads:[~2023-10-19 12:03 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-17 1:32 [PATCH v8 0/4] drivers/perf: add Synopsys DesignWare PCIe PMU driver support Shuai Xue
2023-10-17 1:32 ` [PATCH v8 1/4] docs: perf: Add description for Synopsys DesignWare PCIe PMU driver Shuai Xue
2023-10-17 9:16 ` Jonathan Cameron
2023-10-18 1:19 ` Shuai Xue
2023-10-19 11:06 ` Jonathan Cameron
2023-10-19 11:56 ` Shuai Xue
2023-10-19 7:35 ` Yicong Yang
2023-10-19 11:51 ` Shuai Xue
2023-10-17 1:32 ` [PATCH v8 2/4] PCI: Add Alibaba Vendor ID to linux/pci_ids.h Shuai Xue
2023-10-17 1:32 ` [PATCH v8 3/4] drivers/perf: add DesignWare PCIe PMU driver Shuai Xue
2023-10-17 9:39 ` Jonathan Cameron
2023-10-18 3:33 ` Shuai Xue
2023-10-19 8:05 ` Yicong Yang
2023-10-19 12:02 ` Shuai Xue [this message]
2023-10-17 1:32 ` [PATCH v8 4/4] MAINTAINERS: add maintainers for " Shuai Xue
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=dacd7394-c57a-44ee-a506-3ae0aa9870f9@linux.alibaba.com \
--to=xueshuai@linux.alibaba.com \
--cc=Jonathan.Cameron@Huawei.com \
--cc=baolin.wang@linux.alibaba.com \
--cc=chengyou@linux.alibaba.com \
--cc=helgaas@kernel.org \
--cc=kaishen@linux.alibaba.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mark.rutland@arm.com \
--cc=rdunlap@infradead.org \
--cc=renyu.zj@linux.alibaba.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=yangyicong@hisilicon.com \
--cc=yangyicong@huawei.com \
--cc=zhuo.song@linux.alibaba.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