From: Suzuki K Poulose <Suzuki.Poulose@arm.com>
To: Dave Martin <Dave.Martin@arm.com>, Robin Murphy <robin.murphy@arm.com>
Cc: mark.rutland@arm.com, marc.zyngier@arm.com,
catalin.marinas@arm.com, will.deacon@arm.com,
linux-kernel@vger.kernel.org, james.morse@arm.com,
linux-arm-kernel@lists.infradead.org
Subject: Re: [PATCH v2 0/2] arm64: Run enable method for errata work arounds on late CPUs
Date: Thu, 18 Jan 2018 14:25:52 +0000 [thread overview]
Message-ID: <806b4c01-9c82-8666-aa05-b1dc5d5afd47@arm.com> (raw)
In-Reply-To: <20180118142125.GM22781@e103592.cambridge.arm.com>
On 18/01/18 14:21, Dave Martin wrote:
> On Thu, Jan 18, 2018 at 12:08:43PM +0000, Robin Murphy wrote:
>> On 18/01/18 12:00, Robin Murphy wrote:
>> [...]
>>>> +struct enable_arg {
>>>> + int (*enable)(struct arm64_cpu_capabilities const *);
>>>> + struct arm64_cpu_capabilities const *cap;
>>>> +};
>>>> +
>>>> +static int __enable_cpu_capability(void *arg)
>>>> +{
>>>> + struct enable_arg const *e = arg;
>>>> +
>>>> + return e->enable(e->cap);
>>>> +}
>>>
>>> AFAICS, you shouldn't even need the intermediate struct - if you were
>>> instead to call stop_machine(&caps->enable, ...), the wrapper could be:
>>>
>>> <type> **fn = arg;
>>> *fn(container_of(fn, struct arm64_cpu_capabilities, enable));
>>>
>>> (cheaty pseudocode because there's no way I'm going to write a
>>> pointer-to-function-pointer type correctly in an email client...)
>>>
>>> That's certainly a fair bit simpler in terms of diffstat; whether it's
>>> really as intuitive as I think it is is perhaps another matter, though.
>>
>> Ah, right, but then you'd be back to casting away const, and at that point
>> it makes no sense to do the container_of dance instead of just passing the
>> struct pointer itself around...
>>
>> I shall now excuse myself from this discussion, as I'm clearly not helping
>> :)
>>
>> Robin.
>
> That's what I was about to say... but neat trick.
>
> However, it does concentrate the type fudge in one place and keeps the
> arm64_cpu_capabilities::enable() prototype correct, so it's still better
> than the original.
>
>
> Thinking about it, the following is probably clearer and no worse:
>
> static int __enable_cpu_capability(void *arg)
> {
> struct arm64_cpu_capabilities const *cap = arg;
>
> return cap->enable(cap);
> }
>
> ...
>
> stop_machine(__enable_cpu_capability, (void *)caps, cpu_online_mask);
>
>
> In your version, the argument would be (void *)&caps->enable, which is
> really just a proxy for (void *)caps, unless I missed something.
>
>
> What do you think Suzuki? I can respin my patch if you fancy picking it
> up. Either way, it's not urgent.
Thanks for cooking that up Dave & Robin. I prefer your second version.
Please feel free to respin it. As you rightly said, this is not urgent
and could pick it up in my re-writing of the capability infrastructure ;-)
Meanwhile, I would really like some reviews on the original patch and
push it for 4.16 (as a fix at least).
Cheers
Suzuki
>
> Cheers
> ---Dave
>
next prev parent reply other threads:[~2018-01-18 14:26 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-17 17:42 Suzuki K Poulose
2018-01-17 17:42 ` [PATCH v2 1/2] arm64: capabilities: Clarify argument passed to enable call back Suzuki K Poulose
2018-01-22 12:42 ` Will Deacon
2018-01-17 17:42 ` [PATCH v2 2/2] arm64: Run enable method for errata work arounds on late CPUs Suzuki K Poulose
2018-01-18 11:45 ` [PATCH v2 0/2] " Dave Martin
2018-01-18 12:00 ` Robin Murphy
2018-01-18 12:08 ` Robin Murphy
2018-01-18 14:21 ` Dave Martin
2018-01-18 14:25 ` Suzuki K Poulose [this message]
2018-01-18 18:31 ` Suzuki K Poulose
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=806b4c01-9c82-8666-aa05-b1dc5d5afd47@arm.com \
--to=suzuki.poulose@arm.com \
--cc=Dave.Martin@arm.com \
--cc=catalin.marinas@arm.com \
--cc=james.morse@arm.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marc.zyngier@arm.com \
--cc=mark.rutland@arm.com \
--cc=robin.murphy@arm.com \
--cc=will.deacon@arm.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
all inboxes | Powered by JetHome®