2020-04-09 09:18:09

by Hui Song

[permalink] [raw]
Subject: [PATCH] gpio: mpc8xxx: Add shutdown function.

From: Song Hui <[email protected]>

When the kexec command is executed, the memory area will be re-paginated.
The shutdown function needed to make interrupt handler to be NULL.If
not, an interrupt will be generated during this period. When the interrupt
handler is executed,the handler function address changed and crash will
occur.

Signed-off-by: Song Hui <[email protected]>
---
drivers/gpio/gpio-mpc8xxx.c | 12 ++++++++++++
1 file changed, 12 insertions(+)

diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
index 604dfec..a24e6c5 100644
--- a/drivers/gpio/gpio-mpc8xxx.c
+++ b/drivers/gpio/gpio-mpc8xxx.c
@@ -446,9 +446,21 @@ static int mpc8xxx_remove(struct platform_device *pdev)
return 0;
}

+static int mpc8xxx_shutdown(struct platform_device *pdev)
+{
+ struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
+
+ if (mpc8xxx_gc->irq) {
+ irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, NULL, NULL);
+ irq_domain_remove(mpc8xxx_gc->irq);
+ }
+
+ return 0;
+}
static struct platform_driver mpc8xxx_plat_driver = {
.probe = mpc8xxx_probe,
.remove = mpc8xxx_remove,
+ .shutdown = mpc8xxx_shutdown,
.driver = {
.name = "gpio-mpc8xxx",
.of_match_table = mpc8xxx_gpio_ids,
--
2.9.5


2020-04-09 09:40:03

by Russell King (Oracle)

[permalink] [raw]
Subject: Re: [PATCH] gpio: mpc8xxx: Add shutdown function.

On Thu, Apr 09, 2020 at 05:02:59PM +0800, Hui Song wrote:
> From: Song Hui <[email protected]>
>
> When the kexec command is executed, the memory area will be re-paginated.
> The shutdown function needed to make interrupt handler to be NULL.If
> not, an interrupt will be generated during this period. When the interrupt
> handler is executed,the handler function address changed and crash will
> occur.

I still don't think this is adequate.

When kexec takes effect, the existing kernel is shutdown and replaced
with the new kernel, and it completely takes over the system. The
dynamically allocated structures (which include pointers for the parent
interrupt for mpc8xxx) are irrelevant, as they will need to be
reallocated. It feels like you're just putting a band-aid over a real
problem.

I think rather than producing a patch, you need to give details of the
crash you are seeing. Probably having the kernel message log across
the kexec and into the new kernel up to the point where the crash occurs
would be a good idea.

>
> Signed-off-by: Song Hui <[email protected]>
> ---
> drivers/gpio/gpio-mpc8xxx.c | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c
> index 604dfec..a24e6c5 100644
> --- a/drivers/gpio/gpio-mpc8xxx.c
> +++ b/drivers/gpio/gpio-mpc8xxx.c
> @@ -446,9 +446,21 @@ static int mpc8xxx_remove(struct platform_device *pdev)
> return 0;
> }
>
> +static int mpc8xxx_shutdown(struct platform_device *pdev)
> +{
> + struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
> +
> + if (mpc8xxx_gc->irq) {
> + irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, NULL, NULL);
> + irq_domain_remove(mpc8xxx_gc->irq);
> + }
> +
> + return 0;
> +}
> static struct platform_driver mpc8xxx_plat_driver = {
> .probe = mpc8xxx_probe,
> .remove = mpc8xxx_remove,
> + .shutdown = mpc8xxx_shutdown,
> .driver = {
> .name = "gpio-mpc8xxx",
> .of_match_table = mpc8xxx_gpio_ids,
> --
> 2.9.5
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> [email protected]
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
>

--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTC broadband for 0.8mile line in suburbia: sync at 10.2Mbps down 587kbps up

2020-04-21 05:48:50

by kernel test robot

[permalink] [raw]
Subject: Re: [PATCH] gpio: mpc8xxx: Add shutdown function.

Hi Hui,

Thank you for the patch! Yet something to improve:

[auto build test ERROR on gpio/for-next]
[also build test ERROR on v5.7-rc2 next-20200420]
[if your patch is applied to the wrong git tree, please drop us a note to help
improve the system. BTW, we also suggest to use '--base' option to specify the
base tree in git format-patch, please see https://stackoverflow.com/a/37406982]

url: https://github.com/0day-ci/linux/commits/Hui-Song/gpio-mpc8xxx-Add-shutdown-function/20200410-000846
base: https://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-gpio.git for-next
config: arm64-defconfig (attached as .config)
compiler: aarch64-linux-gcc (GCC) 9.3.0
reproduce:
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
chmod +x ~/bin/make.cross
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day GCC_VERSION=9.3.0 make.cross ARCH=arm64

If you fix the issue, kindly add following tag as appropriate
Reported-by: kbuild test robot <[email protected]>

All errors (new ones prefixed by >>):

>> drivers/gpio/gpio-mpc8xxx.c:463:14: error: initialization of 'void (*)(struct platform_device *)' from incompatible pointer type 'int (*)(struct platform_device *)' [-Werror=incompatible-pointer-types]
463 | .shutdown = mpc8xxx_shutdown,
| ^~~~~~~~~~~~~~~~
drivers/gpio/gpio-mpc8xxx.c:463:14: note: (near initialization for 'mpc8xxx_plat_driver.shutdown')
cc1: some warnings being treated as errors

vim +463 drivers/gpio/gpio-mpc8xxx.c

448
449 static int mpc8xxx_shutdown(struct platform_device *pdev)
450 {
451 struct mpc8xxx_gpio_chip *mpc8xxx_gc = platform_get_drvdata(pdev);
452
453 if (mpc8xxx_gc->irq) {
454 irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, NULL, NULL);
455 irq_domain_remove(mpc8xxx_gc->irq);
456 }
457
458 return 0;
459 }
460 static struct platform_driver mpc8xxx_plat_driver = {
461 .probe = mpc8xxx_probe,
462 .remove = mpc8xxx_remove,
> 463 .shutdown = mpc8xxx_shutdown,
464 .driver = {
465 .name = "gpio-mpc8xxx",
466 .of_match_table = mpc8xxx_gpio_ids,
467 },
468 };
469

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/[email protected]


Attachments:
(No filename) (2.36 kB)
.config.gz (47.10 kB)
Download all attachments