powerpc/powernv: Use uint64_t instead of size_t in OPAL APIs
PATCH 1/4 powerpc/powernv: Use uint64_t instead of size_t in OPAL APIs
Using size_t in our APIs is asking for trouble, especially when some OPAL calls use size_t pointers.
---
arch/powerpc/include/asm/opal.h +6 -6
@@ -850,8 +850,8 @@ int64_t opal_lpc_write(uint32_t chip_id,int64_t opal_lpc_read (uint32_t chip_id,enum OpalLPCAddressType addr_type,uint32_t addr,__be32 *data,uint32_t sz); -int64_t opal_read_elog (uint64_t buffer,size_t size,uint64_t log_id); -int64_t opal_get_elog_size (uint64_t *log_id,size_t *size,uint64_t *elog_type); +int64_t opal_read_elog (uint64_t buffer,uint64_t size,uint64_t log_id); +int64_t opal_get_elog_size (uint64_t *log_id,uint64_t *size,uint64_t *elog_type);int64_t opal_write_elog (uint64_t buffer,uint64_t size,uint64_t offset);int64_t opal_send_ack_elog (uint64_t log_id);void opal_resend_pending_logs (void );
@@ -866,13 +866,13 @@ int64_t opal_dump_read(uint32_t dump_id,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); +int64_t opal_get_msg (uint64_t buffer,uint64_t size); +int64_t opal_check_completion (uint64_t buffer,uint64_t size,uint64_t token);int64_t opal_sync_host_reboot (void );int64_t opal_get_param (uint64_t token,uint32_t param_id,uint64_t buffer, -size_t length); +uint64_t length);int64_t opal_set_param (uint64_t token,uint32_t param_id,uint64_t buffer, -size_t length); +uint64_t length);int64_t opal_sensor_read (uint32_t sensor_hndl,int token,uint32_t *sensor_data);
arch/powerpc/platforms/powernv/opal-elog.c +1 -1
@@ -243,7 +243,7 @@ static struct elog_obj *create_elog_obj(static void elog_work_fn (struct work_struct *work) { -size_t elog_size; +uint64_t elog_size;uint64_t log_id;uint64_t elog_type;int rc;
PATCH 2/4 powerpc/powernv: Remove some OPAL function declaration duplication
We had some duplication of the internal OPAL functions.
---
arch/powerpc/include/asm/opal.h +2 -10
@@ -877,7 +877,8 @@ int64_t opal_sensor_read(uint32_t sensor uint32_t *sensor_data);/* Internal functions */ -extern int early_init_dt_scan_opal (unsigned long node,const char *uname,int depth,void *data); +extern int early_init_dt_scan_opal (unsigned long node,const char *uname, +int depth,void *data);extern int early_init_dt_scan_recoverable_ranges (unsigned long node,const char *uname,int depth,void *data);
@@ -886,10 +887,6 @@ extern int opal_put_chars(uint32_t vtermextern void hvc_opal_init_early (void ); -/* Internal functions */ -extern int early_init_dt_scan_opal (unsigned long node,const char *uname, -int depth,void *data); -extern int opal_notifier_register (struct notifier_block *nb);extern int opal_message_notifier_register (enum OpalMessageType msg_type,struct notifier_block *nb);
@@ -897,9 +894,6 @@ extern void opal_notifier_enable(void);extern void opal_notifier_disable (void );extern void opal_notifier_update_evt (uint64_t evt_mask,uint64_t evt_val); -extern int opal_get_chars (uint32_t vtermno,char *buf,int count); -extern int opal_put_chars (uint32_t vtermno,const char *buf,int total_len); -extern int __opal_async_get_token (void );extern int opal_async_get_token_interruptible (void );extern int __opal_async_release_token (int token);
@@ -907,8 +901,6 @@ extern int opal_async_release_token(intextern int opal_async_wait_response (uint64_t token,struct opal_msg *msg);extern int opal_get_sensor_data (u32 sensor_hndl,u32 *sensor_data); -extern void hvc_opal_init_early (void ); -struct rtc_time ;extern int opal_set_rtc_time (struct rtc_time *tm);extern void opal_get_rtc_time (struct rtc_time *tm);
PATCH 3/4 powerpc/powernv: Fix little endian issues with opal_do_notifier calls
In reply to Anton BlanchardThe bitmap in opal_poll_events and opal_handle_interrupt is big endian, so we need to byteswap it on little endian builds.
---
arch/powerpc/platforms/powernv/opal.c +3 -3
@@ -216,14 +216,14 @@ void opal_notifier_update_evt(uint64_t evoid opal_notifier_enable (void ) {int64_t rc; -uint64_t evt =0 ; +__be64 evt =0 ;atomic_set (&opal_notifier_hold,0 );/* Process pending events */ rc =opal_poll_events (&evt);if (rc ==OPAL_SUCCESS && evt) -opal_do_notifier (evt); +opal_do_notifier (be64_to_cpu (evt)); }void opal_notifier_disable (void )
@@ -501,7 +501,7 @@ static irqreturn_t opal_interrupt(int iropal_handle_interrupt (virq_to_hw (irq), &events); -opal_do_notifier (events); +opal_do_notifier (be64_to_cpu (events));return IRQ_HANDLED ; }
PATCH 4/4 powerpc/powernv: Fix little endian issues OPAL error log code
In reply to Anton BlanchardFix little endian issues with the OPAL error log code.
---
arch/powerpc/platforms/powernv/opal-elog.c +8 -1
@@ -243,18 +243,25 @@ static struct elog_obj *create_elog_obj(static void elog_work_fn (struct work_struct *work) { +__be64 size; +__be64 id; +__be64 type;uint64_t elog_size;uint64_t log_id;uint64_t elog_type;int rc;char name[2 +16 +1 ]; - rc =opal_get_elog_size (&log_id, &elog_size, &elog_type); + rc =opal_get_elog_size (&id, &size, &type);if (rc !=OPAL_SUCCESS ) {pr_err ("ELOG: Opal log read failed\n" );return ; } + elog_size =be64_to_cpu (size); + log_id =be64_to_cpu (id); + elog_type =be64_to_cpu (type); +BUG_ON (elog_size >OPAL_MAX_ERRLOG_SIZE );if (elog_size >=OPAL_MAX_ERRLOG_SIZE )
arch/powerpc/include/asm/opal.h +1 -1
@@ -851,7 +851,7 @@ int64_t opal_lpc_read(uint32_t chip_id, uint32_t addr, __be32 *data, uint32_t sz);int64_t opal_read_elog (uint64_t buffer,uint64_t size,uint64_t log_id); -int64_t opal_get_elog_size (uint64_t *log_id,uint64_t *size,uint64_t *elog_type); +int64_t opal_get_elog_size (__be64 *log_id,__be64 *size,__be64 *elog_type);int64_t opal_write_elog (uint64_t buffer,uint64_t size,uint64_t offset);int64_t opal_send_ack_elog (uint64_t log_id);void opal_resend_pending_logs (void );
Re: [PATCH 4/4] powerpc/powernv: Fix little endian issues OPAL error log code
Quoted 3 lines · Anton Blanchard
Fix little endian issues with the OPAL error log code.
Signed-off-by Anton Blanchard <[email protected]>
Do we also need any magic for the getting of error logs themselves?
You may want to check the md5 of the logs themselves on be and le.
Quoted 46 lines
---
Index:
b/arch/powerpc/platforms/powernv/opal-elog.c
===================================================================arch/powerpc/platforms/powernv/opal-elog.c +8
-1@@ -243,18 +243,25 @@ static struct elog_obj *create_elog_obj(static void elog_work_fn (struct work_struct *work) { +__be64 size; +__be64 id; +__be64 type;uint64_t elog_size;uint64_t log_id;uint64_t elog_type;int rc;char name[2 +16 +1 ]; - rc =opal_get_elog_size (&log_id, &elog_size, &elog_type); + rc =opal_get_elog_size (&id, &size, &type);if (rc !=OPAL_SUCCESS ) {pr_err ("ELOG: Opal log read failed\n" );return ; } + elog_size =be64_to_cpu (size); + log_id =be64_to_cpu (id); + elog_type =be64_to_cpu (type); +BUG_ON (elog_size >OPAL_MAX_ERRLOG_SIZE );if (elog_size >=OPAL_MAX_ERRLOG_SIZE )Index:
b/arch/powerpc/include/asm/opal.h
===================================================================arch/powerpc/include/asm/opal.h +1
-1@@ -851,7 +851,7 @@ int64_t opal_lpc_read(uint32_t chip_id, uint32_t addr, __be32 *data, uint32_t sz);int64_t opal_read_elog (uint64_t buffer,uint64_t size,uint64_t log_id); -int64_t opal_get_elog_size (uint64_t *log_id,uint64_t *size,uint64_t *elog_type); +int64_t opal_get_elog_size (__be64 *log_id,__be64 *size,__be64 *elog_type);int64_t opal_write_elog (uint64_t buffer,uint64_t size,uint64_t offset);int64_t opal_send_ack_elog (uint64_t log_id);void opal_resend_pending_logs (void );
Re: [PATCH 4/4] powerpc/powernv: Fix little endian issues OPAL error log code
Hi Stewart,
Quoted 3 lines
Do we also need any magic for the getting of error logs themselves?
You may want to check the md5 of the logs themselves on be and le.
Good idea. An md5 of the logs in LE and BE on this box checks out, so I think we are good.
Anton
Quoted 4 lines · Anton Blanchard
Using
size_tin our APIs is asking for trouble, especially when some OPAL calls usesize_tpointers.Signed-off-by Anton Blanchard <[email protected]>
Quoted 48 lines
---
Index:
b/arch/powerpc/include/asm/opal.h
===================================================================arch/powerpc/include/asm/opal.h +6
-6@@ -850,8 +850,8 @@ int64_t opal_lpc_write(uint32_t chip_id,int64_t opal_lpc_read (uint32_t chip_id,enum OpalLPCAddressType addr_type,uint32_t addr,__be32 *data,uint32_t sz); -int64_t opal_read_elog (uint64_t buffer,size_t size,uint64_t log_id); -int64_t opal_get_elog_size (uint64_t *log_id,size_t *size,uint64_t *elog_type); +int64_t opal_read_elog (uint64_t buffer,uint64_t size,uint64_t log_id); +int64_t opal_get_elog_size (uint64_t *log_id,uint64_t *size,uint64_t *elog_type);int64_t opal_write_elog (uint64_t buffer,uint64_t size,uint64_t offset);int64_t opal_send_ack_elog (uint64_t log_id);void opal_resend_pending_logs (void );@@ -866,13 +866,13 @@ int64_t opal_dump_read(uint32_t dump_id,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); +int64_t opal_get_msg (uint64_t buffer,uint64_t size); +int64_t opal_check_completion (uint64_t buffer,uint64_t size,uint64_t token);int64_t opal_sync_host_reboot (void );int64_t opal_get_param (uint64_t token,uint32_t param_id,uint64_t buffer, -size_t length); +uint64_t length);int64_t opal_set_param (uint64_t token,uint32_t param_id,uint64_t buffer, -size_t length); +uint64_t length);int64_t opal_sensor_read (uint32_t sensor_hndl,int token,uint32_t *sensor_data);Index:
b/arch/powerpc/platforms/powernv/opal-elog.c
===================================================================arch/powerpc/platforms/powernv/opal-elog.c +1
-1@@ -243,7 +243,7 @@ static struct elog_obj *create_elog_obj(static void elog_work_fn (struct work_struct *work) { -size_t elog_size; +uint64_t elog_size;uint64_t log_id;uint64_t elog_type;int rc;