Skip to contentSkip to conversation

Refactor SDEI client driver

PATCH Superseded Gavin Shan 2 participants 40 messages Jul 22, 2020 – Jul 28, 2020 Software delegated exception interface (sdei)

v2 of 5 Superseded Latest is v5 →

lore
Share & tools
lore

Gavin Shan

author
#0 lore raw

v2 cover Refactor SDEI client driver

This series bases on 5.8-rc6 and refactors the SDEI client driver. It's the preparatory work of virtualizing SDEI afterwords. The series is organized as below:

* PATCH[1-13] refactors and clean up the code. They shouldn't cause any functional changes.
* PATCH[14-15] exposes "struct sdei_event", which will be dereferenced on virtualizing SDEI. After it's applied, the SDEI event is identified by the instance of "struct sdei_event" instead of event number.
* PATCH[16] retrieves the signaled property of the SDEI event when it's populated. It's needed by SDEI virtualization afterwards.
* PATCH[17] exposes API (sdei_event_get_info()), which is needed by SDEI virtualization either.

The series can be checked out from:

    [email protected]:gwshan/linux.git
    (branch: "sdei_client") 

Testing
=======
I have the SDEI virtualization code implemented as part of KVM module. With that, the SDEI event can be registered/unregistered/enabled/disabled. Also, the SDEI event can be injected from host and the guest handler runs properly.

Changelog
=========
v2:

   Rebase to 5.8.rc6                                               (Gavin)
   Improved changelog                                              (James/Gavin)
   Split patches for easy review                                   (Gavin)
   Drop changes to reorder variables                               (James)

Drop unnecessary (@regs removal) cleanup in sdei_event_create() (James)
Fix broken case for device-tree in sdei_init() (James)

Gavin Shan (17):
drivers/firmware/sdei: Remove sdei_is_err() drivers/firmware/sdei: Common block for failing path in
sdei_event_create()
drivers/firmware/sdei: Retrieve event number from event instance drivers/firmware/sdei: Avoid nested statements in sdei_init() drivers/firmware/sdei: Unregister driver on error in sdei_init() drivers/firmware/sdei: Remove duplicate check in sdei_get_conduit() drivers/firmware/sdei: Remove Drop redundant error message in
sdei_probe()
drivers/firmware/sdei: Remove while loop in sdei_event_register() drivers/firmware/sdei: Remove while loop in sdei_event_unregister() drivers/firmware/sdei: Cleanup on cross call function drivers/firmware/sdei: Introduce sdei_do_local_call() drivers/firmware/sdei: Remove _sdei_event_register() drivers/firmware/sdei: Remove _sdei_event_unregister() drivers/firmware/sdei: Move struct sdei_event to header file drivers/firmware/sdei: Identify event by struct sdei_event drivers/firmware/sdei: Retrieve event signaled property on
registration
drivers/firmware/sdei: Add sdei_event_get_info()

 drivers/firmware/arm_sdei.c | 394 ++++++++++++++++--------------------
 include/linux/arm_sdei.h    |  73 ++++---
 2 files changed, 224 insertions(+), 243 deletions(-)
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#1 lore raw

PATCH v2 1/17 drivers/firmware/sdei: Remove sdei_is_err()

sdei_is_err() is only called by sdei_to_linux_errno(). The logic of checking on the error number is common to them. They can be combined finely.

This removes sdei_is_err() and its logic is combined to the function sdei_to_linux_errno(). Also, the assignment of @err to zero is also dropped in invoke_sdei_fn() because it's always overridden afterwards. This shouldn't cause functional changes.

---
v2: Remove the initializer for @err in invoke_sdei_fn()

---
 drivers/firmware/arm_sdei.c | 26 +++-----------------------
 1 file changed, 3 insertions(+), 23 deletions(-)
drivers/firmware/arm_sdei.c +3 -23
index e7e36aab2386..be5367f839f2 100644
@@ -114,26 +114,7 @@ static int sdei_to_linux_errno(unsigned long sdei_err)
 		return -ENOMEM;
 	}
 
-	/* Not an error value ... */
-	return sdei_err;
-}
-
-/*
- * If x0 is any of these values, then the call failed, use sdei_to_linux_errno()
- * to translate.
- */
-static int sdei_is_err(struct arm_smccc_res *res)
-{
-	switch (res->a0) {
-	case SDEI_NOT_SUPPORTED:
-	case SDEI_INVALID_PARAMETERS:
-	case SDEI_DENIED:
-	case SDEI_PENDING:
-	case SDEI_OUT_OF_RESOURCE:
-		return true;
-	}
-
-	return false;
+	return 0;
 }
 
 static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0,
