From: Alexey Kardashevskiy <aik@ozlabs.ru>
To: Gavin Shan <gwshan@linux.vnet.ibm.com>, linuxppc-dev@lists.ozlabs.org
Cc: linux-pci@vger.kernel.org, devicetree@vger.kernel.org,
benh@kernel.crashing.org, mpe@ellerman.id.au,
bhelgaas@google.com, grant.likely@linaro.org,
robherring2@gmail.com, panto@antoniou-consulting.com
Subject: Re: [PATCH v6 15/42] powerpc/powernv: PE oriented during configuration
Date: Mon, 10 Aug 2015 20:02:20 +1000 [thread overview]
Message-ID: <55C876AC.5060205@ozlabs.ru> (raw)
In-Reply-To: <1438834307-26960-16-git-send-email-gwshan@linux.vnet.ibm.com>
On 08/06/2015 02:11 PM, Gavin Shan wrote:
> Several functions used to configure PE take pe_number to indentify
> PE instance. As the pe_number is included in PE instance after it
> is reserved or allocated. It's convienent for those functions to
> return PE instance which includes the required pe_number.
This is a description for the half of the patch but this patch also adds a
return value to functions which did not have it before and I am not sure
you need all of them to return something. It would be cleaner if you added
"return" when/where you really need it, not just because it seems that it
may be convenient later.
>
> Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
> ---
> arch/powerpc/platforms/powernv/pci-ioda.c | 51 ++++++++++++++++---------------
> arch/powerpc/platforms/powernv/pci.h | 2 +-
> 2 files changed, 27 insertions(+), 26 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 3094c61..9f53682 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -132,12 +132,12 @@ static inline bool pnv_pci_is_mem_pref_64(unsigned long flags)
> (IORESOURCE_MEM_64 | IORESOURCE_PREFETCH));
> }
>
> -static void pnv_ioda_reserve_pe(struct pnv_phb *phb, int pe_no)
> +static struct pnv_ioda_pe *pnv_ioda_reserve_pe(struct pnv_phb *phb, int pe_no)
> {
> if (!(pe_no >= 0 && pe_no < phb->ioda.total_pe)) {
> pr_warn("%s: Invalid PE %d on PHB#%x\n",
> __func__, pe_no, phb->hose->global_number);
> - return;
> + return NULL;
> }
>
> if (test_and_set_bit(pe_no, phb->ioda.pe_alloc))
> @@ -146,9 +146,11 @@ static void pnv_ioda_reserve_pe(struct pnv_phb *phb, int pe_no)
>
> phb->ioda.pe_array[pe_no].phb = phb;
> phb->ioda.pe_array[pe_no].pe_number = pe_no;
> +
> + return &phb->ioda.pe_array[pe_no];
> }
>
> -static int pnv_ioda_alloc_pe(struct pnv_phb *phb)
> +static struct pnv_ioda_pe *pnv_ioda_alloc_pe(struct pnv_phb *phb)
> {
> unsigned long pe;
>
> @@ -156,12 +158,12 @@ static int pnv_ioda_alloc_pe(struct pnv_phb *phb)
> pe = find_next_zero_bit(phb->ioda.pe_alloc,
> phb->ioda.total_pe, 0);
> if (pe >= phb->ioda.total_pe)
> - return IODA_INVALID_PE;
> + return NULL;
> } while(test_and_set_bit(pe, phb->ioda.pe_alloc));
>
> phb->ioda.pe_array[pe].phb = phb;
> phb->ioda.pe_array[pe].pe_number = pe;
> - return pe;
> + return &phb->ioda.pe_array[pe];
> }
>
> static void pnv_ioda_free_pe(struct pnv_phb *phb, int pe)
> @@ -334,7 +336,7 @@ static void pnv_ioda_reserve_m64_pe(struct pci_bus *bus,
> }
> }
>
> -static int pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
> +static struct pnv_ioda_pe *pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
> {
> struct pci_controller *hose = pci_bus_to_host(bus);
> struct pnv_phb *phb = hose->private_data;
> @@ -344,7 +346,7 @@ static int pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
>
> /* Root bus shouldn't use M64 */
> if (pci_is_root_bus(bus))
> - return IODA_INVALID_PE;
> + return NULL;
>
> /* Allocate bitmap */
> size = _ALIGN_UP(phb->ioda.total_pe / 8, sizeof(unsigned long));
> @@ -352,7 +354,7 @@ static int pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
> if (!pe_alloc) {
> pr_warn("%s: Out of memory !\n",
> __func__);
> - return IODA_INVALID_PE;
> + return NULL;
> }
>
> /* Figure out reserved PE numbers by the PE */
> @@ -365,7 +367,7 @@ static int pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
> */
> if (bitmap_empty(pe_alloc, phb->ioda.total_pe)) {
> kfree(pe_alloc);
> - return IODA_INVALID_PE;
> + return NULL;
> }
>
> /*
> @@ -416,7 +418,7 @@ static int pnv_ioda_pick_m64_pe(struct pci_bus *bus, bool all)
> }
>
> kfree(pe_alloc);
> - return master_pe->pe_number;
> + return master_pe;
> }
>
> static void __init pnv_ioda_parse_m64_window(struct pnv_phb *phb)
> @@ -1069,28 +1071,26 @@ static void pnv_ioda_setup_same_PE(struct pci_bus *bus, struct pnv_ioda_pe *pe)
> * subordinate PCI devices and buses. The second type of PE is normally
> * orgiriated by PCIe-to-PCI bridge or PLX switch downstream ports.
> */
> -static void pnv_ioda_setup_bus_PE(struct pci_bus *bus, bool all)
> +static struct pnv_ioda_pe *pnv_ioda_setup_bus_PE(struct pci_bus *bus, bool all)
> {
> struct pci_controller *hose = pci_bus_to_host(bus);
> struct pnv_phb *phb = hose->private_data;
> - struct pnv_ioda_pe *pe;
> - int pe_num = IODA_INVALID_PE;
> + struct pnv_ioda_pe *pe = NULL;
>
> /* Check if PE is determined by M64 */
> if (phb->pick_m64_pe)
> - pe_num = phb->pick_m64_pe(bus, all);
> + pe = phb->pick_m64_pe(bus, all);
>
> /* The PE number isn't pinned by M64 */
> - if (pe_num == IODA_INVALID_PE)
> - pe_num = pnv_ioda_alloc_pe(phb);
> + if (!pe)
> + pe = pnv_ioda_alloc_pe(phb);
>
> - if (pe_num == IODA_INVALID_PE) {
> - pr_warning("%s: Not enough PE# available for PCI bus %04x:%02x\n",
> + if (!pe) {
> + pr_warning("%s: No enough PE# for PCI bus %04x:%02x\n",
> __func__, pci_domain_nr(bus), bus->number);
> - return;
> + return NULL;
> }
>
> - pe = &phb->ioda.pe_array[pe_num];
> pe->flags |= (all ? PNV_IODA_PE_BUS_ALL : PNV_IODA_PE_BUS);
> pe->pbus = bus;
> pe->pdev = NULL;
> @@ -1101,17 +1101,16 @@ static void pnv_ioda_setup_bus_PE(struct pci_bus *bus, bool all)
>
> if (all)
> pe_info(pe, "Secondary bus %d..%d associated with PE#%d\n",
> - bus->busn_res.start, bus->busn_res.end, pe_num);
> + bus->busn_res.start, bus->busn_res.end, pe->pe_number);
> else
> pe_info(pe, "Secondary bus %d associated with PE#%d\n",
> - bus->busn_res.start, pe_num);
> + bus->busn_res.start, pe->pe_number);
>
> if (pnv_ioda_configure_pe(phb, pe)) {
> /* XXX What do we do here ? */
> - if (pe_num)
> - pnv_ioda_free_pe(phb, pe_num);
> + pnv_ioda_free_pe(phb, pe->pe_number);
> pe->pbus = NULL;
> - return;
> + return NULL;
> }
>
> /* Associate it with all child devices */
> @@ -1122,6 +1121,8 @@ static void pnv_ioda_setup_bus_PE(struct pci_bus *bus, bool all)
>
> /* Link the PE */
> pnv_ioda_link_pe_by_weight(phb, pe);
> +
> + return pe;
> }
>
> static void pnv_ioda_setup_PEs(struct pci_bus *bus)
> diff --git a/arch/powerpc/platforms/powernv/pci.h b/arch/powerpc/platforms/powernv/pci.h
> index 6f8568e..c0bc57f 100644
> --- a/arch/powerpc/platforms/powernv/pci.h
> +++ b/arch/powerpc/platforms/powernv/pci.h
> @@ -121,7 +121,7 @@ struct pnv_phb {
> int (*init_m64)(struct pnv_phb *phb);
> void (*reserve_m64_pe)(struct pci_bus *bus,
> unsigned long *pe_bitmap, bool all);
> - int (*pick_m64_pe)(struct pci_bus *bus, bool all);
> + struct pnv_ioda_pe* (*pick_m64_pe)(struct pci_bus *bus, bool all);
> int (*get_pe_state)(struct pnv_phb *phb, int pe_no);
> void (*freeze_pe)(struct pnv_phb *phb, int pe_no);
> int (*unfreeze_pe)(struct pnv_phb *phb, int pe_no, int opt);
>
--
Alexey
next prev parent reply other threads:[~2015-08-10 10:02 UTC|newest]
Thread overview: 102+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-08-06 4:11 [PATCH v6 00/42] powerpc/powernv: PCI hotplug suppport Gavin Shan
2015-08-06 4:11 ` [PATCH v6 01/42] PCI: Add pcibios_setup_bridge() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 02/42] powerpc/powernv: Drop pnv_ioda_setup_dev_PE() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 03/42] powerpc/powernv: Enable M64 on P7IOC Gavin Shan
2015-08-10 6:30 ` Alexey Kardashevskiy
2015-08-10 23:45 ` Gavin Shan
2015-08-11 2:06 ` Alexey Kardashevskiy
2015-08-12 10:28 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 04/42] powerpc/powernv: Reorder fields in struct pnv_phb Gavin Shan
2015-08-06 4:11 ` [PATCH v6 05/42] powerpc/powernv: Track IO/M32/M64 segments from PE Gavin Shan
2015-08-10 7:16 ` Alexey Kardashevskiy
2015-08-11 0:03 ` Gavin Shan
2015-08-11 2:23 ` Alexey Kardashevskiy
2015-08-12 10:45 ` Gavin Shan
2015-08-12 11:05 ` Alexey Kardashevskiy
2015-08-12 11:20 ` Gavin Shan
2015-08-12 12:57 ` Alexey Kardashevskiy
2015-08-12 23:34 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 06/42] powerpc/powernv: Simplify pnv_ioda_setup_pe_seg() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 07/42] powerpc/powernv: Improve IO and M32 mapping Gavin Shan
[not found] ` <1438834307-26960-8-git-send-email-gwshan-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2015-08-10 7:40 ` Alexey Kardashevskiy
2015-08-11 0:12 ` Gavin Shan
2015-08-11 2:32 ` Alexey Kardashevskiy
2015-08-12 23:42 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 08/42] powerpc/powernv: Calculate PHB's DMA weight dynamically Gavin Shan
2015-08-10 7:48 ` Alexey Kardashevskiy
2015-08-10 9:21 ` Alexey Kardashevskiy
2015-08-12 23:57 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 09/42] powerpc/powernv: DMA32 cleanup Gavin Shan
2015-08-10 8:07 ` Alexey Kardashevskiy
2015-08-11 0:19 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 10/42] powerpc/powernv: pnv_ioda_setup_dma() configure one PE only Gavin Shan
2015-08-10 9:31 ` Alexey Kardashevskiy
2015-08-11 0:29 ` Gavin Shan
2015-08-11 2:39 ` Alexey Kardashevskiy
2015-08-12 23:59 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 11/42] powerpc/powernv: Trace DMA32 segments consumed by PE Gavin Shan
2015-08-10 9:43 ` Alexey Kardashevskiy
2015-08-11 0:33 ` Gavin Shan
2015-08-13 0:02 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 13/42] powerpc/pci: Cleanup on pci_controller_ops Gavin Shan
2015-08-06 4:11 ` [PATCH v6 14/42] powerpc/pci: Override pcibios_setup_bridge() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 15/42] powerpc/powernv: PE oriented during configuration Gavin Shan
2015-08-10 10:02 ` Alexey Kardashevskiy [this message]
2015-08-11 0:39 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 16/42] powerpc/powernv: Helper function pnv_ioda_init_pe() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 18/42] powerpc/powernv: Allocate PE# in deasending order Gavin Shan
2015-08-10 14:39 ` Alexey Kardashevskiy
2015-08-11 0:43 ` Gavin Shan
2015-08-11 2:50 ` Alexey Kardashevskiy
2015-08-13 0:28 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 19/42] powerpc/powernv: Reserve PE# for root bus Gavin Shan
2015-08-06 4:11 ` [PATCH v6 20/42] powerpc/powernv: Create PEs dynamically Gavin Shan
2015-08-14 13:52 ` Alexey Kardashevskiy
2015-08-15 4:59 ` Gavin Shan
2015-08-15 9:23 ` Alexey Kardashevskiy
2015-08-06 4:11 ` [PATCH v6 21/42] powerpc/powernv: Remove DMA32 list of PEs Gavin Shan
2015-08-06 4:11 ` [PATCH v6 22/42] powerpc/powernv: Move functions around Gavin Shan
2015-08-06 4:11 ` [PATCH v6 23/42] powerpc/powernv: Release PEs dynamically Gavin Shan
2015-08-11 13:03 ` Alexey Kardashevskiy
2015-08-13 0:54 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 24/42] powerpc/powernv: Supports slot ID Gavin Shan
2015-08-06 4:11 ` [PATCH v6 25/42] powerpc/powernv: Use PCI slot reset infrastructure Gavin Shan
2015-08-06 4:11 ` [PATCH v6 26/42] powerpc/powernv: Simplify pnv_eeh_reset() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 27/42] powerpc/powernv: Don't cover root bus in pnv_pci_reset_secondary_bus() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 29/42] powerpc/pci: Don't scan empty slot Gavin Shan
2015-08-06 4:11 ` [PATCH v6 30/42] powerpc/pci: Move pcibios_find_pci_bus() around Gavin Shan
2015-08-06 4:11 ` [PATCH v6 31/42] powerpc/pci: Rename pcibios_{add,remove}_pci_devices Gavin Shan
2015-08-06 4:11 ` [PATCH v6 35/42] powerpc/pci: Export traverse_pci_device_nodes() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 36/42] powerpc/pci: Update bridge windows on PCI plugging Gavin Shan
[not found] ` <1438834307-26960-1-git-send-email-gwshan-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2015-08-06 4:11 ` [PATCH v6 12/42] powerpc/powernv: Increase PE# capacity Gavin Shan
[not found] ` <1438834307-26960-13-git-send-email-gwshan-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2015-08-10 9:53 ` Alexey Kardashevskiy
2015-08-11 0:38 ` Gavin Shan
2015-08-11 2:47 ` Alexey Kardashevskiy
2015-08-13 0:23 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 17/42] powerpc/powernv: Rename PE# fields in PHB Gavin Shan
2015-08-10 14:21 ` Alexey Kardashevskiy
2015-08-11 0:40 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 28/42] powerpc/powernv: Fundamental reset in pnv_pci_reset_secondary_bus() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 32/42] powerpc/powernv: Introduce pnv_pci_poll() Gavin Shan
2015-08-06 4:11 ` [PATCH v6 33/42] powerpc/powernv: Functions to get/reset PCI slot status Gavin Shan
2015-08-06 4:11 ` [PATCH v6 34/42] powerpc/pci: Delay creating pci_dn Gavin Shan
2015-08-06 4:11 ` [PATCH v6 37/42] powerpc/powernv: Select OF_DYNAMIC Gavin Shan
2015-08-06 4:11 ` [PATCH v6 38/42] drivers/of: Unflatten subordinate nodes after specified level Gavin Shan
2015-08-06 14:09 ` Rob Herring
2015-11-03 23:16 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 39/42] drivers/of: Allow to specify root node in of_fdt_unflatten_tree() Gavin Shan
2015-08-10 22:42 ` Frank Rowand
2015-08-11 0:52 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 40/42] drivers/of: Return allocated memory chunk from of_fdt_unflatten_tree() Gavin Shan
[not found] ` <1438834307-26960-41-git-send-email-gwshan-23VcF4HTsmIX0ybBhKVfKdBPR1lH4CV8@public.gmane.org>
2015-08-06 14:19 ` Rob Herring
2015-08-10 22:42 ` Frank Rowand
2015-08-11 0:52 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 41/42] drivers/of: Export OF changeset functions Gavin Shan
2015-08-06 13:48 ` Rob Herring
2015-08-07 1:43 ` Gavin Shan
2015-08-06 4:11 ` [PATCH v6 42/42] pci/hotplug: PowerPC PowerNV PCI hotplug driver Gavin Shan
2015-08-15 3:13 ` Alexey Kardashevskiy
2015-08-15 4:47 ` Gavin Shan
2015-08-15 9:15 ` Alexey Kardashevskiy
2015-08-10 6:05 ` [PATCH v6 00/42] powerpc/powernv: PCI hotplug suppport Alexey Kardashevskiy
2015-08-10 7:17 ` Gavin Shan
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=55C876AC.5060205@ozlabs.ru \
--to=aik@ozlabs.ru \
--cc=benh@kernel.crashing.org \
--cc=bhelgaas@google.com \
--cc=devicetree@vger.kernel.org \
--cc=grant.likely@linaro.org \
--cc=gwshan@linux.vnet.ibm.com \
--cc=linux-pci@vger.kernel.org \
--cc=linuxppc-dev@lists.ozlabs.org \
--cc=mpe@ellerman.id.au \
--cc=panto@antoniou-consulting.com \
--cc=robherring2@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).