diff mbox

[1/2] hw/phys_map: Use raw chip IDs

Message ID 20170516090321.22527-1-oohall@gmail.com
State Superseded
Headers show

Commit Message

Oliver O'Halloran May 16, 2017, 9:03 a.m. UTC
We need to be able to query the BAR mapping from the HDAT parser which
is run prior the the proc_chip structures being initialised. Define
a wrapper for the existing usages and provide a low-level function
that allows the map the be queried with the global hardware chip ID
itself.

Cc: Michael Neuling <mikey@neuling.org>
Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
---
 hw/phys-map.c      |  9 +++++----
 include/phys-map.h | 11 ++++++++++-
 2 files changed, 15 insertions(+), 5 deletions(-)

Comments

Michael Neuling May 16, 2017, 11:01 a.m. UTC | #1
On Tue, 2017-05-16 at 19:03 +1000, Oliver O'Halloran wrote:
> We need to be able to query the BAR mapping from the HDAT parser which
> is run prior the the proc_chip structures being initialised. Define
> a wrapper for the existing usages and provide a low-level function
> that allows the map the be queried with the global hardware chip ID
> itself.

We could just move the main api over to use gcid.... a few of the callers need
to do it anyway, like the fsp code does this...

	phys_map_get(get_chip(chip_id), LPC_BUS, 0, &lpcm_base, NULL);

Mikey

> 
> Cc: Michael Neuling <mikey@neuling.org>
> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
> ---
>  hw/phys-map.c      |  9 +++++----
>  include/phys-map.h | 11 ++++++++++-
>  2 files changed, 15 insertions(+), 5 deletions(-)
> 
> diff --git a/hw/phys-map.c b/hw/phys-map.c
> index 768f464f4682..65c440178283 100644
> --- a/hw/phys-map.c
> +++ b/hw/phys-map.c
> @@ -134,10 +134,11 @@ static inline bool phys_map_entry_null(const struct
> phys_map_entry *e)
>  	return false;
>  }
>  
> +
>  /* This crashes skiboot on error as any bad calls here are almost
>   *  certainly a developer error
>   */
> -void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
> +void __phys_map_get(uint64_t gcid, enum phys_map_type type,
>  		  int index, uint64_t *addr, uint64_t *size) {
>  	const struct phys_map_entry *e;
>  	uint64_t a;
> @@ -162,16 +163,16 @@ void phys_map_get(struct proc_chip *chip, enum
> phys_map_type type,
>  		break;
>  	}
>  	a = e->addr;
> -	a += (uint64_t)chip->id << phys_map->chip_select_shift;
> +	a += gcid << phys_map->chip_select_shift;
>  
>  	if (addr)
>  		*addr = a;
>  	if (size)
>  		*size = e->size;
>  
> -	prlog(PR_TRACE, "Assigning BAR [%x] type:%02i index:%x "
> +	prlog(PR_TRACE, "Assigning BAR [%"PRIx64"] type:%02i index:%x "
>  	      "0x%016"PRIx64" for 0x%016"PRIx64"\n",
> -	      chip->id, type, index, a, e->size);
> +	      gcid, type, index, a, e->size);
>  
>  	return;
>  
> diff --git a/include/phys-map.h b/include/phys-map.h
> index a0124322a608..5738a5456900 100644
> --- a/include/phys-map.h
> +++ b/include/phys-map.h
> @@ -53,9 +53,18 @@ enum phys_map_type {
>  	RESV
>  };
>  
> -extern void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
> +/*
> + * Use this to query the phys map before we've done per-cpu init.
> + */
> +extern void __phys_map_get(uint64_t gcid, enum phys_map_type type,
>  			 int index, uint64_t *addr, uint64_t *size);
>  
> +static inline void phys_map_get(struct proc_chip *chip, enum phys_map_type
> type,
> +			 int index, uint64_t *addr, uint64_t *size)
> +{
> +	__phys_map_get(chip->id, type, index, addr, size);
> +}
> +
>  extern void phys_map_init(void);
>  
>  #endif /* __PHYS_MAP_H */
Oliver O'Halloran May 16, 2017, 11:52 a.m. UTC | #2
On Tue, May 16, 2017 at 9:01 PM, Michael Neuling <mikey@neuling.org> wrote:
> On Tue, 2017-05-16 at 19:03 +1000, Oliver O'Halloran wrote:
>> We need to be able to query the BAR mapping from the HDAT parser which
>> is run prior the the proc_chip structures being initialised. Define
>> a wrapper for the existing usages and provide a low-level function
>> that allows the map the be queried with the global hardware chip ID
>> itself.
>
> We could just move the main api over to use gcid.... a few of the callers need
> to do it anyway, like the fsp code does this...
>
>         phys_map_get(get_chip(chip_id), LPC_BUS, 0, &lpcm_base, NULL);
>

Alright. I'll do a re-spin.

> Mikey
>
>>
>> Cc: Michael Neuling <mikey@neuling.org>
>> Signed-off-by: Oliver O'Halloran <oohall@gmail.com>
>> ---
>>  hw/phys-map.c      |  9 +++++----
>>  include/phys-map.h | 11 ++++++++++-
>>  2 files changed, 15 insertions(+), 5 deletions(-)
>>
>> diff --git a/hw/phys-map.c b/hw/phys-map.c
>> index 768f464f4682..65c440178283 100644
>> --- a/hw/phys-map.c
>> +++ b/hw/phys-map.c
>> @@ -134,10 +134,11 @@ static inline bool phys_map_entry_null(const struct
>> phys_map_entry *e)
>>       return false;
>>  }
>>
>> +
>>  /* This crashes skiboot on error as any bad calls here are almost
>>   *  certainly a developer error
>>   */
>> -void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
>> +void __phys_map_get(uint64_t gcid, enum phys_map_type type,
>>                 int index, uint64_t *addr, uint64_t *size) {
>>       const struct phys_map_entry *e;
>>       uint64_t a;
>> @@ -162,16 +163,16 @@ void phys_map_get(struct proc_chip *chip, enum
>> phys_map_type type,
>>               break;
>>       }
>>       a = e->addr;
>> -     a += (uint64_t)chip->id << phys_map->chip_select_shift;
>> +     a += gcid << phys_map->chip_select_shift;
>>
>>       if (addr)
>>               *addr = a;
>>       if (size)
>>               *size = e->size;
>>
>> -     prlog(PR_TRACE, "Assigning BAR [%x] type:%02i index:%x "
>> +     prlog(PR_TRACE, "Assigning BAR [%"PRIx64"] type:%02i index:%x "
>>             "0x%016"PRIx64" for 0x%016"PRIx64"\n",
>> -           chip->id, type, index, a, e->size);
>> +           gcid, type, index, a, e->size);
>>
>>       return;
>>
>> diff --git a/include/phys-map.h b/include/phys-map.h
>> index a0124322a608..5738a5456900 100644
>> --- a/include/phys-map.h
>> +++ b/include/phys-map.h
>> @@ -53,9 +53,18 @@ enum phys_map_type {
>>       RESV
>>  };
>>
>> -extern void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
>> +/*
>> + * Use this to query the phys map before we've done per-cpu init.
>> + */
>> +extern void __phys_map_get(uint64_t gcid, enum phys_map_type type,
>>                        int index, uint64_t *addr, uint64_t *size);
>>
>> +static inline void phys_map_get(struct proc_chip *chip, enum phys_map_type
>> type,
>> +                      int index, uint64_t *addr, uint64_t *size)
>> +{
>> +     __phys_map_get(chip->id, type, index, addr, size);
>> +}
>> +
>>  extern void phys_map_init(void);
>>
>>  #endif /* __PHYS_MAP_H */
diff mbox

Patch

diff --git a/hw/phys-map.c b/hw/phys-map.c
index 768f464f4682..65c440178283 100644
--- a/hw/phys-map.c
+++ b/hw/phys-map.c
@@ -134,10 +134,11 @@  static inline bool phys_map_entry_null(const struct phys_map_entry *e)
 	return false;
 }
 