@@ -141,14 +122,13 @@ static int invoke_sdei_fn(unsigned long function_id, unsigned long arg0,
 			  unsigned long arg3, unsigned long arg4,
 			  u64 *result)
 {
-	int err = 0;
+	int err;
 	struct arm_smccc_res res;
 
 	if (sdei_firmware_call) {
 		sdei_firmware_call(function_id, arg0, arg1, arg2, arg3, arg4,
 				   &res);
-		if (sdei_is_err(&res))
-			err = sdei_to_linux_errno(res.a0);
+		err = sdei_to_linux_errno(res.a0);
 	} else {
 		/*
 		 * !sdei_firmware_call means we failed to probe or called
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#2 lore raw

PATCH v2 2/17 drivers/firmware/sdei: Common block for failing path in sdei_event_create()

In reply to Gavin Shan

There are multiple calls of kfree(event) in the failing path of sdei_event_create() to free the SDEI event. It means we need to call it again when adding more code in the failing path. It's prone to miss doing that and introduce memory leakage.

This introduces common block for failing path in sdei_event_create() to resolve the issue. This shouldn't cause functional changes.

---
v2: Improved commit log to make the movtivation explicit
Drop the part of changes to reorder the variables

---
 drivers/firmware/arm_sdei.c | 30 ++++++++++++++++--------------
 1 file changed, 16 insertions(+), 14 deletions(-)
drivers/firmware/arm_sdei.c +16 -14
index be5367f839f2..67da02b3a06e 100644
@@ -190,33 +190,31 @@ static struct sdei_event *sdei_event_create(u32 event_num,
 	lockdep_assert_held(&sdei_events_lock);
 
 	event = kzalloc(sizeof(*event), GFP_KERNEL);
-	if (!event)
-		return ERR_PTR(-ENOMEM);
+	if (!event) {
+		err = -ENOMEM;
+		goto fail;
+	}
 
 	INIT_LIST_HEAD(&event->list);
 	event->event_num = event_num;
 
 	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_PRIORITY,
 				      &result);
-	if (err) {
-		kfree(event);
-		return ERR_PTR(err);
-	}
+	if (err)
+		goto fail;
 	event->priority = result;
 
 	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_TYPE,
 				      &result);
-	if (err) {
-		kfree(event);
-		return ERR_PTR(err);
-	}
+	if (err)
+		goto fail;
 	event->type = result;
 
 	if (event->type == SDEI_EVENT_TYPE_SHARED) {
 		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
 		if (!reg) {
-			kfree(event);
-			return ERR_PTR(-ENOMEM);
+			err = -ENOMEM;
+			goto fail;
 		}
 
 		reg->event_num = event_num;
@@ -231,8 +229,8 @@ static struct sdei_event *sdei_event_create(u32 event_num,
 
 		regs = alloc_percpu(struct sdei_registered_event);
 		if (!regs) {
-			kfree(event);
-			return ERR_PTR(-ENOMEM);
+			err = -ENOMEM;
+			goto fail;
 		}
 
 		for_each_possible_cpu(cpu) {
@@ -252,6 +250,10 @@ static struct sdei_event *sdei_event_create(u32 event_num,
 	spin_unlock(&sdei_list_lock);
 
 	return event;
+
+fail:
+	kfree(event);
+	return ERR_PTR(err);
 }
 
 static void sdei_event_destroy_llocked(struct sdei_event *event)
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#3 lore raw

PATCH v2 3/17 drivers/firmware/sdei: Retrieve event number from event instance

In reply to Gavin Shan

In sdei_event_create(), the event number is retrieved from the variable @event_num for the shared event. The event number was stored in the event instance. So we can fetch it from the event instance, similar to what we're doing for the private event.

---
v2: Improved commit log
Dropped changes to remove @regs
Dropped changes to reorder variables

---
 drivers/firmware/arm_sdei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_sdei.c +1 -1
index 67da02b3a06e..86ab878d1198 100644
@@ -217,7 +217,7 @@ static struct sdei_event *sdei_event_create(u32 event_num,
 			goto fail;
 		}
 
-		reg->event_num = event_num;
+		reg->event_num = event->event_num;
 		reg->priority = event->priority;
 
 		reg->callback = cb;
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#4 lore raw

PATCH v2 4/17 drivers/firmware/sdei: Avoid nested statements in sdei_init()

In reply to Gavin Shan

In sdei_init(), the nested statements can be avoided by bailing on error from platform_driver_register() or absent ACPI SDEI table. With it, the code looks a bit more readable.

---
v2: Derived from "drivers/firmware/sdei: Rework sdei_init()"

---
 drivers/firmware/arm_sdei.c | 23 ++++++++++++-----------
 1 file changed, 12 insertions(+), 11 deletions(-)
drivers/firmware/arm_sdei.c +12 -11
index 86ab878d1198..c9f2bedfb6b5 100644
@@ -1081,17 +1081,18 @@ static bool __init sdei_present_acpi(void)
 
 static int __init sdei_init(void)
 {
-	int ret = platform_driver_register(&sdei_driver);
-
-	if (!ret && sdei_present_acpi()) {
-		struct platform_device *pdev;
-
-		pdev = platform_device_register_simple(sdei_driver.driver.name,
-						       0, NULL, 0);
-		if (IS_ERR(pdev))
-			pr_info("Failed to register ACPI:SDEI platform device %ld\n",
-				PTR_ERR(pdev));
-	}
+	struct platform_device *pdev;
+	int ret;
+
+	ret = platform_driver_register(&sdei_driver);
+	if (ret || !sdei_present_acpi())
+		return ret;
+
+	pdev = platform_device_register_simple(sdei_driver.driver.name,
+					       0, NULL, 0);
+	if (IS_ERR(pdev))
+		pr_info("Failed to register ACPI:SDEI platform device %ld\n",
+			PTR_ERR(pdev));
 
 	return ret;
 }
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#5 lore raw

PATCH v2 5/17 drivers/firmware/sdei: Unregister driver on error in sdei_init()

In reply to Gavin Shan

The platform driver needs to be unregistered on error to create the platform device, so that the state is restored to original one.

Besides, the errno (@ret) should be updated acccording in that case.

---
v2: Derived from "drivers/firmware/sdei: Rework sdei_init()"
Unregister platform driver instead of platform device Remove duplicate ACPI enablement checker Update errno (@ret) accordingly

---
 drivers/firmware/arm_sdei.c | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/firmware/arm_sdei.c +6 -3
index c9f2bedfb6b5..909f27abf8a7 100644
@@ -1090,9 +1090,12 @@ static int __init sdei_init(void)
 
 	pdev = platform_device_register_simple(sdei_driver.driver.name,
 					       0, NULL, 0);
-	if (IS_ERR(pdev))
-		pr_info("Failed to register ACPI:SDEI platform device %ld\n",
-			PTR_ERR(pdev));
+	if (IS_ERR(pdev)) {
+		ret = PTR_ERR(pdev);
+		platform_driver_unregister(&sdei_driver);
+		pr_info("Failed to register ACPI:SDEI platform device %d\n",
+			ret);
+	}
 
 	return ret;
 }
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#6 lore raw

PATCH v2 6/17 drivers/firmware/sdei: Remove duplicate check in sdei_get_conduit()

In reply to Gavin Shan

The following two checks are duplicate because @acpi_disabled doesn't depend on CONFIG_ACPI. So the duplicate check (IS_ENABLED(CONFIG_ACPI)) can be dropped. More details is provided to keep the commit log complete:

* @acpi_disabled is defined in arch/arm64/kernel/acpi.c when CONFIG_ACPI is enabled.
* @acpi_disabled in defined in include/acpi.h when CONFIG_ACPI is disabled.

---
v2: Derived from "drivers/firmware/sdei: Remove sdei_get_conduit()"

---
 drivers/firmware/arm_sdei.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/firmware/arm_sdei.c +1 -1
index 909f27abf8a7..240c06ae7bfe 100644
@@ -958,7 +958,7 @@ static int sdei_get_conduit(struct platform_device *pdev)
 		}
 
 		pr_warn("invalid \"method\" property: %s\n", method);
-	} else if (IS_ENABLED(CONFIG_ACPI) && !acpi_disabled) {
+	} else if (!acpi_disabled) {
 		if (acpi_psci_use_hvc()) {
 			sdei_firmware_call = &sdei_smccc_hvc;
 			return SMCCC_CONDUIT_HVC;
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#7 lore raw

PATCH v2 7/17 drivers/firmware/sdei: Remove Drop redundant error message in sdei_probe()

In reply to Gavin Shan

This removes the redundant error message in sdei_probe() because the case can be identified from the errno in next error message.

---
v2: Remove changes to reorder variables

---
 drivers/firmware/arm_sdei.c | 2 --
 1 file changed, 2 deletions(-)
drivers/firmware/arm_sdei.c +0 -2
index 240c06ae7bfe..03b1179da9b4 100644
@@ -982,8 +982,6 @@ static int sdei_probe(struct platform_device *pdev)
 		return 0;
 
 	err = sdei_api_get_version(&ver);
-	if (err == -EOPNOTSUPP)
-		pr_err("advertised but not implemented in platform firmware\n");
 	if (err) {
 		pr_err("Failed to get SDEI version: %d\n", err);
 		sdei_mark_interface_broken();
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#8 lore raw

PATCH v2 8/17 drivers/firmware/sdei: Remove while loop in sdei_event_register()

In reply to Gavin Shan

This removes the unnecessary while loop in sdei_event_register(). This shouldn't cause any functional changes.

---
v2: Derived from "drivers/firmware/sdei: Drop unnecessary while loop"

---
 drivers/firmware/arm_sdei.c | 52 ++++++++++++++++++-------------------
 1 file changed, 25 insertions(+), 27 deletions(-)
drivers/firmware/arm_sdei.c +25 -27
index 03b1179da9b4..ab1088fbdd37 100644
@@ -590,36 +590,34 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 	WARN_ON(in_nmi());
 
 	mutex_lock(&sdei_events_lock);
-	do {
-		if (sdei_event_find(event_num)) {
-			pr_warn("Event %u already registered\n", event_num);
-			err = -EBUSY;
-			break;
-		}
+	if (sdei_event_find(event_num)) {
+		pr_warn("Event %u already registered\n", event_num);
+		err = -EBUSY;
+		goto out;
+	}
 
-		event = sdei_event_create(event_num, cb, arg);
-		if (IS_ERR(event)) {
-			err = PTR_ERR(event);
-			pr_warn("Failed to create event %u: %d\n", event_num,
-				err);
-			break;
-		}
+	event = sdei_event_create(event_num, cb, arg);
+	if (IS_ERR(event)) {
+		err = PTR_ERR(event);
+		pr_warn("Failed to create event %u: %d\n", event_num, err);
+		goto out;
+	}
 
-		cpus_read_lock();
-		err = _sdei_event_register(event);
-		if (err) {
-			sdei_event_destroy(event);
-			pr_warn("Failed to register event %u: %d\n", event_num,
-				err);
-		} else {
-			spin_lock(&sdei_list_lock);
-			event->reregister = true;
-			spin_unlock(&sdei_list_lock);
-		}
-		cpus_read_unlock();
-	} while (0);
-	mutex_unlock(&sdei_events_lock);
+	cpus_read_lock();
+	err = _sdei_event_register(event);
+	if (err) {
+		sdei_event_destroy(event);
+		pr_warn("Failed to register event %u: %d\n", event_num, err);
+		goto cpu_unlock;
+	}
 
+	spin_lock(&sdei_list_lock);
+	event->reregister = true;
+	spin_unlock(&sdei_list_lock);
+cpu_unlock:
+	cpus_read_unlock();
+out:
+	mutex_unlock(&sdei_events_lock);
 	return err;
 }
 
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#9 lore raw

PATCH v2 9/17 drivers/firmware/sdei: Remove while loop in sdei_event_unregister()

In reply to Gavin Shan

This removes the unnecessary while loop in sdei_event_unregister(). This shouldn't cause any functional changes.

---
v2: Derived from "drivers/firmware/sdei: Drop unnecessary while loop"

---
 drivers/firmware/arm_sdei.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/firmware/arm_sdei.c +14 -16
index ab1088fbdd37..d03371161aaf 100644
@@ -491,26 +491,24 @@ int sdei_event_unregister(u32 event_num)
 
 	mutex_lock(&sdei_events_lock);
 	event = sdei_event_find(event_num);
-	do {
-		if (!event) {
-			pr_warn("Event %u not registered\n", event_num);
-			err = -ENOENT;
-			break;
-		}
+	if (!event) {
+		pr_warn("Event %u not registered\n", event_num);
+		err = -ENOENT;
+		goto out;
+	}
 
-		spin_lock(&sdei_list_lock);
-		event->reregister = false;
-		event->reenable = false;
-		spin_unlock(&sdei_list_lock);
+	spin_lock(&sdei_list_lock);
+	event->reregister = false;
+	event->reenable = false;
+	spin_unlock(&sdei_list_lock);
 
-		err = _sdei_event_unregister(event);
-		if (err)
-			break;
+	err = _sdei_event_unregister(event);
+	if (err)
+		goto out;
 
-		sdei_event_destroy(event);
-	} while (0);
+	sdei_event_destroy(event);
+out:
 	mutex_unlock(&sdei_events_lock);
-
 	return err;
 }
 
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#10 lore raw

Re: [PATCH v2 09/17] drivers/firmware/sdei: Remove while loop in sdei_event_unregister()

Quoted 40 lines · On Wed, 22 Jul 2020 19:57:32 +1000 Gavin Shan <[email protected]> wrote:

This removes the unnecessary while loop in sdei_event_unregister(). This shouldn't cause any functional changes.

---
v2: Derived from "drivers/firmware/sdei: Drop unnecessary while loop"

---
 drivers/firmware/arm_sdei.c | 30 ++++++++++++++----------------
 1 file changed, 14 insertions(+), 16 deletions(-)
drivers/firmware/arm_sdei.c +9 -11
index ab1088fbdd37..d03371161aaf 100644
@@ -491,26 +491,24 @@ int sdei_event_unregister(u32 event_num)
 
 	mutex_lock(&sdei_events_lock);
 	event = sdei_event_find(event_num);
-	do {
-		if (!event) {
-			pr_warn("Event %u not registered\n", event_num);
-			err = -ENOENT;
-			break;
-		}
+	if (!event) {
+		pr_warn("Event %u not registered\n", event_num);
+		err = -ENOENT;
+		goto out;
+	}
 
-		spin_lock(&sdei_list_lock);
-		event->reregister = false;
-		event->reenable = false;
-		spin_unlock(&sdei_list_lock);
+	spin_lock(&sdei_list_lock);
+	event->reregister = false;
+	event->reenable = false;
+	spin_unlock(&sdei_list_lock);
 
-		err = _sdei_event_unregister(event);

drivers/firmware/arm_sdei.c int sdei_event_unregister(u32 event_num) · line 510

Quoted 10 lines
drivers/firmware/arm_sdei.c +5 -4
-		if (err)
-			break;
+	err = _sdei_event_unregister(event);
+	if (err)
+		goto out;
 
-		sdei_event_destroy(event);
-	} while (0);
+	sdei_event_destroy(event);
+out:

As in previous I'd give the label a name to indicate there is still work to be done.

drivers/firmware/arm_sdei.c int sdei_event_unregister(u32 event_num) · line 513

Quoted 2 lines
drivers/firmware/arm_sdei.c +0 -1
 	mutex_unlock(&sdei_events_lock);
-

That whitespace is arguably slightly useful from a readability point of view. I would leave it here.

drivers/firmware/arm_sdei.c int sdei_event_unregister(u32 event_num) · line 514

Quoted 3 lines
drivers/firmware/arm_sdei.c +0 -0
 	return err;
 }
 

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#11 lore raw

Re: [PATCH v2 09/17] drivers/firmware/sdei: Remove while loop in sdei_event_unregister()

Hi Jonathan,

Quoted 49 lines · Jonathan Cameron
Quoted 46 lines · On Wed, 22 Jul 2020 19:57:32 +1000 Gavin Shan <[email protected]> wrote:

This removes the unnecessary while loop in sdei_event_unregister(). This shouldn't cause any functional changes.

---
v2: Derived from "drivers/firmware/sdei: Drop unnecessary while loop"

---
  drivers/firmware/arm_sdei.c | 30 ++++++++++++++----------------
  1 file changed, 14 insertions(+), 16 deletions(-)
drivers/firmware/arm_sdei.c +12 -13
index ab1088fbdd37..d03371161aaf 100644
@@ -491,26 +491,24 @@ int sdei_event_unregister(u32 event_num)
 
  	mutex_lock(&sdei_events_lock);
  	event = sdei_event_find(event_num);
-	do {
-		if (!event) {
-			pr_warn("Event %u not registered\n", event_num);
-			err = -ENOENT;
-			break;
-		}
+	if (!event) {
+		pr_warn("Event %u not registered\n", event_num);
+		err = -ENOENT;
+		goto out;
+	}
 
-		spin_lock(&sdei_list_lock);
-		event->reregister = false;
-		event->reenable = false;
-		spin_unlock(&sdei_list_lock);
+	spin_lock(&sdei_list_lock);
+	event->reregister = false;
+	event->reenable = false;
+	spin_unlock(&sdei_list_lock);
 
-		err = _sdei_event_unregister(event);
-		if (err)
-			break;
+	err = _sdei_event_unregister(event);
+	if (err)
+		goto out;
 
Quoted 7 lines

drivers/firmware/arm_sdei.c int sdei_event_unregister(u32 event_num) · line 510

Quoted 4 lines
drivers/firmware/arm_sdei.c +2 -2
-		sdei_event_destroy(event);
-	} while (0);
+	sdei_event_destroy(event);
+out:

As in previous I'd give the label a name to indicate there is still work to be done.

Sure, I will rename this to "unlock" in v3. However, I would hold v3 for a while until v2 is fully reviewed. Please take a look on the left patches if you have more time, thanks for your time on this series.

Quoted 5 lines

drivers/firmware/arm_sdei.c int sdei_event_unregister(u32 event_num) · line 513

Quoted 2 lines
drivers/firmware/arm_sdei.c +0 -1
  	mutex_unlock(&sdei_events_lock);
-

That whitespace is arguably slightly useful from a readability point of view. I would leave it here.

Ok. I will keep this in v3 then.

Quoted 3 lines

drivers/firmware/arm_sdei.c int sdei_event_unregister(u32 event_num) · line 514

Quoted 3 lines
drivers/firmware/arm_sdei.c +0 -0
  	return err;
  }
 

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#12 lore raw

PATCH v2 10/17 drivers/firmware/sdei: Cleanup on cross call function

In reply to Gavin Shan

This applies cleanup on the corss call functions, no functional changes is introduced:

* Cleanup struct sdei_crosscall_arg to use tab between fields and their types
* Refactor CROSSCALL_INIT to use "do { ... } while (0)" to be compatible with scripts/checkpatch.pl
* Remove unnecessary space before @event in sdei_do_cross_call()

---
v2: Drop changes to sdei_cross_call_return()
Remove unnecessary space before @event in sdei_do_cross_call()

---
 drivers/firmware/arm_sdei.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/firmware/arm_sdei.c +9 -6
index d03371161aaf..04dc144a8f31 100644
@@ -73,14 +73,17 @@ static LIST_HEAD(sdei_list);
 
 /* Private events are registered/enabled via IPI passing one of these */
 struct sdei_crosscall_args {
-	struct sdei_event *event;
-	atomic_t errors;
-	int first_error;
+	struct sdei_event	*event;
+	atomic_t		errors;
+	int			first_error;
 };
 
-#define CROSSCALL_INIT(arg, event)	(arg.event = event, \
-					 arg.first_error = 0, \
-					 atomic_set(&arg.errors, 0))
+#define CROSSCALL_INIT(arg, event)		\
+	do {					\
+		arg.event = event;		\
+		arg.first_error = 0;		\
+		atomic_set(&arg.errors, 0);	\
+	} while (0)
 
 static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
 {
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#13 lore raw

Re: [PATCH v2 10/17] drivers/firmware/sdei: Cleanup on cross call function

Quoted 1 line · On Wed, 22 Jul 2020 19:57:33 +1000 Gavin Shan <[email protected]> wrote:

This applies cleanup on the corss call functions, no functional

cross

Quoted 1 line

changes is introduced:

changes are introduced:

Quoted 3 lines

* Cleanup struct sdei_crosscall_arg to use tab between fields and their types

Hmm. I guess there is a consistency argument for doing this but generally that one doesn't look like it actually has much benefit.

Quoted 2 lines

* Refactor CROSSCALL_INIT to use "do { ... } while (0)" to be compatible with scripts/checkpatch.pl

Good to tidy that up.

Quoted 1 line

* Remove unnecessary space before @event in sdei_do_cross_call()

Good change, but seems to have gotten lost in this patch.

Quoted 27 lines

---
v2: Drop changes to sdei_cross_call_return()
Remove unnecessary space before @event in sdei_do_cross_call()

---
 drivers/firmware/arm_sdei.c | 15 +++++++++------
 1 file changed, 9 insertions(+), 6 deletions(-)
drivers/firmware/arm_sdei.c +3 -5
index d03371161aaf..04dc144a8f31 100644
@@ -73,14 +73,17 @@ static LIST_HEAD(sdei_list);
 
 /* Private events are registered/enabled via IPI passing one of these */
 struct sdei_crosscall_args {
-	struct sdei_event *event;
-	atomic_t errors;
-	int first_error;
+	struct sdei_event	*event;
+	atomic_t		errors;
+	int			first_error;
 };
 
-#define CROSSCALL_INIT(arg, event)	(arg.event = event, \
-					 arg.first_error = 0, \

drivers/firmware/arm_sdei.c static LIST_HEAD(sdei_list); · line 89

Quoted 10 lines
drivers/firmware/arm_sdei.c +6 -1
-					 atomic_set(&arg.errors, 0))
+#define CROSSCALL_INIT(arg, event)		\
+	do {					\
+		arg.event = event;		\
+		arg.first_error = 0;		\
+		atomic_set(&arg.errors, 0);	\
+	} while (0)
 
 static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
 {

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#14 lore raw

Re: [PATCH v2 10/17] drivers/firmware/sdei: Cleanup on cross call function

Hi Jonathan,

Quoted 7 lines · Jonathan Cameron
Quoted 1 line · On Wed, 22 Jul 2020 19:57:33 +1000 Gavin Shan <[email protected]> wrote:

This applies cleanup on the corss call functions, no functional

cross

It will be fixed in v3.

Quoted 4 lines
Quoted 1 line

changes is introduced:

changes are introduced:

It will be fixed in v3.

Quoted 6 lines
Quoted 3 lines

* Cleanup struct sdei_crosscall_arg to use tab between fields and their types

Hmm. I guess there is a consistency argument for doing this but generally that one doesn't look like it actually has much benefit.

Sorry, I guess you're talking about "./scripts/cleanpatch"? As stated in the head of the script, the result would be destructive. So I think manual changes would be more reliable. Lets keep this in v3 if you agree.

Extracted from "scripts/cleanpatch":

# Clean a patch file -- or directory of patch files -- of stealth whitespace. # WARNING: this can be a highly destructive operation. Use with caution. #

Quoted 4 lines
Quoted 2 lines

* Refactor CROSSCALL_INIT to use "do { ... } while (0)" to be compatible with scripts/checkpatch.pl

Good to tidy that up.

Thanks.

Quoted 4 lines
Quoted 1 line

* Remove unnecessary space before @event in sdei_do_cross_call()

Good change, but seems to have gotten lost in this patch.

Thanks.

Quoted 35 lines
Quoted 35 lines

---
v2: Drop changes to sdei_cross_call_return()
Remove unnecessary space before @event in sdei_do_cross_call()

---
  drivers/firmware/arm_sdei.c | 15 +++++++++------
  1 file changed, 9 insertions(+), 6 deletions(-)
drivers/firmware/arm_sdei.c +9 -6
index d03371161aaf..04dc144a8f31 100644
@@ -73,14 +73,17 @@ static LIST_HEAD(sdei_list);
 
  /* Private events are registered/enabled via IPI passing one of these */
  struct sdei_crosscall_args {
-	struct sdei_event *event;
-	atomic_t errors;
-	int first_error;
+	struct sdei_event	*event;
+	atomic_t		errors;
+	int			first_error;
  };
 
-#define CROSSCALL_INIT(arg, event)	(arg.event = event, \
-					 arg.first_error = 0, \
-					 atomic_set(&arg.errors, 0))
+#define CROSSCALL_INIT(arg, event)		\
+	do {					\
+		arg.event = event;		\
+		arg.first_error = 0;		\
+		atomic_set(&arg.errors, 0);	\
+	} while (0)
 
Quoted 3 lines

drivers/firmware/arm_sdei.c static LIST_HEAD(sdei_list); · line 89

Quoted 2 lines
drivers/firmware/arm_sdei.c +0 -0
  static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
  {

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#15 lore raw

Re: [PATCH v2 10/17] drivers/firmware/sdei: Cleanup on cross call function

Quoted 27 lines · On Mon, 27 Jul 2020 10:33:46 +1000 Gavin Shan <[email protected]> wrote:

Hi Jonathan,

Quoted 7 lines · Jonathan Cameron
Quoted 1 line · On Wed, 22 Jul 2020 19:57:33 +1000 Gavin Shan <[email protected]> wrote:

This applies cleanup on the corss call functions, no functional

cross

It will be fixed in v3.

Quoted 4 lines
Quoted 1 line

changes is introduced:

changes are introduced:

It will be fixed in v3.

Quoted 6 lines
Quoted 3 lines

* Cleanup struct sdei_crosscall_arg to use tab between fields and their types

Hmm. I guess there is a consistency argument for doing this but generally that one doesn't look like it actually has much benefit.

Quoted 5 lines

Sorry, I guess you're talking about "./scripts/cleanpatch"? As stated in the head of the script, the result would be destructive. So I think manual changes would be more reliable. Lets keep this in v3 if you agree.

Extracted from "scripts/cleanpatch":

No I was talking about doing this change at all. Generally I'd say don't bother making changes like this to existing code. They just add noise.

Quoted 55 lines

# Clean a patch file -- or directory of patch files -- of stealth whitespace. # WARNING: this can be a highly destructive operation. Use with caution. #

Quoted 4 lines
Quoted 2 lines

* Refactor CROSSCALL_INIT to use "do { ... } while (0)" to be compatible with scripts/checkpatch.pl

Good to tidy that up.

Thanks.

Quoted 4 lines
Quoted 1 line

* Remove unnecessary space before @event in sdei_do_cross_call()

Good change, but seems to have gotten lost in this patch.

Thanks.

Quoted 35 lines
Quoted 35 lines

---
v2: Drop changes to sdei_cross_call_return()
Remove unnecessary space before @event in sdei_do_cross_call()

---
  drivers/firmware/arm_sdei.c | 15 +++++++++------
  1 file changed, 9 insertions(+), 6 deletions(-)
drivers/firmware/arm_sdei.c +9 -6
index d03371161aaf..04dc144a8f31 100644
@@ -73,14 +73,17 @@ static LIST_HEAD(sdei_list);
 
  /* Private events are registered/enabled via IPI passing one of these */
  struct sdei_crosscall_args {
-	struct sdei_event *event;
-	atomic_t errors;
-	int first_error;
+	struct sdei_event	*event;
+	atomic_t		errors;
+	int			first_error;
  };
 
-#define CROSSCALL_INIT(arg, event)	(arg.event = event, \
-					 arg.first_error = 0, \
-					 atomic_set(&arg.errors, 0))
+#define CROSSCALL_INIT(arg, event)		\
+	do {					\
+		arg.event = event;		\
+		arg.first_error = 0;		\
+		atomic_set(&arg.errors, 0);	\
+	} while (0)
 
Quoted 7 lines
Quoted 3 lines

drivers/firmware/arm_sdei.c static LIST_HEAD(sdei_list); · line 89

Quoted 2 lines
drivers/firmware/arm_sdei.c +0 -0
  static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
  {  

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#16 lore raw

Re: [PATCH v2 10/17] drivers/firmware/sdei: Cleanup on cross call function

Hi Jonathan,

Quoted 27 lines · Jonathan Cameron
Quoted 25 lines · On Mon, 27 Jul 2020 10:33:46 +1000 Gavin Shan <[email protected]> wrote:
Quoted 7 lines · Jonathan Cameron
Quoted 1 line · On Wed, 22 Jul 2020 19:57:33 +1000 Gavin Shan <[email protected]> wrote:

This applies cleanup on the corss call functions, no functional

cross

It will be fixed in v3.

Quoted 4 lines
Quoted 1 line

changes is introduced:

changes are introduced:

It will be fixed in v3.

Quoted 6 lines
Quoted 3 lines

* Cleanup struct sdei_crosscall_arg to use tab between fields and their types

Hmm. I guess there is a consistency argument for doing this but generally that one doesn't look like it actually has much benefit.

Quoted 9 lines
Quoted 5 lines

Sorry, I guess you're talking about "./scripts/cleanpatch"? As stated in the head of the script, the result would be destructive. So I think manual changes would be more reliable. Lets keep this in v3 if you agree.

Extracted from "scripts/cleanpatch":

No I was talking about doing this change at all. Generally I'd say don't bother making changes like this to existing code. They just add noise.

I will drop the particular changes in v3 then :)

Quoted 55 lines
Quoted 55 lines

# Clean a patch file -- or directory of patch files -- of stealth whitespace. # WARNING: this can be a highly destructive operation. Use with caution. #

Quoted 4 lines
Quoted 2 lines

* Refactor CROSSCALL_INIT to use "do { ... } while (0)" to be compatible with scripts/checkpatch.pl

Good to tidy that up.

Thanks.

Quoted 4 lines
Quoted 1 line

* Remove unnecessary space before @event in sdei_do_cross_call()

Good change, but seems to have gotten lost in this patch.

Thanks.

Quoted 35 lines
Quoted 35 lines

---
v2: Drop changes to sdei_cross_call_return()
Remove unnecessary space before @event in sdei_do_cross_call()

---
   drivers/firmware/arm_sdei.c | 15 +++++++++------
   1 file changed, 9 insertions(+), 6 deletions(-)
drivers/firmware/arm_sdei.c +9 -6
index d03371161aaf..04dc144a8f31 100644
@@ -73,14 +73,17 @@ static LIST_HEAD(sdei_list);
 
   /* Private events are registered/enabled via IPI passing one of these */
   struct sdei_crosscall_args {
-	struct sdei_event *event;
-	atomic_t errors;
-	int first_error;
+	struct sdei_event	*event;
+	atomic_t		errors;
+	int			first_error;
   };
 
-#define CROSSCALL_INIT(arg, event)	(arg.event = event, \
-					 arg.first_error = 0, \
-					 atomic_set(&arg.errors, 0))
+#define CROSSCALL_INIT(arg, event)		\
+	do {					\
+		arg.event = event;		\
+		arg.first_error = 0;		\
+		atomic_set(&arg.errors, 0);	\
+	} while (0)
 
