Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1561993 > unrolled thread

[PATCH v3 0/3] x86/platform/intel-mid: Fix RTC handling

Started byAndy Shevchenko <andriy.shevchenko@linux.intel.com>
First post2017-01-18 18:50 +0100
Last post2017-01-19 18:10 +0100
Articles 5 — 2 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH v3 0/3] x86/platform/intel-mid: Fix RTC handling Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-01-18 18:50 +0100
    [PATCH v3 3/3] x86/platform/intel-mid: Don't shadow error code of mp_map_gsi_to_irq() Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-01-18 18:50 +0100
    [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt for Merrifield Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-01-18 18:50 +0100
      Re: [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt  for Merrifield Thomas Gleixner <tglx@linutronix.de> - 2017-01-19 18:00 +0100
        Re: [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt  for Merrifield Andy Shevchenko <andriy.shevchenko@linux.intel.com> - 2017-01-19 18:10 +0100

#1561993 — [PATCH v3 0/3] x86/platform/intel-mid: Fix RTC handling

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-01-18 18:50 +0100
Subject[PATCH v3 0/3] x86/platform/intel-mid: Fix RTC handling
Message-ID<t12wV-72O-5@gated-at.bofh.it>
Current RTC approach breaks some platforms. Rewrite it completely and
make avaiable only for intended platforms.

Tested on Intel Merrifield, ASuS T100TA (normal and acpi=off cases).

Since v2:
- add mp_map_gsi_to_irq() fix to the series as patch 1
- add patch 3
- rewrite RTC approach as another platform code for Intel MID

Andy Shevchenko (3):
  x86/ioapic: Return suitable error code in mp_map_gsi_to_irq()
  x86/platform/intel-mid: Allocate RTC interrupt for Merrifield
  x86/platform/intel-mid: Don't shadow error code of mp_map_gsi_to_irq()

 arch/x86/kernel/apic/io_apic.c                     |  4 +-
 arch/x86/platform/intel-mid/device_libs/Makefile   |  1 +
 .../intel-mid/device_libs/platform_mrfld_rtc.c     | 48 ++++++++++++++++++++++
 .../intel-mid/device_libs/platform_mrfld_wdt.c     | 10 ++---
 arch/x86/platform/intel-mid/sfi.c                  | 14 -------
 5 files changed, 56 insertions(+), 21 deletions(-)
 create mode 100644 arch/x86/platform/intel-mid/device_libs/platform_mrfld_rtc.c

-- 
2.11.0

[toc] | [next] | [standalone]


#1562006 — [PATCH v3 3/3] x86/platform/intel-mid: Don't shadow error code of mp_map_gsi_to_irq()

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-01-18 18:50 +0100
Subject[PATCH v3 3/3] x86/platform/intel-mid: Don't shadow error code of mp_map_gsi_to_irq()
Message-ID<t12wW-72O-33@gated-at.bofh.it>
In reply to#1561993
When call mp_map_gsi_to_irq() and return its error code do not shadow it.
Note that 0 is not an error.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/platform/intel-mid/device_libs/platform_mrfld_wdt.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/arch/x86/platform/intel-mid/device_libs/platform_mrfld_wdt.c b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_wdt.c
index 3f1f1c77d090..8a10a56f2840 100644
--- a/arch/x86/platform/intel-mid/device_libs/platform_mrfld_wdt.c
+++ b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_wdt.c
@@ -28,9 +28,9 @@ static struct platform_device wdt_dev = {
 
 static int tangier_probe(struct platform_device *pdev)
 {
-	int gsi;
 	struct irq_alloc_info info;
 	struct intel_mid_wdt_pdata *pdata = pdev->dev.platform_data;
+	int gsi, irq;
 
 	if (!pdata)
 		return -EINVAL;
@@ -38,10 +38,10 @@ static int tangier_probe(struct platform_device *pdev)
 	/* IOAPIC builds identity mapping between GSI and IRQ on MID */
 	gsi = pdata->irq;
 	ioapic_set_alloc_attr(&info, cpu_to_node(0), 1, 0);
-	if (mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info) <= 0) {
-		dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n",
-			 gsi);
-		return -EINVAL;
+	irq = mp_map_gsi_to_irq(gsi, IOAPIC_MAP_ALLOC, &info);
+	if (irq < 0) {
+		dev_warn(&pdev->dev, "cannot find interrupt %d in ioapic\n", gsi);
+		return irq;
 	}
 
 	return 0;
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1562007 — [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt for Merrifield

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-01-18 18:50 +0100
Subject[PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt for Merrifield
Message-ID<t12wW-72O-41@gated-at.bofh.it>
In reply to#1561993
Legacy RTC requires interrupt line 8 to be dedicated for it. On
Intel MID platforms the legacy PIC is absent and in order to make RTC
work we need to allocate interrupt separately.

Current solution brought by the commit:

  de1c2540aa4f ("x86/platform/intel-mid: Enable RTC on Intel Merrifield")

does it in a wrong place, and since it's done unconditionally for all
x86 devices, some of them, e.g. PNP based, might get it wrong -- at the
beginning x86_platform.legacy.rtc flag is set for all x86 devices.

Move intel_mid_legacy_rtc_init() to its own module and call it before x86 RTC
CMOS initialization.

Cc: Luis R. Rodriguez <mcgrof@kernel.org>
Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 arch/x86/platform/intel-mid/device_libs/Makefile   |  1 +
 .../intel-mid/device_libs/platform_mrfld_rtc.c     | 48 ++++++++++++++++++++++
 arch/x86/platform/intel-mid/sfi.c                  | 14 -------
 3 files changed, 49 insertions(+), 14 deletions(-)
 create mode 100644 arch/x86/platform/intel-mid/device_libs/platform_mrfld_rtc.c

diff --git a/arch/x86/platform/intel-mid/device_libs/Makefile b/arch/x86/platform/intel-mid/device_libs/Makefile
index 8be58eefb281..5901036311c4 100644
--- a/arch/x86/platform/intel-mid/device_libs/Makefile
+++ b/arch/x86/platform/intel-mid/device_libs/Makefile
@@ -27,6 +27,7 @@ obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_pcal9555a.o
 obj-$(subst m,y,$(CONFIG_GPIO_PCA953X)) += platform_tca6416.o
 # MISC Devices
 obj-$(subst m,y,$(CONFIG_KEYBOARD_GPIO)) += platform_gpio_keys.o
+obj-$(subst m,y,$(CONFIG_RTC_DRV_CMOS)) += platform_mrfld_rtc.o
 obj-$(subst m,y,$(CONFIG_INTEL_MID_WATCHDOG)) += platform_mrfld_wdt.o
 # PWM
 obj-$(subst m,y,$(CONFIG_PINCTRL_MERRIFIELD)) += platform_mrfld_pwm.o
diff --git a/arch/x86/platform/intel-mid/device_libs/platform_mrfld_rtc.c b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_rtc.c
new file mode 100644
index 000000000000..93821b0caff9
--- /dev/null
+++ b/arch/x86/platform/intel-mid/device_libs/platform_mrfld_rtc.c
@@ -0,0 +1,48 @@
+/*
+ * Intel Merrifield legacy RTC initialization file
+ *
+ * (C) Copyright 2017 Intel Corporation
+ *
+ * Author: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; version 2
+ * of the License.
+ */
+
+#include <linux/init.h>
+
+#include <asm/hw_irq.h>
+#include <asm/intel-mid.h>
+#include <asm/io_apic.h>
+#include <asm/time.h>
+#include <asm/x86_init.h>
+
+static int __init mrfld_legacy_rtc_alloc_irq(void)
+{
+	struct irq_alloc_info info;
+	int ret;
+
+	if (!x86_platform.legacy.rtc)
+		return -ENODEV;
+
+	ioapic_set_alloc_attr(&info, NUMA_NO_NODE, 1, 0);
+	ret = mp_map_gsi_to_irq(RTC_IRQ, IOAPIC_MAP_ALLOC, &info);
+	if (ret < 0) {
+		pr_info("Failed to allocate RTC interrupt. Disabling RTC\n");
+		x86_platform.legacy.rtc = 0;
+		return ret;
+	}
+
+	return 0;
+}
+
+static int __init mrfld_legacy_rtc_init(void)
+{
+	if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
+		return -ENODEV;
+
+	return mrfld_legacy_rtc_alloc_irq();
+}
+rootfs_initcall(mrfld_legacy_rtc_init);
diff --git a/arch/x86/platform/intel-mid/sfi.c b/arch/x86/platform/intel-mid/sfi.c
index e4d4cabbb370..19b43e3a9f0f 100644
--- a/arch/x86/platform/intel-mid/sfi.c
+++ b/arch/x86/platform/intel-mid/sfi.c
@@ -41,7 +41,6 @@
 #include <asm/intel_scu_ipc.h>
 #include <asm/apb_timer.h>
 #include <asm/reboot.h>
-#include <asm/time.h>
 
 #define	SFI_SIG_OEM0	"OEM0"
 #define MAX_IPCDEVS	24
@@ -540,21 +539,8 @@ static int __init sfi_parse_devs(struct sfi_table_header *table)
 	return 0;
 }
 
-static int __init intel_mid_legacy_rtc_init(void)
-{
-	struct irq_alloc_info info;
-
-	if (!x86_platform.legacy.rtc)
-		return -ENODEV;
-
-	ioapic_set_alloc_attr(&info, NUMA_NO_NODE, 1, 0);
-	return mp_map_gsi_to_irq(RTC_IRQ, IOAPIC_MAP_ALLOC, &info);
-}
-
 static int __init intel_mid_platform_init(void)
 {
-	intel_mid_legacy_rtc_init();
-
 	sfi_table_parse(SFI_SIG_GPIO, NULL, NULL, sfi_parse_gpio);
 	sfi_table_parse(SFI_SIG_DEVS, NULL, NULL, sfi_parse_devs);
 	return 0;
-- 
2.11.0

[toc] | [prev] | [next] | [standalone]


#1562919 — Re: [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt for Merrifield

FromThomas Gleixner <tglx@linutronix.de>
Date2017-01-19 18:00 +0100
SubjectRe: [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt for Merrifield
Message-ID<t1oe5-40V-15@gated-at.bofh.it>
In reply to#1562007
On Wed, 18 Jan 2017, Andy Shevchenko wrote:
> +#include <linux/init.h>
> +
> +#include <asm/hw_irq.h>
> +#include <asm/intel-mid.h>
> +#include <asm/io_apic.h>
> +#include <asm/time.h>
> +#include <asm/x86_init.h>
> +
> +static int __init mrfld_legacy_rtc_alloc_irq(void)
> +{
> +	struct irq_alloc_info info;
> +	int ret;
> +
> +	if (!x86_platform.legacy.rtc)
> +		return -ENODEV;
> +
> +	ioapic_set_alloc_attr(&info, NUMA_NO_NODE, 1, 0);
> +	ret = mp_map_gsi_to_irq(RTC_IRQ, IOAPIC_MAP_ALLOC, &info);
> +	if (ret < 0) {
> +		pr_info("Failed to allocate RTC interrupt. Disabling RTC\n");
> +		x86_platform.legacy.rtc = 0;
> +		return ret;
> +	}
> +
> +	return 0;
> +}
> +
> +static int __init mrfld_legacy_rtc_init(void)
> +{
> +	if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
> +		return -ENODEV;
> +
> +	return mrfld_legacy_rtc_alloc_irq();
> +}
> +rootfs_initcall(mrfld_legacy_rtc_init);

rootfs_initcall???? That does not make any sense at all. I know you need it
before the device initcalls, but just using a random initcall level before
device_initcall is wrong.

arch_initcall is much more suitable.

Thanks,

	tglx

[toc] | [prev] | [next] | [standalone]


#1562943 — Re: [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt for Merrifield

FromAndy Shevchenko <andriy.shevchenko@linux.intel.com>
Date2017-01-19 18:10 +0100
SubjectRe: [PATCH v3 2/3] x86/platform/intel-mid: Allocate RTC interrupt for Merrifield
Message-ID<t1onM-4jH-23@gated-at.bofh.it>
In reply to#1562919
On Thu, 2017-01-19 at 17:54 +0100, Thomas Gleixner wrote:
> On Wed, 18 Jan 2017, Andy Shevchenko wrote:
> > +#include <linux/init.h>
> > +
> > +#include <asm/hw_irq.h>
> > +#include <asm/intel-mid.h>
> > +#include <asm/io_apic.h>
> > +#include <asm/time.h>
> > +#include <asm/x86_init.h>
> > +
> > +static int __init mrfld_legacy_rtc_alloc_irq(void)
> > +{
> > +	struct irq_alloc_info info;
> > +	int ret;
> > +
> > +	if (!x86_platform.legacy.rtc)
> > +		return -ENODEV;
> > +
> > +	ioapic_set_alloc_attr(&info, NUMA_NO_NODE, 1, 0);
> > +	ret = mp_map_gsi_to_irq(RTC_IRQ, IOAPIC_MAP_ALLOC, &info);
> > +	if (ret < 0) {
> > +		pr_info("Failed to allocate RTC interrupt.
> > Disabling RTC\n");
> > +		x86_platform.legacy.rtc = 0;
> > +		return ret;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int __init mrfld_legacy_rtc_init(void)
> > +{
> > +	if (intel_mid_identify_cpu() != INTEL_MID_CPU_CHIP_TANGIER)
> > +		return -ENODEV;
> > +
> > +	return mrfld_legacy_rtc_alloc_irq();
> > +}
> > +rootfs_initcall(mrfld_legacy_rtc_init);
> 
> rootfs_initcall???? That does not make any sense at all. I know you
> need it
> before the device initcalls, but just using a random initcall level
> before
> device_initcall is wrong.

I copied watchdog approach, would you like me to move watchdog there as
well?

> 
> arch_initcall is much more suitable.

So, I think I need to send v4, but I would wait for answer for the
above.

Thanks for review!

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web