powerpc/powernv: Platform dump interface
PATCH v2 1/1 powerpc/powernv: Platform dump interface
This patch adds interface to retrieve FSP and Platform dump.
Flow:
- We register for OPAL notification events.
- OPAL sends new dump available notification.
- We retrieve the dump via OPAL interface and send it to debugfs.
- User copies the dump data and end ACKs via debugfs.
- We send ACK to OPAL.
OPAL APIs:
- opal_dump_init()
- opal_dump_info()
- opal_dump_read()
- opal_dump_ack()
- opal_dump_resend_notification()
debugfs files:
We create below dump related files under "fsp" directory.
- dump : Dump data
- dump_available : New dump available notification to userspace
- dump_control : ACK dump. Also initiate new FSP dump
- README : README---
Ben,
I have rebased this patch on top of your next branch.
-Vasant
arch/powerpc/include/asm/opal.h | 12 + arch/powerpc/platforms/powernv/Makefile | 2 arch/powerpc/platforms/powernv/opal-dump.c | 436 ++++++++++++++++++++++++ arch/powerpc/platforms/powernv/opal-wrappers.S | 5 arch/powerpc/platforms/powernv/opal.c | 2 5 files changed, 456 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/platforms/powernv/opal-dump.c
arch/powerpc/include/asm/opal.h +12 -0
@@ -154,8 +154,13 @@ extern int opal_enter_rtas(struct rtas_args *args,#define OPAL_FLASH_VALIDATE 76#define OPAL_FLASH_MANAGE 77#define OPAL_FLASH_UPDATE 78 +#define OPAL_DUMP_INIT 81 +#define OPAL_DUMP_INFO 82 +#define OPAL_DUMP_READ 83 +#define OPAL_DUMP_ACK 84#define OPAL_GET_MSG 85#define OPAL_CHECK_ASYNC_COMPLETION 86 +#define OPAL_DUMP_RESEND 91#ifndef __ASSEMBLY__
@@ -236,6 +241,7 @@ enum OpalPendingState {OPAL_EVENT_EPOW =0x80 ,OPAL_EVENT_LED_STATUS =0x100 ,OPAL_EVENT_PCI_ERROR =0x200 , +OPAL_EVENT_DUMP_AVAIL =0x400 , OPAL_EVENT_MSG_PENDING = 0x800, };
@@ -825,6 +831,11 @@ int64_t opal_lpc_read(uint32_t chip_id, enum OpalLPCAddressType addr_type,int64_t opal_validate_flash (uint64_t buffer,uint32_t *size,uint32_t *result);int64_t opal_manage_flash (uint8_t op);int64_t opal_update_flash (uint64_t blk_list); +int64_t opal_dump_init (uint8_t dump_type); +int64_t opal_dump_info (uint32_t *dump_id,uint32_t *dump_size); +int64_t opal_dump_read (uint32_t dump_id,uint64_t buffer); +int64_t opal_dump_ack (uint32_t dump_id); +int64_t opal_dump_resend_notification (void );int64_t opal_get_msg (uint64_t buffer,size_t size);int64_t opal_check_completion (uint64_t buffer,size_t size,uint64_t token);
@@ -859,6 +870,7 @@ extern void opal_get_rtc_time(struct rtc_time *tm);extern unsigned long opal_get_boot_time (void );extern void opal_nvram_init (void );extern void opal_flash_init (void ); +extern void opal_platform_dump_init (void );extern int opal_machine_check (struct pt_regs *regs);
arch/powerpc/platforms/powernv/Makefile +1 -1
@@ -1,6 +1,6 @@ obj-y += setup.o opal-takeover.o opal-wrappers.o opal.o obj-y += opal-rtc.o opal-nvram.o opal-lpc.o opal-flash.o -obj-y += rng.o +obj-y += rng.o opal-dump.o obj-$(CONFIG_SMP) += smp.o obj-$(CONFIG_PCI) += pci.o pci-p5ioc2.o pci-ioda.o
arch/powerpc/platforms/powernv/opal-dump.c new file +436 -0
436 lines not on this page · raw message
arch/powerpc/platforms/powernv/opal-wrappers.S +5 -0
@@ -126,5 +126,10 @@ OPAL_CALL(opal_return_cpu, OPAL_RETURN_CPU); OPAL_CALL(opal_validate_flash, OPAL_FLASH_VALIDATE); OPAL_CALL(opal_manage_flash, OPAL_FLASH_MANAGE); OPAL_CALL(opal_update_flash, OPAL_FLASH_UPDATE); +OPAL_CALL(opal_dump_init, OPAL_DUMP_INIT); +OPAL_CALL(opal_dump_info, OPAL_DUMP_INFO); +OPAL_CALL(opal_dump_read, OPAL_DUMP_READ); +OPAL_CALL(opal_dump_ack, OPAL_DUMP_ACK); OPAL_CALL(opal_get_msg, OPAL_GET_MSG); OPAL_CALL(opal_check_completion, OPAL_CHECK_ASYNC_COMPLETION); +OPAL_CALL(opal_dump_resend_notification, OPAL_DUMP_RESEND);
arch/powerpc/platforms/powernv/opal.c +2 -0
@@ -473,6 +473,8 @@ static int __init opal_init(void)if (rc ==0 ) {/* Setup code update interface */ opal_flash_init (); +/* Setup platform dump extract interface */ +opal_platform_dump_init (); }return 0 ;
Hi Vasant,
Quoted 80 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +36
-0+static void free_dump_sg_list (struct opal_sg_list *list) +{ +struct opal_sg_list *sg1; +while (list) { + sg1 = list->next; +kfree (list); + list = sg1; + } + list =NULL ; +} + +/* +* Build dump buffer scatter gather list +*/ +static struct opal_sg_list *dump_data_to_sglist (void ) +{ +struct opal_sg_list *sg1, *list =NULL ; +void *addr; +int64_t size; + + addr = dump_record.buffer; + size = dump_record.size; + + sg1 =kzalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!sg1) + goto nomem; + + list = sg1; + sg1->num_entries =0 ; +while (size >0 ) { +/* Translate virtual address to physical address */ + sg1->entry[sg1->num_entries].data = + (void *)(vmalloc_to_pfn (addr) <<PAGE_SHIFT ); + +if (size >PAGE_SIZE ) + sg1->entry[sg1->num_entries].length =
PAGE_SIZE;arch/powerpc/platforms/powernv/opal-dump.c new file +35
-0+else + sg1->entry[sg1->num_entries].length = size; + + sg1->num_entries++; +if (sg1->num_entries >=SG_ENTRIES_PER_NODE ) { + sg1->next =kzalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!sg1->next) + goto nomem; + + sg1 = sg1->next; + sg1->num_entries =0 ; + } + addr +=PAGE_SIZE ; + size -=PAGE_SIZE ; + } +return list; + +nomem: +pr_err ("%s : Failed to allocate memory\n" , __func__); +free_dump_sg_list (list); +return NULL ; +} + +/* +* Translate sg list address to absolute +*/ +static void sglist_to_phy_addr (struct opal_sg_list *list) +{ +struct opal_sg_list *sg, *next; + +for (sg = list; sg; sg = next) { + next = sg->next; +/* Don't translate NULL pointer for last entry */ +if (sg->next) + sg->next = (struct opal_sg_list*)__pa(sg->next);
arch/powerpc/platforms/powernv/opal-dump.c new file +6
-0+else + sg->next =NULL ; + +/* Convert num_entries to length */ + sg->num_entries = + sg->num_entries * sizeof(struct
opal_sg_entry) + 16;
arch/powerpc/platforms/powernv/opal-dump.c line 132
Quoted 8 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +8
-0+ } +} + +static void free_dump_data_buf (void ) +{ +vfree (dump_record.buffer); + dump_record.size =0 ; +}
This looks identical to the code in opal-flash.c. Considering how complicated it is, can we put it somewhere common?
Anton
Quoted 83 lines · Anton Blanchard
Hi Vasant,
Quoted 80 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +36
-0+static void free_dump_sg_list (struct opal_sg_list *list) +{ +struct opal_sg_list *sg1; +while (list) { + sg1 = list->next; +kfree (list); + list = sg1; + } + list =NULL ; +} + +/* +* Build dump buffer scatter gather list +*/ +static struct opal_sg_list *dump_data_to_sglist (void ) +{ +struct opal_sg_list *sg1, *list =NULL ; +void *addr; +int64_t size; + + addr = dump_record.buffer; + size = dump_record.size; + + sg1 =kzalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!sg1) + goto nomem; + + list = sg1; + sg1->num_entries =0 ; +while (size >0 ) { +/* Translate virtual address to physical address */ + sg1->entry[sg1->num_entries].data = + (void *)(vmalloc_to_pfn (addr) <<PAGE_SHIFT ); + +if (size >PAGE_SIZE ) + sg1->entry[sg1->num_entries].length =
PAGE_SIZE;arch/powerpc/platforms/powernv/opal-dump.c new file +35
-0+else + sg1->entry[sg1->num_entries].length = size; + + sg1->num_entries++; +if (sg1->num_entries >=SG_ENTRIES_PER_NODE ) { + sg1->next =kzalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!sg1->next) + goto nomem; + + sg1 = sg1->next; + sg1->num_entries =0 ; + } + addr +=PAGE_SIZE ; + size -=PAGE_SIZE ; + } +return list; + +nomem: +pr_err ("%s : Failed to allocate memory\n" , __func__); +free_dump_sg_list (list); +return NULL ; +} + +/* +* Translate sg list address to absolute +*/ +static void sglist_to_phy_addr (struct opal_sg_list *list) +{ +struct opal_sg_list *sg, *next; + +for (sg = list; sg; sg = next) { + next = sg->next; +/* Don't translate NULL pointer for last entry */ +if (sg->next) + sg->next = (struct opal_sg_list*)__pa(sg->next);
arch/powerpc/platforms/powernv/opal-dump.c new file +6
-0+else + sg->next =NULL ; + +/* Convert num_entries to length */ + sg->num_entries = + sg->num_entries * sizeof(struct
opal_sg_entry) + 16;
Quoted 9 lines
arch/powerpc/platforms/powernv/opal-dump.c line 132
Quoted 8 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +8
-0+ } +} + +static void free_dump_data_buf (void ) +{ +vfree (dump_record.buffer); + dump_record.size =0 ; +}
Anton,
Quoted 2 lines
This looks identical to the code in
opal-flash.c. Considering how complicated it is, can we put it somewhere common?
Thanks for the review.. Will look into it next week.
-Vasant
Quoted 3 lines
Anton
Hi Vasant,
Quoted 96 lines · Anton Blanchard
Quoted 85 lines
Hi Vasant,
Quoted 82 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +31
-0+static void free_dump_sg_list (struct opal_sg_list *list) +{ +struct opal_sg_list *sg1; +while (list) { + sg1 = list->next; +kfree (list); + list = sg1; + } + list =NULL ; +} + +/* +* Build dump buffer scatter gather list +*/ +static struct opal_sg_list *dump_data_to_sglist (void ) +{ +struct opal_sg_list *sg1, *list =NULL ; +void *addr; +int64_t size; + + addr = dump_record.buffer; + size = dump_record.size; + + sg1 =kzalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!sg1) + goto nomem; + + list = sg1; + sg1->num_entries =0 ; +while (size >0 ) { +/* Translate virtual address to physical address */
(quoted diff) +2
-0+ sg1->entry[sg1->num_entries].data = + (void *)(vmalloc_to_pfn(addr) <<
PAGE_SHIFT); +(quoted diff) +2
-0+ if (size > PAGE_SIZE) + sg1->entry[sg1->num_entries].length =
PAGE_SIZE;(quoted diff) +2
-0+ else + sg1->entry[sg1->num_entries].length =size; +
arch/powerpc/platforms/powernv/opal-dump.c new file +3
-0+ sg1->num_entries++; +if (sg1->num_entries >=SG_ENTRIES_PER_NODE ) { + sg1->next = kzalloc(PAGE_SIZE,
GFP_KERNEL);arch/powerpc/platforms/powernv/opal-dump.c new file +29
-0+if (!sg1->next) + goto nomem; + + sg1 = sg1->next; + sg1->num_entries =0 ; + } + addr +=PAGE_SIZE ; + size -=PAGE_SIZE ; + } +return list; + +nomem: +pr_err ("%s : Failed to allocate memory\n" , __func__); +free_dump_sg_list (list); +return NULL ; +} + +/* +* Translate sg list address to absolute +*/ +static void sglist_to_phy_addr (struct opal_sg_list *list) +{ +struct opal_sg_list *sg, *next; + +for (sg = list; sg; sg = next) { + next = sg->next; +/* Don't translate NULL pointer for last entry */ +if (sg->next) + sg->next = (struct opal_sg_list*)__pa(sg->next);
arch/powerpc/platforms/powernv/opal-dump.c new file +6
-0+else + sg->next =NULL ; + +/* Convert num_entries to length */ + sg->num_entries = + sg->num_entries * sizeof(struct
opal_sg_entry) + 16;Quoted 9 lines
arch/powerpc/platforms/powernv/opal-dump.c line 132
Quoted 8 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +8
-0+ } +} + +static void free_dump_data_buf (void ) +{ +vfree (dump_record.buffer); + dump_record.size =0 ; +}
Quoted 6 lines
Anton,
Quoted 2 lines
This looks identical to the code in
opal-flash.c. Considering how complicated it is, can we put it somewhere common?Thanks for the review.. Will look into it next week.
This doesn't appear to have been fixed in the version that went into next.
Anton
Quoted 105 lines · Anton Blanchard
Hi Vasant,
Quoted 102 lines · Anton Blanchard
Quoted 85 lines
Hi Vasant,
Quoted 82 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +31
-0+static void free_dump_sg_list (struct opal_sg_list *list) +{ +struct opal_sg_list *sg1; +while (list) { + sg1 = list->next; +kfree (list); + list = sg1; + } + list =NULL ; +} + +/* +* Build dump buffer scatter gather list +*/ +static struct opal_sg_list *dump_data_to_sglist (void ) +{ +struct opal_sg_list *sg1, *list =NULL ; +void *addr; +int64_t size; + + addr = dump_record.buffer; + size = dump_record.size; + + sg1 =kzalloc (PAGE_SIZE ,GFP_KERNEL ); +if (!sg1) + goto nomem; + + list = sg1; + sg1->num_entries =0 ; +while (size >0 ) { +/* Translate virtual address to physical address */
(quoted diff) +2
-0+ sg1->entry[sg1->num_entries].data = + (void *)(vmalloc_to_pfn(addr) <<
PAGE_SHIFT); +(quoted diff) +2
-0+ if (size > PAGE_SIZE) + sg1->entry[sg1->num_entries].length =
PAGE_SIZE;(quoted diff) +2
-0+ else + sg1->entry[sg1->num_entries].length =size; +
arch/powerpc/platforms/powernv/opal-dump.c new file +3
-0+ sg1->num_entries++; +if (sg1->num_entries >=SG_ENTRIES_PER_NODE ) { + sg1->next = kzalloc(PAGE_SIZE,
GFP_KERNEL);arch/powerpc/platforms/powernv/opal-dump.c new file +29
-0+if (!sg1->next) + goto nomem; + + sg1 = sg1->next; + sg1->num_entries =0 ; + } + addr +=PAGE_SIZE ; + size -=PAGE_SIZE ; + } +return list; + +nomem: +pr_err ("%s : Failed to allocate memory\n" , __func__); +free_dump_sg_list (list); +return NULL ; +} + +/* +* Translate sg list address to absolute +*/ +static void sglist_to_phy_addr (struct opal_sg_list *list) +{ +struct opal_sg_list *sg, *next; + +for (sg = list; sg; sg = next) { + next = sg->next; +/* Don't translate NULL pointer for last entry */ +if (sg->next) + sg->next = (struct opal_sg_list*)__pa(sg->next);
arch/powerpc/platforms/powernv/opal-dump.c new file +6
-0+else + sg->next =NULL ; + +/* Convert num_entries to length */ + sg->num_entries = + sg->num_entries * sizeof(struct
opal_sg_entry) + 16;Quoted 9 lines
arch/powerpc/platforms/powernv/opal-dump.c line 132
Quoted 8 lines
arch/powerpc/platforms/powernv/opal-dump.c new file +8
-0+ } +} + +static void free_dump_data_buf (void ) +{ +vfree (dump_record.buffer); + dump_record.size =0 ; +}Anton,
Quoted 2 lines
This looks identical to the code in
opal-flash.c. Considering how complicated it is, can we put it somewhere common?Thanks for the review.. Will look into it next week.
Anton,
Quoted 3 lines
This doesn't appear to have been fixed in the version that went into next.
Stewart rewrote dump interface.. That set of patch went into next, not my original patch.. Yes.. SG list separation is not yet done.. Never got a chance to look into this one.. Will try to do it soon.
-Vasant
Quoted 2 lines
Anton
PATCH v2 1/1 powernv: don't attempt to refetch the FSP dump until the user has explicitly acked it.
In reply to Vasant HegdeThis fixes a bug where we would get two events from OPAL with DUMP_AVAIL set (which is valid for OPAL to do) and in the second run of extract_dump() we would fail to free the memory previously allocated for the dump (leaking ~6MB+) as well as on the second dump_read_data() call OPAL would not retrieve the dump, leaving us with a dump in linux that was the correct size but all zeros.
Changes since v1: fixed typo
--- arch/powerpc/platforms/powernv/opal-dump.c | 8 ++++++++ 1 file changed, 8 insertions(+)
arch/powerpc/platforms/powernv/opal-dump.c +8 -0
@@ -238,6 +238,14 @@ static int extract_dump(void) {int rc; +/* We can get notified that a dump is available multiple times +* (dump_read_info clears the bit in the event from OPAL). +* But we should not re-read the dump from OPAL as we +* don't get the next dump until we've explicitly acked this one. +*/ +if (dump_avail) +return OPAL_SUCCESS ; +/* Get dump ID, size */ rc =dump_read_info ();if (rc !=OPAL_SUCCESS )
Signature · 1 line
1.7.10.4
Re: [PATCH v2] powernv: don't attempt to refetch the FSP dump until the user has explicitly acked it.
Quoted 11 lines · Stewart Smith
This fixes a bug where we would get two events from OPAL with
DUMP_AVAILset (which is valid for OPAL to do) and in the second run ofextract_dump()we would fail to free the memory previously allocated for the dump (leaking ~6MB+) as well as on the seconddump_read_data()call OPAL would not retrieve the dump, leaving us with a dump in linux that was the correct size but all zeros.Changes since v1: fixed typo
Signed-off-by Stewart Smith <[email protected]>
Should we CC stable on this?
Mikey
Quoted 31 lines
--- arch/powerpc/platforms/powernv/opal-dump.c | 8 ++++++++ 1 file changed, 8 insertions(+)arch/powerpc/platforms/powernv/opal-dump.c +8
-0@@ -238,6 +238,14 @@ static int extract_dump(void) {int rc; +/* We can get notified that a dump is available multiple times +* (dump_read_info clears the bit in the event from OPAL). +* But we should not re-read the dump from OPAL as we +* don't get the next dump until we've explicitly acked this one. +*/ +if (dump_avail) +return OPAL_SUCCESS ; +/* Get dump ID, size */ rc =dump_read_info ();if (rc !=OPAL_SUCCESS )Signature · 6 lines
1.7.10.4 _______________________________________________ Linuxppc-dev mailing list [email protected] https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2] powernv: don't attempt to refetch the FSP dump until the user has explicitly acked it.
Quoted 9 lines · Michael Neuling
Quoted 7 lines · Stewart Smith
This fixes a bug where we would get two events from OPAL with
DUMP_AVAILset (which is valid for OPAL to do) and in the second run ofextract_dump()we would fail to free the memory previously allocated for the dump (leaking ~6MB+) as well as on the seconddump_read_data()call OPAL would not retrieve the dump, leaving us with a dump in linux that was the correct size but all zeros.
Quoted 6 lines
Quoted 4 lines
Changes since v1: fixed typo
Signed-off-by Stewart Smith <[email protected]>Should we CC stable on this?
we don't need to as the code this patches hasn't made it to stable yet. Hopefully Vasant resends a version of the patch incorporating my fix :)