diff mbox series

[2/6] pci: Add pci_next_phb()

Message ID 1532702862-22751-3-git-send-email-arbab@linux.ibm.com
State Superseded
Headers show
Series npu2: Add support for relaxed-ordering mode | expand

Checks

Context Check Description
snowpatch_ozlabs/apply_patch success master/apply_patch Successfully applied

Commit Message

Reza Arbab July 27, 2018, 2:47 p.m. UTC
Add an iterator to walk over every PHB.

Signed-off-by: Alistair Popple <alistair@popple.id.au>
Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
---
 core/pci.c    | 12 ++++++++++++
 include/pci.h |  1 +
 2 files changed, 13 insertions(+)

Comments

Alistair Popple July 30, 2018, 5:51 a.m. UTC | #1
Looks good to me.

Reviewed-by: Alistair Popple <alistair@popple.id.au>

On Friday, 27 July 2018 9:47:38 AM AEST Reza Arbab wrote:
> Add an iterator to walk over every PHB.
> 
> Signed-off-by: Alistair Popple <alistair@popple.id.au>
> Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
> ---
>  core/pci.c    | 12 ++++++++++++
>  include/pci.h |  1 +
>  2 files changed, 13 insertions(+)
> 
> diff --git a/core/pci.c b/core/pci.c
> index 6ba6eda..4faf88e 100644
> --- a/core/pci.c
> +++ b/core/pci.c
> @@ -1104,6 +1104,18 @@ struct phb *pci_get_phb(uint64_t phb_id)
>  	return phbs[phb_id];
>  }
>  
> +/* Iterator to walk over every PHB */
> +struct phb *pci_next_phb(struct phb *last)
> +{
> +	uint64_t phb_id = last ? last->opal_id + 1 : 0;
> +
> +	for (; phb_id < ARRAY_SIZE(phbs); phb_id++)
> +		if (phbs[phb_id])
> +			return phbs[phb_id];
> +
> +	return NULL;
> +}
> +
>  static const char *pci_class_name(uint32_t class_code)
>  {
>  	uint8_t class = class_code >> 16;
> diff --git a/include/pci.h b/include/pci.h
> index c6aa664..19fe9c0 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -481,6 +481,7 @@ extern struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd,
>  extern int64_t pci_register_phb(struct phb *phb, int opal_id);
>  extern int64_t pci_unregister_phb(struct phb *phb);
>  extern struct phb *pci_get_phb(uint64_t phb_id);
> +extern struct phb *pci_next_phb(struct phb *last);
>  
>  static inline struct phb *__pci_next_phb_idx(uint64_t *phb_id) {
>  	struct phb *phb = NULL;
>
Oliver O'Halloran July 30, 2018, 6:31 a.m. UTC | #2
On Sat, Jul 28, 2018 at 12:47 AM, Reza Arbab <arbab@linux.ibm.com> wrote:
> Add an iterator to walk over every PHB.
>
> Signed-off-by: Alistair Popple <alistair@popple.id.au>
> Signed-off-by: Reza Arbab <arbab@linux.ibm.com>
> ---
>  core/pci.c    | 12 ++++++++++++
>  include/pci.h |  1 +
>  2 files changed, 13 insertions(+)
>
> diff --git a/core/pci.c b/core/pci.c
> index 6ba6eda..4faf88e 100644
> --- a/core/pci.c
> +++ b/core/pci.c
> @@ -1104,6 +1104,18 @@ struct phb *pci_get_phb(uint64_t phb_id)
>         return phbs[phb_id];
>  }
>
> +/* Iterator to walk over every PHB */
> +struct phb *pci_next_phb(struct phb *last)
> +{
> +       uint64_t phb_id = last ? last->opal_id + 1 : 0;
> +
> +       for (; phb_id < ARRAY_SIZE(phbs); phb_id++)
> +               if (phbs[phb_id])
> +                       return phbs[phb_id];
> +
> +       return NULL;
> +}

So __pci_next_phb_idx() is kind of weird so I don't mind replacing it
with this, but you should probably do the replacement too ;)