Quoted 4 lines
Quoted 4 lines
Quoted 3 lines

drivers/firmware/arm_sdei.c static LIST_HEAD(sdei_list); · line 89

Quoted 2 lines
drivers/firmware/arm_sdei.c +0 -0
   static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
   {

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#17 lore raw

PATCH v2 11/17 drivers/firmware/sdei: Introduce sdei_do_local_call()

In reply to Gavin Shan

During the CPU hotplug, the private events are registered, enabled or unregistered on the specific CPU. It repeats the same steps:
initializing cross call argument, make function call on local CPU, check the returned error.

This introduces sdei_do_local_call() to cover the first steps. The other benefit is to make CROSSCALL_INIT and struct sdei_crosscall_args are only visible to sddi_do_{cross, local}_call().

---
 drivers/firmware/arm_sdei.c | 43 ++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/firmware/arm_sdei.c +26 -17
index 04dc144a8f31..da0e0d5591a8 100644
@@ -85,7 +85,18 @@ struct sdei_crosscall_args {
 		atomic_set(&arg.errors, 0);	\
 	} while (0)
 
-static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
+static inline int sdei_do_local_call(void *fn, struct sdei_event *event)
+{
+	struct sdei_crosscall_args arg;
+	void (*func)(void *) = fn;
+
+	CROSSCALL_INIT(arg, event);
+	func(&arg);
+
+	return arg.first_error;
+}
+
+static inline int sdei_do_cross_call(void *fn, struct sdei_event *event)
 {
 	struct sdei_crosscall_args arg;
 
@@ -675,7 +686,7 @@ static int sdei_reregister_shared(void)
 static int sdei_cpuhp_down(unsigned int cpu)
 {
 	struct sdei_event *event;
-	struct sdei_crosscall_args arg;
+	int err;
 
 	/* un-register private events */
 	spin_lock(&sdei_list_lock);
@@ -683,12 +694,11 @@ static int sdei_cpuhp_down(unsigned int cpu)
 		if (event->type == SDEI_EVENT_TYPE_SHARED)
 			continue;
 
-		CROSSCALL_INIT(arg, event);
-		/* call the cross-call function locally... */
-		_local_event_unregister(&arg);
-		if (arg.first_error)
+		err = sdei_do_local_call(_local_event_unregister, event);
+		if (err) {
 			pr_err("Failed to unregister event %u: %d\n",
-			       event->event_num, arg.first_error);
+			       event->event_num, err);
+		}
 	}
 	spin_unlock(&sdei_list_lock);
 
@@ -698,7 +708,7 @@ static int sdei_cpuhp_down(unsigned int cpu)
 static int sdei_cpuhp_up(unsigned int cpu)
 {
 	struct sdei_event *event;
-	struct sdei_crosscall_args arg;
+	int err;
 
 	/* re-register/enable private events */
 	spin_lock(&sdei_list_lock);
@@ -707,20 +717,19 @@ static int sdei_cpuhp_up(unsigned int cpu)
 			continue;
 
 		if (event->reregister) {
-			CROSSCALL_INIT(arg, event);
-			/* call the cross-call function locally... */
-			_local_event_register(&arg);
-			if (arg.first_error)
+			err = sdei_do_local_call(_local_event_register, event);
+			if (err) {
 				pr_err("Failed to re-register event %u: %d\n",
-				       event->event_num, arg.first_error);
+				       event->event_num, err);
+			}
 		}
 
 		if (event->reenable) {
-			CROSSCALL_INIT(arg, event);
-			_local_event_enable(&arg);
-			if (arg.first_error)
+			err = sdei_do_local_call(_local_event_enable, event);
+			if (err) {
 				pr_err("Failed to re-enable event %u: %d\n",
-				       event->event_num, arg.first_error);
+				       event->event_num, err);
+			}
 		}
 	}
 	spin_unlock(&sdei_list_lock);
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#18 lore raw

Re: [PATCH v2 11/17] drivers/firmware/sdei: Introduce sdei_do_local_call()

Quoted 10 lines · On Wed, 22 Jul 2020 19:57:34 +1000 Gavin Shan <[email protected]> wrote:

During the CPU hotplug, the private events are registered, enabled or unregistered on the specific CPU. It repeats the same steps:
initializing cross call argument, make function call on local CPU, check the returned error.

This introduces sdei_do_local_call() to cover the first steps. The other benefit is to make CROSSCALL_INIT and struct sdei_crosscall_args are only visible to sddi_do_{cross, local}_call().

One comment inline.

Jonathan

Quoted 9 lines
---
 drivers/firmware/arm_sdei.c | 43 ++++++++++++++++++++++---------------
 1 file changed, 26 insertions(+), 17 deletions(-)
drivers/firmware/arm_sdei.c +0 -0
index 04dc144a8f31..da0e0d5591a8 100644

drivers/firmware/arm_sdei.c struct sdei_crosscall_args { · line 88

Quoted 5 lines
drivers/firmware/arm_sdei.c +1 -1
@@ -85,7 +85,18 @@ struct sdei_crosscall_args {
 		atomic_set(&arg.errors, 0);	\
 	} while (0)
 
-static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
+static inline int sdei_do_local_call(void *fn, struct sdei_event *event)

Can we now give the function parameter it's full type and avoid the nasty looking cast below?

Quoted 68 lines
drivers/firmware/arm_sdei.c +21 -14
+{
+	struct sdei_crosscall_args arg;
+	void (*func)(void *) = fn;
+
+	CROSSCALL_INIT(arg, event);
+	func(&arg);
+
+	return arg.first_error;
+}
+
+static inline int sdei_do_cross_call(void *fn, struct sdei_event *event)
 {
 	struct sdei_crosscall_args arg;
 
@@ -675,7 +686,7 @@ static int sdei_reregister_shared(void)
 static int sdei_cpuhp_down(unsigned int cpu)
 {
 	struct sdei_event *event;
-	struct sdei_crosscall_args arg;
+	int err;
 
 	/* un-register private events */
 	spin_lock(&sdei_list_lock);
@@ -683,12 +694,11 @@ static int sdei_cpuhp_down(unsigned int cpu)
 		if (event->type == SDEI_EVENT_TYPE_SHARED)
 			continue;
 
-		CROSSCALL_INIT(arg, event);
-		/* call the cross-call function locally... */
-		_local_event_unregister(&arg);
-		if (arg.first_error)
+		err = sdei_do_local_call(_local_event_unregister, event);
+		if (err) {
 			pr_err("Failed to unregister event %u: %d\n",
-			       event->event_num, arg.first_error);
+			       event->event_num, err);
+		}
 	}
 	spin_unlock(&sdei_list_lock);
 
@@ -698,7 +708,7 @@ static int sdei_cpuhp_down(unsigned int cpu)
 static int sdei_cpuhp_up(unsigned int cpu)
 {
 	struct sdei_event *event;
-	struct sdei_crosscall_args arg;
+	int err;
 
 	/* re-register/enable private events */
 	spin_lock(&sdei_list_lock);
@@ -707,20 +717,19 @@ static int sdei_cpuhp_up(unsigned int cpu)
 			continue;
 
 		if (event->reregister) {
-			CROSSCALL_INIT(arg, event);
-			/* call the cross-call function locally... */
-			_local_event_register(&arg);
-			if (arg.first_error)
+			err = sdei_do_local_call(_local_event_register, event);
+			if (err) {
 				pr_err("Failed to re-register event %u: %d\n",
-				       event->event_num, arg.first_error);
+				       event->event_num, err);
+			}
 		}
 
 		if (event->reenable) {
-			CROSSCALL_INIT(arg, event);
-			_local_event_enable(&arg);

drivers/firmware/arm_sdei.c static int sdei_cpuhp_up(unsigned int cpu) · line 735

Quoted 10 lines
drivers/firmware/arm_sdei.c +4 -2
-			if (arg.first_error)
+			err = sdei_do_local_call(_local_event_enable, event);
+			if (err) {
 				pr_err("Failed to re-enable event %u: %d\n",
-				       event->event_num, arg.first_error);
+				       event->event_num, err);
+			}
 		}
 	}
 	spin_unlock(&sdei_list_lock);

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#19 lore raw

Re: [PATCH v2 11/17] drivers/firmware/sdei: Introduce sdei_do_local_call()

Hi Jonathan,

Quoted 29 lines · Jonathan Cameron
Quoted 10 lines · On Wed, 22 Jul 2020 19:57:34 +1000 Gavin Shan <[email protected]> wrote:

During the CPU hotplug, the private events are registered, enabled or unregistered on the specific CPU. It repeats the same steps:
initializing cross call argument, make function call on local CPU, check the returned error.

This introduces sdei_do_local_call() to cover the first steps. The other benefit is to make CROSSCALL_INIT and struct sdei_crosscall_args are only visible to sddi_do_{cross, local}_call().

One comment inline.

Jonathan

Quoted 12 lines
---
  drivers/firmware/arm_sdei.c | 43 ++++++++++++++++++++++---------------
  1 file changed, 26 insertions(+), 17 deletions(-)
drivers/firmware/arm_sdei.c +0 -0
index 04dc144a8f31..da0e0d5591a8 100644
@@ -85,7 +85,18 @@ struct sdei_crosscall_args {
  		atomic_set(&arg.errors, 0);	\
  	} while (0)
 
Quoted 6 lines

