From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755962AbeARSco (ORCPT ); Thu, 18 Jan 2018 13:32:44 -0500 Received: from foss.arm.com ([217.140.101.70]:59434 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755780AbeARSbm (ORCPT ); Thu, 18 Jan 2018 13:31:42 -0500 Subject: Re: [PATCH v2 0/2] arm64: Run enable method for errata work arounds on late CPUs From: Suzuki K Poulose To: Dave Martin , Robin Murphy 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 References: <20180117174220.7959-1-suzuki.poulose@arm.com> <20180118114540.GL22781@e103592.cambridge.arm.com> <5c1945a8-a66d-9306-1c6d-3c1c8febcab2@arm.com> <851887b9-974a-6f20-920b-d9149d8122fe@arm.com> <20180118142125.GM22781@e103592.cambridge.arm.com> <806b4c01-9c82-8666-aa05-b1dc5d5afd47@arm.com> Message-ID: <7e19c9a0-603f-bbef-bd13-bf7252ad38e6@arm.com> Date: Thu, 18 Jan 2018 18:31:34 +0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: <806b4c01-9c82-8666-aa05-b1dc5d5afd47@arm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 18/01/18 14:25, Suzuki K Poulose wrote: > 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: >>>> >>>>       **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 ;-) Dave, I have picked this up in my new series for revamping cpu capabilities and will send it after a bit of testing. So, no need to respin it. Cheers Suzuki