timer drivers for 5.6
Subsystems (9)
The following changes since commit 9e0333ae38eeb42249e10f95d209244a6e22ac9f:
clocksource/drivers/hyper-v: Set TSC clocksource as default w/
InvariantTSC (2020-01-16 19:09:02 +0100)
are available in the Git repository at:
https://git.linaro.org/people/daniel.lezcano/linux.git
tags/timers-v5.5-rc6
for you to fetch changes up to 9e0333ae38eeb42249e10f95d209244a6e22ac9f:
clocksource/drivers/hyper-v: Set TSC clocksource as default w/
InvariantTSC (2020-01-16 19:09:02 +0100)
----------------------------------------------------------------
- Add suspend/resume for Hyper-V clocksource (Dexuan Cui)
- Fix Kconfig indentation (Krzysztof Kozlowski)
- Add SoC specific bindings for RZ/G2N (r8a774b1) (Biju Das)
- Add Microchip PIT64B support (Claudiu Beznea)
- Convert the cadence ttc driver to a platform driver to initialize later (Rajan Vaja)
- Fix a memory leak when the initialization fails on bcm2835 (Colin Ian King)
- Use the combo devm_platform_ioremap_resource() function for em-sti, ti-dm and switch to platform_get_irq (Yangtao Li)
- Fix Exynos naming in the driver (Krzysztof Kozlowski)
- Fix an uninitialized pointer access in ti-dm timer (Tony Lindgren)
- Fix a sparse warning in microchip-pit64b (Claudiu Beznea)
- Code reorg without functional changes for Hyper-V clocksource (Andrea Parri)
- Decrease the Hyper-V clocksource rating in order to let the stable TSC to be selected instead (Andrea Parri)
----------------------------------------------------------------
Signature · 5 lines
<http://www.linaro.org/> Linaro.org │ Open source software for ARM SoCs Follow Linaro: <http://www.facebook.com/pages/Linaro> Facebook | <http://twitter.com/#!/linaroorg> Twitter | <http://www.linaro.org/linaro-blog/> Blog
PATCH 1/17 clocksource/drivers/hyper-v: Suspend/resume Hyper-V clocksource for hibernation
From: Dexuan Cui <[email protected]>
This is needed for hibernation, e.g. when we resume the old kernel, we need to disable the "current" kernel's TSC page and then resume the old kernel's.
--- drivers/clocksource/hyperv_timer.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
drivers/clocksource/hyperv_timer.c +25 -0
@@ -330,12 +330,37 @@ static u64 read_hv_sched_clock_tsc(void)return read_hv_clock_tsc (NULL ) - hv_sched_clock_offset; } +static void suspend_hv_clock_tsc (struct clocksource *arg) +{ +u64 tsc_msr; + +/* Disable the TSC page */ +hv_get_reference_tsc (tsc_msr); + tsc_msr &= ~BIT_ULL (0 ); +hv_set_reference_tsc (tsc_msr); +} + + +static void resume_hv_clock_tsc (struct clocksource *arg) +{ +phys_addr_t phys_addr =virt_to_phys (&tsc_pg); +u64 tsc_msr; + +/* Re-enable the TSC page */ +hv_get_reference_tsc (tsc_msr); + tsc_msr &=GENMASK_ULL (11 ,0 ); + tsc_msr |=BIT_ULL (0 ) | (u64 )phys_addr; +hv_set_reference_tsc (tsc_msr); +} +static struct clocksource hyperv_cs_tsc = { .name ="hyperv_clocksource_tsc_page" , .rating =400 , .read = read_hv_clock_tsc, .mask =CLOCKSOURCE_MASK (64 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS , + .suspend= suspend_hv_clock_tsc, + .resume = resume_hv_clock_tsc, }; static u64 notrace read_hv_clock_msr(struct clocksource *arg)
Signature · 1 line
2.17.1
PATCH 2/17 clocksource: Fix Kconfig indentation
From: Krzysztof Kozlowski <[email protected]>
Adjust indentation from spaces to tab (+optional two spaces) as in coding style with command like:
$ sed -e 's/^ /\t/' -i */Kconfig
--- drivers/clocksource/Kconfig | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
drivers/clocksource/Kconfig +10 -10
@@ -470,7 +470,7 @@ config OXNAS_RPS_TIMER This enables support for the Oxford Semiconductor OXNAS RPS timers. config SYS_SUPPORTS_SH_CMT - bool + bool config MTK_TIMER bool "Mediatek timer driver" if COMPILE_TEST
@@ -490,13 +490,13 @@ config SPRD_TIMER Enables support for the Spreadtrum timer driver. config SYS_SUPPORTS_SH_MTU2 - bool + bool config SYS_SUPPORTS_SH_TMU - bool + bool config SYS_SUPPORTS_EM_STI - bool + bool config CLKSRC_JCORE_PIT bool "J-Core PIT timer driver" if COMPILE_TEST
@@ -591,21 +591,21 @@ config CLKSRC_PXA platforms. config H8300_TMR8 - bool "Clockevent timer for the H8300 platform" if COMPILE_TEST - depends on HAS_IOMEM + bool "Clockevent timer for the H8300 platform" if COMPILE_TEST + depends on HAS_IOMEM help This enables the 8 bits timer for the H8300 platform. config H8300_TMR16 - bool "Clockevent timer for the H83069 platform" if COMPILE_TEST - depends on HAS_IOMEM + bool "Clockevent timer for the H83069 platform" if COMPILE_TEST + depends on HAS_IOMEM help This enables the 16 bits timer for the H8300 platform with the H83069 cpu. config H8300_TPU - bool "Clocksource for the H8300 platform" if COMPILE_TEST - depends on HAS_IOMEM + bool "Clocksource for the H8300 platform" if COMPILE_TEST + depends on HAS_IOMEM help This enables the clocksource for the H8300 platform with the H8S2678 cpu.
Signature · 1 line
2.17.1
PATCH 3/17 dt-bindings: timer: renesas, cmt: Document r8a774b1 CMT support
In reply to Daniel LezcanoFrom: Biju Das <[email protected]>
Document SoC specific bindings for RZ/G2N (r8a774b1) SoC.
--- Documentation/devicetree/bindings/timer/renesas,cmt.txt | 2 ++ 1 file changed, 2 insertions(+)
Documentation/devicetree/bindings/timer/renesas,cmt.txt +2 -0
@@ -29,6 +29,8 @@ Required Properties: - "renesas,r8a77470-cmt1" for the 48-bit CMT1 device included in r8a77470. - "renesas,r8a774a1-cmt0" for the 32-bit CMT0 device included in r8a774a1. - "renesas,r8a774a1-cmt1" for the 48-bit CMT devices included in r8a774a1. + - "renesas,r8a774b1-cmt0" for the 32-bit CMT0 device included in r8a774b1. + - "renesas,r8a774b1-cmt1" for the 48-bit CMT devices included in r8a774b1. - "renesas,r8a774c0-cmt0" for the 32-bit CMT0 device included in r8a774c0. - "renesas,r8a774c0-cmt1" for the 48-bit CMT devices included in r8a774c0. - "renesas,r8a7790-cmt0" for the 32-bit CMT0 device included in r8a7790.
Signature · 1 line
2.17.1
PATCH 4/17 clocksource: Fix Kconfig miscues
In reply to Daniel LezcanoFrom: Randy Dunlap <[email protected]>
Fix lots of typo, spelling, punctuation, and grammar miscues in drivers/clocksource/Kconfig.
--- drivers/clocksource/Kconfig | 46 ++++++++++++++++++------------------- 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/clocksource/Kconfig +23 -23
@@ -88,7 +88,7 @@ config ROCKCHIP_TIMER select TIMER_OF select CLKSRC_MMIO help - Enables the support for the rockchip timer driver. + Enables the support for the Rockchip timer driver. config ARMADA_370_XP_TIMER bool "Armada 370 and XP timer driver" if COMPILE_TEST
@@ -162,13 +162,13 @@ config NPCM7XX_TIMER select CLKSRC_MMIO help Enable 24-bit TIMER0 and TIMER1 counters in the NPCM7xx architecture, - While TIMER0 serves as clockevent and TIMER1 serves as clocksource. + where TIMER0 serves as clockevent and TIMER1 serves as clocksource. config CADENCE_TTC_TIMER bool "Cadence TTC timer driver" if COMPILE_TEST depends on COMMON_CLK help - Enables support for the cadence ttc driver. + Enables support for the Cadence TTC driver. config ASM9260_TIMER bool "ASM9260 timer driver" if COMPILE_TEST
@@ -190,10 +190,10 @@ config CLKSRC_DBX500_PRCMU bool "Clocksource PRCMU Timer" if COMPILE_TEST depends on HAS_IOMEM help - Use the always on PRCMU Timer as clocksource + Use the always on PRCMU Timer as clocksource. config CLPS711X_TIMER - bool "Cirrus logic timer driver" if COMPILE_TEST + bool "Cirrus Logic timer driver" if COMPILE_TEST select CLKSRC_MMIO help Enables support for the Cirrus Logic PS711 timer.
@@ -205,11 +205,11 @@ config ATLAS7_TIMER Enables support for the Atlas7 timer. config MXS_TIMER - bool "Mxs timer driver" if COMPILE_TEST + bool "MXS timer driver" if COMPILE_TEST select CLKSRC_MMIO select STMP_DEVICE help - Enables support for the Mxs timer. + Enables support for the MXS timer. config PRIMA2_TIMER bool "Prima2 timer driver" if COMPILE_TEST
@@ -238,10 +238,10 @@ config KEYSTONE_TIMER Enables support for the Keystone timer. config INTEGRATOR_AP_TIMER - bool "Integrator-ap timer driver" if COMPILE_TEST + bool "Integrator-AP timer driver" if COMPILE_TEST select CLKSRC_MMIO help - Enables support for the Integrator-ap timer. + Enables support for the Integrator-AP timer. config CLKSRC_EFM32 bool "Clocksource for Energy Micro's EFM32 SoCs" if !ARCH_EFM32
@@ -283,8 +283,8 @@ config CLKSRC_NPS select TIMER_OF if OF help NPS400 clocksource support. - Got 64 bit counter with update rate up to 1000MHz. - This counter is accessed via couple of 32 bit memory mapped registers. + It has a 64-bit counter with update rate up to 1000MHz. + This counter is accessed via couple of 32-bit memory-mapped registers. config CLKSRC_STM32 bool "Clocksource for STM32 SoCs" if !ARCH_STM32
@@ -305,14 +305,14 @@ config ARC_TIMERS help These are legacy 32-bit TIMER0 and TIMER1 counters found on all ARC cores (ARC700 as well as ARC HS38). - TIMER0 serves as clockevent while TIMER1 provides clocksource + TIMER0 serves as clockevent while TIMER1 provides clocksource. config ARC_TIMERS_64BIT bool "Support for 64-bit counters in ARC HS38 cores" if COMPILE_TEST depends on ARC_TIMERS select TIMER_OF help - This enables 2 different 64-bit timers: RTC (for UP) and GFRC (for SMP) + This enables 2 different 64-bit timers: RTC (for UP) and GFRC (for SMP). RTC is implemented inside the core, while GFRC sits outside the core in ARConnect IP block. Driver automatically picks one of them for clocksource as appropriate.
@@ -390,7 +390,7 @@ config ARM_GLOBAL_TIMER select TIMER_OF if OF depends on ARM help - This options enables support for the ARM global timer unit + This option enables support for the ARM global timer unit. config ARM_TIMER_SP804 bool "Support for Dual Timer SP804 module" if COMPILE_TEST
@@ -403,14 +403,14 @@ config CLKSRC_ARM_GLOBAL_TIMER_SCHED_CLOCK depends on ARM_GLOBAL_TIMER default y help - Use ARM global timer clock source as sched_clock + Use ARM global timer clock source as sched_clock. config ARMV7M_SYSTICK bool "Support for the ARMv7M system time" if COMPILE_TEST select TIMER_OF if OF select CLKSRC_MMIO help - This options enables support for the ARMv7M system timer unit + This option enables support for the ARMv7M system timer unit. config ATMEL_PIT bool "Atmel PIT support" if COMPILE_TEST
@@ -460,7 +460,7 @@ config VF_PIT_TIMER bool select CLKSRC_MMIO help - Support for Period Interrupt Timer on Freescale Vybrid Family SoCs. + Support for Periodic Interrupt Timer on Freescale Vybrid Family SoCs. config OXNAS_RPS_TIMER bool "Oxford Semiconductor OXNAS RPS Timers driver" if COMPILE_TEST
@@ -523,7 +523,7 @@ config SH_TIMER_MTU2 help This enables build of a clockevent driver for the Multi-Function Timer Pulse Unit 2 (MTU2) hardware available on SoCs from Renesas. - This hardware comes with 16 bit-timer registers. + This hardware comes with 16-bit timer registers. config RENESAS_OSTM bool "Renesas OSTM timer driver" if COMPILE_TEST
@@ -580,7 +580,7 @@ config CLKSRC_TANGO_XTAL select TIMER_OF select CLKSRC_MMIO help - This enables the clocksource for Tango SoC + This enables the clocksource for Tango SoC. config CLKSRC_PXA bool "Clocksource for PXA or SA-11x0 platform" if COMPILE_TEST
@@ -601,14 +601,14 @@ config H8300_TMR16 depends on HAS_IOMEM help This enables the 16 bits timer for the H8300 platform with the - H83069 cpu. + H83069 CPU. config H8300_TPU bool "Clocksource for the H8300 platform" if COMPILE_TEST depends on HAS_IOMEM help This enables the clocksource for the H8300 platform with the - H8S2678 cpu. + H8S2678 CPU. config CLKSRC_IMX_GPT bool "Clocksource using i.MX GPT" if COMPILE_TEST
@@ -666,8 +666,8 @@ config CSKY_MP_TIMER help Say yes here to enable C-SKY SMP timer driver used for C-SKY SMP system. - csky,mptimer is not only used in SMP system, it also could be used - single core system. It's not a mmio reg and it use mtcr/mfcr instruction. + csky,mptimer is not only used in SMP system, it also could be used in + single core system. It's not a mmio reg and it uses mtcr/mfcr instruction. config GX6605S_TIMER bool "Gx6605s SOC system timer driver" if COMPILE_TEST
Signature · 1 line
2.17.1
PATCH 5/17 clocksource/drivers/hyper-v: Reserve PAGE_SIZE space for tsc page
In reply to Daniel LezcanoFrom: Boqun Feng <[email protected]>
Currently, the reserved size for a tsc page is 4K, which is enough for communicating with hypervisor. However, in the case where we want to export the tsc page to userspace (e.g. for vDSO to read the clocksource), the tsc page should be at least PAGE_SIZE, otherwise, when PAGE_SIZE is larger than 4K, extra kernel data will be mapped into userspace, which means leaking kernel information.
Therefore reserve PAGE_SIZE space for tsc_pg as a preparation for the vDSO support of ARM64 in the future. Also, while at it, replace all reference to tsc_pg with hv_get_tsc_page() since it should be the only interface to access tsc page.
--- drivers/clocksource/hyperv_timer.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-)
drivers/clocksource/hyperv_timer.c +7 -4
@@ -307,17 +307,20 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);struct clocksource *hyperv_cs;EXPORT_SYMBOL_GPL (hyperv_cs); -static struct ms_hyperv_tsc_page tsc_pg__aligned(PAGE_SIZE) ; +static union { +struct ms_hyperv_tsc_page page; +u8 reserved[PAGE_SIZE ]; +} tsc_pg__aligned(PAGE_SIZE) ;struct ms_hyperv_tsc_page *hv_get_tsc_page (void ) { -return &tsc_pg; +return &tsc_pg.page; }EXPORT_SYMBOL_GPL (hv_get_tsc_page); static u64 notrace read_hv_clock_tsc(struct clocksource *arg) { -u64 current_tick =hv_read_tsc_page (&tsc_pg); +u64 current_tick =hv_read_tsc_page (hv_get_tsc_page ());if (current_tick ==U64_MAX )hv_get_time_ref_count (current_tick);
@@ -397,7 +400,7 @@ static bool __init hv_init_tsc_clocksource(void)return false; hyperv_cs = &hyperv_cs_tsc; - phys_addr =virt_to_phys (&tsc_pg); + phys_addr =virt_to_phys (hv_get_tsc_page ());/* * The Hyper-V TLFS specifies to preserve the value of reserved
Signature · 1 line
2.17.1
PATCH 6/17 clocksource/drivers/timer-microchip-pit64b: Add Microchip PIT64B support
In reply to Daniel LezcanoFrom: Claudiu Beznea <[email protected]>
Add driver for Microchip PIT64B timer. Timer could be used in continuous mode or oneshot mode. The hardware has 2x32 bit registers for period emulating a 64 bit timer. The LSB_PR and MSB_PR registers are used to set the period value (compare value). TLSB and TMSB keeps the current value of the counter. After a compare the TLSB and TMSB register resets. The driver uses PIT64B timer for clocksource or clockevent. First requested timer would be registered as clockevent, second one would be registered as clocksource. Individual PIT64B hardware resources were used for clocksource and clockevent to be able to support high resolution timers with this hardware implementation.
--- .../devicetree/bindings/arm/atmel-sysregs.txt | 6 + drivers/clocksource/Kconfig | 10 + drivers/clocksource/Makefile | 1 + drivers/clocksource/timer-microchip-pit64b.c | 449 ++++++++++++++++++ 4 files changed, 466 insertions(+) create mode 100644 drivers/clocksource/timer-microchip-pit64b.c
Documentation/devicetree/bindings/arm/atmel-sysregs.txt +6 -0
@@ -10,6 +10,12 @@ PIT Timer required properties: - interrupts: Should contain interrupt for the PIT which is the IRQ line shared across all System Controller members. +PIT64B Timer required properties: +- compatible: Should be "microchip,sam9x60-pit64b" +- reg: Should contain registers location and length +- interrupts: Should contain interrupt for PIT64B timer +- clocks: Should contain the available clock sources for PIT64B timer. + System Timer (ST) required properties: - compatible: Should be "atmel,at91rm9200-st", "syscon", "simple-mfd" - reg: Should contain registers location and length
drivers/clocksource/Kconfig +10 -0
@@ -697,4 +697,14 @@ config INGENIC_TIMER help Support for the timer/counter unit of the Ingenic JZ SoCs. +config MICROCHIP_PIT64B + bool "Microchip PIT64B support" + depends on OF || COMPILE_TEST + select CLKSRC_MMIO + help + This option enables Microchip PIT64B timer for Atmel + based system. It supports the oneshot, the periodic + modes and high resolution. It is used as a clocksource + and a clockevent. + endmenu
drivers/clocksource/Makefile +1 -0
@@ -88,3 +88,4 @@ obj-$(CONFIG_RISCV_TIMER) += timer-riscv.o obj-$(CONFIG_CSKY_MP_TIMER) += timer-mp-csky.o obj-$(CONFIG_GX6605S_TIMER) += timer-gx6605s.o obj-$(CONFIG_HYPERV_TIMER) += hyperv_timer.o +obj-$(CONFIG_MICROCHIP_PIT64B) += timer-microchip-pit64b.o
drivers/clocksource/timer-microchip-pit64b.c new file +449 -0
449 lines not on this page · raw message
Signature · 1 line
2.17.1
PATCH 7/17 clocksource/drivers/cadence-ttc: Use ttc driver as platform driver
In reply to Daniel LezcanoFrom: Rajan Vaja <[email protected]>
Currently TTC driver is TIMER_OF_DECLARE type driver. Because of that, TTC driver may be initialized before other clock drivers. If TTC driver is dependent on that clock driver then initialization of TTC driver will failed.
So use TTC driver as platform driver instead of using TIMER_OF_DECLARE.
--- drivers/clocksource/timer-cadence-ttc.c | 26 +++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-)
drivers/clocksource/timer-cadence-ttc.c +18 -8
@@ -15,6 +15,8 @@#include <linux/of_irq.h> #include <linux/slab.h> #include <linux/sched_clock.h> +#include <linux/module.h> +#include <linux/of_platform.h> /* * This driver configures the 2 16/32-bit count-up timers as follows:
@@ -464,13 +466,7 @@ static int __init ttc_setup_clockevent(struct clk *clk,return 0 ; } -/** -* ttc_timer_init - Initialize the timer -* -* Initializes the timer hardware and register the clock source and clock event -* timers with Linux kernal timer framework -*/ -static int __init ttc_timer_init (struct device_node *timer) +static int __init ttc_timer_probe (struct platform_device *pdev) {unsigned int irq;void __iomem *timer_baseaddr;
@@ -478,6 +474,7 @@ static int __init ttc_timer_init(struct device_node *timer)static int initialized;int clksel, ret;u32 timer_width =16 ; +struct device_node *timer = pdev->dev.of_node;if (initialized)return 0 ;
@@ -532,4 +529,17 @@ static int __init ttc_timer_init(struct device_node *timer)return 0 ; } -TIMER_OF_DECLARE (ttc,"cdns,ttc" , ttc_timer_init); +static const struct of_device_id ttc_timer_of_match[] = { + {.compatible ="cdns,ttc" }, + {}, +}; + +MODULE_DEVICE_TABLE (of, ttc_timer_of_match); + +static struct platform_driver ttc_timer_driver = { + .driver = { + .name ="cdns_ttc_timer" , + .of_match_table = ttc_timer_of_match, + }, +}; +builtin_platform_driver_probe (ttc_timer_driver, ttc_timer_probe);
Signature · 1 line
2.17.1
PATCH 8/17 clocksource/drivers/bcm2835_timer: Fix memory leak of timer
In reply to Daniel LezcanoFrom: Colin Ian King <[email protected]>
Currently when setup_irq fails the error exit path will leak the recently allocated timer structure. Originally the code would throw a panic but a later commit changed the behaviour to return via the err_iounmap path and hence we now have a memory leak. Fix this by adding a err_timer_free error path that kfree's timer.
Addresses-Coverity: ("Resource Leak")
--- drivers/clocksource/bcm2835_timer.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/clocksource/bcm2835_timer.c +4 -1
@@ -121,7 +121,7 @@ static int __init bcm2835_timer_init(struct device_node *node) ret =setup_irq (irq, &timer->act);if (ret) {pr_err ("Can't set up timer IRQ\n" ); - goto err_iounmap; + goto err_timer_free; }clockevents_config_and_register (&timer->evt, freq,0xf ,0xffffffff );
@@ -130,6 +130,9 @@ static int __init bcm2835_timer_init(struct device_node *node)return 0 ; +err_timer_free: +kfree (timer); + err_iounmap:iounmap (base);return ret;
Signature · 1 line
2.17.1
PATCH 9/17 clocksource/drivers/em_sti: Convert to devm_platform_ioremap_resource
In reply to Daniel LezcanoFrom: Yangtao Li <[email protected]>
Use devm_platform_ioremap_resource() to simplify code, which wraps 'platform_get_resource' and 'devm_ioremap_resource' in a single helper.
--- drivers/clocksource/em_sti.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/clocksource/em_sti.c +1 -3
@@ -279,7 +279,6 @@ static void em_sti_register_clockevent(struct em_sti_priv *p)static int em_sti_probe (struct platform_device *pdev) {struct em_sti_priv *p; -struct resource *res;int irq;int ret;
@@ -295,8 +294,7 @@ static int em_sti_probe(struct platform_device *pdev)return irq;/* map memory, let base point to the STI instance */ - res =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); - p->base =devm_ioremap_resource (&pdev->dev, res); + p->base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (p->base))return PTR_ERR (p->base);
Signature · 1 line
2.17.1
PATCH 10/17 clocksource/drivers/em_sti: Fix variable declaration in em_sti_probe
In reply to Daniel LezcanoFrom: Yangtao Li <[email protected]>
'irq' and 'ret' are variables of the same type and there is no need to use two lines.
--- drivers/clocksource/em_sti.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
drivers/clocksource/em_sti.c +1 -2
@@ -279,8 +279,7 @@ static void em_sti_register_clockevent(struct em_sti_priv *p)static int em_sti_probe (struct platform_device *pdev) {struct em_sti_priv *p; -int irq; -int ret; +int irq, ret; p =devm_kzalloc (&pdev->dev,sizeof (*p),GFP_KERNEL );if (p ==NULL )
Signature · 1 line
2.17.1
PATCH 11/17 clocksource/drivers/timer-ti-dm: Convert to devm_platform_ioremap_resource
In reply to Daniel LezcanoFrom: Yangtao Li <[email protected]>
Use devm_platform_ioremap_resource() to simplify code, which wraps 'platform_get_resource' and 'devm_ioremap_resource' in a single helper.
--- drivers/clocksource/timer-ti-dm.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-)
drivers/clocksource/timer-ti-dm.c +2 -8
@@ -780,7 +780,7 @@ static int omap_dm_timer_probe(struct platform_device *pdev) {unsigned long flags;struct omap_dm_timer *timer; -struct resource *mem, *irq; +struct resource *irq;struct device *dev = &pdev->dev;const struct dmtimer_platform_data *pdata;int ret;
@@ -802,18 +802,12 @@ static int omap_dm_timer_probe(struct platform_device *pdev)return -ENODEV ; } - mem =platform_get_resource (pdev,IORESOURCE_MEM ,0 ); -if (unlikely (!mem)) { -dev_err (dev,"%s: no memory resource.\n" , __func__); -return -ENODEV ; - } - timer =devm_kzalloc (dev,sizeof (*timer),GFP_KERNEL );if (!timer)return -ENOMEM ; timer->fclk =ERR_PTR (-ENODEV ); - timer->io_base =devm_ioremap_resource (dev, mem); + timer->io_base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (timer->io_base))return PTR_ERR (timer->io_base);
Signature · 1 line
2.17.1
PATCH 12/17 clocksource/drivers/timer-ti-dm: Switch to platform_get_irq
In reply to Daniel LezcanoFrom: Yangtao Li <[email protected]>
platform_get_resource(pdev, IORESOURCE_IRQ) is not recommended for requesting IRQ's resources, as they can be not ready yet. Using platform_get_irq() instead is preferred for getting IRQ even if it was not retrieved earlier.
--- drivers/clocksource/timer-ti-dm.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-)
drivers/clocksource/timer-ti-dm.c +3 -7
@@ -780,7 +780,6 @@ static int omap_dm_timer_probe(struct platform_device *pdev) {unsigned long flags;struct omap_dm_timer *timer; -struct resource *irq;struct device *dev = &pdev->dev;const struct dmtimer_platform_data *pdata;int ret;
@@ -796,11 +795,9 @@ static int omap_dm_timer_probe(struct platform_device *pdev)return -ENODEV ; } - irq =platform_get_resource (pdev,IORESOURCE_IRQ ,0 ); -if (unlikely (!irq)) { -dev_err (dev,"%s: no IRQ resource.\n" , __func__); -return -ENODEV ; - } + timer->irq =platform_get_irq (pdev,0 ); +if (timer->irq <0 ) +return timer->irq; timer =devm_kzalloc (dev,sizeof (*timer),GFP_KERNEL );if (!timer)
@@ -830,7 +827,6 @@ static int omap_dm_timer_probe(struct platform_device *pdev)if (pdata) timer->errata = pdata->timer_errata; - timer->irq = irq->start; timer->pdev = pdev;pm_runtime_enable (dev);
Signature · 1 line
2.17.1
PATCH 13/17 clocksource/drivers/timer-ti-dm: Fix uninitialized pointer access
In reply to Daniel LezcanoFrom: Tony Lindgren <[email protected]>
Clean-up commit 8c82723414d5 ("clocksource/drivers/timer-ti-dm: Switch to platform_get_irq") caused a regression where we now try to access uninitialized data for timer:
drivers/clocksource/timer-ti-dm.c: In function 'omap_dm_timer_probe':drivers/clocksource/timer-ti-dm.c:798:13: warning: 'timer' may be used uninitialized in this function [-Wmaybe-uninitialized]
On boot we now get:
Unable to handle kernel NULL pointer dereference at virtual address
00000004
...
(omap_dm_timer_probe) from [<c061ac7c>] (platform_drv_probe+0x48/0x98) (platform_drv_probe) from [<c0618c04>] (really_probe+0x1dc/0x348) (really_probe) from [<c0618ef4>] (driver_probe_device+0x5c/0x160)
Let's fix the issue by moving platform_get_irq to happen after timer has been allocated.
--- drivers/clocksource/timer-ti-dm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-)
drivers/clocksource/timer-ti-dm.c +4 -4
@@ -795,14 +795,14 @@ static int omap_dm_timer_probe(struct platform_device *pdev)return -ENODEV ; } - timer->irq =platform_get_irq (pdev,0 ); -if (timer->irq <0 ) -return timer->irq; - timer =devm_kzalloc (dev,sizeof (*timer),GFP_KERNEL );if (!timer)return -ENOMEM ; + timer->irq =platform_get_irq (pdev,0 ); +if (timer->irq <0 ) +return timer->irq; + timer->fclk =ERR_PTR (-ENODEV ); timer->io_base =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (timer->io_base))
Signature · 1 line
2.17.1
PATCH 14/17 clocksource/drivers/exynos_mct: Rename Exynos to lowercase
In reply to Daniel LezcanoFrom: Krzysztof Kozlowski <[email protected]>
Fix up inconsistent usage of upper and lowercase letters in "Exynos" name.
"EXYNOS" is not an abbreviation but a regular trademarked name. Therefore it should be written with lowercase letters starting with capital letter.
The lowercase "Exynos" name is promoted by its manufacturer Samsung Electronics Co., Ltd., in advertisement materials and on website.
--- drivers/clocksource/exynos_mct.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clocksource/exynos_mct.c +1 -1
@@ -4,7 +4,7 @@* Copyright (c) 2011 Samsung Electronics Co., Ltd. * http://www.samsung.com * -* EXYNOS4 MCT(Multi-Core Timer) support +* Exynos4 MCT(Multi-Core Timer) support */ #include <linux/interrupt.h>
Signature · 1 line
2.17.1
PATCH 15/17 clocksource/drivers/timer-microchip-pit64b: Fix sparse warning
In reply to Daniel LezcanoFrom: Claudiu Beznea <[email protected]>
Fix sparse warning:
"warning: Using plain integer as NULL pointer"
--- drivers/clocksource/timer-microchip-pit64b.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clocksource/timer-microchip-pit64b.c +3 -1
@@ -248,6 +248,8 @@ static int __init mchp_pit64b_init_mode(struct mchp_pit64b_timer *timer,if (!pclk_rate)return -EINVAL ; + timer->mode =0 ; +/* Try using GCLK. */ gclk_round =clk_round_rate (timer->gclk, max_rate);if (gclk_round <0 )
@@ -360,7 +362,7 @@ static int __init mchp_pit64b_dt_init_timer(struct device_node *node, bool clkevt) {u32 freq = clkevt ?MCHP_PIT64B_DEF_CE_FREQ :MCHP_PIT64B_DEF_CS_FREQ ; -struct mchp_pit64b_timer timer = {0 }; +struct mchp_pit64b_timer timer;unsigned long clk_rate;u32 irq =0 ;int ret;
Signature · 1 line
2.17.1
PATCH 16/17 clocksource/drivers/hyper-v: Untangle stimers and timesync from clocksources
In reply to Daniel LezcanoFrom: Andrea Parri <[email protected]>
hyperv_timer.c exports hyperv_cs, which is used by stimers and the timesync mechanism. However, the clocksource dependency is not
needed: these mechanisms only depend on the partition reference counter (which can be read via a MSR or via the TSC Reference Page).
Introduce the (function) pointer hv_read_reference_counter, as an embodiment of the partition reference counter read, and export it in place of the hyperv_cs pointer. The latter can be removed.
This should clarify that there's no relationship between Hyper-V stimers & timesync and the Linux clocksource abstractions. No functional or semantic change.
--- drivers/clocksource/hyperv_timer.c | 36 +++++++++++++++++++----------- drivers/hv/hv_util.c | 8 +++---- include/clocksource/hyperv_timer.h | 2 +- 3 files changed, 28 insertions(+), 18 deletions(-)
drivers/clocksource/hyperv_timer.c +23 -13
@@ -66,7 +66,7 @@ static int hv_ce_set_next_event(unsigned long delta, {u64 current_tick; - current_tick = hyperv_cs->read (NULL ); + current_tick =hv_read_reference_counter (); current_tick += delta;hv_init_timer (0 , current_tick);return 0 ;
@@ -304,8 +304,8 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);* Hyper-V and 32-bit x86. The TSC reference page version is preferred. */ -struct clocksource *hyperv_cs; -EXPORT_SYMBOL_GPL (hyperv_cs); +u64 (*hv_read_reference_counter)(void); +EXPORT_SYMBOL_GPL (hv_read_reference_counter); static union { struct ms_hyperv_tsc_page page;
@@ -318,7 +318,7 @@ struct ms_hyperv_tsc_page *hv_get_tsc_page(void) }EXPORT_SYMBOL_GPL (hv_get_tsc_page); -static u64 notrace read_hv_clock_tsc(struct clocksource *arg) +static u64 notrace read_hv_clock_tsc(void) {u64 current_tick =hv_read_tsc_page (hv_get_tsc_page ());
@@ -328,9 +328,14 @@ static u64 notrace read_hv_clock_tsc(struct clocksource *arg)return current_tick; } +static u64 notrace read_hv_clock_tsc_cs(struct clocksource *arg) +{ +return read_hv_clock_tsc (); +} +static u64 read_hv_sched_clock_tsc (void ) { -return read_hv_clock_tsc (NULL ) - hv_sched_clock_offset; +return read_hv_clock_tsc () - hv_sched_clock_offset; }static void suspend_hv_clock_tsc (struct clocksource *arg)
@@ -359,14 +364,14 @@ static void resume_hv_clock_tsc(struct clocksource *arg)static struct clocksource hyperv_cs_tsc = { .name ="hyperv_clocksource_tsc_page" , .rating =400 , - .read = read_hv_clock_tsc, + .read = read_hv_clock_tsc_cs, .mask =CLOCKSOURCE_MASK (64 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS , .suspend= suspend_hv_clock_tsc, .resume = resume_hv_clock_tsc, }; -static u64 notrace read_hv_clock_msr(struct clocksource *arg) +static u64 notrace read_hv_clock_msr(void) {u64 current_tick;/*
@@ -378,15 +383,20 @@ static u64 notrace read_hv_clock_msr(struct clocksource *arg)return current_tick; } +static u64 notrace read_hv_clock_msr_cs(struct clocksource *arg) +{ +return read_hv_clock_msr (); +} +static u64 read_hv_sched_clock_msr (void ) { -return read_hv_clock_msr (NULL ) - hv_sched_clock_offset; +return read_hv_clock_msr () - hv_sched_clock_offset; }static struct clocksource hyperv_cs_msr = { .name ="hyperv_clocksource_msr" , .rating =400 , - .read = read_hv_clock_msr, + .read = read_hv_clock_msr_cs, .mask =CLOCKSOURCE_MASK (64 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS , };
@@ -399,7 +409,7 @@ static bool __init hv_init_tsc_clocksource(void)if (!(ms_hyperv.features &HV_MSR_REFERENCE_TSC_AVAILABLE ))return false; - hyperv_cs = &hyperv_cs_tsc; + hv_read_reference_counter = read_hv_clock_tsc; phys_addr =virt_to_phys (hv_get_tsc_page ());/*
@@ -417,7 +427,7 @@ static bool __init hv_init_tsc_clocksource(void)hv_set_clocksource_vdso (hyperv_cs_tsc);clocksource_register_hz (&hyperv_cs_tsc,NSEC_PER_SEC /100 ); - hv_sched_clock_offset = hyperv_cs->read (hyperv_cs); + hv_sched_clock_offset =hv_read_reference_counter ();hv_setup_sched_clock (read_hv_sched_clock_tsc);return true;
@@ -439,10 +449,10 @@ void __init hv_init_clocksource(void)if (!(ms_hyperv.features &HV_MSR_TIME_REF_COUNT_AVAILABLE ))return ; - hyperv_cs = &hyperv_cs_msr; + hv_read_reference_counter = read_hv_clock_msr;clocksource_register_hz (&hyperv_cs_msr,NSEC_PER_SEC /100 ); - hv_sched_clock_offset = hyperv_cs->read (hyperv_cs); + hv_sched_clock_offset =hv_read_reference_counter ();hv_setup_sched_clock (read_hv_sched_clock_msr); }EXPORT_SYMBOL_GPL (hv_init_clocksource);
drivers/hv/hv_util.c +4 -4
@@ -211,7 +211,7 @@ static struct timespec64 hv_get_adj_host_time(void)unsigned long flags;spin_lock_irqsave (&host_ts.lock, flags); - reftime = hyperv_cs->read (hyperv_cs); + reftime =hv_read_reference_counter (); newtime = host_ts.host_time + (reftime - host_ts.ref_time); ts =ns_to_timespec64 ((newtime -WLTIMEDELTA ) *100 );spin_unlock_irqrestore (&host_ts.lock, flags);
@@ -250,7 +250,7 @@ static inline void adj_guesttime(u64 hosttime, u64 reftime, u8 adj_flags)*/ spin_lock_irqsave (&host_ts.lock, flags); - cur_reftime = hyperv_cs->read (hyperv_cs); + cur_reftime =hv_read_reference_counter (); host_ts.host_time = hosttime; host_ts.ref_time = cur_reftime;
@@ -315,7 +315,7 @@ static void timesync_onchannelcallback(void *context)sizeof (struct vmbuspipe_hdr ) + sizeof(struct icmsg_hdr)];adj_guesttime (timedatap->parenttime, - hyperv_cs->read (hyperv_cs), +hv_read_reference_counter (), timedatap->flags); } }
@@ -524,7 +524,7 @@ static struct ptp_clock *hv_ptp_clock;static int hv_timesync_init (struct hv_util_service *srv) {/* TimeSync requires Hyper-V clocksource. */ -if (!hyperv_cs) +if (!hv_read_reference_counter)return -ENODEV ;spin_lock_init (&host_ts.lock);
include/clocksource/hyperv_timer.h +1 -1
@@ -30,7 +30,7 @@ extern void hv_stimer_global_cleanup(void);extern void hv_stimer0_isr (void );#ifdef CONFIG_HYPERV_TIMER -extern struct clocksource *hyperv_cs; +extern u64 (*hv_read_reference_counter)(void );extern void hv_init_clocksource (void );extern struct ms_hyperv_tsc_page *hv_get_tsc_page (void );
Signature · 1 line
2.17.1
PATCH 17/17 clocksource/drivers/hyper-v: Set TSC clocksource as default w/ InvariantTSC
In reply to Daniel LezcanoFrom: Andrea Parri <[email protected]>
Change the Hyper-V clocksource ratings to 250, below the TSC clocksource rating of 300. In configurations where Hyper-V offers an InvariantTSC, the TSC is not marked "unstable", so the TSC clocksource is available and preferred. With the higher rating, it will be the default. On older hardware and Hyper-V versions, the TSC is marked "unstable", so no TSC clocksource is created and the selected Hyper-V clocksource will be the default.
--- drivers/clocksource/hyperv_timer.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
drivers/clocksource/hyperv_timer.c +10 -2
@@ -302,6 +302,14 @@ EXPORT_SYMBOL_GPL(hv_stimer_global_cleanup);* the other that uses the TSC reference page feature as defined in the * TLFS. The MSR version is for compatibility with old versions of * Hyper-V and 32-bit x86. The TSC reference page version is preferred. +* +* The Hyper-V clocksource ratings of 250 are chosen to be below the +* TSC clocksource rating of 300. In configurations where Hyper-V offers +* an InvariantTSC, the TSC is not marked "unstable", so the TSC clocksource +* is available and preferred. With the higher rating, it will be the +* default. On older hardware and Hyper-V versions, the TSC is marked +* "unstable", so no TSC clocksource is created and the selected Hyper-V +* clocksource will be the default. */ u64 (*hv_read_reference_counter)(void);
@@ -363,7 +371,7 @@ static void resume_hv_clock_tsc(struct clocksource *arg)static struct clocksource hyperv_cs_tsc = { .name ="hyperv_clocksource_tsc_page" , - .rating =400 , + .rating =250 , .read = read_hv_clock_tsc_cs, .mask =CLOCKSOURCE_MASK (64 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS ,
@@ -395,7 +403,7 @@ static u64 read_hv_sched_clock_msr(void)static struct clocksource hyperv_cs_msr = { .name ="hyperv_clocksource_msr" , - .rating =400 , + .rating =250 , .read = read_hv_clock_msr_cs, .mask =CLOCKSOURCE_MASK (64 ), .flags =CLOCK_SOURCE_IS_CONTINUOUS ,
Signature · 1 line
2.17.1