SA1100/PXA RTC clean-up
Subsystems (5)
v4 cover SA1100/PXA RTC clean-up
This series enables building the SA1100 RTC driver for ARM64 in preparation for enabling CONFIG_ARCH_MMP on ARM64. This is needed for supporting the PXA1928 SOC. Clean-up of SA1100 RTC is complicated by the fact that some PXA chips use both sa1100-rtc and pxa-rtc drivers and share the same registers. This does not work well with the Linux driver model. So the first step is removing this sharing by the 2 drivers and making sa1100-rtc and pxa-rtc mutually exclusive.
The previous versions can be found here[1][2][3]. Patches 1 and 2 are new. Patches 3, 5, and 6 are unchanged. Patch 4 is mostly the same, but adjusted due to patches 1 and 2.
A git branch is here[4]. I've tested sa1100-rtc on PXA1928. I need help testing on PXA27x/3xx.
Rob
[1] http://comments.gmane.org/gmane.linux.ports.arm.kernel/391410
[2] http://comments.gmane.org/gmane.linux.ports.arm.kernel/409740
[3] http://comments.gmane.org/gmane.linux.ports.arm.kernel/412047
[4] git://git.kernel.org/pub/scm/linux/kernel/git/robh/linux.git marvell/rtc
Rob Herring (6):
rtc: sa1100: prepare to share sa1100_rtc_ops
rtc: pxa: convert to use shared sa1100 functions
ARM: pxa: add memory resource to SA1100 RTC device
rtc: sa1100/pxa: convert to run-time register mapping
ARM: sa1100: remove unused RTC register definitions
ARM: mmp: remove unused RTC register definitions
arch/arm/mach-mmp/include/mach/regs-rtc.h | 23 ----- arch/arm/mach-pxa/devices.c | 18 +--- arch/arm/mach-pxa/pxa27x.c | 1 - arch/arm/mach-pxa/pxa3xx.c | 1 - arch/arm/mach-sa1100/include/mach/SA-1100.h | 34 ------- drivers/rtc/Kconfig | 4 +- drivers/rtc/rtc-pxa.c | 55 +++++------ drivers/rtc/rtc-sa1100.c | 139 +++++++++++++++++----------- drivers/rtc/rtc-sa1100.h | 23 +++++ 9 files changed, 140 insertions(+), 158 deletions(-) delete mode 100644 arch/arm/mach-mmp/include/mach/regs-rtc.h create mode 100644 drivers/rtc/rtc-sa1100.h
--
2.1.0
PATCH v4 1/6 rtc: sa1100: prepare to share sa1100_rtc_ops
Factor out the RTC initialization from the platform device specific parts in order to share the RTC device ops with other drivers. Specifically, it will be shared with rtc-pxa driver.
--- drivers/rtc/rtc-sa1100.c | 59 ++++++++++++++++++++++++------------------------ drivers/rtc/rtc-sa1100.h | 19 ++++++++++++++++ 2 files changed, 49 insertions(+), 29 deletions(-) create mode 100644 drivers/rtc/rtc-sa1100.h
drivers/rtc/rtc-sa1100.c +30 -29
@@ -42,17 +42,12 @@#include <mach/regs-rtc.h> #endif +#include "rtc-sa1100.h" +#define RTC_DEF_DIVIDER (32768 - 1)#define RTC_DEF_TRIM 0#define RTC_FREQ 1024 -struct sa1100_rtc { -spinlock_t lock; -int irq_1hz; -int irq_alarm; -struct rtc_device *rtc; -struct clk *clk; -};static irqreturn_t sa1100_rtc_interrupt (int irq,void *dev_id) {
@@ -223,29 +218,18 @@ static const struct rtc_class_ops sa1100_rtc_ops = { .alarm_irq_enable = sa1100_rtc_alarm_irq_enable, }; -static int sa1100_rtc_probe (struct platform_device *pdev) +int sa1100_rtc_init (struct platform_device *pdev,struct sa1100_rtc *info) {struct rtc_device *rtc; -struct sa1100_rtc *info; -int irq_1hz, irq_alarm, ret =0 ; +int ret; - irq_1hz =platform_get_irq_byname (pdev,"rtc 1Hz" ); - irq_alarm =platform_get_irq_byname (pdev,"rtc alarm" ); -if (irq_1hz <0 || irq_alarm <0 ) -return -ENODEV ; +spin_lock_init (&info->lock); - info =devm_kzalloc (&pdev->dev,sizeof (struct sa1100_rtc ),GFP_KERNEL ); -if (!info) -return -ENOMEM ; info->clk =devm_clk_get (&pdev->dev,NULL );if (IS_ERR (info->clk)) {dev_err (&pdev->dev,"failed to find rtc clock source\n" );return PTR_ERR (info->clk); } - info->irq_1hz = irq_1hz; - info->irq_alarm = irq_alarm; -spin_lock_init (&info->lock); -platform_set_drvdata (pdev, info); ret =clk_prepare_enable (info->clk);if (ret)
@@ -265,14 +249,11 @@ static int sa1100_rtc_probe(struct platform_device *pdev)RCNR =0 ; } -device_init_wakeup (&pdev->dev,1 ); - rtc =devm_rtc_device_register (&pdev->dev, pdev->name, &sa1100_rtc_ops,THIS_MODULE ); -if (IS_ERR (rtc)) { - ret =PTR_ERR (rtc); - goto err_dev; +clk_disable_unprepare (info->clk); +return PTR_ERR (rtc); } info->rtc = rtc;
@@ -301,9 +282,29 @@ static int sa1100_rtc_probe(struct platform_device *pdev)RTSR =RTSR_AL |RTSR_HZ ;return 0 ; -err_dev: -clk_disable_unprepare (info->clk); -return ret; +} +EXPORT_SYMBOL_GPL (sa1100_rtc_init); + +static int sa1100_rtc_probe (struct platform_device *pdev) +{ +struct sa1100_rtc *info; +int irq_1hz, irq_alarm; + + irq_1hz =platform_get_irq_byname (pdev,"rtc 1Hz" ); + irq_alarm =platform_get_irq_byname (pdev,"rtc alarm" ); +if (irq_1hz <0 || irq_alarm <0 ) +return -ENODEV ; + + info =devm_kzalloc (&pdev->dev,sizeof (struct sa1100_rtc ),GFP_KERNEL ); +if (!info) +return -ENOMEM ; + info->irq_1hz = irq_1hz; + info->irq_alarm = irq_alarm; + +platform_set_drvdata (pdev, info); +device_init_wakeup (&pdev->dev,1 ); + +return sa1100_rtc_init (pdev, info); }static int sa1100_rtc_remove (struct platform_device *pdev)
drivers/rtc/rtc-sa1100.h new file +19 -0
@@ -0,0 +1,19 @@ +#ifndef __RTC_SA1100_H__ +#define __RTC_SA1100_H__ + +#include <linux/kernel.h> + +struct clk ; +struct platform_device ; + +struct sa1100_rtc { +spinlock_t lock; +int irq_1hz; +int irq_alarm; +struct rtc_device *rtc; +struct clk *clk; +}; + +int sa1100_rtc_init (struct platform_device *pdev,struct sa1100_rtc *info); + +#endif
Signature · 1 line
2.1.0
PATCH v4 2/6 rtc: pxa: convert to use shared sa1100 functions
In reply to Rob HerringCurrently, the rtc-sa1100 and rtc-pxa drivers co-exist as rtc-pxa has a superset of functionality. Having 2 drivers sharing the same memory resource is not allowed by the driver model if resources are properly declared. This problem was avoided by not adding memory resources to the SA1100 RTC driver, but that prevents clean-up of the SA1100 driver.
This commit converts the PXA RTC to use the exported SA1100 RTC functions. Now the sa1100-rtc and pxa-rtc devices are mutually exclusive, so we must remove the sa1100-rtc from pxa27x and pxa3xx.
--- arch/arm/mach-pxa/pxa27x.c | 1 - arch/arm/mach-pxa/pxa3xx.c | 1 - drivers/rtc/Kconfig | 4 +++- drivers/rtc/rtc-pxa.c | 51 ++++++++++++++++++++++------------------------ 4 files changed, 27 insertions(+), 30 deletions(-)
arch/arm/mach-pxa/pxa27x.c +0 -1
@@ -449,7 +449,6 @@ static struct platform_device *devices[] __initdata = { &pxa_device_asoc_ssp2, &pxa_device_asoc_ssp3, &pxa_device_asoc_platform, - &sa1100_device_rtc, &pxa_device_rtc, &pxa27x_device_ssp1, &pxa27x_device_ssp2,
arch/arm/mach-pxa/pxa3xx.c +0 -1
@@ -450,7 +450,6 @@ static struct platform_device *devices[] __initdata = { &pxa_device_asoc_ssp3, &pxa_device_asoc_ssp4, &pxa_device_asoc_platform, - &sa1100_device_rtc, &pxa_device_rtc, &pxa3xx_device_ssp1, &pxa3xx_device_ssp2,
drivers/rtc/Kconfig +3 -1
@@ -1301,9 +1301,11 @@ config RTC_DRV_GENERIC config RTC_DRV_PXA tristate "PXA27x/PXA3xx" depends on ARCH_PXA + select RTC_DRV_SA1100 help If you say Y here you will get access to the real time clock - built into your PXA27x or PXA3xx CPU. + built into your PXA27x or PXA3xx CPU. This RTC is actually 2 RTCs + consisting of an SA1100 compatible RTC and the extended PXA RTC. This RTC driver uses PXA RTC registers available since pxa27x series (RDxR, RYxR) instead of legacy RCNR, RTAR.
drivers/rtc/rtc-pxa.c +24 -27
127 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v4 3/6 ARM: pxa: add memory resource to SA1100 RTC device
In reply to Rob HerringThe drivers for the SA1100 and PXA RTCs are now mutually exclusive, so add the memory resource for the sa1100-rtc device. Since the memory resource is already present in the pxa_rtc_resources, that makes sa1100_rtc_resources and pxa_rtc_resources equivalent, so use pxa_rtc_resources for both devices and remove the duplicate sa1100_rtc_resources.
--- arch/arm/mach-pxa/devices.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-)
arch/arm/mach-pxa/devices.c +2 -16
@@ -439,25 +439,11 @@ struct platform_device pxa_device_rtc = { .resource = pxa_rtc_resources, }; -static struct resource sa1100_rtc_resources[] = { - { - .start = IRQ_RTC1Hz, - .end = IRQ_RTC1Hz, - .name ="rtc 1Hz" , - .flags =IORESOURCE_IRQ , - }, { - .start = IRQ_RTCAlrm, - .end = IRQ_RTCAlrm, - .name ="rtc alarm" , - .flags =IORESOURCE_IRQ , - }, -}; -struct platform_device sa1100_device_rtc = { .name ="sa1100-rtc" , .id =-1 , - .num_resources =ARRAY_SIZE (sa1100_rtc_resources), - .resource = sa1100_rtc_resources, + .num_resources =ARRAY_SIZE (pxa_rtc_resources), + .resource = pxa_rtc_resources, };static struct resource pxa_ac97_resources[] = {
Signature · 1 line
2.1.0
PATCH v4 4/6 rtc: sa1100/pxa: convert to run-time register mapping
In reply to Rob HerringSA1100 and PXA differ only in register offsets which are currently hardcoded in a machine specific header. Some arm64 platforms (PXA1928) have this RTC block as well (and not the PXA270 variant).
Convert the driver to use ioremap and set the register offsets dynamically. Since we are touching all the register accesses, convert them all to readl_relaxed/writel_relaxed.
--- drivers/rtc/rtc-pxa.c | 4 +++ drivers/rtc/rtc-sa1100.c | 82 ++++++++++++++++++++++++++++++++---------------- drivers/rtc/rtc-sa1100.h | 4 +++ 3 files changed, 63 insertions(+), 27 deletions(-)
drivers/rtc/rtc-pxa.c +4 -0
@@ -356,6 +356,10 @@ static int __init pxa_rtc_probe(struct platform_device *pdev)return -ENOMEM ; } + sa1100_rtc->rcnr = pxa_rtc->base +0x0 ; + sa1100_rtc->rtsr = pxa_rtc->base +0x8 ; + sa1100_rtc->rtar = pxa_rtc->base +0x4 ; + sa1100_rtc->rttr = pxa_rtc->base +0xc ; ret =sa1100_rtc_init (pdev, sa1100_rtc);if (!ret) {dev_err (dev,"Unable to init SA1100 RTC sub-device\n" );
drivers/rtc/rtc-sa1100.c +55 -27
193 lines not on this page · raw message
drivers/rtc/rtc-sa1100.h +4 -0
@@ -8,6 +8,10 @@ struct platform_device;struct sa1100_rtc {spinlock_t lock; +void __iomem *rcnr; +void __iomem *rtar; +void __iomem *rtsr; +void __iomem *rttr;int irq_1hz;int irq_alarm;struct rtc_device *rtc;
Signature · 1 line
2.1.0
PATCH v4 5/6 ARM: sa1100: remove unused RTC register definitions
In reply to Rob HerringNow that register definitions have been moved to the driver, we can remove them from machine specific code.
--- arch/arm/mach-sa1100/include/mach/SA-1100.h | 34 ----------------------------- 1 file changed, 34 deletions(-)
arch/arm/mach-sa1100/include/mach/SA-1100.h +0 -34
@@ -858,40 +858,6 @@/* -* Real-Time Clock (RTC) control registers -* -* Registers -* RTAR Real-Time Clock (RTC) Alarm Register (read/write). -* RCNR Real-Time Clock (RTC) CouNt Register (read/write). -* RTTR Real-Time Clock (RTC) Trim Register (read/write). -* RTSR Real-Time Clock (RTC) Status Register (read/write). -* -* Clocks -* frtx, Trtx Frequency, period of the real-time clock crystal -* (32.768 kHz nominal). -* frtc, Trtc Frequency, period of the real-time clock counter -* (1 Hz nominal). -*/ - -#define RTAR __REG(0x90010000)/* RTC Alarm Reg. */ -#define RCNR __REG(0x90010004)/* RTC CouNt Reg. */ -#define RTTR __REG(0x90010008)/* RTC Trim Reg. */ -#define RTSR __REG(0x90010010)/* RTC Status Reg. */ - -#define RTTR_C Fld (16, 0)/* clock divider Count - 1 */ -#define RTTR_D Fld (10, 16)/* trim Delete count */ -/* frtc = (1023*(C + 1) - D)*frtx/ */ -/* (1023*(C + 1)^2) */ -/* Trtc = (1023*(C + 1)^2)*Trtx/ */ -/* (1023*(C + 1) - D) */ - -#define RTSR_AL 0x00000001/* ALarm detected */ -#define RTSR_HZ 0x00000002/* 1 Hz clock detected */ -#define RTSR_ALE 0x00000004/* ALarm interrupt Enable */ -#define RTSR_HZE 0x00000008/* 1 Hz clock interrupt Enable */ - - -/* * Power Manager (PM) control registers * * Registers
Signature · 1 line
2.1.0
PATCH v4 6/6 ARM: mmp: remove unused RTC register definitions
In reply to Rob HerringNow that register definitions have been moved to the driver, regs-rtc.h is no longer used and can be removed.
--- arch/arm/mach-mmp/include/mach/regs-rtc.h | 23 ----------------------- 1 file changed, 23 deletions(-) delete mode 100644 arch/arm/mach-mmp/include/mach/regs-rtc.h
arch/arm/mach-mmp/include/mach/regs-rtc.h deleted +0 -23
@@ -1,23 +0,0 @@ -#ifndef __ASM_MACH_REGS_RTC_H -#define __ASM_MACH_REGS_RTC_H - -#include <mach/addr-map.h> - -#define RTC_VIRT_BASE (APB_VIRT_BASE + 0x10000) -#define RTC_REG (x) (*((volatile u32 __iomem *)(RTC_VIRT_BASE + (x)))) - -/* -* Real Time Clock -*/ - -#define RCNR RTC_REG(0x00)/* RTC Count Register */ -#define RTAR RTC_REG(0x04)/* RTC Alarm Register */ -#define RTSR RTC_REG(0x08)/* RTC Status Register */ -#define RTTR RTC_REG(0x0C)/* RTC Timer Trim Register */ - -#define RTSR_HZE (1 << 3)/* HZ interrupt enable */ -#define RTSR_ALE (1 << 2)/* RTC alarm interrupt enable */ -#define RTSR_HZ (1 << 1)/* HZ rising-edge detected */ -#define RTSR_AL (1 << 0)/* RTC alarm detected */ - -#endif /* __ASM_MACH_REGS_RTC_H */
Signature · 1 line
2.1.0
Robert Jarzmik
maintainerv4 cover SA1100/PXA RTC clean-up
In reply to Rob HerringQuoted 2 lines · Rob Herring
A git branch is here[4]. I've tested sa1100-rtc on PXA1928. I need help testing on PXA27x/3xx.
Hi Rob,
I tested on PXA27x. It works for the boards which used pxa-rtc. For the others, their defconfig become broken, because the pxa boards with sa1100-rtc do not work anymore. And of course no .config manipulation will fix this, because PXA architecture is denied the sa1100-rtc driver.
As a consequence, these boards should transition from sa1100-rtc to pxa-rtc to get back a working rtc, amongst which :
cm_x2xx_defconfig em_x270_defconfig h5000_defconfig jornada720_defconfig magician_defconfig palmz72_defconfig pcm027_defconfig trizeps4_defconfig viper_defconfig xcep_defconfig
I think you should at least Cc the maintainers of these boards to see their reaction. They should be aware of the impacts and comment.
I'll make a test for pxa3xx in the next week.
Cheers.
--
Robert
v4 cover SA1100/PXA RTC clean-up
Quoted 10 lines · Robert Jarzmik
Quoted 2 lines · Rob Herring
A git branch is here[4]. I've tested sa1100-rtc on PXA1928. I need help testing on PXA27x/3xx.
Hi Rob,
I tested on PXA27x. It works for the boards which used pxa-rtc. For the others, their defconfig become broken, because the pxa boards with sa1100-rtc do not work anymore. And of course no .config manipulation will fix this, because PXA architecture is denied the sa1100-rtc driver.
Ah, I didn't realize there is a mixture of use.
I could just do something like this instead of removing sa1100_device_rtc registration:
#ifndef CONFIG_RTC_DRV_PXA
&sa1100_device_rtc,#else
&pxa_device_rtc,
#endif
Rob
Robert Jarzmik
maintainerv4 cover SA1100/PXA RTC clean-up
Quoted 14 lines · Rob Herring
Quoted 10 lines · Robert Jarzmik
Quoted 2 lines · Rob Herring
A git branch is here[4]. I've tested sa1100-rtc on PXA1928. I need help testing on PXA27x/3xx.
Hi Rob,
I tested on PXA27x. It works for the boards which used pxa-rtc. For the others, their defconfig become broken, because the pxa boards with sa1100-rtc do not work anymore. And of course no .config manipulation will fix this, because PXA architecture is denied the sa1100-rtc driver.
Ah, I didn't realize there is a mixture of use.
Quoted 8 lines
I could just do something like this instead of removing
sa1100_device_rtcregistration:#ifndef CONFIG_RTC_DRV_PXA &sa1100_device_rtc,#else
&pxa_device_rtc,
#endif
I ... don't like that much, especially when you consider both rtc might be modules for example. I rather like that patch in pxa as they are.
I'm rather in a mood for a more aggressive approach :
- you fire an incremental patch to patch the 10 defconfigs on PXA architecture (pxa27x and pxa3xx)
- in this patch, you replace 's/CONFIG_RTC_DRV_SA1100/CONFIG_RTC_DRV_PXA/'
- you send this patch to the maintainers and me
- you explain in the commit message that from a userland perspective, nothing changes, except that the RTC IP will change, and any dependency on a bootloader fidling with RTC should be considered as a source of regression. Moreover the first reboot will have the wrong date, until it is set.
After that, if no board maintainer complains, or doesn't answer (and therefore doesn't care), and you have my blessing to make the switch. If one complains and demonstrates why this change might break his board, we'll see.
Cheers.
Signature · 1 line
Robert
v4 cover SA1100/PXA RTC clean-up
Quoted 24 lines · Robert Jarzmik
Quoted 14 lines · Rob Herring
Quoted 10 lines · Robert Jarzmik
Quoted 2 lines · Rob Herring
A git branch is here[4]. I've tested sa1100-rtc on PXA1928. I need help testing on PXA27x/3xx.
Hi Rob,
I tested on PXA27x. It works for the boards which used pxa-rtc. For the others, their defconfig become broken, because the pxa boards with sa1100-rtc do not work anymore. And of course no .config manipulation will fix this, because PXA architecture is denied the sa1100-rtc driver.
Ah, I didn't realize there is a mixture of use.
Quoted 8 lines
I could just do something like this instead of removing
sa1100_device_rtcregistration:#ifndef CONFIG_RTC_DRV_PXA &sa1100_device_rtc,#else
&pxa_device_rtc,
#endif
Quoted 7 lines
I ... don't like that much, especially when you consider both rtc might be modules for example. I rather like that patch in pxa as they are.
I'm rather in a mood for a more aggressive approach :
- you fire an incremental patch to patch the 10 defconfigs on PXA architecture (pxa27x and pxa3xx)
Here's the breakdown of configs which enable SA1100 RTC only. Only the last 6 need to change by my count:
pxa25xarch/arm/configs/h5000_defconfigarch/arm/configs/xcep_defconfigarch/arm/configs/viper_defconfig
pxa255/270arch/arm/configs/cm_x2xx_defconfig
pxa270arch/arm/configs/em_x270_defconfigarch/arm/configs/magician_defconfigarch/arm/configs/palmz72_defconfigarch/arm/configs/pcm027_defconfigarch/arm/configs/trizeps4_defconfig
Quoted 4 lines
- in this patch, you replace 's/CONFIG_RTC_DRV_SA1100/CONFIG_RTC_DRV_PXA/'
- you send this patch to the maintainers and me
- you explain in the commit message that from a userland perspective, nothing changes, except that the RTC IP will change, and any dependency on a
The IP does not change here. rtc0 is still going to be the SA1100 RTC being registered first. The only change will be the addition of rtc1.
Quoted 1 line
bootloader fidling with RTC should be considered as a source of regression.
I'm not sure that I follow.
Quoted 1 line
Moreover the first reboot will have the wrong date, until it is set.
Only for rtc1, right?
Rob
Robert Jarzmik
maintainerv4 cover SA1100/PXA RTC clean-up
Quoted 16 lines · Rob Herring
Quoted 4 lines
I'm rather in a mood for a more aggressive approach :
- you fire an incremental patch to patch the 10 defconfigs on PXA architecture (pxa27x and pxa3xx)
Here's the breakdown of configs which enable SA1100 RTC only. Only the last 6 need to change by my count:
pxa25x
arch/arm/configs/h5000_defconfigarch/arm/configs/xcep_defconfigarch/arm/configs/viper_defconfigpxa255/270
arch/arm/configs/cm_x2xx_defconfig
Quoted 6 lines
pxa270
arch/arm/configs/em_x270_defconfigarch/arm/configs/magician_defconfigarch/arm/configs/palmz72_defconfigarch/arm/configs/pcm027_defconfigarch/arm/configs/trizeps4_defconfig
And arch/arm/configs/jornada720_defconfig I counted wrongly as it's sa1100. So I agree with your list of last 6 defconfigs.
Quoted 7 lines
Quoted 4 lines
- in this patch, you replace 's/CONFIG_RTC_DRV_SA1100/CONFIG_RTC_DRV_PXA/'
- you send this patch to the maintainers and me
- you explain in the commit message that from a userland perspective, nothing changes, except that the RTC IP will change, and any dependency on aThe IP does not change here. rtc0 is still going to be the SA1100 RTC being registered first. The only change will be the addition of rtc1.
For boards which were only using rtc-pxa.c (as mioa701 for example), they relied on the fact that rtc0 == pxa_rtc. Their time is stored in PXA IP. Therefore, each of their hwclock will end up on sa1100-rtc instead of pxa-rtc.
So for these boards, ie. for all boards where only rtc-pxa.c was used, the IP addressed changes from a casual userspace perspective.
Quoted 3 lines
Quoted 1 line
bootloader fidling with RTC should be considered as a source of regression.
I'm not sure that I follow.
Let's talk about how a double boot windows + linux box works. The bootloader ensures that :
- sa1100-rtc holds the number of seconds since the OS start (think jiffies)
- pxa-rtc holds the wall clock time
Upon each reboot, sa1100-rtc is checked to see how much time has passed. If an "oustanding number" is detected, for example 10 years, the firmware resets the data partition.
Now think what will happen when this change will be commited, upon the first reboot after the linux kernel has change sa1100-rtc time.
Quoted 2 lines
Quoted 1 line
Moreover the first reboot will have the wrong date, until it is set.
Only for rtc1, right?
Yes, right, unless the bootloader logic is ... over-engineered.
All of this to say maintainers should be forwarned at least. After that, up to them to react.
Cheers.
Signature · 1 line
Robert
v4 cover SA1100/PXA RTC clean-up
Quoted 32 lines · Robert Jarzmik
Quoted 16 lines · Rob Herring
Quoted 4 lines
I'm rather in a mood for a more aggressive approach :
- you fire an incremental patch to patch the 10 defconfigs on PXA architecture (pxa27x and pxa3xx)
Here's the breakdown of configs which enable SA1100 RTC only. Only the last 6 need to change by my count:
pxa25x
arch/arm/configs/h5000_defconfigarch/arm/configs/xcep_defconfigarch/arm/configs/viper_defconfigpxa255/270
arch/arm/configs/cm_x2xx_defconfigQuoted 6 lines
pxa270
arch/arm/configs/em_x270_defconfigarch/arm/configs/magician_defconfigarch/arm/configs/palmz72_defconfigarch/arm/configs/pcm027_defconfigarch/arm/configs/trizeps4_defconfigAnd
arch/arm/configs/jornada720_defconfigI counted wrongly as it's sa1100. So I agree with your list of last 6 defconfigs.Quoted 5 lines
Quoted 4 lines
- in this patch, you replace 's/CONFIG_RTC_DRV_SA1100/CONFIG_RTC_DRV_PXA/'
- you send this patch to the maintainers and me
- you explain in the commit message that from a userland perspective, nothing changes, except that the RTC IP will change, and any dependency on a
Quoted 8 lines
Quoted 2 lines
The IP does not change here. rtc0 is still going to be the SA1100 RTC being registered first. The only change will be the addition of rtc1.
For boards which were only using
rtc-pxa.c(as mioa701 for example), they relied on the fact that rtc0 ==pxa_rtc. Their time is stored in PXA IP. Therefore, each of their hwclock will end up on sa1100-rtc instead of pxa-rtc.So for these boards, ie. for all boards where only
rtc-pxa.cwas used, the IP addressed changes from a casual userspace perspective.
Okay, so this is the case where the time will be wrong.
I could remove the select of the sa1100-rtc and do an empty function for sa1100_rtc_init. This would preserve current behavior.
Quoted 9 lines
Quoted 4 lines
Quoted 2 lines
bootloader fidling with RTC should be considered as a source of regression.
I'm not sure that I follow.
Let's talk about how a double boot windows + linux box works. The bootloader ensures that :
- sa1100-rtc holds the number of seconds since the OS start (think jiffies)
- pxa-rtc holds the wall clock time
Quoted 6 lines
Upon each reboot, sa1100-rtc is checked to see how much time has passed. If an "oustanding number" is detected, for example 10 years, the firmware resets the data partition.
Now think what will happen when this change will be commited, upon the first reboot after the linux kernel has change sa1100-rtc time.
That would be bad. But on these platforms, the kernel has been using both RTCs right? Presumably on platforms only using 1 of the RTCs, the bootloader does not touch the RTCs.
Rob
Quoted 12 lines
Quoted 3 lines
Quoted 2 lines
Moreover the first reboot will have the wrong date, until it is set.
Only for rtc1, right?
Yes, right, unless the bootloader logic is ... over-engineered.
All of this to say maintainers should be forwarned at least. After that, up to them to react.
Cheers.
--
Robert
Robert Jarzmik
maintainerv4 cover SA1100/PXA RTC clean-up
Quoted 9 lines · Rob Herring
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
- you explain in the commit message that from a userland perspective, nothing changes, except that the RTC IP will change, and any dependency on a
The IP does not change here. rtc0 is still going to be the SA1100 RTC being registered first. The only change will be the addition of rtc1.
For boards which were only using
rtc-pxa.c(as mioa701 for example), they relied on the fact that rtc0 ==pxa_rtc. Their time is stored in PXA IP. Therefore, each of their hwclock will end up on sa1100-rtc instead of pxa-rtc.
Quoted 7 lines
Quoted 2 lines
So for these boards, ie. for all boards where only
rtc-pxa.cwas used, the IP addressed changes from a casual userspace perspective.Okay, so this is the case where the time will be wrong.
I could remove the select of the sa1100-rtc and do an empty function for
sa1100_rtc_init. This would preserve current behavior.
Please don't. I only ask for a sentence in the commit message.
Quoted 12 lines
Quoted 12 lines
Quoted 3 lines
Quoted 1 line
bootloader fidling with RTC should be considered as a source of regression.
I'm not sure that I follow.
Let's talk about how a double boot windows + linux box works. The bootloader ensures that :
- sa1100-rtc holds the number of seconds since the OS start (think jiffies)
- pxa-rtc holds the wall clock timeUpon each reboot, sa1100-rtc is checked to see how much time has passed. If an "oustanding number" is detected, for example 10 years, the firmware resets the data partition.
Quoted 6 lines
Quoted 2 lines
Now think what will happen when this change will be commited, upon the first reboot after the linux kernel has change sa1100-rtc time.
That would be bad. But on these platforms, the kernel has been using both RTCs right? Presumably on platforms only using 1 of the RTCs, the bootloader does not touch the RTCs.
No, the kernel has been using only pxa-rtc. The sa1100-rtc is not used, and yet it accounts the passed time in it.
On platforms where all the OSes use only 1 RTC, the bootloader only touches one RTC, that's correct. Or said differently : the bootloader touches the union of all the RTCs the OSes it launches do touch.
Quoted 2 lines
Quoted 2 lines
All of this to say maintainers should be forwarned at least. After that, up to them to react.
Cheers.
Signature · 1 line
Robert
v4 cover SA1100/PXA RTC clean-up
Quoted 38 lines · Robert Jarzmik
Quoted 9 lines · Rob Herring
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
- you explain in the commit message that from a userland perspective, nothing changes, except that the RTC IP will change, and any dependency on a
The IP does not change here. rtc0 is still going to be the SA1100 RTC being registered first. The only change will be the addition of rtc1.
For boards which were only using
rtc-pxa.c(as mioa701 for example), they relied on the fact that rtc0 ==pxa_rtc. Their time is stored in PXA IP. Therefore, each of their hwclock will end up on sa1100-rtc instead of pxa-rtc.Quoted 7 lines
Quoted 2 lines
So for these boards, ie. for all boards where only
rtc-pxa.cwas used, the IP addressed changes from a casual userspace perspective.Okay, so this is the case where the time will be wrong.
I could remove the select of the sa1100-rtc and do an empty function for
sa1100_rtc_init. This would preserve current behavior.Please don't. I only ask for a sentence in the commit message.
Quoted 12 lines
Quoted 12 lines
Quoted 3 lines
Quoted 1 line
bootloader fidling with RTC should be considered as a source of regression.
I'm not sure that I follow.
Let's talk about how a double boot windows + linux box works. The bootloader ensures that :
- sa1100-rtc holds the number of seconds since the OS start (think jiffies)
- pxa-rtc holds the wall clock timeUpon each reboot, sa1100-rtc is checked to see how much time has passed. If an "oustanding number" is detected, for example 10 years, the firmware resets the data partition.
Quoted 6 lines
Quoted 2 lines
Now think what will happen when this change will be commited, upon the first reboot after the linux kernel has change sa1100-rtc time.
That would be bad. But on these platforms, the kernel has been using both RTCs right? Presumably on platforms only using 1 of the RTCs, the bootloader does not touch the RTCs.
Quoted 6 lines
No, the kernel has been using only pxa-rtc. The sa1100-rtc is not used, and yet it accounts the passed time in it.
On platforms where all the OSes use only 1 RTC, the bootloader only touches one RTC, that's correct. Or said differently : the bootloader touches the union of all the RTCs the OSes it launches do touch.
Sorry, I'm being dense here, but I'm not any less confused as to which scenarios you think have an issue. Rather than go around again on this, perhaps you can just provide the warning for the commit text. Here's what I have.
Rob
8<-------------------------------------------------------------------
Quoted 1 line
From
e43db14b27486faef8d8e74e4aa555aba7f31a0eMon Sep 17 00:00:00 2001
From: Rob Herring <[email protected]>
Date: Mon, 1 Jun 2015 07:53:01 -0500
Subject: [PATCH] ARM: config: Switch PXA27x platforms to use PXA RTC driver
With the SA1100 and PXA RTC drivers be mutually exclusive and no longer sharing hardware, PXA27x/PXA3xx platforms must use the PXA RTC driver as the SA1100 platform device is no longer registered.
This change should be transparent to userspace, but the first reboot after the switch will have the wrong time.
--- arch/arm/configs/cm_x2xx_defconfig | 2 +- arch/arm/configs/em_x270_defconfig | 2 +- arch/arm/configs/magician_defconfig | 2 +- arch/arm/configs/palmz72_defconfig | 2 +- arch/arm/configs/pcm027_defconfig | 2 +- arch/arm/configs/trizeps4_defconfig | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-)
arch/arm/configs/cm_x2xx_defconfig +1 -1
@@ -157,7 +157,7 @@ CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_V3020=y -CONFIG_RTC_DRV_SA1100=y +CONFIG_RTC_DRV_PXA=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y CONFIG_INOTIFY=y
arch/arm/configs/em_x270_defconfig +1 -1
@@ -157,7 +157,7 @@ CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_HEARTBEAT=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_V3020=y -CONFIG_RTC_DRV_SA1100=y +CONFIG_RTC_DRV_PXA=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y CONFIG_INOTIFY=y
arch/arm/configs/magician_defconfig +1 -1
@@ -150,7 +150,7 @@ CONFIG_LEDS_TRIGGERS=y CONFIG_LEDS_TRIGGER_BACKLIGHT=y CONFIG_RTC_CLASS=y CONFIG_RTC_DEBUG=y -CONFIG_RTC_DRV_SA1100=y +CONFIG_RTC_DRV_PXA=y CONFIG_EXT2_FS=y CONFIG_INOTIFY=y CONFIG_MSDOS_FS=m
arch/arm/configs/palmz72_defconfig +1 -1
@@ -67,7 +67,7 @@ CONFIG_MMC=y CONFIG_MMC_DEBUG=y CONFIG_MMC_PXA=y CONFIG_RTC_CLASS=y -CONFIG_RTC_DRV_SA1100=y +CONFIG_RTC_DRV_PXA=y CONFIG_EXT2_FS=y CONFIG_EXT3_FS=y # CONFIG_DNOTIFY is not set
arch/arm/configs/pcm027_defconfig +1 -1
@@ -82,7 +82,7 @@ CONFIG_MMC=y CONFIG_MMC_PXA=y CONFIG_RTC_CLASS=y CONFIG_RTC_DRV_PCF8563=m -CONFIG_RTC_DRV_SA1100=m +CONFIG_RTC_DRV_PXA=m CONFIG_EXT2_FS=m CONFIG_EXT3_FS=m # CONFIG_DNOTIFY is not set
arch/arm/configs/trizeps4_defconfig +1 -1
@@ -177,7 +177,7 @@ CONFIG_NEW_LEDS=y CONFIG_RTC_CLASS=y # CONFIG_RTC_HCTOSYS is not set CONFIG_RTC_DRV_PCF8583=m -CONFIG_RTC_DRV_SA1100=y +CONFIG_RTC_DRV_PXA=y CONFIG_EXT2_FS=y CONFIG_EXT2_FS_XATTR=y CONFIG_EXT2_FS_POSIX_ACL=y
Signature · 1 line
2.1.0
Robert Jarzmik
maintainerv4 cover SA1100/PXA RTC clean-up
Quoted 15 lines · Rob Herring
Quoted 3 lines
On platforms where all the OSes use only 1 RTC, the bootloader only touches one RTC, that's correct. Or said differently : the bootloader touches the union of all the RTCs the OSes it launches do touch.
Sorry, I'm being dense here, but I'm not any less confused as to which scenarios you think have an issue. Rather than go around again on this, perhaps you can just provide the warning for the commit text. Here's what I have.
8<------------------------------------------------------------------- From
e43db14b27486faef8d8e74e4aa555aba7f31a0eMon Sep 17 00:00:00 2001
From: Rob Herring <[email protected]>
Date: Mon, 1 Jun 2015 07:53:01 -0500
Subject: [PATCH] ARM: config: Switch PXA27x platforms to use PXA RTC driver
Quoted 6 lines
With the SA1100 and PXA RTC drivers be mutually exclusive and no longer sharing hardware, PXA27x/PXA3xx platforms must use the PXA RTC driver as the SA1100 platform device is no longer registered.
This change should be transparent to userspace, but the first reboot after the switch will have the wrong time.
I'll switch that last sentence to :
"This change should be almost transparent to userspace. Former users of pxa-rtc should be aware that 2 rtc will be available on their kernels, rtc0 being sa1100-rtc and rtc1 being pxa-rtc. Any userspace relying on the fact that rtc0 was pxa-rtc should be fixed.
As a consequence :
- the first reboot after the switch will have the wrong time,
- on dual boot platform where the other OS programs some logic into the sa1100 rtc IP, a lack of fix in userspace, ie. a kernel changing sa1100-rtc thinking it is pxa-rtc could have dire consequence, such as wiping the other OS data partition.
"
And add :
Cc: Mike Rapoport <[email protected]>
Cc: Philipp Zabel <[email protected]>
With that, I'll be happy. I'll throw this serie at my jenkins, but there's no reason for it to complain, and unless I've forgotten some unaddressed comment, you'll have my ack within the next couple of days.
Cheers.
--
Robert