drivers/firmware/arm_sdei.c struct sdei_crosscall_args { · line 88

Quoted 2 lines
drivers/firmware/arm_sdei.c +1 -1
-static inline int sdei_do_cross_call(void *fn, struct sdei_event * event)
+static inline int sdei_do_local_call(void *fn, struct sdei_event *event)

Can we now give the function parameter it's full type and avoid the nasty looking cast below?

Nice idea. I will use smp_call_func_t defined as below in include/linux/smp.h

typedef void (*smp_call_func_t)(void *info);

Quoted 65 lines
Quoted 65 lines
drivers/firmware/arm_sdei.c +21 -12
+{
+	struct sdei_crosscall_args arg;
+	void (*func)(void *) = fn;
+
+	CROSSCALL_INIT(arg, event);
+	func(&arg);
+
+	return arg.first_error;
+}
+
+static inline int sdei_do_cross_call(void *fn, struct sdei_event *event)
  {
  	struct sdei_crosscall_args arg;
 
@@ -675,7 +686,7 @@ static int sdei_reregister_shared(void)
  static int sdei_cpuhp_down(unsigned int cpu)
  {
  	struct sdei_event *event;
-	struct sdei_crosscall_args arg;
+	int err;
 
  	/* un-register private events */
  	spin_lock(&sdei_list_lock);
@@ -683,12 +694,11 @@ static int sdei_cpuhp_down(unsigned int cpu)
  		if (event->type == SDEI_EVENT_TYPE_SHARED)
  			continue;
 
-		CROSSCALL_INIT(arg, event);
-		/* call the cross-call function locally... */
-		_local_event_unregister(&arg);
-		if (arg.first_error)
+		err = sdei_do_local_call(_local_event_unregister, event);
+		if (err) {
  			pr_err("Failed to unregister event %u: %d\n",
-			       event->event_num, arg.first_error);
+			       event->event_num, err);
+		}
  	}
  	spin_unlock(&sdei_list_lock);
 
@@ -698,7 +708,7 @@ static int sdei_cpuhp_down(unsigned int cpu)
  static int sdei_cpuhp_up(unsigned int cpu)
  {
  	struct sdei_event *event;
-	struct sdei_crosscall_args arg;
+	int err;
 
  	/* re-register/enable private events */
  	spin_lock(&sdei_list_lock);
@@ -707,20 +717,19 @@ static int sdei_cpuhp_up(unsigned int cpu)
  			continue;
 
  		if (event->reregister) {
-			CROSSCALL_INIT(arg, event);
-			/* call the cross-call function locally... */
-			_local_event_register(&arg);
-			if (arg.first_error)
+			err = sdei_do_local_call(_local_event_register, event);
+			if (err) {
  				pr_err("Failed to re-register event %u: %d\n",
-				       event->event_num, arg.first_error);
+				       event->event_num, err);
+			}
  		}
 
Quoted 13 lines

drivers/firmware/arm_sdei.c static int sdei_cpuhp_up(unsigned int cpu) · line 735

Quoted 13 lines
drivers/firmware/arm_sdei.c +4 -4
  		if (event->reenable) {
-			CROSSCALL_INIT(arg, event);
-			_local_event_enable(&arg);
-			if (arg.first_error)
+			err = sdei_do_local_call(_local_event_enable, event);
+			if (err) {
  				pr_err("Failed to re-enable event %u: %d\n",
-				       event->event_num, arg.first_error);
+				       event->event_num, err);
+			}
  		}
  	}
  	spin_unlock(&sdei_list_lock);

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#20 lore raw

PATCH v2 12/17 drivers/firmware/sdei: Remove _sdei_event_register()

In reply to Gavin Shan

The function _sdei_event_register() is called by sdei_event_register() and sdei_device_thaw() as the following functional call chain shows. _sdei_event_register() covers the shared and privte events, but sdei_device_thaw() only covers the shared events. So the logic to cover the private events in _sdei_event_register() isn't needed by sdei_device_thaw().

Similarly, sdei_reregister_event_llocked() covers the shared and private events in the regard of reenablement. The logic to cover the private events isn't needed by sdei_device_thaw() either.

sdei_event_register sdei_device_thaw
_sdei_event_register sdei_reregister_shared
sdei_reregister_event_llocked
_sdei_event_register

This removes _sdei_event_register() and sdei_reregister_event_llocked(). Their logic is moved to sdei_event_register() and sdei_reregister_shared(). This shouldn't cause any logicial changes.

---
v2: Improved commit log
Drop changes to reorder the variables

---
 drivers/firmware/arm_sdei.c | 77 ++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 49 deletions(-)
drivers/firmware/arm_sdei.c +28 -49
index da0e0d5591a8..f4cd9791242f 100644
@@ -575,25 +575,6 @@ static void _local_event_register(void *data)
 	sdei_cross_call_return(arg, err);
 }
 
-static int _sdei_event_register(struct sdei_event *event)
-{
-	int err;
-
-	lockdep_assert_held(&sdei_events_lock);
-
-	if (event->type == SDEI_EVENT_TYPE_SHARED)
-		return sdei_api_event_register(event->event_num,
-					       sdei_entry_point,
-					       event->registered,
-					       SDEI_EVENT_REGISTER_RM_ANY, 0);
-
-	err = sdei_do_cross_call(_local_event_register, event);
-	if (err)
-		sdei_do_cross_call(_local_event_unregister, event);
-
-	return err;
-}
-
 int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 {
 	int err;
@@ -616,7 +597,17 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 	}
 
 	cpus_read_lock();
-	err = _sdei_event_register(event);
+	if (event->type == SDEI_EVENT_TYPE_SHARED) {
+		err = sdei_api_event_register(event->event_num,
+					      sdei_entry_point,
+					      event->registered,
+					      SDEI_EVENT_REGISTER_RM_ANY, 0);
+	} else {
+		err = sdei_do_cross_call(_local_event_register, event);
+		if (err)
+			sdei_do_cross_call(_local_event_unregister, event);
+	}
+
 	if (err) {
 		sdei_event_destroy(event);
 		pr_warn("Failed to register event %u: %d\n", event_num, err);
@@ -633,33 +624,6 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 	return err;
 }
 
-static int sdei_reregister_event_llocked(struct sdei_event *event)
-{
-	int err;
-
-	lockdep_assert_held(&sdei_events_lock);
-	lockdep_assert_held(&sdei_list_lock);
-
-	err = _sdei_event_register(event);
-	if (err) {
-		pr_err("Failed to re-register event %u\n", event->event_num);
-		sdei_event_destroy_llocked(event);
-		return err;
-	}
-
-	if (event->reenable) {
-		if (event->type == SDEI_EVENT_TYPE_SHARED)
-			err = sdei_api_event_enable(event->event_num);
-		else
-			err = sdei_do_cross_call(_local_event_enable, event);
-	}
-
-	if (err)
-		pr_err("Failed to re-enable event %u\n", event->event_num);
-
-	return err;
-}
-
 static int sdei_reregister_shared(void)
 {
 	int err = 0;
@@ -672,9 +636,24 @@ static int sdei_reregister_shared(void)
 			continue;
 
 		if (event->reregister) {
-			err = sdei_reregister_event_llocked(event);
-			if (err)
+			err = sdei_api_event_register(event->event_num,
+					sdei_entry_point, event->registered,
+					SDEI_EVENT_REGISTER_RM_ANY, 0);
+			if (err) {
+				sdei_event_destroy_llocked(event);
+				pr_err("Failed to re-register event %u\n",
+				       event->event_num);
 				break;
+			}
+		}
+
+		if (event->reenable) {
+			err = sdei_api_event_enable(event->event_num);
+			if (err) {
+				pr_err("Failed to re-enable event %u\n",
+				       event->event_num);
+				break;
+			}
 		}
 	}
 	spin_unlock(&sdei_list_lock);
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
Reviewed-by on v2 12/17
#21 lore raw

Re: [PATCH v2 12/17] drivers/firmware/sdei: Remove _sdei_event_register()

Quoted 3 lines · On Wed, 22 Jul 2020 19:57:35 +1000 Gavin Shan <[email protected]> wrote:

The function _sdei_event_register() is called by sdei_event_register() and sdei_device_thaw() as the following functional call chain shows. _sdei_event_register() covers the shared and privte events, but

private

Quoted 13 lines

sdei_device_thaw() only covers the shared events. So the logic to cover the private events in _sdei_event_register() isn't needed by sdei_device_thaw().

Similarly, sdei_reregister_event_llocked() covers the shared and private events in the regard of reenablement. The logic to cover the private events isn't needed by sdei_device_thaw() either.

sdei_event_register sdei_device_thaw
_sdei_event_register sdei_reregister_shared
sdei_reregister_event_llocked
_sdei_event_register

Quoted 5 lines

This removes _sdei_event_register() and sdei_reregister_event_llocked(). Their logic is moved to sdei_event_register() and sdei_reregister_shared(). This shouldn't cause any logicial changes.

Otherwise looks good to me.

Quoted 107 lines

---
v2: Improved commit log
Drop changes to reorder the variables

---
 drivers/firmware/arm_sdei.c | 77 ++++++++++++++-----------------------
 1 file changed, 28 insertions(+), 49 deletions(-)
drivers/firmware/arm_sdei.c +21 -49
index da0e0d5591a8..f4cd9791242f 100644
@@ -575,25 +575,6 @@ static void _local_event_register(void *data)
 	sdei_cross_call_return(arg, err);
 }
 
-static int _sdei_event_register(struct sdei_event *event)
-{
-	int err;
-
-	lockdep_assert_held(&sdei_events_lock);
-
-	if (event->type == SDEI_EVENT_TYPE_SHARED)
-		return sdei_api_event_register(event->event_num,
-					       sdei_entry_point,
-					       event->registered,
-					       SDEI_EVENT_REGISTER_RM_ANY, 0);
-
-	err = sdei_do_cross_call(_local_event_register, event);
-	if (err)
-		sdei_do_cross_call(_local_event_unregister, event);
-
-	return err;
-}
-
 int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 {
 	int err;
@@ -616,7 +597,17 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 	}
 
 	cpus_read_lock();
-	err = _sdei_event_register(event);
+	if (event->type == SDEI_EVENT_TYPE_SHARED) {
+		err = sdei_api_event_register(event->event_num,
+					      sdei_entry_point,
+					      event->registered,
+					      SDEI_EVENT_REGISTER_RM_ANY, 0);
+	} else {
+		err = sdei_do_cross_call(_local_event_register, event);
+		if (err)
+			sdei_do_cross_call(_local_event_unregister, event);
+	}
+
 	if (err) {
 		sdei_event_destroy(event);
 		pr_warn("Failed to register event %u: %d\n", event_num, err);
@@ -633,33 +624,6 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 	return err;
 }
 
-static int sdei_reregister_event_llocked(struct sdei_event *event)
-{
-	int err;
-
-	lockdep_assert_held(&sdei_events_lock);
-	lockdep_assert_held(&sdei_list_lock);
-
-	err = _sdei_event_register(event);
-	if (err) {
-		pr_err("Failed to re-register event %u\n", event->event_num);
-		sdei_event_destroy_llocked(event);
-		return err;
-	}
-
-	if (event->reenable) {
-		if (event->type == SDEI_EVENT_TYPE_SHARED)
-			err = sdei_api_event_enable(event->event_num);
-		else
-			err = sdei_do_cross_call(_local_event_enable, event);
-	}
-
-	if (err)
-		pr_err("Failed to re-enable event %u\n", event->event_num);
-
-	return err;
-}
-
 static int sdei_reregister_shared(void)
 {
 	int err = 0;
@@ -672,9 +636,24 @@ static int sdei_reregister_shared(void)
 			continue;
 
 		if (event->reregister) {
-			err = sdei_reregister_event_llocked(event);
-			if (err)
+			err = sdei_api_event_register(event->event_num,
+					sdei_entry_point, event->registered,
+					SDEI_EVENT_REGISTER_RM_ANY, 0);
+			if (err) {
+				sdei_event_destroy_llocked(event);
+				pr_err("Failed to re-register event %u\n",
+				       event->event_num);
 				break;
+			}
+		}
+

drivers/firmware/arm_sdei.c static int sdei_reregister_shared(void) · line 659

Quoted 10 lines
drivers/firmware/arm_sdei.c +7 -0
+		if (event->reenable) {
+			err = sdei_api_event_enable(event->event_num);
+			if (err) {
+				pr_err("Failed to re-enable event %u\n",
+				       event->event_num);
+				break;
+			}
 		}
 	}
 	spin_unlock(&sdei_list_lock);

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#22 lore raw

Re: [PATCH v2 12/17] drivers/firmware/sdei: Remove _sdei_event_register()

Hi Jonathan,

Quoted 9 lines · Jonathan Cameron
Quoted 3 lines · On Wed, 22 Jul 2020 19:57:35 +1000 Gavin Shan <[email protected]> wrote:

The function _sdei_event_register() is called by sdei_event_register() and sdei_device_thaw() as the following functional call chain shows. _sdei_event_register() covers the shared and privte events, but

private

Will be fixed in v3.

Quoted 17 lines
Quoted 17 lines

sdei_device_thaw() only covers the shared events. So the logic to cover the private events in _sdei_event_register() isn't needed by sdei_device_thaw().

Similarly, sdei_reregister_event_llocked() covers the shared and private events in the regard of reenablement. The logic to cover the private events isn't needed by sdei_device_thaw() either.

sdei_event_register sdei_device_thaw
_sdei_event_register sdei_reregister_shared
sdei_reregister_event_llocked
_sdei_event_register

This removes _sdei_event_register() and sdei_reregister_event_llocked(). Their logic is moved to sdei_event_register() and sdei_reregister_shared(). This shouldn't cause any logicial changes.

Quoted 5 lines
Quoted 1 line

Otherwise looks good to me.

Will be picked up in v3.

Quoted 109 lines
Quoted 109 lines

---
v2: Improved commit log
Drop changes to reorder the variables

---
  drivers/firmware/arm_sdei.c | 77 ++++++++++++++-----------------------
  1 file changed, 28 insertions(+), 49 deletions(-)
drivers/firmware/arm_sdei.c +23 -49
index da0e0d5591a8..f4cd9791242f 100644
@@ -575,25 +575,6 @@ static void _local_event_register(void *data)
  	sdei_cross_call_return(arg, err);
  }
 
-static int _sdei_event_register(struct sdei_event *event)
-{
-	int err;
-
-	lockdep_assert_held(&sdei_events_lock);
-
-	if (event->type == SDEI_EVENT_TYPE_SHARED)
-		return sdei_api_event_register(event->event_num,
-					       sdei_entry_point,
-					       event->registered,
-					       SDEI_EVENT_REGISTER_RM_ANY, 0);
-
-	err = sdei_do_cross_call(_local_event_register, event);
-	if (err)
-		sdei_do_cross_call(_local_event_unregister, event);
-
-	return err;
-}
-
  int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
  {
  	int err;
@@ -616,7 +597,17 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
  	}
 
  	cpus_read_lock();
