[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <2f1beb3e-c9df-46c5-fe5d-0d688a730521@arm.com>
Date: Mon, 21 Aug 2023 10:29:22 +0100
From: Robin Murphy <robin.murphy@....com>
To: Besar Wicaksono <bwicaksono@...dia.com>,
Suzuki K Poulose <suzuki.poulose@....com>
Cc: "ilkka@...amperecomputing.com" <ilkka@...amperecomputing.com>,
"catalin.marinas@....com" <catalin.marinas@....com>,
"will@...nel.org" <will@...nel.org>,
"mark.rutland@....com" <mark.rutland@....com>,
"linux-arm-kernel@...ts.infradead.org"
<linux-arm-kernel@...ts.infradead.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"linux-tegra@...r.kernel.org" <linux-tegra@...r.kernel.org>,
Thierry Reding <treding@...dia.com>,
Jonathan Hunter <jonathanh@...dia.com>,
Vikram Sethi <vsethi@...dia.com>,
Richard Wiley <rwiley@...dia.com>,
Eric Funsten <efunsten@...dia.com>
Subject: Re: [PATCH v5] perf: arm_cspmu: Separate Arm and vendor module
On 2023-08-19 21:11, Besar Wicaksono wrote:
[...]
>>> +void arm_cspmu_impl_unregister(const struct arm_cspmu_impl_match
>> *impl_match)
>>> +{
>>> + struct device *dev;
>>> + struct arm_cspmu_impl_match *match;
>>> +
>>> + match = arm_cspmu_impl_match_get(impl_match->pmiidr_val);
>>> +
>>> + WARN_ON(!match);
Nit: do "if (WARN_ON(!match)) return;" rather than indenting almost the
whole function.
>>> +
>>> + if (match) {
>>> + /* Unbind the driver from all matching backend devices. */
>>> +dev_release:
>>> + dev = driver_find_device(&arm_cspmu_driver.driver, NULL,
>>> + match, arm_cspmu_match_device);
>>> + if (dev) {
>>> + device_release_driver(dev);
>>> + goto dev_release;
>>> + }
>>
>> minor nit: We could simply do :
>>
>> static int arm_cspmu_release_driver(struct device *dev, void *data)
>> {
>> struct arm_cspmu *cspmu =
>> platform_get_drvdata(to_platform_device(dev));
>>
>> if (cspmu && cspmu->impl.match == match)
>> device_release_driver(dev);
>> return 0;
>> }
>>
>> ret = driver_for_each_device(&driver, NULL, match,
>> arm_csmpu_release_driver);
>>
>
> It doesn’t seem to work for me.
> Is it safe to release while iterating via driver_for_each_device ?
Looking at the klist code it doesn't *obviously* appear safe to modify
the list during iteration, so probably best not to risk it anyway.
However, please try to write this loop as an actual loop, e.g.:
while ((dev = driver_find_device()))
device_release_driver();
At first glance I thought there was a bug here that it's only processing
a single device, then eventually I saw the goto and my thought changed
to "Eww..."
Thanks,
Robin.
Powered by blists - more mailing lists