All of lore.kernel.org
 help / color / mirror / Atom feed
From: Boyoun Park <boyoun.park@samsung.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: "xen-devel@lists.xenproject.org" <xen-devel@lists.xenproject.org>,
	Jan Beulich <jbeulich@suse.com>,
	"julien@xen.org" <julien@xen.org>,
	"bertrand.marquis@arm.com" <bertrand.marquis@arm.com>,
	"Volodymyr_Babchuk@epam.com" <Volodymyr_Babchuk@epam.com>,
	"andrew.cooper3@citrix.com" <andrew.cooper3@citrix.com>,
	"george.dunlap@citrix.com" <george.dunlap@citrix.com>,
	"wl@xen.org" <wl@xen.org>,
	"roger.pau@citrix.com" <roger.pau@citrix.com>,
	Chungwoo Park <cww.park@samsung.com>,
	Gang Li <gang30.li@samsung.com>,
	Lei Wang <lei19.wang@samsung.com>,
	SoungKwan Kimn <sk.kimn@samsung.com>,
	DongJin PARK <djpax.park@samsung.com>,
	Joonjae Lee <joonjae7.lee@samsung.com>
Subject: [PATCH v2 1/2] xen: add late init call in start_xen
Date: Wed, 03 Aug 2022 11:40:57 +0900	[thread overview]
Message-ID: <1470588578.9967963.1659494457934@mail-kr2-1> (raw)
In-Reply-To: <alpine.DEB.2.22.394.2207291447080.4648@ubuntu-linux-20-04-desktop>

