1c7e64b9cSStewart Smith /* 2c7e64b9cSStewart Smith * PowerNV OPAL Dump Interface 3c7e64b9cSStewart Smith * 4c7e64b9cSStewart Smith * Copyright 2013,2014 IBM Corp. 5c7e64b9cSStewart Smith * 6c7e64b9cSStewart Smith * This program is free software; you can redistribute it and/or 7c7e64b9cSStewart Smith * modify it under the terms of the GNU General Public License 8c7e64b9cSStewart Smith * as published by the Free Software Foundation; either version 9c7e64b9cSStewart Smith * 2 of the License, or (at your option) any later version. 10c7e64b9cSStewart Smith */ 11c7e64b9cSStewart Smith 12c7e64b9cSStewart Smith #include <linux/kobject.h> 13c7e64b9cSStewart Smith #include <linux/mm.h> 14c7e64b9cSStewart Smith #include <linux/slab.h> 15c7e64b9cSStewart Smith #include <linux/vmalloc.h> 16c7e64b9cSStewart Smith #include <linux/pagemap.h> 17c7e64b9cSStewart Smith #include <linux/delay.h> 188034f715SAlistair Popple #include <linux/interrupt.h> 19c7e64b9cSStewart Smith 20c7e64b9cSStewart Smith #include <asm/opal.h> 21c7e64b9cSStewart Smith 22c7e64b9cSStewart Smith #define DUMP_TYPE_FSP 0x01 23c7e64b9cSStewart Smith 24c7e64b9cSStewart Smith struct dump_obj { 25c7e64b9cSStewart Smith struct kobject kobj; 26c7e64b9cSStewart Smith struct bin_attribute dump_attr; 27c7e64b9cSStewart Smith uint32_t id; /* becomes object name */ 28c7e64b9cSStewart Smith uint32_t type; 29c7e64b9cSStewart Smith uint32_t size; 30c7e64b9cSStewart Smith char *buffer; 31c7e64b9cSStewart Smith }; 32c7e64b9cSStewart Smith #define to_dump_obj(x) container_of(x, struct dump_obj, kobj) 33c7e64b9cSStewart Smith 34c7e64b9cSStewart Smith struct dump_attribute { 35c7e64b9cSStewart Smith struct attribute attr; 36c7e64b9cSStewart Smith ssize_t (*show)(struct dump_obj *dump, struct dump_attribute *attr, 37c7e64b9cSStewart Smith char *buf); 38c7e64b9cSStewart Smith ssize_t (*store)(struct dump_obj *dump, struct dump_attribute *attr, 39c7e64b9cSStewart Smith const char *buf, size_t count); 40c7e64b9cSStewart Smith }; 41c7e64b9cSStewart Smith #define to_dump_attr(x) container_of(x, struct dump_attribute, attr) 42c7e64b9cSStewart Smith 43c7e64b9cSStewart Smith static ssize_t dump_id_show(struct dump_obj *dump_obj, 44c7e64b9cSStewart Smith struct dump_attribute *attr, 45c7e64b9cSStewart Smith char *buf) 46c7e64b9cSStewart Smith { 47c7e64b9cSStewart Smith return sprintf(buf, "0x%x\n", dump_obj->id); 48c7e64b9cSStewart Smith } 49c7e64b9cSStewart Smith 50c7e64b9cSStewart Smith static const char* dump_type_to_string(uint32_t type) 51c7e64b9cSStewart Smith { 52c7e64b9cSStewart Smith switch (type) { 53c7e64b9cSStewart Smith case 0x01: return "SP Dump"; 54c7e64b9cSStewart Smith case 0x02: return "System/Platform Dump"; 55c7e64b9cSStewart Smith case 0x03: return "SMA Dump"; 56c7e64b9cSStewart Smith default: return "unknown"; 57c7e64b9cSStewart Smith } 58c7e64b9cSStewart Smith } 59c7e64b9cSStewart Smith 60c7e64b9cSStewart Smith static ssize_t dump_type_show(struct dump_obj *dump_obj, 61c7e64b9cSStewart Smith struct dump_attribute *attr, 62c7e64b9cSStewart Smith char *buf) 63c7e64b9cSStewart Smith { 64c7e64b9cSStewart Smith 65c7e64b9cSStewart Smith return sprintf(buf, "0x%x %s\n", dump_obj->type, 66c7e64b9cSStewart Smith dump_type_to_string(dump_obj->type)); 67c7e64b9cSStewart Smith } 68c7e64b9cSStewart Smith 69c7e64b9cSStewart Smith static ssize_t dump_ack_show(struct dump_obj *dump_obj, 70c7e64b9cSStewart Smith struct dump_attribute *attr, 71c7e64b9cSStewart Smith char *buf) 72c7e64b9cSStewart Smith { 73c7e64b9cSStewart Smith return sprintf(buf, "ack - acknowledge dump\n"); 74c7e64b9cSStewart Smith } 75c7e64b9cSStewart Smith 76c7e64b9cSStewart Smith /* 77c7e64b9cSStewart Smith * Send acknowledgement to OPAL 78c7e64b9cSStewart Smith */ 79c7e64b9cSStewart Smith static int64_t dump_send_ack(uint32_t dump_id) 80c7e64b9cSStewart Smith { 81c7e64b9cSStewart Smith int rc; 82c7e64b9cSStewart Smith 83c7e64b9cSStewart Smith rc = opal_dump_ack(dump_id); 84c7e64b9cSStewart Smith if (rc) 85c7e64b9cSStewart Smith pr_warn("%s: Failed to send ack to Dump ID 0x%x (%d)\n", 86c7e64b9cSStewart Smith __func__, dump_id, rc); 87c7e64b9cSStewart Smith return rc; 88c7e64b9cSStewart Smith } 89c7e64b9cSStewart Smith 90c7e64b9cSStewart Smith static ssize_t dump_ack_store(struct dump_obj *dump_obj, 91c7e64b9cSStewart Smith struct dump_attribute *attr, 92c7e64b9cSStewart Smith const char *buf, 93c7e64b9cSStewart Smith size_t count) 94c7e64b9cSStewart Smith { 95c7e64b9cSStewart Smith dump_send_ack(dump_obj->id); 96cc4f265aSStewart Smith sysfs_remove_file_self(&dump_obj->kobj, &attr->attr); 97cc4f265aSStewart Smith kobject_put(&dump_obj->kobj); 98c7e64b9cSStewart Smith return count; 99c7e64b9cSStewart Smith } 100c7e64b9cSStewart Smith 101c7e64b9cSStewart Smith /* Attributes of a dump 102c7e64b9cSStewart Smith * The binary attribute of the dump itself is dynamic 103c7e64b9cSStewart Smith * due to the dynamic size of the dump 104c7e64b9cSStewart Smith */ 105c7e64b9cSStewart Smith static struct dump_attribute id_attribute = 10676215b04SRusty Russell __ATTR(id, S_IRUGO, dump_id_show, NULL); 107c7e64b9cSStewart Smith static struct dump_attribute type_attribute = 10876215b04SRusty Russell __ATTR(type, S_IRUGO, dump_type_show, NULL); 109c7e64b9cSStewart Smith static struct dump_attribute ack_attribute = 110c7e64b9cSStewart Smith __ATTR(acknowledge, 0660, dump_ack_show, dump_ack_store); 111c7e64b9cSStewart Smith 112c7e64b9cSStewart Smith static ssize_t init_dump_show(struct dump_obj *dump_obj, 113c7e64b9cSStewart Smith struct dump_attribute *attr, 114c7e64b9cSStewart Smith char *buf) 115c7e64b9cSStewart Smith { 116cdd91b89SVasant Hegde return sprintf(buf, "1 - initiate Service Processor(FSP) dump\n"); 117c7e64b9cSStewart Smith } 118c7e64b9cSStewart Smith 119c7e64b9cSStewart Smith static int64_t dump_fips_init(uint8_t type) 120c7e64b9cSStewart Smith { 121c7e64b9cSStewart Smith int rc; 122c7e64b9cSStewart Smith 123c7e64b9cSStewart Smith rc = opal_dump_init(type); 124c7e64b9cSStewart Smith if (rc) 125cdd91b89SVasant Hegde pr_warn("%s: Failed to initiate FSP dump (%d)\n", 126c7e64b9cSStewart Smith __func__, rc); 127c7e64b9cSStewart Smith return rc; 128c7e64b9cSStewart Smith } 129c7e64b9cSStewart Smith 130c7e64b9cSStewart Smith static ssize_t init_dump_store(struct dump_obj *dump_obj, 131c7e64b9cSStewart Smith struct dump_attribute *attr, 132c7e64b9cSStewart Smith const char *buf, 133c7e64b9cSStewart Smith size_t count) 134c7e64b9cSStewart Smith { 135cdd91b89SVasant Hegde int rc; 136cdd91b89SVasant Hegde 137cdd91b89SVasant Hegde rc = dump_fips_init(DUMP_TYPE_FSP); 138cdd91b89SVasant Hegde if (rc == OPAL_SUCCESS) 139c7e64b9cSStewart Smith pr_info("%s: Initiated FSP dump\n", __func__); 140cdd91b89SVasant Hegde 141c7e64b9cSStewart Smith return count; 142c7e64b9cSStewart Smith } 143c7e64b9cSStewart Smith 144c7e64b9cSStewart Smith static struct dump_attribute initiate_attribute = 145c7e64b9cSStewart Smith __ATTR(initiate_dump, 0600, init_dump_show, init_dump_store); 146c7e64b9cSStewart Smith 147c7e64b9cSStewart Smith static struct attribute *initiate_attrs[] = { 148c7e64b9cSStewart Smith &initiate_attribute.attr, 149c7e64b9cSStewart Smith NULL, 150c7e64b9cSStewart Smith }; 151c7e64b9cSStewart Smith 152c7e64b9cSStewart Smith static struct attribute_group initiate_attr_group = { 153c7e64b9cSStewart Smith .attrs = initiate_attrs, 154c7e64b9cSStewart Smith }; 155c7e64b9cSStewart Smith 156c7e64b9cSStewart Smith static struct kset *dump_kset; 157c7e64b9cSStewart Smith 158c7e64b9cSStewart Smith static ssize_t dump_attr_show(struct kobject *kobj, 159c7e64b9cSStewart Smith struct attribute *attr, 160c7e64b9cSStewart Smith char *buf) 161c7e64b9cSStewart Smith { 162c7e64b9cSStewart Smith struct dump_attribute *attribute; 163c7e64b9cSStewart Smith struct dump_obj *dump; 164c7e64b9cSStewart Smith 165c7e64b9cSStewart Smith attribute = to_dump_attr(attr); 166c7e64b9cSStewart Smith dump = to_dump_obj(kobj); 167c7e64b9cSStewart Smith 168c7e64b9cSStewart Smith if (!attribute->show) 169c7e64b9cSStewart Smith return -EIO; 170c7e64b9cSStewart Smith 171c7e64b9cSStewart Smith return attribute->show(dump, attribute, buf); 172c7e64b9cSStewart Smith } 173c7e64b9cSStewart Smith 174c7e64b9cSStewart Smith static ssize_t dump_attr_store(struct kobject *kobj, 175c7e64b9cSStewart Smith struct attribute *attr, 176c7e64b9cSStewart Smith const char *buf, size_t len) 177c7e64b9cSStewart Smith { 178c7e64b9cSStewart Smith struct dump_attribute *attribute; 179c7e64b9cSStewart Smith struct dump_obj *dump; 180c7e64b9cSStewart Smith 181c7e64b9cSStewart Smith attribute = to_dump_attr(attr); 182c7e64b9cSStewart Smith dump = to_dump_obj(kobj); 183c7e64b9cSStewart Smith 184c7e64b9cSStewart Smith if (!attribute->store) 185c7e64b9cSStewart Smith return -EIO; 186c7e64b9cSStewart Smith 187c7e64b9cSStewart Smith return attribute->store(dump, attribute, buf, len); 188c7e64b9cSStewart Smith } 189c7e64b9cSStewart Smith 190c7e64b9cSStewart Smith static const struct sysfs_ops dump_sysfs_ops = { 191c7e64b9cSStewart Smith .show = dump_attr_show, 192c7e64b9cSStewart Smith .store = dump_attr_store, 193c7e64b9cSStewart Smith }; 194c7e64b9cSStewart Smith 195c7e64b9cSStewart Smith static void dump_release(struct kobject *kobj) 196c7e64b9cSStewart Smith { 197c7e64b9cSStewart Smith struct dump_obj *dump; 198c7e64b9cSStewart Smith 199c7e64b9cSStewart Smith dump = to_dump_obj(kobj); 200c7e64b9cSStewart Smith vfree(dump->buffer); 201c7e64b9cSStewart Smith kfree(dump); 202c7e64b9cSStewart Smith } 203c7e64b9cSStewart Smith 204c7e64b9cSStewart Smith static struct attribute *dump_default_attrs[] = { 205c7e64b9cSStewart Smith &id_attribute.attr, 206c7e64b9cSStewart Smith &type_attribute.attr, 207c7e64b9cSStewart Smith &ack_attribute.attr, 208c7e64b9cSStewart Smith NULL, 209c7e64b9cSStewart Smith }; 210c7e64b9cSStewart Smith 211c7e64b9cSStewart Smith static struct kobj_type dump_ktype = { 212c7e64b9cSStewart Smith .sysfs_ops = &dump_sysfs_ops, 213c7e64b9cSStewart Smith .release = &dump_release, 214c7e64b9cSStewart Smith .default_attrs = dump_default_attrs, 215c7e64b9cSStewart Smith }; 216c7e64b9cSStewart Smith 2172d6b63bbSAnton Blanchard static int64_t dump_read_info(uint32_t *dump_id, uint32_t *dump_size, uint32_t *dump_type) 218c7e64b9cSStewart Smith { 2192d6b63bbSAnton Blanchard __be32 id, size, type; 220c7e64b9cSStewart Smith int rc; 221c7e64b9cSStewart Smith 2222d6b63bbSAnton Blanchard type = cpu_to_be32(0xffffffff); 223c7e64b9cSStewart Smith 2242d6b63bbSAnton Blanchard rc = opal_dump_info2(&id, &size, &type); 225c7e64b9cSStewart Smith if (rc == OPAL_PARAMETER) 2262d6b63bbSAnton Blanchard rc = opal_dump_info(&id, &size); 2272d6b63bbSAnton Blanchard 2282d6b63bbSAnton Blanchard *dump_id = be32_to_cpu(id); 2292d6b63bbSAnton Blanchard *dump_size = be32_to_cpu(size); 2302d6b63bbSAnton Blanchard *dump_type = be32_to_cpu(type); 231c7e64b9cSStewart Smith 232c7e64b9cSStewart Smith if (rc) 233c7e64b9cSStewart Smith pr_warn("%s: Failed to get dump info (%d)\n", 234c7e64b9cSStewart Smith __func__, rc); 235c7e64b9cSStewart Smith return rc; 236c7e64b9cSStewart Smith } 237c7e64b9cSStewart Smith 238c7e64b9cSStewart Smith static int64_t dump_read_data(struct dump_obj *dump) 239c7e64b9cSStewart Smith { 240c7e64b9cSStewart Smith struct opal_sg_list *list; 241c7e64b9cSStewart Smith uint64_t addr; 242c7e64b9cSStewart Smith int64_t rc; 243c7e64b9cSStewart Smith 244c7e64b9cSStewart Smith /* Allocate memory */ 245c7e64b9cSStewart Smith dump->buffer = vzalloc(PAGE_ALIGN(dump->size)); 246c7e64b9cSStewart Smith if (!dump->buffer) { 247c7e64b9cSStewart Smith pr_err("%s : Failed to allocate memory\n", __func__); 248c7e64b9cSStewart Smith rc = -ENOMEM; 249c7e64b9cSStewart Smith goto out; 250c7e64b9cSStewart Smith } 251c7e64b9cSStewart Smith 252c7e64b9cSStewart Smith /* Generate SG list */ 2533441f04bSAnton Blanchard list = opal_vmalloc_to_sg_list(dump->buffer, dump->size); 254c7e64b9cSStewart Smith if (!list) { 255c7e64b9cSStewart Smith rc = -ENOMEM; 256c7e64b9cSStewart Smith goto out; 257c7e64b9cSStewart Smith } 258c7e64b9cSStewart Smith 259c7e64b9cSStewart Smith /* First entry address */ 260c7e64b9cSStewart Smith addr = __pa(list); 261c7e64b9cSStewart Smith 262c7e64b9cSStewart Smith /* Fetch data */ 263c7e64b9cSStewart Smith rc = OPAL_BUSY_EVENT; 264c7e64b9cSStewart Smith while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) { 265c7e64b9cSStewart Smith rc = opal_dump_read(dump->id, addr); 266c7e64b9cSStewart Smith if (rc == OPAL_BUSY_EVENT) { 267c7e64b9cSStewart Smith opal_poll_events(NULL); 268c7e64b9cSStewart Smith msleep(20); 269c7e64b9cSStewart Smith } 270c7e64b9cSStewart Smith } 271c7e64b9cSStewart Smith 272c7e64b9cSStewart Smith if (rc != OPAL_SUCCESS && rc != OPAL_PARTIAL) 273c7e64b9cSStewart Smith pr_warn("%s: Extract dump failed for ID 0x%x\n", 274c7e64b9cSStewart Smith __func__, dump->id); 275c7e64b9cSStewart Smith 276c7e64b9cSStewart Smith /* Free SG list */ 2773441f04bSAnton Blanchard opal_free_sg_list(list); 278c7e64b9cSStewart Smith 279c7e64b9cSStewart Smith out: 280c7e64b9cSStewart Smith return rc; 281c7e64b9cSStewart Smith } 282c7e64b9cSStewart Smith 283c7e64b9cSStewart Smith static ssize_t dump_attr_read(struct file *filep, struct kobject *kobj, 284c7e64b9cSStewart Smith struct bin_attribute *bin_attr, 285c7e64b9cSStewart Smith char *buffer, loff_t pos, size_t count) 286c7e64b9cSStewart Smith { 287c7e64b9cSStewart Smith ssize_t rc; 288c7e64b9cSStewart Smith 289c7e64b9cSStewart Smith struct dump_obj *dump = to_dump_obj(kobj); 290c7e64b9cSStewart Smith 291c7e64b9cSStewart Smith if (!dump->buffer) { 292c7e64b9cSStewart Smith rc = dump_read_data(dump); 293c7e64b9cSStewart Smith 294c7e64b9cSStewart Smith if (rc != OPAL_SUCCESS && rc != OPAL_PARTIAL) { 295c7e64b9cSStewart Smith vfree(dump->buffer); 296c7e64b9cSStewart Smith dump->buffer = NULL; 297c7e64b9cSStewart Smith 298c7e64b9cSStewart Smith return -EIO; 299c7e64b9cSStewart Smith } 300c7e64b9cSStewart Smith if (rc == OPAL_PARTIAL) { 301c7e64b9cSStewart Smith /* On a partial read, we just return EIO 302c7e64b9cSStewart Smith * and rely on userspace to ask us to try 303c7e64b9cSStewart Smith * again. 304c7e64b9cSStewart Smith */ 305c7e64b9cSStewart Smith pr_info("%s: Platform dump partially read. ID = 0x%x\n", 306c7e64b9cSStewart Smith __func__, dump->id); 307c7e64b9cSStewart Smith return -EIO; 308c7e64b9cSStewart Smith } 309c7e64b9cSStewart Smith } 310c7e64b9cSStewart Smith 311c7e64b9cSStewart Smith memcpy(buffer, dump->buffer + pos, count); 312c7e64b9cSStewart Smith 313c7e64b9cSStewart Smith /* You may think we could free the dump buffer now and retrieve 314c7e64b9cSStewart Smith * it again later if needed, but due to current firmware limitation, 315c7e64b9cSStewart Smith * that's not the case. So, once read into userspace once, 316c7e64b9cSStewart Smith * we keep the dump around until it's acknowledged by userspace. 317c7e64b9cSStewart Smith */ 318c7e64b9cSStewart Smith 319c7e64b9cSStewart Smith return count; 320c7e64b9cSStewart Smith } 321c7e64b9cSStewart Smith 322c7e64b9cSStewart Smith static struct dump_obj *create_dump_obj(uint32_t id, size_t size, 323c7e64b9cSStewart Smith uint32_t type) 324c7e64b9cSStewart Smith { 325c7e64b9cSStewart Smith struct dump_obj *dump; 326c7e64b9cSStewart Smith int rc; 327c7e64b9cSStewart Smith 328c7e64b9cSStewart Smith dump = kzalloc(sizeof(*dump), GFP_KERNEL); 329c7e64b9cSStewart Smith if (!dump) 330c7e64b9cSStewart Smith return NULL; 331c7e64b9cSStewart Smith 332c7e64b9cSStewart Smith dump->kobj.kset = dump_kset; 333c7e64b9cSStewart Smith 334c7e64b9cSStewart Smith kobject_init(&dump->kobj, &dump_ktype); 335c7e64b9cSStewart Smith 336c7e64b9cSStewart Smith sysfs_bin_attr_init(&dump->dump_attr); 337c7e64b9cSStewart Smith 338c7e64b9cSStewart Smith dump->dump_attr.attr.name = "dump"; 339c7e64b9cSStewart Smith dump->dump_attr.attr.mode = 0400; 340c7e64b9cSStewart Smith dump->dump_attr.size = size; 341c7e64b9cSStewart Smith dump->dump_attr.read = dump_attr_read; 342c7e64b9cSStewart Smith 343c7e64b9cSStewart Smith dump->id = id; 344c7e64b9cSStewart Smith dump->size = size; 345c7e64b9cSStewart Smith dump->type = type; 346c7e64b9cSStewart Smith 347c7e64b9cSStewart Smith rc = kobject_add(&dump->kobj, NULL, "0x%x-0x%x", type, id); 348c7e64b9cSStewart Smith if (rc) { 349c7e64b9cSStewart Smith kobject_put(&dump->kobj); 350c7e64b9cSStewart Smith return NULL; 351c7e64b9cSStewart Smith } 352c7e64b9cSStewart Smith 353c7e64b9cSStewart Smith rc = sysfs_create_bin_file(&dump->kobj, &dump->dump_attr); 354c7e64b9cSStewart Smith if (rc) { 355c7e64b9cSStewart Smith kobject_put(&dump->kobj); 356c7e64b9cSStewart Smith return NULL; 357c7e64b9cSStewart Smith } 358c7e64b9cSStewart Smith 359c7e64b9cSStewart Smith pr_info("%s: New platform dump. ID = 0x%x Size %u\n", 360c7e64b9cSStewart Smith __func__, dump->id, dump->size); 361c7e64b9cSStewart Smith 362c7e64b9cSStewart Smith kobject_uevent(&dump->kobj, KOBJ_ADD); 363c7e64b9cSStewart Smith 364c7e64b9cSStewart Smith return dump; 365c7e64b9cSStewart Smith } 366c7e64b9cSStewart Smith 3678034f715SAlistair Popple static irqreturn_t process_dump(int irq, void *data) 368c7e64b9cSStewart Smith { 369c7e64b9cSStewart Smith int rc; 370c7e64b9cSStewart Smith uint32_t dump_id, dump_size, dump_type; 371c7e64b9cSStewart Smith struct dump_obj *dump; 372c7e64b9cSStewart Smith char name[22]; 373c7e64b9cSStewart Smith 374c7e64b9cSStewart Smith rc = dump_read_info(&dump_id, &dump_size, &dump_type); 375c7e64b9cSStewart Smith if (rc != OPAL_SUCCESS) 376c7e64b9cSStewart Smith return rc; 377c7e64b9cSStewart Smith 378c7e64b9cSStewart Smith sprintf(name, "0x%x-0x%x", dump_type, dump_id); 379c7e64b9cSStewart Smith 380c7e64b9cSStewart Smith /* we may get notified twice, let's handle 381c7e64b9cSStewart Smith * that gracefully and not create two conflicting 382c7e64b9cSStewart Smith * entries. 383c7e64b9cSStewart Smith */ 384c7e64b9cSStewart Smith if (kset_find_obj(dump_kset, name)) 385c7e64b9cSStewart Smith return 0; 386c7e64b9cSStewart Smith 387c7e64b9cSStewart Smith dump = create_dump_obj(dump_id, dump_size, dump_type); 388c7e64b9cSStewart Smith if (!dump) 389c7e64b9cSStewart Smith return -1; 390c7e64b9cSStewart Smith 3918034f715SAlistair Popple return IRQ_HANDLED; 392c7e64b9cSStewart Smith } 393c7e64b9cSStewart Smith 394c7e64b9cSStewart Smith void __init opal_platform_dump_init(void) 395c7e64b9cSStewart Smith { 396c7e64b9cSStewart Smith int rc; 3978034f715SAlistair Popple int dump_irq; 398c7e64b9cSStewart Smith 399831cf65bSMichael Neuling /* ELOG not supported by firmware */ 400831cf65bSMichael Neuling if (!opal_check_token(OPAL_DUMP_READ)) 401831cf65bSMichael Neuling return; 402831cf65bSMichael Neuling 403c7e64b9cSStewart Smith dump_kset = kset_create_and_add("dump", NULL, opal_kobj); 404c7e64b9cSStewart Smith if (!dump_kset) { 405c7e64b9cSStewart Smith pr_warn("%s: Failed to create dump kset\n", __func__); 406c7e64b9cSStewart Smith return; 407c7e64b9cSStewart Smith } 408c7e64b9cSStewart Smith 409c7e64b9cSStewart Smith rc = sysfs_create_group(&dump_kset->kobj, &initiate_attr_group); 410c7e64b9cSStewart Smith if (rc) { 411c7e64b9cSStewart Smith pr_warn("%s: Failed to create initiate dump attr group\n", 412c7e64b9cSStewart Smith __func__); 413c7e64b9cSStewart Smith kobject_put(&dump_kset->kobj); 414c7e64b9cSStewart Smith return; 415c7e64b9cSStewart Smith } 416c7e64b9cSStewart Smith 4178034f715SAlistair Popple dump_irq = opal_event_request(ilog2(OPAL_EVENT_DUMP_AVAIL)); 4188034f715SAlistair Popple if (!dump_irq) { 4198034f715SAlistair Popple pr_err("%s: Can't register OPAL event irq (%d)\n", 4208034f715SAlistair Popple __func__, dump_irq); 4218034f715SAlistair Popple return; 4228034f715SAlistair Popple } 4238034f715SAlistair Popple 4248034f715SAlistair Popple rc = request_threaded_irq(dump_irq, NULL, process_dump, 4258034f715SAlistair Popple IRQF_TRIGGER_HIGH | IRQF_ONESHOT, 4268034f715SAlistair Popple "opal-dump", NULL); 427c7e64b9cSStewart Smith if (rc) { 4288034f715SAlistair Popple pr_err("%s: Can't request OPAL event irq (%d)\n", 429c7e64b9cSStewart Smith __func__, rc); 430c7e64b9cSStewart Smith return; 431c7e64b9cSStewart Smith } 432c7e64b9cSStewart Smith 4337e73a3b7SStewart Smith if (opal_check_token(OPAL_DUMP_RESEND)) 434c7e64b9cSStewart Smith opal_dump_resend_notification(); 435c7e64b9cSStewart Smith } 436