All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] of/irq: fix bug in computing output requester-id for an msi-map
@ 2016-02-08 22:30 ` Stuart Yoder
  0 siblings, 0 replies; 4+ messages in thread
From: Stuart Yoder @ 2016-02-08 22:30 UTC (permalink / raw)
  To: robh, frowand.list, grant.likely, devicetree, linux-kernel
  Cc: marc.zyngier, david.daney, mark.rutland, Stuart Yoder

From: Stuart Yoder <stuart.yoder@nxp.com>

The binding for msi-map specifies that the output requester id
should be computed as: (r - rid-base + msi-base)

...update the code accordingly.

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
---
 drivers/of/irq.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 706e3ff..3f5e5fd 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -589,6 +589,7 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
 	struct device_node *msi_controller_node;
 	struct device_node *msi_np = *np;
 	u32 map_mask, masked_rid, rid_base, msi_base, rid_len, phandle;
+	u32 masked_rid_base;
 	int msi_map_len;
 	bool matched;
 	u32 rid_out = rid_in;
@@ -654,7 +655,8 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
 	if (!matched)
 		return rid_out;
 
-	rid_out = masked_rid + msi_base;
+	masked_rid_base = map_mask & rid_base;
+	rid_out = msi_base + (masked_rid - masked_rid_base);
 	dev_dbg(dev,
 		"msi-map at: %s, using mask %08x, rid-base: %08x, msi-base: %08x, length: %08x, rid: %08x -> %08x\n",
 		dev_name(parent_dev), map_mask, rid_base, msi_base,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH] of/irq: fix bug in computing output requester-id for an msi-map
@ 2016-02-08 22:30 ` Stuart Yoder
  0 siblings, 0 replies; 4+ messages in thread
From: Stuart Yoder @ 2016-02-08 22:30 UTC (permalink / raw)
  To: robh, frowand.list, grant.likely, devicetree, linux-kernel
  Cc: marc.zyngier, david.daney, mark.rutland, Stuart Yoder

From: Stuart Yoder <stuart.yoder@nxp.com>

The binding for msi-map specifies that the output requester id
should be computed as: (r - rid-base + msi-base)

...update the code accordingly.

Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
---
 drivers/of/irq.c |    4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 706e3ff..3f5e5fd 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -589,6 +589,7 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
 	struct device_node *msi_controller_node;
 	struct device_node *msi_np = *np;
 	u32 map_mask, masked_rid, rid_base, msi_base, rid_len, phandle;
+	u32 masked_rid_base;
 	int msi_map_len;
 	bool matched;
 	u32 rid_out = rid_in;
@@ -654,7 +655,8 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
 	if (!matched)
 		return rid_out;
 
-	rid_out = masked_rid + msi_base;
+	masked_rid_base = map_mask & rid_base;
+	rid_out = msi_base + (masked_rid - masked_rid_base);
 	dev_dbg(dev,
 		"msi-map at: %s, using mask %08x, rid-base: %08x, msi-base: %08x, length: %08x, rid: %08x -> %08x\n",
 		dev_name(parent_dev), map_mask, rid_base, msi_base,
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] of/irq: fix bug in computing output requester-id for an msi-map
  2016-02-08 22:30 ` Stuart Yoder
@ 2016-02-08 23:47   ` David Daney
  -1 siblings, 0 replies; 4+ messages in thread
From: David Daney @ 2016-02-08 23:47 UTC (permalink / raw)
  To: Stuart Yoder
  Cc: robh, frowand.list, grant.likely, devicetree, linux-kernel,
	marc.zyngier, david.daney, mark.rutland

On 02/08/2016 02:30 PM, Stuart Yoder wrote:
> From: Stuart Yoder <stuart.yoder@nxp.com>
>
> The binding for msi-map specifies that the output requester id
> should be computed as: (r - rid-base + msi-base)
>
> ...update the code accordingly.

I agree there is a problem  however ...

>
> Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
> ---
>   drivers/of/irq.c |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 706e3ff..3f5e5fd 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -589,6 +589,7 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
>   	struct device_node *msi_controller_node;
>   	struct device_node *msi_np = *np;
>   	u32 map_mask, masked_rid, rid_base, msi_base, rid_len, phandle;
> +	u32 masked_rid_base;
>   	int msi_map_len;
>   	bool matched;
>   	u32 rid_out = rid_in;
> @@ -654,7 +655,8 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
>   	if (!matched)
>   		return rid_out;
>
> -	rid_out = masked_rid + msi_base;
> +	masked_rid_base = map_mask & rid_base;