-	err = _sdei_event_register(event);
+	if (event->type == SDEI_EVENT_TYPE_SHARED) {
+		err = sdei_api_event_register(event->event_num,
+					      sdei_entry_point,
+					      event->registered,
+					      SDEI_EVENT_REGISTER_RM_ANY, 0);
+	} else {
+		err = sdei_do_cross_call(_local_event_register, event);
+		if (err)
+			sdei_do_cross_call(_local_event_unregister, event);
+	}
+
  	if (err) {
  		sdei_event_destroy(event);
  		pr_warn("Failed to register event %u: %d\n", event_num, err);
@@ -633,33 +624,6 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
  	return err;
  }
 
-static int sdei_reregister_event_llocked(struct sdei_event *event)
-{
-	int err;
-
-	lockdep_assert_held(&sdei_events_lock);
-	lockdep_assert_held(&sdei_list_lock);
-
-	err = _sdei_event_register(event);
-	if (err) {
-		pr_err("Failed to re-register event %u\n", event->event_num);
-		sdei_event_destroy_llocked(event);
-		return err;
-	}
-
-	if (event->reenable) {
-		if (event->type == SDEI_EVENT_TYPE_SHARED)
-			err = sdei_api_event_enable(event->event_num);
-		else
-			err = sdei_do_cross_call(_local_event_enable, event);
-	}
-
-	if (err)
-		pr_err("Failed to re-enable event %u\n", event->event_num);
-
-	return err;
-}
-
  static int sdei_reregister_shared(void)
  {
  	int err = 0;
@@ -672,9 +636,24 @@ static int sdei_reregister_shared(void)
  			continue;
 
  		if (event->reregister) {
-			err = sdei_reregister_event_llocked(event);
-			if (err)
+			err = sdei_api_event_register(event->event_num,
+					sdei_entry_point, event->registered,
+					SDEI_EVENT_REGISTER_RM_ANY, 0);
+			if (err) {
+				sdei_event_destroy_llocked(event);
+				pr_err("Failed to re-register event %u\n",
+				       event->event_num);
  				break;
+			}
+		}
+
+		if (event->reenable) {
+			err = sdei_api_event_enable(event->event_num);
Quoted 8 lines

drivers/firmware/arm_sdei.c static int sdei_reregister_shared(void) · line 659

Quoted 8 lines
drivers/firmware/arm_sdei.c +5 -0
+			if (err) {
+				pr_err("Failed to re-enable event %u\n",
+				       event->event_num);
+				break;
+			}
  		}
  	}
  	spin_unlock(&sdei_list_lock);

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#23 lore raw

PATCH v2 13/17 drivers/firmware/sdei: Remove _sdei_event_unregister()

In reply to Gavin Shan

_sdei_event_unregister() is called by sdei_event_unregister() and sdei_device_freeze(). _sdei_event_unregister() covers the shared and private events, but sdei_device_freeze() only covers the shared events. So the logic to cover the private events isn't needed by sdei_device_freeze().

sdei_event_unregister sdei_device_freeze
_sdei_event_unregister sdei_unregister_shared
_sdei_event_unregister

This removes _sdei_event_unregister(). Its logic is moved to its callers accordingly. This shouldn't cause any logicial changes.

---
v2: Improved change log

---
 drivers/firmware/arm_sdei.c | 18 ++++++------------
 1 file changed, 6 insertions(+), 12 deletions(-)
drivers/firmware/arm_sdei.c +6 -12
index f4cd9791242f..a52dcff59a20 100644
@@ -486,16 +486,6 @@ static void _local_event_unregister(void *data)
 	sdei_cross_call_return(arg, err);
 }
 
-static int _sdei_event_unregister(struct sdei_event *event)
-{
-	lockdep_assert_held(&sdei_events_lock);
-
-	if (event->type == SDEI_EVENT_TYPE_SHARED)
-		return sdei_api_event_unregister(event->event_num);
-
-	return sdei_do_cross_call(_local_event_unregister, event);
-}
-
 int sdei_event_unregister(u32 event_num)
 {
 	int err;
@@ -516,7 +506,11 @@ int sdei_event_unregister(u32 event_num)
 	event->reenable = false;
 	spin_unlock(&sdei_list_lock);
 
-	err = _sdei_event_unregister(event);
+	if (event->type == SDEI_EVENT_TYPE_SHARED)
+		err = sdei_api_event_unregister(event->event_num);
+	else
+		err = sdei_do_cross_call(_local_event_unregister, event);
+
 	if (err)
 		goto out;
 
@@ -541,7 +535,7 @@ static int sdei_unregister_shared(void)
 		if (event->type != SDEI_EVENT_TYPE_SHARED)
 			continue;
 
-		err = _sdei_event_unregister(event);
+		err = sdei_api_event_unregister(event->event_num);
 		if (err)
 			break;
 	}
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#24 lore raw

PATCH v2 14/17 drivers/firmware/sdei: Move struct sdei_event to header file

In reply to Gavin Shan

This moves struct sdei_event to the header file so that it can be dereferenced by external modules. This is needed by the code to virtualize SDEI functionality, as part of the arm64/kvm.

---
v2: Derived from "drivers/firmware/sdei: Identify event by struct"

---
 drivers/firmware/arm_sdei.c | 20 ------------
 include/linux/arm_sdei.h    | 61 ++++++++++++++++++++++++-------------
 2 files changed, 40 insertions(+), 41 deletions(-)
drivers/firmware/arm_sdei.c +0 -20
index a52dcff59a20..bdd2de0149c0 100644
@@ -44,26 +44,6 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
 /* entry point from firmware to arch asm code */
 static unsigned long sdei_entry_point;
 
-struct sdei_event {
-	/* These three are protected by the sdei_list_lock */
-	struct list_head	list;
-	bool			reregister;
-	bool			reenable;
-
-	u32			event_num;
-	u8			type;
-	u8			priority;
-
-	/* This pointer is handed to firmware as the event argument. */
-	union {
-		/* Shared events */
-		struct sdei_registered_event *registered;
-
-		/* CPU private events */
-		struct sdei_registered_event __percpu *private_registered;
-	};
-};
-
 /* Take the mutex for any API call or modification. Take the mutex first. */
 static DEFINE_MUTEX(sdei_events_lock);
 
include/linux/arm_sdei.h +40 -21

73 lines not on this page · raw message

Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#25 lore raw

Re: [PATCH v2 14/17] drivers/firmware/sdei: Move struct sdei_event to header file

Quoted 5 lines · On Wed, 22 Jul 2020 19:57:37 +1000 Gavin Shan <[email protected]> wrote:

This moves struct sdei_event to the header file so that it can be dereferenced by external modules. This is needed by the code to virtualize SDEI functionality, as part of the arm64/kvm.

Hi Gavin,

One question inline.

Jonathan

Quoted 58 lines

---
v2: Derived from "drivers/firmware/sdei: Identify event by struct"

---
 drivers/firmware/arm_sdei.c | 20 ------------
 include/linux/arm_sdei.h    | 61 ++++++++++++++++++++++++-------------
 2 files changed, 40 insertions(+), 41 deletions(-)
drivers/firmware/arm_sdei.c +0 -20
index a52dcff59a20..bdd2de0149c0 100644
@@ -44,26 +44,6 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
 /* entry point from firmware to arch asm code */
 static unsigned long sdei_entry_point;
 
-struct sdei_event {
-	/* These three are protected by the sdei_list_lock */
-	struct list_head	list;
-	bool			reregister;
-	bool			reenable;
-
-	u32			event_num;
-	u8			type;
-	u8			priority;
-
-	/* This pointer is handed to firmware as the event argument. */
-	union {
-		/* Shared events */
-		struct sdei_registered_event *registered;
-
-		/* CPU private events */
-		struct sdei_registered_event __percpu *private_registered;
-	};
-};
-
 /* Take the mutex for any API call or modification. Take the mutex first. */
 static DEFINE_MUTEX(sdei_events_lock);
 
include/linux/arm_sdei.h +12 -0
index 0a241c5c911d..fdc2f868d84b 100644
@@ -22,6 +22,46 @@
  */
 typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
 
+/*
+ * This struct represents an event that has been registered. The driver
+ * maintains a list of all events, and which ones are registered. (Private
+ * events have one entry in the list, but are registered on each CPU).
+ * A pointer to this struct is passed to firmware, and back to the event
+ * handler. The event handler can then use this to invoke the registered
+ * callback, without having to walk the list.
+ *
+ * For CPU private events, this structure is per-cpu.
+ */
+struct sdei_registered_event {
+	/* For use by arch code: */

include/linux/arm_sdei.h line 46

Quoted 10 lines
include/linux/arm_sdei.h +10 -0
+	struct pt_regs          interrupted_regs;
+
+	sdei_event_callback	*callback;
+	void			*callback_arg;
+	u32			 event_num;
+	u8			 priority;
+};
+
+struct sdei_event {
+	/* These three are protected by the sdei_list_lock */

As this patch leaves the sdei_list_lock as local to arm_sdei.c, is this comment still valid?

Quoted 39 lines
include/linux/arm_sdei.h +18 -14
+	struct list_head	list;
+	bool			reregister;
+	bool			reenable;
+
+	u32			event_num;
+	u8			type;
+	u8			priority;
+
+	/* This pointer is handed to firmware as the event argument. */
+	union {
+		/* Shared events */
+		struct sdei_registered_event *registered;
+
+		/* CPU private events */
+		struct sdei_registered_event __percpu *private_registered;
+	};
+};
+
 /*
  * Register your callback to claim an event. The event must be described
  * by firmware.
@@ -51,27 +91,6 @@ static inline int sdei_mask_local_cpu(void) { return 0; }
 static inline int sdei_unmask_local_cpu(void) { return 0; }
 #endif /* CONFIG_ARM_SDE_INTERFACE */
 
-
-/*
- * This struct represents an event that has been registered. The driver
- * maintains a list of all events, and which ones are registered. (Private
- * events have one entry in the list, but are registered on each CPU).
- * A pointer to this struct is passed to firmware, and back to the event
- * handler. The event handler can then use this to invoke the registered
- * callback, without having to walk the list.
- *
- * For CPU private events, this structure is per-cpu.
- */
-struct sdei_registered_event {
-	/* For use by arch code: */
-	struct pt_regs          interrupted_regs;

include/linux/arm_sdei.h static inline int sdei_mask_local_cpu(void) { return 0; } · line 96

Quoted 10 lines
include/linux/arm_sdei.h +0 -7
-
-	sdei_event_callback	*callback;
-	void			*callback_arg;
-	u32			 event_num;
-	u8			 priority;
-};
-
 /* The arch code entry point should then call this when an event arrives. */
 int notrace sdei_event_handler(struct pt_regs *regs,
 			       struct sdei_registered_event *arg);

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#26 lore raw

Re: [PATCH v2 14/17] drivers/firmware/sdei: Move struct sdei_event to header file

Hi Jonathan,

Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:37 +1000 Gavin Shan <[email protected]> wrote:

This moves struct sdei_event to the header file so that it can be dereferenced by external modules. This is needed by the code to virtualize SDEI functionality, as part of the arm64/kvm.

[...]

Quoted 62 lines
Quoted 62 lines

---
v2: Derived from "drivers/firmware/sdei: Identify event by struct"

---
  drivers/firmware/arm_sdei.c | 20 ------------
  include/linux/arm_sdei.h    | 61 ++++++++++++++++++++++++-------------
  2 files changed, 40 insertions(+), 41 deletions(-)
drivers/firmware/arm_sdei.c +0 -20
index a52dcff59a20..bdd2de0149c0 100644
@@ -44,26 +44,6 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
  /* entry point from firmware to arch asm code */
  static unsigned long sdei_entry_point;
 
-struct sdei_event {
-	/* These three are protected by the sdei_list_lock */
-	struct list_head	list;
-	bool			reregister;
-	bool			reenable;
-
-	u32			event_num;
-	u8			type;
-	u8			priority;
-
-	/* This pointer is handed to firmware as the event argument. */
-	union {
-		/* Shared events */
-		struct sdei_registered_event *registered;
-
-		/* CPU private events */
-		struct sdei_registered_event __percpu *private_registered;
-	};
-};
-
  /* Take the mutex for any API call or modification. Take the mutex first. */
  static DEFINE_MUTEX(sdei_events_lock);
 
include/linux/arm_sdei.h +16 -0
index 0a241c5c911d..fdc2f868d84b 100644
@@ -22,6 +22,46 @@
   */
  typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
 
+/*
+ * This struct represents an event that has been registered. The driver
+ * maintains a list of all events, and which ones are registered. (Private
+ * events have one entry in the list, but are registered on each CPU).
+ * A pointer to this struct is passed to firmware, and back to the event
+ * handler. The event handler can then use this to invoke the registered
+ * callback, without having to walk the list.
+ *
+ * For CPU private events, this structure is per-cpu.
+ */
+struct sdei_registered_event {
+	/* For use by arch code: */
+	struct pt_regs          interrupted_regs;
+
+	sdei_event_callback	*callback;
+	void			*callback_arg;
Quoted 9 lines

include/linux/arm_sdei.h line 46

Quoted 6 lines
include/linux/arm_sdei.h +6 -0
+	u32			 event_num;
+	u8			 priority;
+};
+
+struct sdei_event {
+	/* These three are protected by the sdei_list_lock */

As this patch leaves the sdei_list_lock as local to arm_sdei.c, is this comment still valid?

Yes, the comment is still valid. @sdei_list_lock is used to protect the linked list (@sdei_list) and all elements (@event) in the list. For example, the lock is taken before updating @event->reenabled in function sdei_event_enable().

Quoted 41 lines
Quoted 41 lines
include/linux/arm_sdei.h +18 -16
+	struct list_head	list;
+	bool			reregister;
+	bool			reenable;
+
+	u32			event_num;
+	u8			type;
+	u8			priority;
+
+	/* This pointer is handed to firmware as the event argument. */
+	union {
+		/* Shared events */
+		struct sdei_registered_event *registered;
+
+		/* CPU private events */
+		struct sdei_registered_event __percpu *private_registered;
+	};
+};
+
  /*
   * Register your callback to claim an event. The event must be described
   * by firmware.
@@ -51,27 +91,6 @@ static inline int sdei_mask_local_cpu(void) { return 0; }
  static inline int sdei_unmask_local_cpu(void) { return 0; }
  #endif /* CONFIG_ARM_SDE_INTERFACE */
 
-
-/*
- * This struct represents an event that has been registered. The driver
- * maintains a list of all events, and which ones are registered. (Private
- * events have one entry in the list, but are registered on each CPU).
- * A pointer to this struct is passed to firmware, and back to the event
- * handler. The event handler can then use this to invoke the registered
- * callback, without having to walk the list.
- *
- * For CPU private events, this structure is per-cpu.
- */
-struct sdei_registered_event {
-	/* For use by arch code: */
-	struct pt_regs          interrupted_regs;
-
-	sdei_event_callback	*callback;
Quoted 8 lines

include/linux/arm_sdei.h static inline int sdei_mask_local_cpu(void) { return 0; } · line 96

Quoted 8 lines
include/linux/arm_sdei.h +0 -5
-	void			*callback_arg;
-	u32			 event_num;
-	u8			 priority;
-};
-
  /* The arch code entry point should then call this when an event arrives. */
  int notrace sdei_event_handler(struct pt_regs *regs,
  			       struct sdei_registered_event *arg); 

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#27 lore raw

