linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] Add option to skip using RTC
@ 2019-08-27  9:26 Rahul Tanwar
  2019-08-27  9:26 ` [PATCH v2 1/1] x86/init: Noop get/set wallclock when platform doesn't support RTC Rahul Tanwar
  0 siblings, 1 reply; 4+ messages in thread
From: Rahul Tanwar @ 2019-08-27  9:26 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, tony.luck, x86
  Cc: andriy.shevchenko, alan, linux-kernel, qi-ming.wu, chuanhua.lei,
	cheol.yong.kim, rahul.tanwar, Rahul Tanwar

Hi,

There is a new product which does not support RTC as persistent clock source.

Platform ops get/set wallclock are used to get/set timespec through kernel 
timekeeping read/update_persistent_clock64() routines. Presently, get/set
wallclock ops always use MC146818A RTC/CMOS device to read & set time.
This causes boot failure on our new SOC with no RTC.

Make RTC read/write optional by detecting platforms which does not support
RTC/CMOS device through the corresponding DT node status property. If status
says disabled, then noop the get/set wallclock ops.

For non DT enabled machines or for DT enabled machines which does not define
optional status property, proceed same as before.

These patches are baselined upon Linux 5.3-rc6 at below Git tree:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86/core

v2:
* As per review feedback, do not hack RTC read/write functions directly. 
  Instead, override get/set wallclock ops during setup_arch init sequence.

v1:
* Detect platforms with no RTC in RTC read/write functions and skip RTC
  read/write if not applicable.

Rahul Tanwar (1):
  x86/init: Noop get/set wallclock when platform doesn't support RTC

 arch/x86/kernel/x86_init.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

-- 
2.11.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/1] x86/init: Noop get/set wallclock when platform doesn't support RTC
  2019-08-27  9:26 [PATCH v2 0/1] Add option to skip using RTC Rahul Tanwar
@ 2019-08-27  9:26 ` Rahul Tanwar
  2019-08-29 18:51   ` kbuild test robot
  2019-08-29 18:51   ` [RFC PATCH] x86/init: x86_wallclock_init() can be static kbuild test robot
  0 siblings, 2 replies; 4+ messages in thread
From: Rahul Tanwar @ 2019-08-27  9:26 UTC (permalink / raw)
  To: tglx, mingo, bp, hpa, tony.luck, x86
  Cc: andriy.shevchenko, alan, linux-kernel, qi-ming.wu, chuanhua.lei,
	cheol.yong.kim, rahul.tanwar, Rahul Tanwar

Use wallclock_init() op to detect platforms which does not support RTC and
noop get/set wallclock ops for such platforms.

Suggested-by: Andy Shevchenko <andriy.shevchenko@intel.com>
Signed-off-by: Rahul Tanwar <rahul.tanwar@linux.intel.com>
---
 arch/x86/kernel/x86_init.c | 26 +++++++++++++++++++++++++-
 1 file changed, 25 insertions(+), 1 deletion(-)

diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 1bef687faf22..88c120710d5d 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -31,6 +31,30 @@ static int __init iommu_init_noop(void) { return 0; }
 static void iommu_shutdown_noop(void) { }
 bool __init bool_x86_init_noop(void) { return false; }
 void x86_op_int_noop(int cpu) { }