... The binding document nowhere, that I see, talks about applying the 
mask to the rid-base.

The device tree should already contain the rid-base in the correct range.

If you remove this masking step, I think it may be correct.

If you just do:

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 7ee21ae..92abe01 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -654,7 +654,7 @@ static u32 __of_msi_map_rid(struct device *dev, 
struct device_node **np,
         if (!matched)
                 return rid_out;

-       rid_out = masked_rid + msi_base;
+       rid_out = msi_base + (masked_rid - rid_base);
         dev_dbg(dev,
                 "msi-map at: %s, using mask %08x, rid-base: %08x, 
msi-base: %08x, length: %08x, rid: %08x -> %08x\n",

It think it will be correct.

I have tested it that way.  If you do that,

Acked-by: David Daney <david.daney@cavium.com>

> +	rid_out = msi_base + (masked_rid - masked_rid_base);
>   	dev_dbg(dev,
>   		"msi-map at: %s, using mask %08x, rid-base: %08x, msi-base: %08x, length: %08x, rid: %08x -> %08x\n",
>   		dev_name(parent_dev), map_mask, rid_base, msi_base,
>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] of/irq: fix bug in computing output requester-id for an msi-map
@ 2016-02-08 23:47   ` David Daney
  0 siblings, 0 replies; 4+ messages in thread
From: David Daney @ 2016-02-08 23:47 UTC (permalink / raw)
  To: Stuart Yoder
  Cc: robh, frowand.list, grant.likely, devicetree, linux-kernel,
	marc.zyngier, david.daney, mark.rutland

On 02/08/2016 02:30 PM, Stuart Yoder wrote:
> From: Stuart Yoder <stuart.yoder@nxp.com>
>
> The binding for msi-map specifies that the output requester id
> should be computed as: (r - rid-base + msi-base)
>
> ...update the code accordingly.

I agree there is a problem  however ...

>
> Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
> ---
>   drivers/of/irq.c |    4 +++-
>   1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/of/irq.c b/drivers/of/irq.c
> index 706e3ff..3f5e5fd 100644
> --- a/drivers/of/irq.c
> +++ b/drivers/of/irq.c
> @@ -589,6 +589,7 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
>   	struct device_node *msi_controller_node;
>   	struct device_node *msi_np = *np;
>   	u32 map_mask, masked_rid, rid_base, msi_base, rid_len, phandle;
> +	u32 masked_rid_base;
>   	int msi_map_len;
>   	bool matched;
>   	u32 rid_out = rid_in;
> @@ -654,7 +655,8 @@ static u32 __of_msi_map_rid(struct device *dev, struct device_node **np,
>   	if (!matched)
>   		return rid_out;
>
> -	rid_out = masked_rid + msi_base;
> +	masked_rid_base = map_mask & rid_base;

... The binding document nowhere, that I see, talks about applying the 
mask to the rid-base.

The device tree should already contain the rid-base in the correct range.

If you remove this masking step, I think it may be correct.

If you just do:

diff --git a/drivers/of/irq.c b/drivers/of/irq.c
index 7ee21ae..92abe01 100644
--- a/drivers/of/irq.c
+++ b/drivers/of/irq.c
@@ -654,7 +654,7 @@ static u32 __of_msi_map_rid(struct device *dev, 
struct device_node **np,
         if (!matched)
                 return rid_out;

-       rid_out = masked_rid + msi_base;
+       rid_out = msi_base + (masked_rid - rid_base);
         dev_dbg(dev,
                 "msi-map at: %s, using mask %08x, rid-base: %08x, 
msi-base: %08x, length: %08x, rid: %08x -> %08x\n",

It think it will be correct.

I have tested it that way.  If you do that,

Acked-by: David Daney <david.daney@cavium.com>

> +	rid_out = msi_base + (masked_rid - masked_rid_base);
>   	dev_dbg(dev,
>   		"msi-map at: %s, using mask %08x, rid-base: %08x, msi-base: %08x, length: %08x, rid: %08x -> %08x\n",
>   		dev_name(parent_dev), map_mask, rid_base, msi_base,
>

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2016-02-09  0:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-02-08 22:30 [PATCH] of/irq: fix bug in computing output requester-id for an msi-map Stuart Yoder
2016-02-08 22:30 ` Stuart Yoder
2016-02-08 23:47 ` David Daney
2016-02-08 23:47   ` David Daney

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.