Re: [PATCH v2 14/17] drivers/firmware/sdei: Move struct sdei_event to header file

Quoted 86 lines · On Mon, 27 Jul 2020 10:46:52 +1000 Gavin Shan <[email protected]> wrote:

Hi Jonathan,

Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:37 +1000 Gavin Shan <[email protected]> wrote:

This moves struct sdei_event to the header file so that it can be dereferenced by external modules. This is needed by the code to virtualize SDEI functionality, as part of the arm64/kvm.

[...]

Quoted 62 lines
Quoted 62 lines

---
v2: Derived from "drivers/firmware/sdei: Identify event by struct"

---
  drivers/firmware/arm_sdei.c | 20 ------------
  include/linux/arm_sdei.h    | 61 ++++++++++++++++++++++++-------------
  2 files changed, 40 insertions(+), 41 deletions(-)
drivers/firmware/arm_sdei.c +0 -20
index a52dcff59a20..bdd2de0149c0 100644
@@ -44,26 +44,6 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
  /* entry point from firmware to arch asm code */
  static unsigned long sdei_entry_point;
 
-struct sdei_event {
-	/* These three are protected by the sdei_list_lock */
-	struct list_head	list;
-	bool			reregister;
-	bool			reenable;
-
-	u32			event_num;
-	u8			type;
-	u8			priority;
-
-	/* This pointer is handed to firmware as the event argument. */
-	union {
-		/* Shared events */
-		struct sdei_registered_event *registered;
-
-		/* CPU private events */
-		struct sdei_registered_event __percpu *private_registered;
-	};
-};
-
  /* Take the mutex for any API call or modification. Take the mutex first. */
  static DEFINE_MUTEX(sdei_events_lock);
 
include/linux/arm_sdei.h +16 -0
index 0a241c5c911d..fdc2f868d84b 100644
@@ -22,6 +22,46 @@
   */
  typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
 
+/*
+ * This struct represents an event that has been registered. The driver
+ * maintains a list of all events, and which ones are registered. (Private
+ * events have one entry in the list, but are registered on each CPU).
+ * A pointer to this struct is passed to firmware, and back to the event
+ * handler. The event handler can then use this to invoke the registered
+ * callback, without having to walk the list.
+ *
+ * For CPU private events, this structure is per-cpu.
+ */
+struct sdei_registered_event {
+	/* For use by arch code: */
+	struct pt_regs          interrupted_regs;
+
+	sdei_event_callback	*callback;
+	void			*callback_arg;
Quoted 9 lines

include/linux/arm_sdei.h line 46

Quoted 6 lines
include/linux/arm_sdei.h +6 -0
+	u32			 event_num;
+	u8			 priority;
+};
+
+struct sdei_event {
+	/* These three are protected by the sdei_list_lock */  

As this patch leaves the sdei_list_lock as local to arm_sdei.c, is this comment still valid?

Quoted 4 lines

Yes, the comment is still valid. @sdei_list_lock is used to protect the linked list (@sdei_list) and all elements (@event) in the list. For example, the lock is taken before updating @event->reenabled in function sdei_event_enable().

OK. I assume your new KVM code will simply not touch the list. That's a bit messy from a 'scope' point of view, but I guess it's not worth doing something like:

struct sdei_event_opaque {
	struct list_head list;
	// Whatever else the kvm code doesn't need
	struct sdei_event {
		// The bits that you want to expose more widely (i.e. use in the
		// kvm code.  + you ensure that code only ever sees this internal structure.

	};

}

Quoted 45 lines
Quoted 45 lines
Quoted 45 lines
include/linux/arm_sdei.h +18 -19
+	struct list_head	list;
+	bool			reregister;
+	bool			reenable;
+
+	u32			event_num;
+	u8			type;
+	u8			priority;
+
+	/* This pointer is handed to firmware as the event argument. */
+	union {
+		/* Shared events */
+		struct sdei_registered_event *registered;
+
+		/* CPU private events */
+		struct sdei_registered_event __percpu *private_registered;
+	};
+};
+
  /*
   * Register your callback to claim an event. The event must be described
   * by firmware.
@@ -51,27 +91,6 @@ static inline int sdei_mask_local_cpu(void) { return 0; }
  static inline int sdei_unmask_local_cpu(void) { return 0; }
  #endif /* CONFIG_ARM_SDE_INTERFACE */
 
-
-/*
- * This struct represents an event that has been registered. The driver
- * maintains a list of all events, and which ones are registered. (Private
- * events have one entry in the list, but are registered on each CPU).
- * A pointer to this struct is passed to firmware, and back to the event
- * handler. The event handler can then use this to invoke the registered
- * callback, without having to walk the list.
- *
- * For CPU private events, this structure is per-cpu.
- */
-struct sdei_registered_event {
-	/* For use by arch code: */
-	struct pt_regs          interrupted_regs;
-
-	sdei_event_callback	*callback;
-	void			*callback_arg;
-	u32			 event_num;
-	u8			 priority;
Quoted 9 lines
Quoted 5 lines

include/linux/arm_sdei.h static inline int sdei_mask_local_cpu(void) { return 0; } · line 96

Quoted 5 lines
include/linux/arm_sdei.h +0 -2
-};
-
  /* The arch code entry point should then call this when an event arrives. */
  int notrace sdei_event_handler(struct pt_regs *regs,
  			       struct sdei_registered_event *arg);   

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#28 lore raw

Re: [PATCH v2 14/17] drivers/firmware/sdei: Move struct sdei_event to header file

Hi Jonathan,

Quoted 103 lines · Jonathan Cameron
Quoted 84 lines · On Mon, 27 Jul 2020 10:46:52 +1000 Gavin Shan <[email protected]> wrote:
Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:37 +1000 Gavin Shan <[email protected]> wrote:

This moves struct sdei_event to the header file so that it can be dereferenced by external modules. This is needed by the code to virtualize SDEI functionality, as part of the arm64/kvm.

[...]

Quoted 62 lines
Quoted 62 lines

---
v2: Derived from "drivers/firmware/sdei: Identify event by struct"

---
   drivers/firmware/arm_sdei.c | 20 ------------
   include/linux/arm_sdei.h    | 61 ++++++++++++++++++++++++-------------
   2 files changed, 40 insertions(+), 41 deletions(-)
drivers/firmware/arm_sdei.c +0 -20
index a52dcff59a20..bdd2de0149c0 100644
@@ -44,26 +44,6 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
   /* entry point from firmware to arch asm code */
   static unsigned long sdei_entry_point;
 
-struct sdei_event {
-	/* These three are protected by the sdei_list_lock */
-	struct list_head	list;
-	bool			reregister;
-	bool			reenable;
-
-	u32			event_num;
-	u8			type;
-	u8			priority;
-
-	/* This pointer is handed to firmware as the event argument. */
-	union {
-		/* Shared events */
-		struct sdei_registered_event *registered;
-
-		/* CPU private events */
-		struct sdei_registered_event __percpu *private_registered;
-	};
-};
-
   /* Take the mutex for any API call or modification. Take the mutex first. */
   static DEFINE_MUTEX(sdei_events_lock);
 
include/linux/arm_sdei.h +16 -0
index 0a241c5c911d..fdc2f868d84b 100644
@@ -22,6 +22,46 @@
    */
   typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
 
+/*
+ * This struct represents an event that has been registered. The driver
+ * maintains a list of all events, and which ones are registered. (Private
+ * events have one entry in the list, but are registered on each CPU).
+ * A pointer to this struct is passed to firmware, and back to the event
+ * handler. The event handler can then use this to invoke the registered
+ * callback, without having to walk the list.
+ *
+ * For CPU private events, this structure is per-cpu.
+ */
+struct sdei_registered_event {
+	/* For use by arch code: */
+	struct pt_regs          interrupted_regs;
+
+	sdei_event_callback	*callback;
+	void			*callback_arg;
Quoted 9 lines

include/linux/arm_sdei.h line 46

Quoted 6 lines
include/linux/arm_sdei.h +6 -0
+	u32			 event_num;
+	u8			 priority;
+};
+
+struct sdei_event {
+	/* These three are protected by the sdei_list_lock */

As this patch leaves the sdei_list_lock as local to arm_sdei.c, is this comment still valid?

Quoted 4 lines

Yes, the comment is still valid. @sdei_list_lock is used to protect the linked list (@sdei_list) and all elements (@event) in the list. For example, the lock is taken before updating @event->reenabled in function sdei_event_enable().

OK. I assume your new KVM code will simply not touch the list. That's a bit messy from a 'scope' point of view, but I guess it's not worth doing something like:

struct sdei_event_opaque {
	struct list_head list;
	// Whatever else the kvm code doesn't need
	struct sdei_event {
		// The bits that you want to expose more widely (i.e. use in the
		// kvm code.  + you ensure that code only ever sees this internal structure.

	};
Quoted 1 line

}

Yes, your assumption is correct. The list is still managed by drivers/firmware/arm_sdei.c and it's invisible to the new KVM code for SDEI virtualization.

It's worthy to hide those fields in "struct sdei_event" from external by introducing another struct, from the point of "scope". But it's not free to maintain another struct in this case. I would say lets avoid introducing another struct if you agree.

Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
Quoted 42 lines
include/linux/arm_sdei.h +18 -16
+	struct list_head	list;
+	bool			reregister;
+	bool			reenable;
+
+	u32			event_num;
+	u8			type;
+	u8			priority;
+
+	/* This pointer is handed to firmware as the event argument. */
+	union {
+		/* Shared events */
+		struct sdei_registered_event *registered;
+
+		/* CPU private events */
+		struct sdei_registered_event __percpu *private_registered;
+	};
+};
+
   /*
    * Register your callback to claim an event. The event must be described
    * by firmware.
@@ -51,27 +91,6 @@ static inline int sdei_mask_local_cpu(void) { return 0; }
   static inline int sdei_unmask_local_cpu(void) { return 0; }
   #endif /* CONFIG_ARM_SDE_INTERFACE */
 
-
-/*
- * This struct represents an event that has been registered. The driver
- * maintains a list of all events, and which ones are registered. (Private
- * events have one entry in the list, but are registered on each CPU).
- * A pointer to this struct is passed to firmware, and back to the event
- * handler. The event handler can then use this to invoke the registered
- * callback, without having to walk the list.
- *
- * For CPU private events, this structure is per-cpu.
- */
-struct sdei_registered_event {
-	/* For use by arch code: */
-	struct pt_regs          interrupted_regs;
-
-	sdei_event_callback	*callback;
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/linux/arm_sdei.h static inline int sdei_mask_local_cpu(void) { return 0; } · line 96

Quoted 8 lines
include/linux/arm_sdei.h +0 -5
-	void			*callback_arg;
-	u32			 event_num;
-	u8			 priority;
-};
-
   /* The arch code entry point should then call this when an event arrives. */
   int notrace sdei_event_handler(struct pt_regs *regs,
   			       struct sdei_registered_event *arg);

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#29 lore raw

Re: [PATCH v2 14/17] drivers/firmware/sdei: Move struct sdei_event to header file

Quoted 108 lines · On Mon, 27 Jul 2020 19:59:24 +1000 Gavin Shan <[email protected]> wrote:

Hi Jonathan,

Quoted 103 lines · Jonathan Cameron
Quoted 84 lines · On Mon, 27 Jul 2020 10:46:52 +1000 Gavin Shan <[email protected]> wrote:
Quoted 8 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:37 +1000 Gavin Shan <[email protected]> wrote:

This moves struct sdei_event to the header file so that it can be dereferenced by external modules. This is needed by the code to virtualize SDEI functionality, as part of the arm64/kvm.

[...]

Quoted 62 lines
Quoted 62 lines

---
v2: Derived from "drivers/firmware/sdei: Identify event by struct"

---
   drivers/firmware/arm_sdei.c | 20 ------------
   include/linux/arm_sdei.h    | 61 ++++++++++++++++++++++++-------------
   2 files changed, 40 insertions(+), 41 deletions(-)