+static int set_rtc_noop(const struct timespec64 *now) { return -EINVAL; }
+static void get_rtc_noop(struct timespec64 *now) { }
+
+static const struct of_device_id of_cmos_match[] = {
+	{ .compatible = "motorola,mc146818" },
+	{}
+};
+
+void x86_wallclock_init(void)
+{
+	struct device_node *node;
+
+	node = of_find_matching_node(NULL, of_cmos_match);
+	if (node && !of_device_is_available(node)) {
+		/*
+		 * Some products do not support RTC as persistent clock source. This can be
+		 * optionally indicated by having status property as disabled in the
+		 * corresponding DT node. Override get/set wallclock routines to noops for
+		 * such products.
+		 */
+		x86_platform.get_wallclock = get_rtc_noop;
+		x86_platform.set_wallclock = set_rtc_noop;
+	}
+}
 
 /*
  * The platform setup functions are preset with the default functions
@@ -73,7 +97,7 @@ struct x86_init_ops x86_init __initdata = {
 	.timers = {
 		.setup_percpu_clockev	= setup_boot_APIC_clock,
 		.timer_init		= hpet_time_init,
-		.wallclock_init		= x86_init_noop,
+		.wallclock_init		= x86_wallclock_init,
 	},
 
 	.iommu = {
-- 
2.11.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 1/1] x86/init: Noop get/set wallclock when platform doesn't support RTC
  2019-08-27  9:26 ` [PATCH v2 1/1] x86/init: Noop get/set wallclock when platform doesn't support RTC Rahul Tanwar
@ 2019-08-29 18:51   ` kbuild test robot
  2019-08-29 18:51   ` [RFC PATCH] x86/init: x86_wallclock_init() can be static kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2019-08-29 18:51 UTC (permalink / raw)
  To: Rahul Tanwar
  Cc: kbuild-all, tglx, mingo, bp, hpa, tony.luck, x86,
	andriy.shevchenko, alan, linux-kernel, qi-ming.wu, chuanhua.lei,
	cheol.yong.kim, rahul.tanwar, Rahul Tanwar

Hi Rahul,

Thank you for the patch! Perhaps something to improve:

[auto build test WARNING on linus/master]
[cannot apply to v5.3-rc6 next-20190829]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Rahul-Tanwar/x86-init-Noop-get-set-wallclock-when-platform-doesn-t-support-RTC/20190829-202237
reproduce:
        # apt-get install sparse
        # sparse version: v0.6.1-rc1-7-g2b96cd8-dirty
        make ARCH=x86_64 allmodconfig
        make C=1 CF='-fdiagnostic-prefix -D__CHECK_ENDIAN__'

If you fix the issue, kindly add following tag
Reported-by: kbuild test robot <lkp@intel.com>


sparse warnings: (new ones prefixed by >>)

>> arch/x86/kernel/x86_init.c:42:6: sparse: sparse: symbol 'x86_wallclock_init' was not declared. Should it be static?

Please review and possibly fold the followup patch.

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [RFC PATCH] x86/init: x86_wallclock_init() can be static
  2019-08-27  9:26 ` [PATCH v2 1/1] x86/init: Noop get/set wallclock when platform doesn't support RTC Rahul Tanwar
  2019-08-29 18:51   ` kbuild test robot
@ 2019-08-29 18:51   ` kbuild test robot
  1 sibling, 0 replies; 4+ messages in thread
From: kbuild test robot @ 2019-08-29 18:51 UTC (permalink / raw)
  To: Rahul Tanwar
  Cc: kbuild-all, tglx, mingo, bp, hpa, tony.luck, x86,
	andriy.shevchenko, alan, linux-kernel, qi-ming.wu, chuanhua.lei,
	cheol.yong.kim, rahul.tanwar, Rahul Tanwar


Fixes: 1461badd03e7 ("x86/init: Noop get/set wallclock when platform doesn't support RTC")
Signed-off-by: kbuild test robot <lkp@intel.com>
---
 x86_init.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kernel/x86_init.c b/arch/x86/kernel/x86_init.c
index 88c120710d5d5..50aa8257fd20a 100644
--- a/arch/x86/kernel/x86_init.c
+++ b/arch/x86/kernel/x86_init.c
@@ -39,7 +39,7 @@ static const struct of_device_id of_cmos_match[] = {
 	{}
 };
 
-void x86_wallclock_init(void)
+static void x86_wallclock_init(void)
 {
 	struct device_node *node;
 

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2019-08-29 18:52 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-27  9:26 [PATCH v2 0/1] Add option to skip using RTC Rahul Tanwar
2019-08-27  9:26 ` [PATCH v2 1/1] x86/init: Noop get/set wallclock when platform doesn't support RTC Rahul Tanwar
2019-08-29 18:51   ` kbuild test robot
2019-08-29 18:51   ` [RFC PATCH] x86/init: x86_wallclock_init() can be static kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).