diff mbox series

[RFC] npu2: Remove redundand dt_node

Message ID 20180815082513.18567-1-aik@ozlabs.ru
State RFC
Headers show
Series [RFC] npu2: Remove redundand dt_node | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied
snowpatch_ozlabs/make_check success Test make_check on branch master

Commit Message

Alexey Kardashevskiy Aug. 15, 2018, 8:25 a.m. UTC
The npu2 struct embeds a phb struct which also has a DT node pointer,
use that.

Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
---

On witherspoon it is just always NULL.
---
 include/npu2.h     | 1 -
 hw/npu2-opencapi.c | 6 +++---
 2 files changed, 3 insertions(+), 4 deletions(-)

Comments

Andrew Donnellan Aug. 15, 2018, 2:38 p.m. UTC | #1
On 15/08/18 18:25, Alexey Kardashevskiy wrote:
> The npu2 struct embeds a phb struct which also has a DT node pointer,
> use that.
> 
> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>

We don't initialise npu->phb_nvlink when the NPU is set up in OpenCAPI 
mode so this won't work.


Andrew

> ---
> 
> On witherspoon it is just always NULL.
> ---
>   include/npu2.h     | 1 -
>   hw/npu2-opencapi.c | 6 +++---
>   2 files changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/include/npu2.h b/include/npu2.h
> index 4c2e20e..34bc650 100644
> --- a/include/npu2.h
> +++ b/include/npu2.h
> @@ -142,7 +142,6 @@ struct npu2_dev {
>   
>   struct npu2 {
>   	uint32_t	index;
> -	struct dt_node	*dt_node;
>   	uint32_t	chip_id;
>   	uint64_t	xscom_base;
>   	void		*regs;
> diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
> index 57c2f2f..e55bdcb 100644
> --- a/hw/npu2-opencapi.c
> +++ b/hw/npu2-opencapi.c
> @@ -1584,7 +1584,7 @@ static void npu2_opencapi_setup_device(struct dt_node *dn_link, struct npu2 *n,
>   	uint64_t mm_win[2];
>   
>   	dev_index = dt_prop_get_u32(dn_link, "ibm,npu-link-index");
> -	npu_index = dt_prop_get_u32(n->dt_node, "ibm,npu-index");
> +	npu_index = dt_prop_get_u32(n->phb_nvlink.dt_node, "ibm,npu-index");
>   
>   	/* Populate PHB device node */
>   	phys_map_get(n->chip_id, NPU_OCAPI_MMIO, dev_index, &mm_win[0],
> @@ -1610,7 +1610,8 @@ static void npu2_opencapi_setup_device(struct dt_node *dn_link, struct npu2 *n,
>   	dt_add_property_cells(dn_phb, "ibm,npu-index", npu_index);
>   	dt_add_property_cells(dn_phb, "ibm,chip-id", n->chip_id);
>   	dt_add_property_cells(dn_phb, "ibm,xscom-base", n->xscom_base);
> -	dt_add_property_cells(dn_phb, "ibm,npcq", n->dt_node->phandle);
> +	dt_add_property_cells(dn_phb, "ibm,npcq",
> +			      n->phb_nvlink.dt_node->phandle);
>   	dt_add_property_cells(dn_phb, "ibm,links", 1);
>   	dt_add_property(dn_phb, "ibm,mmio-window", mm_win, sizeof(mm_win));
>   	dt_add_property_cells(dn_phb, "ibm,phb-diag-data-size", 0);
> @@ -1730,7 +1731,6 @@ static void npu2_opencapi_probe(struct dt_node *dn)
>   	n->chip_id = gcid;
>   	n->xscom_base = scom_base;
>   	n->regs = (void *)reg[0];
> -	n->dt_node = dn;
>   
>   	dt_for_each_compatible(dn, link, "ibm,npu-link") {
>   		dev_index = dt_prop_get_u32(link, "ibm,npu-link-index");
>
Alexey Kardashevskiy Aug. 16, 2018, 2:48 a.m. UTC | #2
On 16/08/2018 00:38, Andrew Donnellan wrote:
> On 15/08/18 18:25, Alexey Kardashevskiy wrote:
>> The npu2 struct embeds a phb struct which also has a DT node pointer,
>> use that.
>>
>> Signed-off-by: Alexey Kardashevskiy <aik@ozlabs.ru>
> 
> We don't initialise npu->phb_nvlink when the NPU is set up in OpenCAPI
> mode so this won't work.


Ah, true. Never mind than. Thanks,

> 
> 
> Andrew
> 
>> ---
>>
>> On witherspoon it is just always NULL.
>> ---
>>   include/npu2.h     | 1 -
>>   hw/npu2-opencapi.c | 6 +++---
>>   2 files changed, 3 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/npu2.h b/include/npu2.h
>> index 4c2e20e..34bc650 100644
>> --- a/include/npu2.h
>> +++ b/include/npu2.h
>> @@ -142,7 +142,6 @@ struct npu2_dev {
>>     struct npu2 {
>>       uint32_t    index;
>> -    struct dt_node    *dt_node;
>>       uint32_t    chip_id;
>>       uint64_t    xscom_base;
>>       void        *regs;
>> diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
>> index 57c2f2f..e55bdcb 100644
>> --- a/hw/npu2-opencapi.c
>> +++ b/hw/npu2-opencapi.c
>> @@ -1584,7 +1584,7 @@ static void npu2_opencapi_setup_device(struct
>> dt_node *dn_link, struct npu2 *n,
>>       uint64_t mm_win[2];
>>         dev_index = dt_prop_get_u32(dn_link, "ibm,npu-link-index");
>> -    npu_index = dt_prop_get_u32(n->dt_node, "ibm,npu-index");
>> +    npu_index = dt_prop_get_u32(n->phb_nvlink.dt_node, "ibm,npu-index");
>>         /* Populate PHB device node */
>>       phys_map_get(n->chip_id, NPU_OCAPI_MMIO, dev_index, &mm_win[0],
>> @@ -1610,7 +1610,8 @@ static void npu2_opencapi_setup_device(struct
>> dt_node *dn_link, struct npu2 *n,
>>       dt_add_property_cells(dn_phb, "ibm,npu-index", npu_index);
>>       dt_add_property_cells(dn_phb, "ibm,chip-id", n->chip_id);
>>       dt_add_property_cells(dn_phb, "ibm,xscom-base", n->xscom_base);
>> -    dt_add_property_cells(dn_phb, "ibm,npcq", n->dt_node->phandle);
>> +    dt_add_property_cells(dn_phb, "ibm,npcq",
>> +                  n->phb_nvlink.dt_node->phandle);
>>       dt_add_property_cells(dn_phb, "ibm,links", 1);
>>       dt_add_property(dn_phb, "ibm,mmio-window", mm_win, sizeof(mm_win));
>>       dt_add_property_cells(dn_phb, "ibm,phb-diag-data-size", 0);
>> @@ -1730,7 +1731,6 @@ static void npu2_opencapi_probe(struct dt_node *dn)
>>       n->chip_id = gcid;
>>       n->xscom_base = scom_base;
>>       n->regs = (void *)reg[0];
>> -    n->dt_node = dn;
>>         dt_for_each_compatible(dn, link, "ibm,npu-link") {
>>           dev_index = dt_prop_get_u32(link, "ibm,npu-link-index");
>>
>
diff mbox series

Patch

diff --git a/include/npu2.h b/include/npu2.h
index 4c2e20e..34bc650 100644
--- a/include/npu2.h
+++ b/include/npu2.h
@@ -142,7 +142,6 @@  struct npu2_dev {
 
 struct npu2 {
 	uint32_t	index;
-	struct dt_node	*dt_node;
 	uint32_t	chip_id;
 	uint64_t	xscom_base;
 	void		*regs;
diff --git a/hw/npu2-opencapi.c b/hw/npu2-opencapi.c
index 57c2f2f..e55bdcb 100644
--- a/hw/npu2-opencapi.c
+++ b/hw/npu2-opencapi.c
@@ -1584,7 +1584,7 @@  static void npu2_opencapi_setup_device(struct dt_node *dn_link, struct npu2 *n,
 	uint64_t mm_win[2];
 
 	dev_index = dt_prop_get_u32(dn_link, "ibm,npu-link-index");
-	npu_index = dt_prop_get_u32(n->dt_node, "ibm,npu-index");
+	npu_index = dt_prop_get_u32(n->phb_nvlink.dt_node, "ibm,npu-index");
 
 	/* Populate PHB device node */
 	phys_map_get(n->chip_id, NPU_OCAPI_MMIO, dev_index, &mm_win[0],
@@ -1610,7 +1610,8 @@  static void npu2_opencapi_setup_device(struct dt_node *dn_link, struct npu2 *n,
 	dt_add_property_cells(dn_phb, "ibm,npu-index", npu_index);
 	dt_add_property_cells(dn_phb, "ibm,chip-id", n->chip_id);
 	dt_add_property_cells(dn_phb, "ibm,xscom-base", n->xscom_base);
-	dt_add_property_cells(dn_phb, "ibm,npcq", n->dt_node->phandle);
+	dt_add_property_cells(dn_phb, "ibm,npcq",
+			      n->phb_nvlink.dt_node->phandle);
 	dt_add_property_cells(dn_phb, "ibm,links", 1);
 	dt_add_property(dn_phb, "ibm,mmio-window", mm_win, sizeof(mm_win));
 	dt_add_property_cells(dn_phb, "ibm,phb-diag-data-size", 0);
@@ -1730,7 +1731,6 @@  static void npu2_opencapi_probe(struct dt_node *dn)
 	n->chip_id = gcid;
 	n->xscom_base = scom_base;
 	n->regs = (void *)reg[0];
-	n->dt_node = dn;
 
 	dt_for_each_compatible(dn, link, "ibm,npu-link") {
 		dev_index = dt_prop_get_u32(link, "ibm,npu-link-index");