From 0b671eed0cf069839c4e73b66d88ec483ee6c3f5 Mon Sep 17 00:00:00 2001 From: Tang Bin Date: Wed, 8 Apr 2020 19:59:58 +0800 Subject: ipmi:bt-bmc: Avoid unnecessary check bt_bmc_probe() is only called with an openfirmware platform device. Therefore there is no need to check that the passed in device is NULL or that it has an openfirmware node. Signed-off-by: Tang Bin Message-Id: <20200408115958.2848-1-tangbin@cmss.chinamobile.com> [Fixed the title up a bit.] Signed-off-by: Corey Minyard --- drivers/char/ipmi/bt-bmc.c | 3 --- 1 file changed, 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c index d36aeacb290e..890ad55aae79 100644 --- a/drivers/char/ipmi/bt-bmc.c +++ b/drivers/char/ipmi/bt-bmc.c @@ -430,9 +430,6 @@ static int bt_bmc_probe(struct platform_device *pdev) struct device *dev; int rc; - if (!pdev || !pdev->dev.of_node) - return -ENODEV; - dev = &pdev->dev; dev_info(dev, "Found bt bmc device\n"); -- cgit v1.2.3-59-g8ed1b From 8ed678dbac8c8c5685893f3af1c47f167b61c5ec Mon Sep 17 00:00:00 2001 From: Tang Bin Date: Tue, 14 Apr 2020 22:18:14 +0800 Subject: ipmi:bt-bmc: Fix some format issue of the code Fix some format issue of the code in bt-bmc.c Signed-off-by: Tang Bin Signed-off-by: Shengju Zhang Message-Id: <20200414141814.19048-1-tangbin@cmss.chinamobile.com> Signed-off-by: Corey Minyard --- drivers/char/ipmi/bt-bmc.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c index 890ad55aae79..cd0349bfffe9 100644 --- a/drivers/char/ipmi/bt-bmc.c +++ b/drivers/char/ipmi/bt-bmc.c @@ -463,9 +463,9 @@ static int bt_bmc_probe(struct platform_device *pdev) init_waitqueue_head(&bt_bmc->queue); bt_bmc->miscdev.minor = MISC_DYNAMIC_MINOR, - bt_bmc->miscdev.name = DEVICE_NAME, - bt_bmc->miscdev.fops = &bt_bmc_fops, - bt_bmc->miscdev.parent = dev; + bt_bmc->miscdev.name = DEVICE_NAME, + bt_bmc->miscdev.fops = &bt_bmc_fops, + bt_bmc->miscdev.parent = dev; rc = misc_register(&bt_bmc->miscdev); if (rc) { dev_err(dev, "Unable to register misc device\n"); -- cgit v1.2.3-59-g8ed1b From 7c47a219b95d0e06b5ef5fcc7bad807895015eac Mon Sep 17 00:00:00 2001 From: Feng Tang Date: Fri, 17 Apr 2020 12:48:28 +0800 Subject: ipmi: use vzalloc instead of kmalloc for user creation We met mulitple times of failure of staring bmc-watchdog, due to the runtime memory allocation failure of order 4. bmc-watchdog: page allocation failure: order:4, mode:0x40cc0(GFP_KERNEL|__GFP_COMP), nodemask=(null),cpuset=/,mems_allowed=0-1 CPU: 1 PID: 2571 Comm: bmc-watchdog Not tainted 5.5.0-00045-g7d6bb61d6188c #1 Hardware name: Intel Corporation S2600WFT/S2600WFT, BIOS SE5C620.86B.00.01.0015.110720180833 11/07/2018 Call Trace: dump_stack+0x66/0x8b warn_alloc+0xfe/0x160 __alloc_pages_slowpath+0xd3e/0xd80 __alloc_pages_nodemask+0x2f0/0x340 kmalloc_order+0x18/0x70 kmalloc_order_trace+0x1d/0xb0 ipmi_create_user+0x55/0x2c0 [ipmi_msghandler] ipmi_open+0x72/0x110 [ipmi_devintf] chrdev_open+0xcb/0x1e0 do_dentry_open+0x1ce/0x380 path_openat+0x305/0x14f0 do_filp_open+0x9b/0x110 do_sys_open+0x1bd/0x250 do_syscall_64+0x5b/0x1f0 entry_SYSCALL_64_after_hwframe+0x44/0xa9 Using vzalloc/vfree for creating ipmi_user heals the problem Thanks to Stephen Rothwell for finding the vmalloc.h inclusion issue. Signed-off-by: Feng Tang Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_msghandler.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index c48d8f086382..9afd220cd824 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -33,6 +33,7 @@ #include #include #include +#include #define IPMI_DRIVER_VERSION "39.2" @@ -1153,7 +1154,7 @@ static void free_user_work(struct work_struct *work) remove_work); cleanup_srcu_struct(&user->release_barrier); - kfree(user); + vfree(user); } int ipmi_create_user(unsigned int if_num, @@ -1185,7 +1186,7 @@ int ipmi_create_user(unsigned int if_num, if (rv) return rv; - new_user = kmalloc(sizeof(*new_user), GFP_KERNEL); + new_user = vzalloc(sizeof(*new_user)); if (!new_user) return -ENOMEM; @@ -1232,7 +1233,7 @@ int ipmi_create_user(unsigned int if_num, out_kfree: srcu_read_unlock(&ipmi_interfaces_srcu, index); - kfree(new_user); + vfree(new_user); return rv; } EXPORT_SYMBOL(ipmi_create_user); -- cgit v1.2.3-59-g8ed1b From 878caa96596963ba2d73393572b02624cd23e4ff Mon Sep 17 00:00:00 2001 From: Andy Shevchenko Date: Wed, 22 Apr 2020 16:03:48 +0300 Subject: ipmi: Replace guid_copy() with import_guid() where it makes sense There is a specific API to treat raw data as GUID, i.e. import_guid(). Use it instead of guid_copy() with explicit casting. Signed-off-by: Andy Shevchenko Message-Id: <20200422130348.38749-1-andriy.shevchenko@linux.intel.com> Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_msghandler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_msghandler.c b/drivers/char/ipmi/ipmi_msghandler.c index 9afd220cd824..e1b22fe0916c 100644 --- a/drivers/char/ipmi/ipmi_msghandler.c +++ b/drivers/char/ipmi/ipmi_msghandler.c @@ -3172,7 +3172,7 @@ static void guid_handler(struct ipmi_smi *intf, struct ipmi_recv_msg *msg) goto out; } - guid_copy(&bmc->fetch_guid, (guid_t *)(msg->msg.data + 1)); + import_guid(&bmc->fetch_guid, msg->msg.data + 1); /* * Make sure the guid data is available before setting * dyn_guid_set. -- cgit v1.2.3-59-g8ed1b From 49826937e7c7917140515aaf10c17bedcc4acaad Mon Sep 17 00:00:00 2001 From: Tang Bin Date: Tue, 5 May 2020 18:29:06 +0800 Subject: ipmi:bt-bmc: Fix error handling and status check If the function platform_get_irq() failed, the negative value returned will not be detected here. So fix error handling in bt_bmc_config_irq(). And in the function bt_bmc_probe(), when get irq failed, it will print error message. So use platform_get_irq_optional() to simplify code. Finally in the function bt_bmc_remove() should make the right status check if get irq failed. Signed-off-by: Shengju Zhang Signed-off-by: Tang Bin Message-Id: <20200505102906.17196-1-tangbin@cmss.chinamobile.com> [Also set bt_bmc->irq to a negative value if devm_request_irq() fails.] Signed-off-by: Corey Minyard --- drivers/char/ipmi/bt-bmc.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/bt-bmc.c b/drivers/char/ipmi/bt-bmc.c index cd0349bfffe9..a395e2e70dc5 100644 --- a/drivers/char/ipmi/bt-bmc.c +++ b/drivers/char/ipmi/bt-bmc.c @@ -399,15 +399,15 @@ static int bt_bmc_config_irq(struct bt_bmc *bt_bmc, struct device *dev = &pdev->dev; int rc; - bt_bmc->irq = platform_get_irq(pdev, 0); - if (!bt_bmc->irq) - return -ENODEV; + bt_bmc->irq = platform_get_irq_optional(pdev, 0); + if (bt_bmc->irq < 0) + return bt_bmc->irq; rc = devm_request_irq(dev, bt_bmc->irq, bt_bmc_irq, IRQF_SHARED, DEVICE_NAME, bt_bmc); if (rc < 0) { dev_warn(dev, "Unable to request IRQ %d\n", bt_bmc->irq); - bt_bmc->irq = 0; + bt_bmc->irq = rc; return rc; } @@ -474,7 +474,7 @@ static int bt_bmc_probe(struct platform_device *pdev) bt_bmc_config_irq(bt_bmc, pdev); - if (bt_bmc->irq) { + if (bt_bmc->irq >= 0) { dev_info(dev, "Using IRQ %d\n", bt_bmc->irq); } else { dev_info(dev, "No IRQ; using timer\n"); @@ -500,7 +500,7 @@ static int bt_bmc_remove(struct platform_device *pdev) struct bt_bmc *bt_bmc = dev_get_drvdata(&pdev->dev); misc_deregister(&bt_bmc->miscdev); - if (!bt_bmc->irq) + if (bt_bmc->irq < 0) del_timer_sync(&bt_bmc->poll_timer); return 0; } -- cgit v1.2.3-59-g8ed1b From 429b00f606659cbaee41da60be6a6f8965a4f6f8 Mon Sep 17 00:00:00 2001 From: Stuart Hayes Date: Wed, 11 Mar 2020 15:24:09 -0400 Subject: ipmi_si: Load acpi_ipmi when ACPI IPMI interface added Try to load acpi_ipmi when an ACPI IPMI interface is added, so that the ACPI IPMI OpRegion is accessible. Signed-off-by: Stuart Hayes Message-Id: <20200311192409.59923-1-stuart.w.hayes@gmail.com> Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_si_platform.c | 2 ++ 1 file changed, 2 insertions(+) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_si_platform.c b/drivers/char/ipmi/ipmi_si_platform.c index 638c693e17ad..129b5713f187 100644 --- a/drivers/char/ipmi/ipmi_si_platform.c +++ b/drivers/char/ipmi/ipmi_si_platform.c @@ -393,6 +393,8 @@ static int acpi_ipmi_probe(struct platform_device *pdev) dev_info(io.dev, "%pR regsize %d spacing %d irq %d\n", res, io.regsize, io.regspacing, io.irq); + request_module("acpi_ipmi"); + return ipmi_si_add_smi(&io); err_free: -- cgit v1.2.3-59-g8ed1b From e641abd3c7261741f295d41d80b213c20f127de2 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Mon, 11 May 2020 16:13:59 -0500 Subject: Try to load acpi_ipmi when an SSIF ACPI IPMI interface is added This is similar to the recent patch for the SI interface, but for SSIF. Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_ssif.c | 1 + 1 file changed, 1 insertion(+) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 2704470e021d..6fffeb241f45 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -1472,6 +1472,7 @@ static bool check_acpi(struct ssif_info *ssif_info, struct device *dev) if (acpi_handle) { ssif_info->addr_source = SI_ACPI; ssif_info->addr_info.acpi_info.acpi_handle = acpi_handle; + request_module("acpi_ipmi"); return true; } #endif -- cgit v1.2.3-59-g8ed1b From 2a556ce779e39b15cbb74e896ca640e86baeb1a1 Mon Sep 17 00:00:00 2001 From: Corey Minyard Date: Wed, 27 May 2020 18:25:56 -0500 Subject: ipmi:ssif: Remove dynamic platform device handing Platform devices can only come in through the DMI interface, and that will get done before initialization is complete. Therefore there is no reason to hande getting a device in new_ssif_client after initialization. Dynamic entries can still come in through the i2c interfaces, but that's handled differently. Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_ssif.c | 23 +---------------------- 1 file changed, 1 insertion(+), 22 deletions(-) (limited to 'drivers/char') diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 6fffeb241f45..198b65d45c5e 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -189,8 +189,6 @@ struct ssif_addr_info { struct device *dev; struct i2c_client *client; - struct i2c_client *added_client; - struct mutex clients_mutex; struct list_head clients; @@ -1941,21 +1939,6 @@ out_remove_attr: goto out; } -static int ssif_adapter_handler(struct device *adev, void *opaque) -{ - struct ssif_addr_info *addr_info = opaque; - - if (adev->type != &i2c_adapter_type) - return 0; - - addr_info->added_client = i2c_new_client_device(to_i2c_adapter(adev), - &addr_info->binfo); - - if (!addr_info->adapter_name) - return 1; /* Only try the first I2C adapter by default. */ - return 0; -} - static int new_ssif_client(int addr, char *adapter_name, int debug, int slave_addr, enum ipmi_addr_src addr_src, @@ -1999,9 +1982,7 @@ static int new_ssif_client(int addr, char *adapter_name, list_add_tail(&addr_info->link, &ssif_infos); - if (initialized) - i2c_for_each_dev(addr_info, ssif_adapter_handler); - /* Otherwise address list will get it */ + /* Address list will get it */ out_unlock: mutex_unlock(&ssif_infos_mutex); @@ -2121,8 +2102,6 @@ static int ssif_platform_remove(struct platform_device *dev) return 0; mutex_lock(&ssif_infos_mutex); - i2c_unregister_device(addr_info->added_client); - list_del(&addr_info->link); kfree(addr_info); mutex_unlock(&ssif_infos_mutex); -- cgit v1.2.3-59-g8ed1b