drivers/firmware/arm_sdei.c +0 -20
index a52dcff59a20..bdd2de0149c0 100644
@@ -44,26 +44,6 @@ static asmlinkage void (*sdei_firmware_call)(unsigned long function_id,
   /* entry point from firmware to arch asm code */
   static unsigned long sdei_entry_point;
 
-struct sdei_event {
-	/* These three are protected by the sdei_list_lock */
-	struct list_head	list;
-	bool			reregister;
-	bool			reenable;
-
-	u32			event_num;
-	u8			type;
-	u8			priority;
-
-	/* This pointer is handed to firmware as the event argument. */
-	union {
-		/* Shared events */
-		struct sdei_registered_event *registered;
-
-		/* CPU private events */
-		struct sdei_registered_event __percpu *private_registered;
-	};
-};
-
   /* Take the mutex for any API call or modification. Take the mutex first. */
   static DEFINE_MUTEX(sdei_events_lock);
 
include/linux/arm_sdei.h +16 -0
index 0a241c5c911d..fdc2f868d84b 100644
@@ -22,6 +22,46 @@
    */
   typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
 
+/*
+ * This struct represents an event that has been registered. The driver
+ * maintains a list of all events, and which ones are registered. (Private
+ * events have one entry in the list, but are registered on each CPU).
+ * A pointer to this struct is passed to firmware, and back to the event
+ * handler. The event handler can then use this to invoke the registered
+ * callback, without having to walk the list.
+ *
+ * For CPU private events, this structure is per-cpu.
+ */
+struct sdei_registered_event {
+	/* For use by arch code: */
+	struct pt_regs          interrupted_regs;
+
+	sdei_event_callback	*callback;
+	void			*callback_arg;
Quoted 9 lines

include/linux/arm_sdei.h line 46

Quoted 6 lines
include/linux/arm_sdei.h +6 -0
+	u32			 event_num;
+	u8			 priority;
+};
+
+struct sdei_event {
+	/* These three are protected by the sdei_list_lock */  

As this patch leaves the sdei_list_lock as local to arm_sdei.c, is this comment still valid?

Quoted 4 lines

Yes, the comment is still valid. @sdei_list_lock is used to protect the linked list (@sdei_list) and all elements (@event) in the list. For example, the lock is taken before updating @event->reenabled in function sdei_event_enable().

OK. I assume your new KVM code will simply not touch the list. That's a bit messy from a 'scope' point of view, but I guess it's not worth doing something like:

struct sdei_event_opaque {
	struct list_head list;
	// Whatever else the kvm code doesn't need
	struct sdei_event {
		// The bits that you want to expose more widely (i.e. use in the
		// kvm code.  + you ensure that code only ever sees this internal structure.

	};
Quoted 1 line

}

Quoted 8 lines

Yes, your assumption is correct. The list is still managed by drivers/firmware/arm_sdei.c and it's invisible to the new KVM code for SDEI virtualization.

It's worthy to hide those fields in "struct sdei_event" from external by introducing another struct, from the point of "scope". But it's not free to maintain another struct in this case. I would say lets avoid introducing another struct if you agree.

I'm fine either way.

Jonathan

Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
Quoted 46 lines
include/linux/arm_sdei.h +18 -19
+	struct list_head	list;
+	bool			reregister;
+	bool			reenable;
+
+	u32			event_num;
+	u8			type;
+	u8			priority;
+
+	/* This pointer is handed to firmware as the event argument. */
+	union {
+		/* Shared events */
+		struct sdei_registered_event *registered;
+
+		/* CPU private events */
+		struct sdei_registered_event __percpu *private_registered;
+	};
+};
+
   /*
    * Register your callback to claim an event. The event must be described
    * by firmware.
@@ -51,27 +91,6 @@ static inline int sdei_mask_local_cpu(void) { return 0; }
   static inline int sdei_unmask_local_cpu(void) { return 0; }
   #endif /* CONFIG_ARM_SDE_INTERFACE */
 
-
-/*
- * This struct represents an event that has been registered. The driver
- * maintains a list of all events, and which ones are registered. (Private
- * events have one entry in the list, but are registered on each CPU).
- * A pointer to this struct is passed to firmware, and back to the event
- * handler. The event handler can then use this to invoke the registered
- * callback, without having to walk the list.
- *
- * For CPU private events, this structure is per-cpu.
- */
-struct sdei_registered_event {
-	/* For use by arch code: */
-	struct pt_regs          interrupted_regs;
-
-	sdei_event_callback	*callback;
-	void			*callback_arg;
-	u32			 event_num;
-	u8			 priority;
Quoted 9 lines
Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

include/linux/arm_sdei.h static inline int sdei_mask_local_cpu(void) { return 0; } · line 96

Quoted 5 lines
include/linux/arm_sdei.h +0 -2
-};
-
   /* The arch code entry point should then call this when an event arrives. */
   int notrace sdei_event_handler(struct pt_regs *regs,
   			       struct sdei_registered_event *arg);  

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#30 lore raw

Re: [PATCH v2 14/17] drivers/firmware/sdei: Move struct sdei_event to header file

Hi Jonathan,

Quoted 8 lines · Jonathan Cameron
Quoted 6 lines · On Mon, 27 Jul 2020 19:59:24 +1000 Gavin Shan <[email protected]> wrote:
Quoted 5 lines · Jonathan Cameron
Quoted 3 lines · On Mon, 27 Jul 2020 10:46:52 +1000 Gavin Shan <[email protected]> wrote:
Quoted 2 lines · Jonathan Cameron

On Wed, 22 Jul 2020 19:57:37 +1000
Gavin Shan <[email protected]> wrote:

[...]

Quoted 58 lines
Quoted 58 lines
Quoted 52 lines
Quoted 35 lines
Quoted 25 lines
Quoted 25 lines
include/linux/arm_sdei.h +16 -0
index 0a241c5c911d..fdc2f868d84b 100644
@@ -22,6 +22,46 @@
     */
    typedef int (sdei_event_callback)(u32 event, struct pt_regs *regs, void *arg);
 
+/*
+ * This struct represents an event that has been registered. The driver
+ * maintains a list of all events, and which ones are registered. (Private
+ * events have one entry in the list, but are registered on each CPU).
+ * A pointer to this struct is passed to firmware, and back to the event
+ * handler. The event handler can then use this to invoke the registered
+ * callback, without having to walk the list.
+ *
+ * For CPU private events, this structure is per-cpu.
+ */
+struct sdei_registered_event {
+	/* For use by arch code: */
+	struct pt_regs          interrupted_regs;
+
+	sdei_event_callback	*callback;
+	void			*callback_arg;
Quoted 9 lines

include/linux/arm_sdei.h line 46

Quoted 6 lines
include/linux/arm_sdei.h +6 -0
+	u32			 event_num;
+	u8			 priority;
+};
+
+struct sdei_event {
+	/* These three are protected by the sdei_list_lock */

As this patch leaves the sdei_list_lock as local to arm_sdei.c, is this comment still valid?

Quoted 4 lines

Yes, the comment is still valid. @sdei_list_lock is used to protect the linked list (@sdei_list) and all elements (@event) in the list. For example, the lock is taken before updating @event->reenabled in function sdei_event_enable().

OK. I assume your new KVM code will simply not touch the list. That's a bit messy from a 'scope' point of view, but I guess it's not worth doing something like:

struct sdei_event_opaque {
	struct list_head list;
	// Whatever else the kvm code doesn't need
	struct sdei_event {
		// The bits that you want to expose more widely (i.e. use in the
		// kvm code.  + you ensure that code only ever sees this internal structure.

	};
Quoted 1 line

}

Yes, your assumption is correct. The list is still managed by drivers/firmware/arm_sdei.c and it's invisible to the new KVM code for SDEI virtualization.

Quoted 7 lines
Quoted 4 lines

It's worthy to hide those fields in "struct sdei_event" from external by introducing another struct, from the point of "scope". But it's not free to maintain another struct in this case. I would say lets avoid introducing another struct if you agree.

I'm fine either way.

Thanks again for your feedback. I think about it again and it's really nice idea to narrow the scopes of the fields in the struct. I will split original struct sdei_event into struct sdei_event and struct sdei_internal_event in v3, which will be posted shortly.

As the naems indicate, struct sdei_event can be dereferenced by external modules like arm64/kvm in the future, while struct sdei_internal_event is used by the SDEI client driver only :)

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
include/linux/arm_sdei.h +10 -0
+	struct list_head	list;
+	bool			reregister;
+	bool			reenable;
+
+	u32			event_num;
+	u8			type;
+	u8			priority;
+
+	/* This pointer is handed to firmware as the event argument. */
+	union {
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines

include/linux/arm_sdei.h line 64

Quoted 8 lines
include/linux/arm_sdei.h +8 -0
+		/* Shared events */
+		struct sdei_registered_event *registered;
+
+		/* CPU private events */
+		struct sdei_registered_event __percpu *private_registered;
+	};
+};
+

[...]

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#31 lore raw

PATCH v2 15/17 drivers/firmware/sdei: Identify event by struct sdei_event

In reply to Gavin Shan

There are 4 APIs exported by the driver as below. They are using the event number as the identifier to the event. It's conflicting with the requirement to dereference the event by struct sdei_event instance when SDEI virtualization is supported. So this reworks on the APIs accordingly to dereference the event by struct sdei_event instance:

* sdei_event_register() returns the struct sdei_event instance.
* sdei_event_unregister() and sdei_event_{enable, disable}() accepts struct sdei_event instance as the parameter.
* Rework sdei_{register,unregister}_ghes() to use the modified APIs.

---
v2: Derived from "drivers/firmware/sdei: Identify event by struct"

---
 drivers/firmware/arm_sdei.c | 60 +++++++++++++++++--------------------
 include/linux/arm_sdei.h    |  9 +++---
 2 files changed, 32 insertions(+), 37 deletions(-)
drivers/firmware/arm_sdei.c +27 -33
index bdd2de0149c0..cf10fec57f2a 100644
@@ -376,18 +376,11 @@ static void _local_event_enable(void *data)
 	sdei_cross_call_return(arg, err);
 }
 
-int sdei_event_enable(u32 event_num)
+int sdei_event_enable(struct sdei_event *event)
 {
 	int err = -EINVAL;
-	struct sdei_event *event;
 
 	mutex_lock(&sdei_events_lock);
-	event = sdei_event_find(event_num);
-	if (!event) {
-		mutex_unlock(&sdei_events_lock);
-		return -ENOENT;
-	}
-
 
 	cpus_read_lock();
 	if (event->type == SDEI_EVENT_TYPE_SHARED)
@@ -422,17 +415,11 @@ static void _ipi_event_disable(void *data)
 	sdei_cross_call_return(arg, err);
 }
 
-int sdei_event_disable(u32 event_num)
+int sdei_event_disable(struct sdei_event *event)
 {
 	int err = -EINVAL;
-	struct sdei_event *event;
 
 	mutex_lock(&sdei_events_lock);
-	event = sdei_event_find(event_num);
-	if (!event) {
-		mutex_unlock(&sdei_events_lock);
-		return -ENOENT;
-	}
 
 	spin_lock(&sdei_list_lock);
 	event->reenable = false;
@@ -466,20 +453,13 @@ static void _local_event_unregister(void *data)
 	sdei_cross_call_return(arg, err);
 }
 
-int sdei_event_unregister(u32 event_num)
+int sdei_event_unregister(struct sdei_event *event)
 {
 	int err;
-	struct sdei_event *event;
 
 	WARN_ON(in_nmi());
 
 	mutex_lock(&sdei_events_lock);
-	event = sdei_event_find(event_num);
-	if (!event) {
-		pr_warn("Event %u not registered\n", event_num);
-		err = -ENOENT;
-		goto out;
-	}
 
 	spin_lock(&sdei_list_lock);
 	event->reregister = false;
@@ -549,7 +529,8 @@ static void _local_event_register(void *data)
 	sdei_cross_call_return(arg, err);
 }
 
-int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
+struct sdei_event *sdei_event_register(u32 event_num, sdei_event_callback *cb,
+				       void *arg)
 {
 	int err;
 	struct sdei_event *event;
@@ -559,14 +540,14 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 	mutex_lock(&sdei_events_lock);
 	if (sdei_event_find(event_num)) {
 		pr_warn("Event %u already registered\n", event_num);
-		err = -EBUSY;
+		event = ERR_PTR(-EBUSY);
 		goto out;
 	}
 
 	event = sdei_event_create(event_num, cb, arg);
 	if (IS_ERR(event)) {
-		err = PTR_ERR(event);
-		pr_warn("Failed to create event %u: %d\n", event_num, err);
+		pr_warn("Failed to create event %u: %ld\n",
+			event_num, PTR_ERR(event));
 		goto out;
 	}
 
@@ -584,6 +565,7 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 
 	if (err) {
 		sdei_event_destroy(event);
+		event = ERR_PTR(err);
 		pr_warn("Failed to register event %u: %d\n", event_num, err);
 		goto cpu_unlock;
 	}
@@ -595,7 +577,7 @@ int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg)
 	cpus_read_unlock();
 out:
 	mutex_unlock(&sdei_events_lock);
-	return err;
+	return event;
 }
 
 static int sdei_reregister_shared(void)
@@ -838,6 +820,7 @@ int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
 	u64 result;
 	u32 event_num;
 	sdei_event_callback *cb;
+	struct sdei_event *event;
 
 	if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES))
 		return -EOPNOTSUPP;
@@ -861,9 +844,13 @@ int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
 	else
 		cb = normal_cb;
 
-	err = sdei_event_register(event_num, cb, ghes);
-	if (!err)
-		err = sdei_event_enable(event_num);
+	event = sdei_event_register(event_num, cb, ghes);
+	if (IS_ERR(event)) {
+		err = PTR_ERR(event);
+		return err;
+	}
+
+	err = sdei_event_enable(event);
 
 	return err;
 }
@@ -873,22 +860,29 @@ int sdei_unregister_ghes(struct ghes *ghes)
 	int i;
 	int err;
 	u32 event_num = ghes->generic->notify.vector;
+	struct sdei_event *event;
 
 	might_sleep();
 
 	if (!IS_ENABLED(CONFIG_ACPI_APEI_GHES))
 		return -EOPNOTSUPP;
 
+	mutex_lock(&sdei_events_lock);
+	event = sdei_event_find(event_num);
+	mutex_unlock(&sdei_events_lock);
+	if (!event)
+		return -ENOENT;
+
 	/*
 	 * The event may be running on another CPU. Disable it
 	 * to stop new events, then try to unregister a few times.
 	 */