+
 /* This crashes skiboot on error as any bad calls here are almost
  *  certainly a developer error
  */
-void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
+void __phys_map_get(uint64_t gcid, enum phys_map_type type,
 		  int index, uint64_t *addr, uint64_t *size) {
 	const struct phys_map_entry *e;
 	uint64_t a;
@@ -162,16 +163,16 @@  void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
 		break;
 	}
 	a = e->addr;
-	a += (uint64_t)chip->id << phys_map->chip_select_shift;
+	a += gcid << phys_map->chip_select_shift;
 
 	if (addr)
 		*addr = a;
 	if (size)
 		*size = e->size;
 
-	prlog(PR_TRACE, "Assigning BAR [%x] type:%02i index:%x "
+	prlog(PR_TRACE, "Assigning BAR [%"PRIx64"] type:%02i index:%x "
 	      "0x%016"PRIx64" for 0x%016"PRIx64"\n",
-	      chip->id, type, index, a, e->size);
+	      gcid, type, index, a, e->size);
 
 	return;
 
diff --git a/include/phys-map.h b/include/phys-map.h
index a0124322a608..5738a5456900 100644
--- a/include/phys-map.h
+++ b/include/phys-map.h
@@ -53,9 +53,18 @@  enum phys_map_type {
 	RESV
 };
 
-extern void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
+/*
+ * Use this to query the phys map before we've done per-cpu init.
+ */
+extern void __phys_map_get(uint64_t gcid, enum phys_map_type type,
 			 int index, uint64_t *addr, uint64_t *size);
 
+static inline void phys_map_get(struct proc_chip *chip, enum phys_map_type type,
+			 int index, uint64_t *addr, uint64_t *size)
+{
+	__phys_map_get(chip->id, type, index, addr, size);
+}
+
 extern void phys_map_init(void);
 
 #endif /* __PHYS_MAP_H */