> +
>  static const char *pci_class_name(uint32_t class_code)
>  {
>         uint8_t class = class_code >> 16;
> diff --git a/include/pci.h b/include/pci.h
> index c6aa664..19fe9c0 100644
> --- a/include/pci.h
> +++ b/include/pci.h
> @@ -481,6 +481,7 @@ extern struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd,
>  extern int64_t pci_register_phb(struct phb *phb, int opal_id);
>  extern int64_t pci_unregister_phb(struct phb *phb);
>  extern struct phb *pci_get_phb(uint64_t phb_id);
> +extern struct phb *pci_next_phb(struct phb *last);
>
>  static inline struct phb *__pci_next_phb_idx(uint64_t *phb_id) {
>         struct phb *phb = NULL;
> --
> 1.8.3.1
>
> _______________________________________________
> Skiboot mailing list
> Skiboot@lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/skiboot
Oliver O'Halloran July 30, 2018, 6:33 a.m. UTC | #3
On Mon, Jul 30, 2018 at 3:51 PM, Alistair Popple <alistair@popple.id.au> wrote:
> Looks good to me.
>
> Reviewed-by: Alistair Popple <alistair@popple.id.au>

hmm

>
> On Friday, 27 July 2018 9:47:38 AM AEST Reza Arbab wrote:
>> Add an iterator to walk over every PHB.
>>
>> Signed-off-by: Alistair Popple <alistair@popple.id.au>
>> Signed-off-by: Reza Arbab <arbab@linux.ibm.com>

Hmmmmmm

Sounds like someone is gaming the system to get CRAPs. I'm on to you Popple.

Oliver
Reza Arbab July 30, 2018, 4 p.m. UTC | #4
On Mon, Jul 30, 2018 at 04:31:43PM +1000, Oliver wrote:
>On Sat, Jul 28, 2018 at 12:47 AM, Reza Arbab <arbab@linux.ibm.com> wrote:
>> diff --git a/core/pci.c b/core/pci.c
>> index 6ba6eda..4faf88e 100644
>> --- a/core/pci.c
>> +++ b/core/pci.c
>> @@ -1104,6 +1104,18 @@ struct phb *pci_get_phb(uint64_t phb_id)
>>         return phbs[phb_id];
>>  }
>>
>> +/* Iterator to walk over every PHB */
>> +struct phb *pci_next_phb(struct phb *last)
>> +{
>> +       uint64_t phb_id = last ? last->opal_id + 1 : 0;
>> +
>> +       for (; phb_id < ARRAY_SIZE(phbs); phb_id++)
>> +               if (phbs[phb_id])
>> +                       return phbs[phb_id];
>> +
>> +       return NULL;
>> +}
>
>So __pci_next_phb_idx() is kind of weird so I don't mind replacing it
>with this, but you should probably do the replacement too ;)

Now that I look, the rest of the set doesn't even actually use 
pci_next_phb(), so I'm going to drop this patch entirely.

Man... who wrote this crap?
diff mbox series

Patch

diff --git a/core/pci.c b/core/pci.c
index 6ba6eda..4faf88e 100644
--- a/core/pci.c
+++ b/core/pci.c
@@ -1104,6 +1104,18 @@  struct phb *pci_get_phb(uint64_t phb_id)
 	return phbs[phb_id];
 }
 
+/* Iterator to walk over every PHB */
+struct phb *pci_next_phb(struct phb *last)
+{
+	uint64_t phb_id = last ? last->opal_id + 1 : 0;
+
+	for (; phb_id < ARRAY_SIZE(phbs); phb_id++)
+		if (phbs[phb_id])
+			return phbs[phb_id];
+
+	return NULL;
+}
+
 static const char *pci_class_name(uint32_t class_code)
 {
 	uint8_t class = class_code >> 16;
diff --git a/include/pci.h b/include/pci.h
index c6aa664..19fe9c0 100644
--- a/include/pci.h
+++ b/include/pci.h
@@ -481,6 +481,7 @@  extern struct pci_cfg_reg_filter *pci_add_cfg_reg_filter(struct pci_device *pd,
 extern int64_t pci_register_phb(struct phb *phb, int opal_id);
 extern int64_t pci_unregister_phb(struct phb *phb);
 extern struct phb *pci_get_phb(uint64_t phb_id);
+extern struct phb *pci_next_phb(struct phb *last);
 
 static inline struct phb *__pci_next_phb_idx(uint64_t *phb_id) {
 	struct phb *phb = NULL;