-	err = sdei_event_disable(event_num);
+	err = sdei_event_disable(event);
 	if (err)
 		return err;
 
 	for (i = 0; i < 3; i++) {
-		err = sdei_event_unregister(event_num);
+		err = sdei_event_unregister(event);
 		if (err != -EINPROGRESS)
 			break;
 
include/linux/arm_sdei.h +5 -4
index fdc2f868d84b..11af6410dd52 100644
@@ -66,16 +66,17 @@ struct sdei_event {
  * Register your callback to claim an event. The event must be described
  * by firmware.
  */
-int sdei_event_register(u32 event_num, sdei_event_callback *cb, void *arg);
+struct sdei_event *sdei_event_register(u32 event_num, sdei_event_callback *cb,
+				       void *arg);
 
 /*
  * Calls to sdei_event_unregister() may return EINPROGRESS. Keep calling
  * it until it succeeds.
  */
-int sdei_event_unregister(u32 event_num);
+int sdei_event_unregister(struct sdei_event *event);
 
-int sdei_event_enable(u32 event_num);
-int sdei_event_disable(u32 event_num);
+int sdei_event_enable(struct sdei_event *event);
+int sdei_event_disable(struct sdei_event *event);
 
 /* GHES register/unregister helpers */
 int sdei_register_ghes(struct ghes *ghes, sdei_event_callback *normal_cb,
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
author
#32 lore raw

PATCH v2 16/17 drivers/firmware/sdei: Retrieve event signaled property on registration

In reply to Gavin Shan

This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported.

---
 drivers/firmware/arm_sdei.c | 6 ++++++
 include/linux/arm_sdei.h    | 1 +
 2 files changed, 7 insertions(+)
drivers/firmware/arm_sdei.c +6 -0
index cf10fec57f2a..7518d3febf53 100644
@@ -204,6 +204,12 @@ static struct sdei_event *sdei_event_create(u32 event_num,
 		goto fail;
 	event->type = result;
 
+	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED,
+				      &result);
+	if (err)
+		goto fail;
+	event->signaled = result;
+
 	if (event->type == SDEI_EVENT_TYPE_SHARED) {
 		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
 		if (!reg) {
include/linux/arm_sdei.h +1 -0
index 11af6410dd52..7f3ed7e4b680 100644
@@ -51,6 +51,7 @@ struct sdei_event {
 	u32			event_num;
 	u8			type;
 	u8			priority;
+	u8			signaled;
 
 	/* This pointer is handed to firmware as the event argument. */
 	union {
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
#33 lore raw

Re: [PATCH v2 16/17] drivers/firmware/sdei: Retrieve event signaled property on registration

Quoted 5 lines · On Wed, 22 Jul 2020 19:57:39 +1000 Gavin Shan <[email protected]> wrote:

This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported.

These last two patches are probably fine but hard to tell without a user.

Jonathan

Quoted 27 lines
---
 drivers/firmware/arm_sdei.c | 6 ++++++
 include/linux/arm_sdei.h    | 1 +
 2 files changed, 7 insertions(+)
drivers/firmware/arm_sdei.c +6 -0
index cf10fec57f2a..7518d3febf53 100644
@@ -204,6 +204,12 @@ static struct sdei_event *sdei_event_create(u32 event_num,
 		goto fail;
 	event->type = result;
 
+	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED,
+				      &result);
+	if (err)
+		goto fail;
+	event->signaled = result;
+
 	if (event->type == SDEI_EVENT_TYPE_SHARED) {
 		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
 		if (!reg) {
include/linux/arm_sdei.h +0 -0
index 11af6410dd52..7f3ed7e4b680 100644

include/linux/arm_sdei.h struct sdei_event { · line 57

Quoted 7 lines
include/linux/arm_sdei.h +1 -0
@@ -51,6 +51,7 @@ struct sdei_event {
 	u32			event_num;
 	u8			type;
 	u8			priority;
+	u8			signaled;
 
 	/* This pointer is handed to firmware as the event argument. */
 	union {

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#34 lore raw

Re: [PATCH v2 16/17] drivers/firmware/sdei: Retrieve event signaled property on registration

Hi Jonathan,

Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:39 +1000 Gavin Shan <[email protected]> wrote:

This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported.

These last two patches are probably fine but hard to tell without a user.

Good question. Let me explain the background and please let me know if you have more questions. SDEI was suggested by Marc to deliver the notification during the asynchronous page fault, so that the process can be rescheduled in guest. Unfortunately, we don't have SDEI (or virtualized SDEI) supported yet. So the additional event information is needed when SDEI virtualization is supported.

The code of SDEI virtualization can be checked out from github:

https://github.com/gwshan/linux/tree/sdei (branch: "sdei")

Quoted 32 lines
Quoted 32 lines
---
  drivers/firmware/arm_sdei.c | 6 ++++++
  include/linux/arm_sdei.h    | 1 +
  2 files changed, 7 insertions(+)
drivers/firmware/arm_sdei.c +6 -0
index cf10fec57f2a..7518d3febf53 100644
@@ -204,6 +204,12 @@ static struct sdei_event *sdei_event_create(u32 event_num,
  		goto fail;
  	event->type = result;
 
+	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED,
+				      &result);
+	if (err)
+		goto fail;
+	event->signaled = result;
+
  	if (event->type == SDEI_EVENT_TYPE_SHARED) {
  		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
  		if (!reg) {
include/linux/arm_sdei.h +1 -0
index 11af6410dd52..7f3ed7e4b680 100644
@@ -51,6 +51,7 @@ struct sdei_event {
  	u32			event_num;
  	u8			type;
  	u8			priority;
+	u8			signaled;
 
Quoted 2 lines

include/linux/arm_sdei.h struct sdei_event { · line 57

Quoted 2 lines
include/linux/arm_sdei.h +0 -0
  	/* This pointer is handed to firmware as the event argument. */
  	union {

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

#35 lore raw

Re: [PATCH v2 16/17] drivers/firmware/sdei: Retrieve event signaled property on registration

Quoted 22 lines · On Mon, 27 Jul 2020 10:53:27 +1000 Gavin Shan <[email protected]> wrote:

Hi Jonathan,

Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:39 +1000 Gavin Shan <[email protected]> wrote:

This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported.

These last two patches are probably fine but hard to tell without a user.

Good question. Let me explain the background and please let me know if you have more questions. SDEI was suggested by Marc to deliver the notification during the asynchronous page fault, so that the process can be rescheduled in guest. Unfortunately, we don't have SDEI (or virtualized SDEI) supported yet. So the additional event information is needed when SDEI virtualization is supported.

Quoted 3 lines

The code of SDEI virtualization can be checked out from github:

https://github.com/gwshan/linux/tree/sdei (branch: "sdei")

Thanks.

I'd be tempted to move these two patches to the next series that includes the users.

I forgot to say, I'm fine with all the patches I didn't comment on.

Jonathan

Quoted 34 lines
Quoted 34 lines
Quoted 34 lines
  
---
  drivers/firmware/arm_sdei.c | 6 ++++++
  include/linux/arm_sdei.h    | 1 +
  2 files changed, 7 insertions(+)
drivers/firmware/arm_sdei.c +6 -0
index cf10fec57f2a..7518d3febf53 100644
@@ -204,6 +204,12 @@ static struct sdei_event *sdei_event_create(u32 event_num,
  		goto fail;
  	event->type = result;
 
+	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED,
+				      &result);
+	if (err)
+		goto fail;
+	event->signaled = result;
+
  	if (event->type == SDEI_EVENT_TYPE_SHARED) {
  		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
  		if (!reg) {
include/linux/arm_sdei.h +1 -0
index 11af6410dd52..7f3ed7e4b680 100644
@@ -51,6 +51,7 @@ struct sdei_event {
  	u32			event_num;
  	u8			type;
  	u8			priority;
+	u8			signaled;
 
Quoted 6 lines
Quoted 2 lines

include/linux/arm_sdei.h struct sdei_event { · line 57

Quoted 2 lines
include/linux/arm_sdei.h +0 -0
  	/* This pointer is handed to firmware as the event argument. */
  	union {  

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#36 lore raw

Re: [PATCH v2 16/17] drivers/firmware/sdei: Retrieve event signaled property on registration

Hi Jonathan,

Quoted 24 lines · Jonathan Cameron
Quoted 22 lines · On Mon, 27 Jul 2020 10:53:27 +1000 Gavin Shan <[email protected]> wrote:
Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:39 +1000 Gavin Shan <[email protected]> wrote:

This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported.

These last two patches are probably fine but hard to tell without a user.

Good question. Let me explain the background and please let me know if you have more questions. SDEI was suggested by Marc to deliver the notification during the asynchronous page fault, so that the process can be rescheduled in guest. Unfortunately, we don't have SDEI (or virtualized SDEI) supported yet. So the additional event information is needed when SDEI virtualization is supported.

The code of SDEI virtualization can be checked out from github:

Quoted 8 lines
Quoted 1 line

https://github.com/gwshan/linux/tree/sdei (branch: "sdei")

Thanks.

I'd be tempted to move these two patches to the next series that includes the users.

I forgot to say, I'm fine with all the patches I didn't comment on.

Yes, it's fine to move the last two patches to where we need them. Thanks for your review and comments. May I have your reviewed-by on those patches you didn't comment on? I would like to pick the reviwed-by in v3 :)

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
   
---
   drivers/firmware/arm_sdei.c | 6 ++++++
   include/linux/arm_sdei.h    | 1 +
   2 files changed, 7 insertions(+)
drivers/firmware/arm_sdei.c +6 -0
index cf10fec57f2a..7518d3febf53 100644
@@ -204,6 +204,12 @@ static struct sdei_event *sdei_event_create(u32 event_num,
   		goto fail;
   	event->type = result;
 
+	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED,
+				      &result);
+	if (err)
+		goto fail;
+	event->signaled = result;
+
   	if (event->type == SDEI_EVENT_TYPE_SHARED) {
   		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
   		if (!reg) {
include/linux/arm_sdei.h +1 -0
index 11af6410dd52..7f3ed7e4b680 100644
@@ -51,6 +51,7 @@ struct sdei_event {
   	u32			event_num;
   	u8			type;
   	u8			priority;
+	u8			signaled;
 
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

include/linux/arm_sdei.h struct sdei_event { · line 57

Quoted 2 lines
include/linux/arm_sdei.h +0 -0
   	/* This pointer is handed to firmware as the event argument. */
   	union {

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

Reviewed-by
#37 lore raw

Re: [PATCH v2 16/17] drivers/firmware/sdei: Retrieve event signaled property on registration

Quoted 33 lines · On Mon, 27 Jul 2020 20:03:32 +1000 Gavin Shan <[email protected]> wrote:

Hi Jonathan,

Quoted 30 lines · Jonathan Cameron
Quoted 20 lines · On Mon, 27 Jul 2020 10:53:27 +1000 Gavin Shan <[email protected]> wrote:
Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:39 +1000 Gavin Shan <[email protected]> wrote:

This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported.

These last two patches are probably fine but hard to tell without a user.

Good question. Let me explain the background and please let me know if you have more questions. SDEI was suggested by Marc to deliver the notification during the asynchronous page fault, so that the process can be rescheduled in guest. Unfortunately, we don't have SDEI (or virtualized SDEI) supported yet. So the additional event information is needed when SDEI virtualization is supported.

Quoted 3 lines

The code of SDEI virtualization can be checked out from github:

https://github.com/gwshan/linux/tree/sdei (branch: "sdei")

Thanks.

I'd be tempted to move these two patches to the next series that includes the users.

Quoted 8 lines
Quoted 2 lines

I forgot to say, I'm fine with all the patches I didn't comment on.

Yes, it's fine to move the last two patches to where we need them. Thanks for your review and comments. May I have your reviewed-by on those patches you didn't comment on? I would like to pick the reviwed-by in v3 :)

Sure FWIW (I'm far from an expert in this area!)

for patches
1-7,13,15 as is
8-10 with trivial changes as discussed.
12 already given

Given postponing 16 and 17, that just leaves 11 and 14 that I'd like to take a quick look at in v3.

Jonathan

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
     
---
   drivers/firmware/arm_sdei.c | 6 ++++++
   include/linux/arm_sdei.h    | 1 +
   2 files changed, 7 insertions(+)
drivers/firmware/arm_sdei.c +6 -0
index cf10fec57f2a..7518d3febf53 100644
@@ -204,6 +204,12 @@ static struct sdei_event *sdei_event_create(u32 event_num,
   		goto fail;
   	event->type = result;
 
+	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED,
+				      &result);
+	if (err)
+		goto fail;
+	event->signaled = result;
+
   	if (event->type == SDEI_EVENT_TYPE_SHARED) {
   		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
   		if (!reg) {
include/linux/arm_sdei.h +1 -0
index 11af6410dd52..7f3ed7e4b680 100644
@@ -51,6 +51,7 @@ struct sdei_event {
   	u32			event_num;
   	u8			type;
   	u8			priority;
+	u8			signaled;
 
Quoted 7 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

include/linux/arm_sdei.h struct sdei_event { · line 57

Quoted 2 lines
include/linux/arm_sdei.h +0 -0
   	/* This pointer is handed to firmware as the event argument. */
   	union {  

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#38 lore raw

Re: [PATCH v2 16/17] drivers/firmware/sdei: Retrieve event signaled property on registration

Hi Jonathan,

Quoted 43 lines · Jonathan Cameron
Quoted 31 lines · On Mon, 27 Jul 2020 20:03:32 +1000 Gavin Shan <[email protected]> wrote:
Quoted 30 lines · Jonathan Cameron
Quoted 20 lines · On Mon, 27 Jul 2020 10:53:27 +1000 Gavin Shan <[email protected]> wrote:
Quoted 11 lines · Jonathan Cameron
Quoted 5 lines · On Wed, 22 Jul 2020 19:57:39 +1000 Gavin Shan <[email protected]> wrote:

This retrieves the event signaled property when it's created for the first time. The property will be needed when SDEI virtualization is supported.

These last two patches are probably fine but hard to tell without a user.

Good question. Let me explain the background and please let me know if you have more questions. SDEI was suggested by Marc to deliver the notification during the asynchronous page fault, so that the process can be rescheduled in guest. Unfortunately, we don't have SDEI (or virtualized SDEI) supported yet. So the additional event information is needed when SDEI virtualization is supported.

Quoted 3 lines

The code of SDEI virtualization can be checked out from github:

https://github.com/gwshan/linux/tree/sdei (branch: "sdei")

Thanks.

I'd be tempted to move these two patches to the next series that includes the users.

Quoted 8 lines
Quoted 2 lines

I forgot to say, I'm fine with all the patches I didn't comment on.

Yes, it's fine to move the last two patches to where we need them. Thanks for your review and comments. May I have your reviewed-by on those patches you didn't comment on? I would like to pick the reviwed-by in v3 :)

Sure FWIW (I'm far from an expert in this area!)

Quoted 9 lines

for patches
1-7,13,15 as is
8-10 with trivial changes as discussed.
12 already given

Given postponing 16 and 17, that just leaves 11 and 14 that I'd like to take a quick look at in v3.

Thanks for your confirmation. Except PATCH[11] and PATCH[14], all other patches in v3 will include your r-b. Thanks again for your time and comments :)

Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
Quoted 33 lines
      
---
    drivers/firmware/arm_sdei.c | 6 ++++++
    include/linux/arm_sdei.h    | 1 +
    2 files changed, 7 insertions(+)
drivers/firmware/arm_sdei.c +6 -0
index cf10fec57f2a..7518d3febf53 100644
@@ -204,6 +204,12 @@ static struct sdei_event *sdei_event_create(u32 event_num,
    		goto fail;
    	event->type = result;
 
+	err = sdei_api_event_get_info(event_num, SDEI_EVENT_INFO_EV_SIGNALED,
+				      &result);
+	if (err)
+		goto fail;
+	event->signaled = result;
+
    	if (event->type == SDEI_EVENT_TYPE_SHARED) {
    		reg = kzalloc(sizeof(*reg), GFP_KERNEL);
    		if (!reg) {
include/linux/arm_sdei.h +1 -0
index 11af6410dd52..7f3ed7e4b680 100644
@@ -51,6 +51,7 @@ struct sdei_event {
    	u32			event_num;
    	u8			type;
    	u8			priority;
+	u8			signaled;
 
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 2 lines

include/linux/arm_sdei.h struct sdei_event { · line 57

Quoted 2 lines
include/linux/arm_sdei.h +0 -0
    	/* This pointer is handed to firmware as the event argument. */
    	union {

Thanks,
Gavin

_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

author
#39 lore raw

PATCH v2 17/17 drivers/firmware/sdei: Add sdei_event_get_info()

In reply to Gavin Shan

This adds API sdei_event_get_info(), to be used when virtualized SDEI is supported to retrieve the information about the specified event.

---
 drivers/firmware/arm_sdei.c | 13 +++++++++++++
 include/linux/arm_sdei.h    |  2 ++
 2 files changed, 15 insertions(+)
drivers/firmware/arm_sdei.c +13 -0
index 7518d3febf53..cb7f8c6849a1 100644
@@ -172,6 +172,19 @@ static int sdei_api_event_get_info(u32 event, u32 info, u64 *result)
 			      0, 0, result);
 }
 
+int sdei_event_get_info(u32 event_num, u32 info, u64 *result)
+{
+	int err;
+
+	mutex_lock(&sdei_events_lock);
+
+	err = sdei_api_event_get_info(event_num, info, result);
+
+	mutex_unlock(&sdei_events_lock);
+
+	return err;
+}
+
 static struct sdei_event *sdei_event_create(u32 event_num,
 					    sdei_event_callback *cb,
 					    void *cb_arg)
include/linux/arm_sdei.h +2 -0
index 7f3ed7e4b680..93e372a1454c 100644
@@ -63,6 +63,8 @@ struct sdei_event {
 	};
 };
 
+int sdei_event_get_info(u32 event_num, u32 info, u64 *result);
+
 /*
  * Register your callback to claim an event. The event must be described
  * by firmware.
Signature · 7 lines
2.23.0


_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel