From: David Daney <ddaney@caviumnetworks.com>
To: James Hogan <james.hogan@imgtec.com>
Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>,
<linux-mips@linux-mips.org>, David Daney <ddaney.cavm@gmail.com>,
"Ralf Baechle" <ralf@linux-mips.org>, <kvm@vger.kernel.org>,
David Daney <david.daney@cavium.com>
Subject: Re: [PATCH 10/15] MIPS: Add code for new system 'paravirt'.
Date: Wed, 21 May 2014 09:31:02 -0700 [thread overview]
Message-ID: <537CD4C6.5080905@caviumnetworks.com> (raw)
In-Reply-To: <537CAC74.4030800@imgtec.com>
On 05/21/2014 06:39 AM, James Hogan wrote:
[...]
>> diff --git a/arch/mips/paravirt/paravirt-irq.c b/arch/mips/paravirt/paravirt-irq.c
>> new file mode 100644
>> index 0000000..e1603dd
>> --- /dev/null
>> +++ b/arch/mips/paravirt/paravirt-irq.c
[...]
>
>> +static void irq_core_set_enable_local(void *arg)
>> +{
>> + struct irq_data *data = arg;
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> + unsigned int mask = 0x100 << cd->bit;
>> +
>> + /*
>> + * Interrupts are already disabled, so these are atomic.
>
> Really? Even when called directly from irq_core_bus_sync_unlock with
> only a single core online?
>
Yes, but...
>> + */
>> + if (cd->desired_en)
>> + set_c0_status(mask);
>> + else
>> + clear_c0_status(mask);
>> +
>> +}
>> +
>> +static void irq_core_disable(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> + cd->desired_en = false;
>> +}
>> +
>> +static void irq_core_enable(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> + cd->desired_en = true;
>> +}
>> +
>> +static void irq_core_bus_lock(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> +
>> + mutex_lock(&cd->core_irq_mutex);
>> +}
>> +
>> +static void irq_core_bus_sync_unlock(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> +
>> + if (cd->desired_en != cd->current_en) {
>> + /*
>> + * Can be called in early init when on_each_cpu() will
>> + * unconditionally enable irqs, so handle the case
>> + * where only a single CPU is online specially, and
>> + * directly call.
>> + */
>> + if (num_online_cpus() == 1)
>> + irq_core_set_enable_local(data);
>> + else
>> + on_each_cpu(irq_core_set_enable_local, data, 1);
>> +
... This code is not correct. It was initially done as a workaround
for the issues fixed in commit 202da4005.
Now that on_each_cpu() is less buggy, we can unconditionally use it and
the assertion above about "Interrupts are already disabled" will be true.
>> + cd->current_en = cd->desired_en;
>> + }
>> +
>> + mutex_unlock(&cd->core_irq_mutex);
>> +}
>
>
>> +static int irq_pci_set_affinity(struct irq_data *data, const struct cpumask *dest, bool force)
>> +{
>> + return 0;
>> +}
>
> Is there any point even providing this callback?
I guess we can add them only when they are implemented.
>
>> +
>> +static void irq_pci_cpu_offline(struct irq_data *data)
>> +{
>> +}
>
> Or this one?
Same.
>
>> +
>> +static struct irq_chip irq_chip_pci = {
>> + .name = "PCI",
>> + .irq_enable = irq_pci_enable,
>> + .irq_disable = irq_pci_disable,
>> + .irq_ack = irq_pci_ack,
>> + .irq_mask = irq_pci_mask,
>> + .irq_unmask = irq_pci_unmask,
>> + .irq_set_affinity = irq_pci_set_affinity,
>> + .irq_cpu_offline = irq_pci_cpu_offline,
>> +};
>
>
>> diff --git a/arch/mips/paravirt/paravirt-smp.c b/arch/mips/paravirt/paravirt-smp.c
>> new file mode 100644
>> index 0000000..52f86eb
>> --- /dev/null
>> +++ b/arch/mips/paravirt/paravirt-smp.c
>
>> +static void paravirt_smp_finish(void)
>> +{
>> + /* to generate the first CPU timer interrupt */
>> + write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ);
>
> This strikes me as a bit hacky. Are you sure it's actually necessary? (I
> would have expected some generic hotplug notifier somewhere to ensure
> that percpu clocksources gets initialised sensibly when a new CPU is
> brought up)
>
>
>> +static void paravirt_boot_secondary(int cpu, struct task_struct *idle)
>> +{
>> + paravirt_smp_gp[cpu] = (unsigned long)(task_thread_info(idle));
>
> spurious brackets around task_thread_info(idle)
>
>> + wmb();
>
> Wouldn't smp_wmb() be more accurate?
Probably.
>
>> + paravirt_smp_sp[cpu] = __KSTK_TOS(idle);
>> + mb();
>
> is this barrier necessary?
Really it is just make_writes_visible_asap(), but for OCTEON mb() or
smp_wmb() is the closest that the kernel has.
It may not be necessary, but it doesn't really harm anything.
>
>> diff --git a/arch/mips/paravirt/serial.c b/arch/mips/paravirt/serial.c
>> new file mode 100644
>> index 0000000..e3f98b2
>> --- /dev/null
>> +++ b/arch/mips/paravirt/serial.c
>> @@ -0,0 +1,38 @@
>> +/*
>> + * This file is subject to the terms and conditions of the GNU General Public
>> + * License. See the file "COPYING" in the main directory of this archive
>> + * for more details.
>> + *
>> + * Copyright (C) 2013 Cavium, Inc.
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/virtio_console.h>
>> +
>> +#include <asm/mipsregs.h>
>> +
>> +/*
>> + * Emit one character to the boot console.
>> + */
>> +int prom_putchar(char c)
>> +{
>> + hypcall3(0 /* Console output */, 0 /* port 0 */, (unsigned long)&c, 1 /* len == 1 */);
>
> I think the hypcall API needs to be clearly specified and Documented
> somewhere along with its HYPCALL codes and scope. I.e. is it specific to
> kvmtool, or attempting to be a standard API across MIPS hypervisors.
>
I was intending it to be the later. (standard API across MIPS hypervisors.)
The idea being that the first argument would be broken up into several
ranges.
0..x : Globally available HYPCALL provided by all hypervisors.
m..n : MIPS KVM specific.
y..z : Reserved for the vendor.
For some values of x, m, n, y and z.
But perhaps it should just be MIPS KVM specific. If making it global is
too much trouble.
> It probably should have nice definitions in a header and wrappers
> somewhere to make the arguments explicit and so there's no need for the
> comments explaining what the magic values mean.
>
> Cheers
> James
>
WARNING: multiple messages have this Message-ID (diff)
From: David Daney <ddaney@caviumnetworks.com>
To: James Hogan <james.hogan@imgtec.com>
Cc: Andreas Herrmann <andreas.herrmann@caviumnetworks.com>,
linux-mips@linux-mips.org, David Daney <ddaney.cavm@gmail.com>,
Ralf Baechle <ralf@linux-mips.org>,
kvm@vger.kernel.org, David Daney <david.daney@cavium.com>
Subject: Re: [PATCH 10/15] MIPS: Add code for new system 'paravirt'.
Date: Wed, 21 May 2014 09:31:02 -0700 [thread overview]
Message-ID: <537CD4C6.5080905@caviumnetworks.com> (raw)
Message-ID: <20140521163102.SngSL12_25jb8rEO_bnV_P5mriGF0cArdml_Qilkga8@z> (raw)
In-Reply-To: <537CAC74.4030800@imgtec.com>
On 05/21/2014 06:39 AM, James Hogan wrote:
[...]
>> diff --git a/arch/mips/paravirt/paravirt-irq.c b/arch/mips/paravirt/paravirt-irq.c
>> new file mode 100644
>> index 0000000..e1603dd
>> --- /dev/null
>> +++ b/arch/mips/paravirt/paravirt-irq.c
[...]
>
>> +static void irq_core_set_enable_local(void *arg)
>> +{
>> + struct irq_data *data = arg;
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> + unsigned int mask = 0x100 << cd->bit;
>> +
>> + /*
>> + * Interrupts are already disabled, so these are atomic.
>
> Really? Even when called directly from irq_core_bus_sync_unlock with
> only a single core online?
>
Yes, but...
>> + */
>> + if (cd->desired_en)
>> + set_c0_status(mask);
>> + else
>> + clear_c0_status(mask);
>> +
>> +}
>> +
>> +static void irq_core_disable(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> + cd->desired_en = false;
>> +}
>> +
>> +static void irq_core_enable(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> + cd->desired_en = true;
>> +}
>> +
>> +static void irq_core_bus_lock(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> +
>> + mutex_lock(&cd->core_irq_mutex);
>> +}
>> +
>> +static void irq_core_bus_sync_unlock(struct irq_data *data)
>> +{
>> + struct core_chip_data *cd = irq_data_get_irq_chip_data(data);
>> +
>> + if (cd->desired_en != cd->current_en) {
>> + /*
>> + * Can be called in early init when on_each_cpu() will
>> + * unconditionally enable irqs, so handle the case
>> + * where only a single CPU is online specially, and
>> + * directly call.
>> + */
>> + if (num_online_cpus() == 1)
>> + irq_core_set_enable_local(data);
>> + else
>> + on_each_cpu(irq_core_set_enable_local, data, 1);
>> +
... This code is not correct. It was initially done as a workaround
for the issues fixed in commit 202da4005.
Now that on_each_cpu() is less buggy, we can unconditionally use it and
the assertion above about "Interrupts are already disabled" will be true.
>> + cd->current_en = cd->desired_en;
>> + }
>> +
>> + mutex_unlock(&cd->core_irq_mutex);
>> +}
>
>
>> +static int irq_pci_set_affinity(struct irq_data *data, const struct cpumask *dest, bool force)
>> +{
>> + return 0;
>> +}
>
> Is there any point even providing this callback?
I guess we can add them only when they are implemented.
>
>> +
>> +static void irq_pci_cpu_offline(struct irq_data *data)
>> +{
>> +}
>
> Or this one?
Same.
>
>> +
>> +static struct irq_chip irq_chip_pci = {
>> + .name = "PCI",
>> + .irq_enable = irq_pci_enable,
>> + .irq_disable = irq_pci_disable,
>> + .irq_ack = irq_pci_ack,
>> + .irq_mask = irq_pci_mask,
>> + .irq_unmask = irq_pci_unmask,
>> + .irq_set_affinity = irq_pci_set_affinity,
>> + .irq_cpu_offline = irq_pci_cpu_offline,
>> +};
>
>
>> diff --git a/arch/mips/paravirt/paravirt-smp.c b/arch/mips/paravirt/paravirt-smp.c
>> new file mode 100644
>> index 0000000..52f86eb
>> --- /dev/null
>> +++ b/arch/mips/paravirt/paravirt-smp.c
>
>> +static void paravirt_smp_finish(void)
>> +{
>> + /* to generate the first CPU timer interrupt */
>> + write_c0_compare(read_c0_count() + mips_hpt_frequency / HZ);
>
> This strikes me as a bit hacky. Are you sure it's actually necessary? (I
> would have expected some generic hotplug notifier somewhere to ensure
> that percpu clocksources gets initialised sensibly when a new CPU is
> brought up)
>
>
>> +static void paravirt_boot_secondary(int cpu, struct task_struct *idle)
>> +{
>> + paravirt_smp_gp[cpu] = (unsigned long)(task_thread_info(idle));
>
> spurious brackets around task_thread_info(idle)
>
>> + wmb();
>
> Wouldn't smp_wmb() be more accurate?
Probably.
>
>> + paravirt_smp_sp[cpu] = __KSTK_TOS(idle);
>> + mb();
>
> is this barrier necessary?
Really it is just make_writes_visible_asap(), but for OCTEON mb() or
smp_wmb() is the closest that the kernel has.
It may not be necessary, but it doesn't really harm anything.
>
>> diff --git a/arch/mips/paravirt/serial.c b/arch/mips/paravirt/serial.c
>> new file mode 100644
>> index 0000000..e3f98b2
>> --- /dev/null
>> +++ b/arch/mips/paravirt/serial.c
>> @@ -0,0 +1,38 @@
>> +/*
>> + * This file is subject to the terms and conditions of the GNU General Public
>> + * License. See the file "COPYING" in the main directory of this archive
>> + * for more details.
>> + *
>> + * Copyright (C) 2013 Cavium, Inc.
>> + */
>> +
>> +#include <linux/kernel.h>
>> +#include <linux/virtio_console.h>
>> +
>> +#include <asm/mipsregs.h>
>> +
>> +/*
>> + * Emit one character to the boot console.
>> + */
>> +int prom_putchar(char c)
>> +{
>> + hypcall3(0 /* Console output */, 0 /* port 0 */, (unsigned long)&c, 1 /* len == 1 */);
>
> I think the hypcall API needs to be clearly specified and Documented
> somewhere along with its HYPCALL codes and scope. I.e. is it specific to
> kvmtool, or attempting to be a standard API across MIPS hypervisors.
>
I was intending it to be the later. (standard API across MIPS hypervisors.)
The idea being that the first argument would be broken up into several
ranges.
0..x : Globally available HYPCALL provided by all hypervisors.
m..n : MIPS KVM specific.
y..z : Reserved for the vendor.
For some values of x, m, n, y and z.
But perhaps it should just be MIPS KVM specific. If making it global is
too much trouble.
> It probably should have nice definitions in a header and wrappers
> somewhere to make the arguments explicit and so there's no need for the
> comments explaining what the magic values mean.
>
> Cheers
> James
>
next prev parent reply other threads:[~2014-05-21 16:31 UTC|newest]
Thread overview: 90+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-05-20 14:47 [PATCH 00/15] MIPS: Add mips_paravirt Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 01/15] MIPS: OCTEON: Enable use of FPU Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 02/15] MIPS: Move system level config items from CPU_CAVIUM_OCTEON to CAVIUM_OCTEON_SOC Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 03/15] MIPS: OCTEON: Move CAVIUM_OCTEON_CVMSEG_SIZE to CPU_CAVIUM_OCTEON Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 22:52 ` James Hogan
2014-05-20 23:23 ` David Daney
2014-05-20 23:23 ` David Daney
2014-05-21 6:22 ` Andreas Herrmann
2014-05-21 6:22 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 04/15] MIPS: Don't use RI/XI with 32-bit kernels on 64-bit CPUs Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 05/15] MIPS: Don't build fast TLB refill handler with 32-bit kernels Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-21 9:38 ` James Hogan
2014-05-21 9:38 ` James Hogan
2014-05-21 13:04 ` Ralf Baechle
2014-05-21 13:17 ` Andreas Herrmann
2014-05-21 13:17 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 06/15] MIPS: Add minimal support for OCTEON3 to c-r4k.c Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-21 10:04 ` James Hogan
2014-05-21 10:04 ` James Hogan
2014-05-21 16:10 ` David Daney
2014-05-21 16:10 ` David Daney
2014-05-21 12:40 ` Ralf Baechle
2014-05-21 21:02 ` Andreas Herrmann
2014-05-21 21:02 ` Andreas Herrmann
2014-05-22 7:59 ` Ralf Baechle
2014-05-20 14:47 ` [PATCH 07/15] MIPS: Add mips_cpunum() function Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-21 11:10 ` James Hogan
2014-05-21 11:10 ` James Hogan
2014-05-22 16:13 ` Andreas Herrmann
2014-05-22 16:13 ` Andreas Herrmann
2014-05-22 16:15 ` James Hogan
2014-05-22 16:15 ` James Hogan
2014-05-20 14:47 ` [PATCH 08/15] MIPS: OCTEON: Add OCTEON3 to __get_cpu_type Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 09/15] MIPS: Add functions for hypervisor call Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-21 0:16 ` James Hogan
2014-05-21 7:30 ` Andreas Herrmann
2014-05-21 7:30 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 10/15] MIPS: Add code for new system 'paravirt' Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-21 13:39 ` James Hogan
2014-05-21 13:39 ` James Hogan
2014-05-21 16:31 ` David Daney [this message]
2014-05-21 16:31 ` David Daney
2014-05-21 16:46 ` James Hogan
2014-05-21 16:46 ` James Hogan
2014-05-23 20:31 ` Andreas Herrmann
2014-05-23 20:31 ` Andreas Herrmann
2014-05-22 16:54 ` Andreas Herrmann
2014-05-22 16:54 ` Andreas Herrmann
2014-05-23 20:28 ` Andreas Herrmann
2014-05-23 20:28 ` Andreas Herrmann
2014-05-23 21:47 ` Ralf Baechle
2014-05-20 14:47 ` [PATCH 11/15] MIPS: paravirt: Add pci controller for virtio Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-21 11:42 ` James Hogan
2014-05-21 11:42 ` James Hogan
2014-05-22 20:17 ` Andreas Herrmann
2014-05-22 20:17 ` Andreas Herrmann
2014-05-28 22:10 ` Andreas Herrmann
2014-05-28 22:10 ` Andreas Herrmann
2014-05-21 13:34 ` Ralf Baechle
2014-05-20 14:47 ` [PATCH 12/15] MIPS: Enable build for new system 'paravirt' Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 13/15] MIPS: Add defconfig for mips_paravirt Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 23:14 ` James Hogan
2014-05-21 6:29 ` Andreas Herrmann
2014-05-21 6:29 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 14/15] MIPS: paravirt: Update mips_paravirt_defconfig Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-20 23:17 ` James Hogan
2014-05-21 6:36 ` Andreas Herrmann
2014-05-21 6:36 ` Andreas Herrmann
2014-05-20 14:47 ` [PATCH 15/15] MIPS: paravirt: Provide _machine_halt function to exit VM on shutdown of guest Andreas Herrmann
2014-05-20 14:47 ` Andreas Herrmann
2014-05-21 13:44 ` James Hogan
2014-05-21 13:44 ` James Hogan
2014-05-28 22:04 ` Andreas Herrmann
2014-05-28 22:04 ` Andreas Herrmann
2014-05-28 23:18 ` James Hogan
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=537CD4C6.5080905@caviumnetworks.com \
--to=ddaney@caviumnetworks.com \
--cc=andreas.herrmann@caviumnetworks.com \
--cc=david.daney@cavium.com \
--cc=ddaney.cavm@gmail.com \
--cc=james.hogan@imgtec.com \
--cc=kvm@vger.kernel.org \
--cc=linux-mips@linux-mips.org \
--cc=ralf@linux-mips.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.