Message ID | 20211010183815.5780-2-svens@stackframe.org (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | add TOC support | expand |
> --- a/arch/parisc/include/uapi/asm/pdc.h > +++ b/arch/parisc/include/uapi/asm/pdc.h > @@ -689,6 +689,28 @@ struct pdc_hpmc_pim_20 { /* PDC_PIM */ > unsigned long long fr[32]; > }; > > +struct pdc_toc_pim_11 { > + unsigned int gr[32]; > + unsigned int cr[32]; > + unsigned int sr[8]; > + unsigned int iasq_back; > + unsigned int iaoq_back; > + unsigned int check_type; > + unsigned int hversion; > + unsigned int cpu_state; > +}; > + > +struct pdc_toc_pim_20 { > + unsigned long long gr[32]; > + unsigned long long cr[32]; > + unsigned long long sr[8]; > + unsigned long long iasq_back; > + unsigned long long iaoq_back; > + unsigned int check_type; > + unsigned int hversion; > + unsigned int cpu_state; > +}; > + > #endif /* !defined(__ASSEMBLY__) */ Since these are defined by the hardware and have a well defined size I suggest using u32 and u64 to cover this. > diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c > index 7034227dbdf3..9179b4409b63 100644 > --- a/arch/parisc/kernel/firmware.c > +++ b/arch/parisc/kernel/firmware.c > @@ -1061,6 +1061,38 @@ int pdc_mem_pdt_read_entries(struct pdc_mem_read_pdt > *pret, return retval; > } > > +/** > + * pdc_pim_toc11 - Fetch TOC PIM 1.1 data from firmware. > + * @ret: pointer to return buffer > + */ > +int pdc_pim_toc11(struct pdc_toc_pim_11 *ret) > +{ > + int retval; > + unsigned long flags; > + > + spin_lock_irqsave(&pdc_lock, flags); > + retval = mem_pdc_call(PDC_PIM, PDC_PIM_TOC, __pa(pdc_result), > + __pa(ret), sizeof(struct pdc_toc_pim_11)); sizeof(*ret) > + spin_unlock_irqrestore(&pdc_lock, flags); > + return retval; > +} > + > +/** > + * pdc_pim_toc20 - Fetch TOC PIM 2.0 data from firmware. > + * @ret: pointer to return buffer > + */ > +int pdc_pim_toc20(struct pdc_toc_pim_20 *ret) > +{ > + int retval; > + unsigned long flags; > + > + spin_lock_irqsave(&pdc_lock, flags); > + retval = mem_pdc_call(PDC_PIM, PDC_PIM_TOC, __pa(pdc_result), > + __pa(ret), sizeof(struct pdc_toc_pim_20)); sizeof(*ret) > + spin_unlock_irqrestore(&pdc_lock, flags); > + return retval; > +} > + > /** > * pdc_tod_set - Set the Time-Of-Day clock. > * @sec: The number of seconds since epoch.
On 10/11/21 17:05, Rolf Eike Beer wrote: >> --- a/arch/parisc/include/uapi/asm/pdc.h >> +++ b/arch/parisc/include/uapi/asm/pdc.h >> @@ -689,6 +689,28 @@ struct pdc_hpmc_pim_20 { /* PDC_PIM */ >> unsigned long long fr[32]; >> }; >> >> +struct pdc_toc_pim_11 { >> + unsigned int gr[32]; >> + unsigned int cr[32]; >> + unsigned int sr[8]; >> + unsigned int iasq_back; >> + unsigned int iaoq_back; >> + unsigned int check_type; >> + unsigned int hversion; >> + unsigned int cpu_state; >> +}; >> + >> +struct pdc_toc_pim_20 { >> + unsigned long long gr[32]; >> + unsigned long long cr[32]; >> + unsigned long long sr[8]; >> + unsigned long long iasq_back; >> + unsigned long long iaoq_back; >> + unsigned int check_type; >> + unsigned int hversion; >> + unsigned int cpu_state; >> +}; >> + >> #endif /* !defined(__ASSEMBLY__) */ > > Since these are defined by the hardware and have a well defined size I suggest > using u32 and u64 to cover this. You're right. But in the whole file we use "unsigned int" for 32bit, and "unsigned long long" for 64bit, so this change is consistent with the other contents. Helge
Helge Deller <deller@gmx.de> writes: > On 10/11/21 17:05, Rolf Eike Beer wrote: >>> --- a/arch/parisc/include/uapi/asm/pdc.h >>> +++ b/arch/parisc/include/uapi/asm/pdc.h >>> @@ -689,6 +689,28 @@ struct pdc_hpmc_pim_20 { /* PDC_PIM */ >>> unsigned long long fr[32]; >>> }; >>> >>> +struct pdc_toc_pim_11 { >>> + unsigned int gr[32]; >>> + unsigned int cr[32]; >>> + unsigned int sr[8]; >>> + unsigned int iasq_back; >>> + unsigned int iaoq_back; >>> + unsigned int check_type; >>> + unsigned int hversion; >>> + unsigned int cpu_state; >>> +}; >>> + >>> +struct pdc_toc_pim_20 { >>> + unsigned long long gr[32]; >>> + unsigned long long cr[32]; >>> + unsigned long long sr[8]; >>> + unsigned long long iasq_back; >>> + unsigned long long iaoq_back; >>> + unsigned int check_type; >>> + unsigned int hversion; >>> + unsigned int cpu_state; >>> +}; >>> + >>> #endif /* !defined(__ASSEMBLY__) */ >> >> Since these are defined by the hardware and have a well defined size I suggest >> using u32 and u64 to cover this. > > You're right. > But in the whole file we use "unsigned int" for 32bit, and "unsigned long long" > for 64bit, so this change is consistent with the other contents. Yes, especially the 'unsigned long long' catched my eye. However, i kept it that way so it is consistent with the other structs. I'm happy to change the types with a cleanup patch, but i'm wondering: why is that all uapi? IMHO this should go to include/asm? Any objections against moving it? I don't see how userspace could use that given that only the kernel should be able to call into firmware.
On 10/12/21 22:33, Sven Schnelle wrote: > Helge Deller <deller@gmx.de> writes: > >> On 10/11/21 17:05, Rolf Eike Beer wrote: >>>> --- a/arch/parisc/include/uapi/asm/pdc.h >>>> +++ b/arch/parisc/include/uapi/asm/pdc.h >>>> @@ -689,6 +689,28 @@ struct pdc_hpmc_pim_20 { /* PDC_PIM */ >>>> unsigned long long fr[32]; >>>> }; >>>> >>>> +struct pdc_toc_pim_11 { >>>> + unsigned int gr[32]; >>>> + unsigned int cr[32]; >>>> + unsigned int sr[8]; >>>> + unsigned int iasq_back; >>>> + unsigned int iaoq_back; >>>> + unsigned int check_type; >>>> + unsigned int hversion; >>>> + unsigned int cpu_state; >>>> +}; >>>> + >>>> +struct pdc_toc_pim_20 { >>>> + unsigned long long gr[32]; >>>> + unsigned long long cr[32]; >>>> + unsigned long long sr[8]; >>>> + unsigned long long iasq_back; >>>> + unsigned long long iaoq_back; >>>> + unsigned int check_type; >>>> + unsigned int hversion; >>>> + unsigned int cpu_state; >>>> +}; >>>> + >>>> #endif /* !defined(__ASSEMBLY__) */ >>> >>> Since these are defined by the hardware and have a well defined size I suggest >>> using u32 and u64 to cover this. >> >> You're right. >> But in the whole file we use "unsigned int" for 32bit, and "unsigned long long" >> for 64bit, so this change is consistent with the other contents. > > Yes, especially the 'unsigned long long' catched my eye. However, i kept > it that way so it is consistent with the other structs. I'm happy to > change the types with a cleanup patch, but i'm wondering: why is that > all uapi? IMHO this should go to include/asm? Any objections against > moving it? I don't see how userspace could use that given that only the > kernel should be able to call into firmware. I think for the palo bootloader and the qemu sources they were put in include/uapi. Both projects have copies though, so I think it can go to include/asm. If you send a patch I can take it. Helge
diff --git a/arch/parisc/include/asm/pdc.h b/arch/parisc/include/asm/pdc.h index b388d8176588..18b957a8630d 100644 --- a/arch/parisc/include/asm/pdc.h +++ b/arch/parisc/include/asm/pdc.h @@ -51,6 +51,8 @@ int pdc_spaceid_bits(unsigned long *space_bits); int pdc_btlb_info(struct pdc_btlb_info *btlb); int pdc_mem_map_hpa(struct pdc_memory_map *r_addr, struct pdc_module_path *mod_path); #endif /* !CONFIG_PA20 */ +int pdc_pim_toc11(struct pdc_toc_pim_11 *ret); +int pdc_pim_toc20(struct pdc_toc_pim_20 *ret); int pdc_lan_station_id(char *lan_addr, unsigned long net_hpa); int pdc_stable_read(unsigned long staddr, void *memaddr, unsigned long count); diff --git a/arch/parisc/include/uapi/asm/pdc.h b/arch/parisc/include/uapi/asm/pdc.h index 15211723ebf5..ad51df8ba952 100644 --- a/arch/parisc/include/uapi/asm/pdc.h +++ b/arch/parisc/include/uapi/asm/pdc.h @@ -689,6 +689,28 @@ struct pdc_hpmc_pim_20 { /* PDC_PIM */ unsigned long long fr[32]; }; +struct pdc_toc_pim_11 { + unsigned int gr[32]; + unsigned int cr[32]; + unsigned int sr[8]; + unsigned int iasq_back; + unsigned int iaoq_back; + unsigned int check_type; + unsigned int hversion; + unsigned int cpu_state; +}; + +struct pdc_toc_pim_20 { + unsigned long long gr[32]; + unsigned long long cr[32]; + unsigned long long sr[8]; + unsigned long long iasq_back; + unsigned long long iaoq_back; + unsigned int check_type; + unsigned int hversion; + unsigned int cpu_state; +}; + #endif /* !defined(__ASSEMBLY__) */ #endif /* _UAPI_PARISC_PDC_H */ diff --git a/arch/parisc/kernel/firmware.c b/arch/parisc/kernel/firmware.c index 7034227dbdf3..9179b4409b63 100644 --- a/arch/parisc/kernel/firmware.c +++ b/arch/parisc/kernel/firmware.c @@ -1061,6 +1061,38 @@ int pdc_mem_pdt_read_entries(struct pdc_mem_read_pdt *pret, return retval; } +/** + * pdc_pim_toc11 - Fetch TOC PIM 1.1 data from firmware. + * @ret: pointer to return buffer + */ +int pdc_pim_toc11(struct pdc_toc_pim_11 *ret) +{ + int retval; + unsigned long flags; + + spin_lock_irqsave(&pdc_lock, flags); + retval = mem_pdc_call(PDC_PIM, PDC_PIM_TOC, __pa(pdc_result), + __pa(ret), sizeof(struct pdc_toc_pim_11)); + spin_unlock_irqrestore(&pdc_lock, flags); + return retval; +} + +/** + * pdc_pim_toc20 - Fetch TOC PIM 2.0 data from firmware. + * @ret: pointer to return buffer + */ +int pdc_pim_toc20(struct pdc_toc_pim_20 *ret) +{ + int retval; + unsigned long flags; + + spin_lock_irqsave(&pdc_lock, flags); + retval = mem_pdc_call(PDC_PIM, PDC_PIM_TOC, __pa(pdc_result), + __pa(ret), sizeof(struct pdc_toc_pim_20)); + spin_unlock_irqrestore(&pdc_lock, flags); + return retval; +} + /** * pdc_tod_set - Set the Time-Of-Day clock. * @sec: The number of seconds since epoch.
Add functions to retrieve TOC data from firmware both for 1.1 and 2.0 PDC. Signed-off-by: Sven Schnelle <svens@stackframe.org> --- arch/parisc/include/asm/pdc.h | 2 ++ arch/parisc/include/uapi/asm/pdc.h | 22 ++++++++++++++++++++ arch/parisc/kernel/firmware.c | 32 ++++++++++++++++++++++++++++++ 3 files changed, 56 insertions(+)