From: Punit Agrawal <punit.agrawal@arm.com>
To: "Suzuki K. Poulose" <suzuki.poulose@arm.com>
Cc: linux-arm-kernel@lists.infradead.org, leo.yan@linaro.org,
yexl@marvell.com, Will.Deacon@arm.com, Catalin.Marinas@arm.com,
Mark.Rutland@arm.com, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/3] arm64: Consolidate hotplug notifier for instruction emulation
Date: Fri, 23 Jan 2015 12:31:40 +0000 [thread overview]
Message-ID: <9hhoappn0er.fsf@e105922-lin.cambridge.arm.com> (raw)
In-Reply-To: <1421844191-9263-3-git-send-email-suzuki.poulose@arm.com> (Suzuki K. Poulose's message of "Wed, 21 Jan 2015 12:43:10 +0000")
Hi Suzuki,
A possible simplification below.
"Suzuki K. Poulose" <suzuki.poulose@arm.com> writes:
> From: "Suzuki K. Poulose" <suzuki.poulose@arm.com>
>
> As of now each insn_emulation has a cpu hotplug notifier that
> enables/disables the CPU feature bit for the functionality. This
> patch re-arranges the code, such that there is only one notifier
> that runs through the list of registered emulation hooks and runs
> their corresponding set_hw_mode.
>
> We do nothing when a CPU is dying as we will set the appropriate bits
> as it comes back online based on the state of the hooks.
>
> Signed-off-by: Mark Rutland <mark.rutland@arm.com>
> Signed-off-by: Suzuki K. Poulose <suzuki.poulose@arm.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Cc: Punit Agrawal <punit.agrawal@arm.com>
> ---
> arch/arm64/include/asm/cputype.h | 2 +
> arch/arm64/kernel/armv8_deprecated.c | 125 +++++++++++++++++++++-------------
> 2 files changed, 79 insertions(+), 48 deletions(-)
>
[...]
> diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c
> index c363671..2c991f1 100644
> --- a/arch/arm64/kernel/armv8_deprecated.c
> +++ b/arch/arm64/kernel/armv8_deprecated.c
> @@ -19,6 +19,7 @@
> #include <asm/system_misc.h>
> #include <asm/traps.h>
> #include <asm/uaccess.h>
> +#include <asm/cpufeature.h>
>
> #define CREATE_TRACE_POINTS
> #include "trace-events-emulation.h"
> @@ -85,6 +86,57 @@ static void remove_emulation_hooks(struct insn_emulation_ops *ops)
> pr_notice("Removed %s emulation handler\n", ops->name);
> }
>
> +static void enable_insn_hw_mode(void *data)
> +{
> + struct insn_emulation *insn = (struct insn_emulation *)data;
> + if (insn && insn->ops->set_hw_mode)
You can simplify (drop?) this...
> + insn->ops->set_hw_mode(true);
> +}
> +
> +static void disable_insn_hw_mode(void *data)
> +{
> + struct insn_emulation *insn = (struct insn_emulation *)data;
> + if (insn && insn->ops->set_hw_mode)
and this check since...
> + insn->ops->set_hw_mode(false);
> +}
> +
> +/* Run set_hw_mode(mode) on all active CPUs */
> +static int run_all_cpu_set_hw_mode(struct insn_emulation *insn, bool enable)
> +{
> + if (!insn->ops->set_hw_mode)
> + return -EINVAL;
insn->ops->set_hw_mode is already checked here.
> + if (enable)
> + on_each_cpu(enable_insn_hw_mode, (void *)insn, true);
> + else
> + on_each_cpu(disable_insn_hw_mode, (void *)insn, true);
> + return 0;
> +}
> +
> +/*
> + * Run set_hw_mode for all insns on a starting CPU.
> + * Returns:
> + * 0 - If all the hooks ran successfully.
> + * -EINVAL - At least one hook is not supported by the CPU.
> + */
> +static int run_all_insn_set_hw_mode(unsigned long cpu)
> +{
> + int rc = 0;
> + unsigned long flags;
> + struct insn_emulation *insn;
> +
> + raw_spin_lock_irqsave(&insn_emulation_lock, flags);
> + list_for_each_entry(insn, &insn_emulation, node) {
> + bool enable = (insn->current_mode == INSN_HW);
> + if (insn->ops->set_hw_mode && insn->ops->set_hw_mode(enable)) {
> + pr_warn(enable, "CPU[%ld] cannot support the emulation of %s",
> + cpu, insn->ops->name);
> + rc = -EINVAL;
> + }
> + }
> + raw_spin_unlock_irqrestore(&insn_emulation_lock, flags);
> + return rc;
> +}
> +
> static int update_insn_emulation_mode(struct insn_emulation *insn,
> enum insn_emulation_mode prev)
> {
[...]
next prev parent reply other threads:[~2015-01-23 12:32 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-21 12:43 [PATCHv3 0/3] Handle SETEND for AArch32 tasks Suzuki K. Poulose
2015-01-21 12:43 ` [PATCH 1/3] arm64: Track system support for mixed endian EL0 Suzuki K. Poulose
2015-01-21 12:43 ` [PATCH 2/3] arm64: Consolidate hotplug notifier for instruction emulation Suzuki K. Poulose
2015-01-21 12:43 ` [PATCH 3/3] arm64: Emulate SETEND for AArch32 tasks Suzuki K. Poulose
2015-01-23 12:31 ` Punit Agrawal [this message]
2015-01-23 17:16 ` [PATCHv3 0/3] Handle " Catalin Marinas
-- strict thread matches above, loose matches on Subject: below --
2015-01-15 12:36 [PATCHv2 " Suzuki K. Poulose
2015-01-15 12:36 ` [PATCH 2/3] arm64: Consolidate hotplug notifier for instruction emulation Suzuki K. Poulose
2015-01-16 16:07 ` Will Deacon
2015-01-16 16:32 ` Mark Rutland
2015-01-16 16:44 ` Will Deacon
2015-01-16 16:48 ` Mark Rutland
2015-01-16 16:47 ` 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=9hhoappn0er.fsf@e105922-lin.cambridge.arm.com \
--to=punit.agrawal@arm.com \
--cc=Catalin.Marinas@arm.com \
--cc=Mark.Rutland@arm.com \
--cc=Will.Deacon@arm.com \
--cc=leo.yan@linaro.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=suzuki.poulose@arm.com \
--cc=yexl@marvell.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®