[-- Attachment #1: Type: text/plain, Size: 6897 bytes --]

Thank you for your reply. I will seriously consider contributing
platform specific drivers. Currently, I make a sample usage by applying this
to a function in start_xen. I think functions in start_xen could be reduced
for readability and understandability.
These patches are just one of my suggestion. So feel free to reject it.

On Sat, 30 Jul 2022, Stefano Stabellini wrote:
> On Fri, 29 Jul 2022, Boyoun Park wrote:
>> I really appreciate all the comments and reviews.
>> I understand that it is hard to add this patch without any usage.
>> 
>> On Fri, 29 Jul 2022, Stefano Stabellini:
>>> On Thu, 28 Jul 2022, Jan Beulich wrote:
>>>> On 28.07.2022 11:22, Boyoun Park wrote:
>>>>> Subject: [PATCH v1] xen: add late init call in start_xen
>>>>> 
>>>>> This patch added late_initcall section in init.data.
>>>>> 
>>>>> The late initcall would be called after initcall
>>>>> 
>>>>> in the start_xen function.
>>>>> 
>>>>> Some initializing works on priority should be run
>>>>> 
>>>>> in do_initcalls and other non-prioritized works
>>>>> 
>>>>> would be run in do_late_initcalls.
>>>>> 
>>>>> To call some functions by late_initcall,
>>>>> 
>>>>> then it is possible by using
>>>>> 
>>>>> __late_initcall(/*Function Name*/);
>>>>> 
>>>>> Signed-off-by: Boyoun Park <boyoun.park@samsung.com>
>>>> 
>>>> So I could imagine this patch to be in a series where a subsequent
>>>> patch then adds an actual use of the new functionality. Without
>>>> that what you're proposing is to add dead code.
>>> 
>>> Yeah, I think it would be cool to have late initcalls but it makes sense
>>> to add them if we have someone that makes use of them.
>> 
>> I totally agree with your comments. Some drivers that I'm developing now and use this function are specific to my hardware environment.
>> Thus, it seems difficult to arrange them in the near future.
>> I will update patches if I can suggest an actual use.
> 
> I totally understand custom setups and non-upstreamable configurations
> and I have certainly some of them myself.
> 
> However, I just wanted to let you know that we are fine with accepting
> platform specific drivers in Xen where it makes sense, for instance:
> 
> - Renesas IPMMU-VMSA found in R-Car Gen3/Gen4 SoCs (an IOMMU driver)
> xen/drivers/passthrough/arm/ipmmu-vmsa.c
> 
> - Xilinx EEMI firmware interface "mediator" in Xen (power management)
> xen/arch/arm/platforms/xilinx-zynqmp-eemi.c

From: Boyoun Park <boyoun.park@samsung.com>
Date: Tue, 15 Mar 2022 12:57:59 +0900
Subject: [PATCH v2 1/2] xen: add late init call in start_xen

This patch added late_initcall section in init.data.
The late initcall would be called after initcall
in the start_xen function.

Some initializing works on priority should be run
in do_initcalls and other non-prioritized works
would be run in do_late_initcalls.

To call some functions by late_initcall,
then it is possible by using
__late_initcall(/*Function Name*/);

Signed-off-by: Boyoun Park <boyoun.park@samsung.com>
---
 xen/arch/arm/setup.c   | 2 ++
 xen/arch/arm/xen.lds.S | 2 ++
 xen/arch/x86/setup.c   | 2 ++
 xen/arch/x86/xen.lds.S | 2 ++
 xen/common/kernel.c    | 9 ++++++++-
 xen/include/xen/init.h | 3 +++
 6 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 85ff956..332a207 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -1063,6 +1063,8 @@ void __init start_xen(unsigned long boot_phys_offset,
     /* Hide UART from DOM0 if we're using it */
     serial_endboot();
 
+    do_late_initcalls();
+
     if ( (rc = xsm_set_system_active()) != 0 )
         panic("xsm: unable to switch to SYSTEM_ACTIVE privilege: %d\n", rc);
 
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 1e986e2..215e2c3 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -163,6 +163,8 @@ SECTIONS
        __presmp_initcall_end = .;
        *(.initcall1.init)
        __initcall_end = .;
+       *(.initcalllate.init)
+       __late_initcall_end = .;
 
        . = ALIGN(4);
        __alt_instructions = .;
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index f08b07b..5dc6654 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1952,6 +1952,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     setup_io_bitmap(dom0);
 
+    do_late_initcalls();
+
     if ( bsp_delay_spec_ctrl )
     {
         info->spec_ctrl_flags &= ~SCF_use_shadow;
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 8930e14..c90c7b0 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -250,6 +250,8 @@ SECTIONS
        __presmp_initcall_end = .;
        *(.initcall1.init)
        __initcall_end = .;
+       *(.initcalllate.init)
+       __late_initcall_end = .;
 
        *(.init.data)
        *(.init.data.rel)
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index f8134d3..5a3d037 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -369,7 +369,7 @@ void add_taint(unsigned int flag)
 }
 
 extern const initcall_t __initcall_start[], __presmp_initcall_end[],
-    __initcall_end[];
+    __initcall_end[], __late_initcall_end[];
 
 void __init do_presmp_initcalls(void)
 {
@@ -385,6 +385,13 @@ void __init do_initcalls(void)
         (*call)();
 }
 
+void __init do_late_initcalls(void)
+{
+    const initcall_t *call;
+    for ( call = __initcall_end; call < __late_initcall_end; call++ )
+        (*call)();
+}
+
 #ifdef CONFIG_HYPFS
 static unsigned int __read_mostly major_version;
 static unsigned int __read_mostly minor_version;
diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h
index 0af0e23..48210ee 100644
--- a/xen/include/xen/init.h
+++ b/xen/include/xen/init.h
@@ -68,11 +68,14 @@ typedef void (*exitcall_t)(void);
     const static initcall_t __initcall_##fn __init_call("presmp") = fn
 #define __initcall(fn) \
     const static initcall_t __initcall_##fn __init_call("1") = fn
+#define __late_initcall(fn) \
+    const static initcall_t __initcall_##fn __init_call("late") = fn
 #define __exitcall(fn) \
     static exitcall_t __exitcall_##fn __exit_call = fn
 
 void do_presmp_initcalls(void);
 void do_initcalls(void);
+void do_late_initcalls(void);
 
 #endif /* __ASSEMBLY__ */
 
-- 
2.7.4

Boyoun Park

[-- Attachment #2: v2-0001-xen-add-late-init-call-in-start_xen.patch --]
[-- Type: application/octet-stream, Size: 3991 bytes --]

From 5fd58ac8679189a878609e45b4bce1e78dee4848 Mon Sep 17 00:00:00 2001
Message-Id: <5fd58ac8679189a878609e45b4bce1e78dee4848.1659492818.git.boyoun.park@samsung.com>
From: Boyoun Park <boyoun.park@samsung.com>
Date: Tue, 15 Mar 2022 12:57:59 +0900
Subject: [PATCH v2 1/2] xen: add late init call in start_xen

This patch added late_initcall section in init.data.
The late initcall would be called after initcall
in the start_xen function.

Some initializing works on priority should be run
in do_initcalls and other non-prioritized works
would be run in do_late_initcalls.

To call some functions by late_initcall,
then it is possible by using
__late_initcall(/*Function Name*/);

Signed-off-by: Boyoun Park <boyoun.park@samsung.com>
---
 xen/arch/arm/setup.c   | 2 ++
 xen/arch/arm/xen.lds.S | 2 ++
 xen/arch/x86/setup.c   | 2 ++
 xen/arch/x86/xen.lds.S | 2 ++
 xen/common/kernel.c    | 9 ++++++++-
 xen/include/xen/init.h | 3 +++
 6 files changed, 19 insertions(+), 1 deletion(-)

diff --git a/xen/arch/arm/setup.c b/xen/arch/arm/setup.c
index 85ff956..332a207 100644
--- a/xen/arch/arm/setup.c
+++ b/xen/arch/arm/setup.c
@@ -1063,6 +1063,8 @@ void __init start_xen(unsigned long boot_phys_offset,
     /* Hide UART from DOM0 if we're using it */
     serial_endboot();
 
+    do_late_initcalls();
+
     if ( (rc = xsm_set_system_active()) != 0 )
         panic("xsm: unable to switch to SYSTEM_ACTIVE privilege: %d\n", rc);
 
diff --git a/xen/arch/arm/xen.lds.S b/xen/arch/arm/xen.lds.S
index 1e986e2..215e2c3 100644
--- a/xen/arch/arm/xen.lds.S
+++ b/xen/arch/arm/xen.lds.S
@@ -163,6 +163,8 @@ SECTIONS
        __presmp_initcall_end = .;
        *(.initcall1.init)
        __initcall_end = .;
+       *(.initcalllate.init)
+       __late_initcall_end = .;
 
        . = ALIGN(4);
        __alt_instructions = .;
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index f08b07b..5dc6654 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1952,6 +1952,8 @@ void __init noreturn __start_xen(unsigned long mbi_p)
 
     setup_io_bitmap(dom0);
 
+    do_late_initcalls();
+
     if ( bsp_delay_spec_ctrl )
     {
         info->spec_ctrl_flags &= ~SCF_use_shadow;
diff --git a/xen/arch/x86/xen.lds.S b/xen/arch/x86/xen.lds.S
index 8930e14..c90c7b0 100644
--- a/xen/arch/x86/xen.lds.S
+++ b/xen/arch/x86/xen.lds.S
@@ -250,6 +250,8 @@ SECTIONS
        __presmp_initcall_end = .;
        *(.initcall1.init)
        __initcall_end = .;
+       *(.initcalllate.init)
+       __late_initcall_end = .;
 
        *(.init.data)
        *(.init.data.rel)
diff --git a/xen/common/kernel.c b/xen/common/kernel.c
index f8134d3..5a3d037 100644
--- a/xen/common/kernel.c
+++ b/xen/common/kernel.c
@@ -369,7 +369,7 @@ void add_taint(unsigned int flag)
 }
 
 extern const initcall_t __initcall_start[], __presmp_initcall_end[],
-    __initcall_end[];
+    __initcall_end[], __late_initcall_end[];
 
 void __init do_presmp_initcalls(void)
 {
@@ -385,6 +385,13 @@ void __init do_initcalls(void)
         (*call)();
 }
 
+void __init do_late_initcalls(void)
+{
+    const initcall_t *call;
+    for ( call = __initcall_end; call < __late_initcall_end; call++ )
+        (*call)();
+}
+
 #ifdef CONFIG_HYPFS
 static unsigned int __read_mostly major_version;
 static unsigned int __read_mostly minor_version;
diff --git a/xen/include/xen/init.h b/xen/include/xen/init.h
index 0af0e23..48210ee 100644
--- a/xen/include/xen/init.h
+++ b/xen/include/xen/init.h
@@ -68,11 +68,14 @@ typedef void (*exitcall_t)(void);
     const static initcall_t __initcall_##fn __init_call("presmp") = fn
 #define __initcall(fn) \
     const static initcall_t __initcall_##fn __init_call("1") = fn
+#define __late_initcall(fn) \
+    const static initcall_t __initcall_##fn __init_call("late") = fn
 #define __exitcall(fn) \
     static exitcall_t __exitcall_##fn __exit_call = fn
 
 void do_presmp_initcalls(void);
 void do_initcalls(void);
+void do_late_initcalls(void);
 
 #endif /* __ASSEMBLY__ */
 
-- 
2.7.4


  parent reply	other threads:[~2022-08-03  2:41 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20220728092237epcms2p53821bba31388763f45b5204d56520c20@epcms2p5>
2022-07-28  9:22 ` [PATCH v1] xen: add late init call in start_xen Boyoun Park
2022-07-28 11:48   ` Jan Beulich
2022-07-28 19:55     ` Stefano Stabellini
2022-07-29 11:03 ` Boyoun Park
2022-07-29 21:51   ` Stefano Stabellini
     [not found]   ` <CGME20220728092237epcms2p53821bba31388763f45b5204d56520c20@epcms2p8>
2022-08-03  2:40     ` Boyoun Park [this message]
2022-08-03  8:14       ` [PATCH v2 1/2] " Julien Grall
     [not found]   ` <CGME20220728092237epcms2p53821bba31388763f45b5204d56520c20@epcms2p2>
2022-08-03  2:44     ` [PATCH v2 2/2] xen: remove init_constructors out of start_xen Boyoun Park
2022-08-03  7:10       ` Jan Beulich
2022-08-04 11:42 ` [PATCH v2 1/2] xen: add late init call in start_xen Boyoun Park

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=1470588578.9967963.1659494457934@mail-kr2-1 \
    --to=boyoun.park@samsung.com \
    --cc=Volodymyr_Babchuk@epam.com \
    --cc=andrew.cooper3@citrix.com \
    --cc=bertrand.marquis@arm.com \
    --cc=cww.park@samsung.com \
    --cc=djpax.park@samsung.com \
    --cc=gang30.li@samsung.com \
    --cc=george.dunlap@citrix.com \
    --cc=jbeulich@suse.com \
    --cc=joonjae7.lee@samsung.com \
    --cc=julien@xen.org \
    --cc=lei19.wang@samsung.com \
    --cc=roger.pau@citrix.com \
    --cc=sk.kimn@samsung.com \
    --cc=sstabellini@kernel.org \
    --cc=wl@xen.org \
    --cc=xen-devel@lists.xenproject.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.