public inbox for devicetree@vger.kernel.org
 help / color / mirror / Atom feed
From: Gavin Shan <gwshan@linux.vnet.ibm.com>
To: Alexey Kardashevskiy <aik@ozlabs.ru>
Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>,
	linuxppc-dev@lists.ozlabs.org, 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 07/42] powerpc/powernv: Improve IO and M32 mapping
Date: Thu, 13 Aug 2015 09:42:20 +1000	[thread overview]
Message-ID: <20150812234220.GB4240@gwshan> (raw)
In-Reply-To: <55C95EAD.5070603@ozlabs.ru>

On Tue, Aug 11, 2015 at 12:32:13PM +1000, Alexey Kardashevskiy wrote:
>On 08/11/2015 10:12 AM, Gavin Shan wrote:
>>On Mon, Aug 10, 2015 at 05:40:08PM +1000, Alexey Kardashevskiy wrote:
>>>On 08/06/2015 02:11 PM, Gavin Shan wrote:
>>>>There're 3 windows (IO, M32 and M64) for PHB, root port and upstream
>>>
>>>These are actually IO, non-prefetchable and prefetchable windows which happen
>>>to be IO, 32bit and 64bit windows but this has nothing to do with the M32/M64
>>>BAR registers in P7IOC/PHB3, do I understand this correctly?
>>>
>>
>>In pci-ioda.c, we have below definiations that are defined when
>>developing the code, not from any specification:
>>
>>IO  - resources with IO property
>>M32 - 32-bits or non-prefetchable resources
>>M64 - 64-bits and prefetchable resources
>
>
>This what I am saying - it is incorrect and confusing. M32/M64 are PHB3
>register names and associated windows (with "M" in the beginning) but not
>device resources.
>

I don't see how it's incorrect and confusing. M32/M64 are not PHB3
register names. Also, device resource is either IO, 32-bits prefetchable,
memory, 32-bits non-prefetchable memory, 64-bits non-prefetchable memory,
64-bits prefetchable memory. They match with IO, M32, M64.


>>>>port of the PCIE switch behind root port. In order to support PCI
>>>>hotplug, we extend the start/end address of those 3 windows of root
>>>>port or upstream port to the start/end address of the 3 PHB's windows.
>>>>The current implementation, assigning IO or M32 segment based on the
>>>>bridge's windows, isn't reliable.
>>>>
>>>>The patch fixes above issue by calculating PE's consumed IO or M32
>>>>segments from its contained devices, no PCI bridge windows involved
>>>>if the PE doesn't contain all the subordinate PCI buses.
>>>
>>>Please, rephrase it. How can PCI bridges be involved in PE consumption?
>>>
>>
>>Ok. Will add something like below:
>>
>>if the PE, corresponding to the PCI bus, doesn't contain all the subordinate
>>PCI buses.
>
>
>No, my question was about "PCI bridge windows involved" - what do you do to
>the windows if PE does not own all child buses?
>

All of it is about the original implementation: When the PE doesn't include
all child buses, the resource consumed by the PE is: resources assigned to
current PCI bus and then exclude the resources assigned to the child buses.
Note that PCI bridge windows are actually PCI bus's resource.

>>>
>>>>Otherwise,
>>>>the PCI bridge windows still contribute to PE's consumed IO or M32
>>>>segments.
>>>
>>>PCI bridge windows themselves consume PEs? Is that correct?
>>>
>>
>>PCI bridge windows consume IO, M32, M64 segments, not PEs.
>
>Ah, right.
>
>
>>>>
>>>>Signed-off-by: Gavin Shan <gwshan@linux.vnet.ibm.com>
>>>>---
>>>>  arch/powerpc/platforms/powernv/pci-ioda.c | 136 +++++++++++++++++-------------
>>>>  1 file changed, 79 insertions(+), 57 deletions(-)
>>>>
>>>>diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
>>>>index 488a53e..713f4b4 100644
>>>>--- a/arch/powerpc/platforms/powernv/pci-ioda.c
>>>>+++ b/arch/powerpc/platforms/powernv/pci-ioda.c
>>>>@@ -2844,75 +2844,97 @@ static void pnv_pci_ioda_fixup_iov_resources(struct pci_dev *pdev)
>>>>  }
>>>>  #endif /* CONFIG_PCI_IOV */
>>>>
>>>>-/*
>>>>- * This function is supposed to be called on basis of PE from top
>>>>- * to bottom style. So the the I/O or MMIO segment assigned to
>>>>- * parent PE could be overrided by its child PEs if necessary.
>>>>- */
>>>>-static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
>>>>-				  struct pnv_ioda_pe *pe)
>>>>+static int pnv_ioda_setup_one_res(struct pci_controller *hose,
>>>>+				  struct pnv_ioda_pe *pe,
>>>>+				  struct resource *res)
>>>>  {
>>>>  	struct pnv_phb *phb = hose->private_data;
>>>>  	struct pci_bus_region region;
>>>>-	struct resource *res;
>>>>-	int i, index;
>>>>-	unsigned int segsize;
>>>>+	unsigned int index, segsize;
>>>>  	unsigned long *segmap, *pe_segmap;
>>>>  	uint16_t win;
>>>>  	int64_t rc;
>>>>
>>>>-	/*
>>>>-	 * NOTE: We only care PCI bus based PE for now. For PCI
>>>>-	 * device based PE, for example SRIOV sensitive VF should
>>>>-	 * be figured out later.
>>>>-	 */
>>>>-	BUG_ON(!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)));
>>>>+	/* Check if we need map the resource */
>>>>+	if (!res->parent || !res->flags || res->start > res->end)
>>>
>>>res->start >= res->end ?
>>>
>>
>>No, res->start == res->end is valid.
>>
>>>
>>>>+		return 0;
>>>>
>>>>-	pci_bus_for_each_resource(pe->pbus, res, i) {
>>>>-		if (!res || !res->flags ||
>>>>-		    res->start > res->end)
>>>>-			continue;
>>>>+	if (res->flags & IORESOURCE_IO) {
>>>>+		region.start = res->start - phb->ioda.io_pci_base;
>>>>+		region.end   = res->end - phb->ioda.io_pci_base;
>>>>+		segsize      = phb->ioda.io_segsize;
>>>>+		segmap       = phb->ioda.io_segmap;
>>>>+		pe_segmap    = pe->io_segmap;
>>>>+		win          = OPAL_IO_WINDOW_TYPE;
>>>>+	} else if ((res->flags & IORESOURCE_MEM) &&
>>>>+		   !pnv_pci_is_mem_pref_64(res->flags)) {
>>>>+		region.start = res->start -
>>>>+			       hose->mem_offset[0] -
>>>>+			       phb->ioda.m32_pci_base;
>>>>+		region.end   = res->end -
>>>>+			       hose->mem_offset[0] -
>>>>+			       phb->ioda.m32_pci_base;
>>>>+		segsize      = phb->ioda.m32_segsize;
>>>>+		segmap       = phb->ioda.m32_segmap;
>>>>+		pe_segmap    = pe->m32_segmap;
>>>>+		win          = OPAL_M32_WINDOW_TYPE;
>>>>+	} else {
>>>>+		return 0;
>>>>+	}
>>>>
>>>>-		if (res->flags & IORESOURCE_IO) {
>>>>-			region.start = res->start - phb->ioda.io_pci_base;
>>>>-			region.end   = res->end - phb->ioda.io_pci_base;
>>>>-			segsize      = phb->ioda.io_segsize;
>>>>-			segmap       = phb->ioda.io_segmap;
>>>>-			pe_segmap    = pe->io_segmap;
>>>>-			win          = OPAL_IO_WINDOW_TYPE;
>>>>-		} else if ((res->flags & IORESOURCE_MEM) &&
>>>>-			   !pnv_pci_is_mem_pref_64(res->flags)) {
>>>>-			region.start = res->start -
>>>>-				       hose->mem_offset[0] -
>>>>-				       phb->ioda.m32_pci_base;
>>>>-			region.end   = res->end -
>>>>-				       hose->mem_offset[0] -
>>>>-				       phb->ioda.m32_pci_base;
>>>>-			segsize      = phb->ioda.m32_segsize;
>>>>-			segmap       = phb->ioda.m32_segmap;
>>>>-			pe_segmap    = pe->m32_segmap;
>>>>-			win          = OPAL_M32_WINDOW_TYPE;
>>>>-		} else {
>>>>-			continue;
>>>>+	region.start = _ALIGN_DOWN(region.start, segsize);
>>>>+	region.end   = _ALIGN_UP(region.end, segsize);
>>>>+	index = region.start / segsize;
>>>>+	while (index < phb->ioda.total_pe &&
>>>>+	       region.start < region.end) {
>>>>+		rc = opal_pci_map_pe_mmio_window(phb->opal_id,
>>>>+				pe->pe_number, win, 0, index);
>>>>+		if (rc != OPAL_SUCCESS) {
>>>>+			pr_warn("%s: Error %lld mapping (%d) seg#%d to PHB#%d-PE#%d\n",
>>>>+				__func__, rc, win, index,
>>>>+				pe->phb->hose->global_number,
>>>>+				pe->pe_number);
>>>>+			return -EIO;
>>>>  		}
>>>>
>>>>-		index = region.start / phb->ioda.io_segsize;
>>>>-		while (index < phb->ioda.total_pe &&
>>>>-		       region.start <= region.end) {
>>>>-			set_bit(index, segmap);
>>>>-			set_bit(index, pe_segmap);
>>>>-			rc = opal_pci_map_pe_mmio_window(phb->opal_id,
>>>>-					pe->pe_number, win, 0, index);
>>>>-			if (rc != OPAL_SUCCESS) {
>>>>-				pr_warn("%s: Error %lld mapping (%d) seg#%d to PHB#%d-PE#%d\n",
>>>>-					__func__, rc, win, index,
>>>>-					pe->phb->hose->global_number,
>>>>-					pe->pe_number);
>>>>-				break;
>>>>-			}
>>>>+		set_bit(index, segmap);
>>>>+		set_bit(index, pe_segmap);
>>>>+		region.start += segsize;
>>>>+		index++;
>>>>+	}
>>>>+
>>>>+	return 0;
>>>>+}
>>>>+
>>>>+static void pnv_ioda_setup_pe_seg(struct pci_controller *hose,
>>>>+				  struct pnv_ioda_pe *pe)
>>>>+{
>>>>+	struct pci_dev *pdev;
>>>>+	struct resource *res;
>>>>+	int i;
>>>>+
>>>>+	/* This function only works for bus dependent PE */
>>>>+	BUG_ON(!(pe->flags & (PNV_IODA_PE_BUS | PNV_IODA_PE_BUS_ALL)));
>>>>+
>>>>+	list_for_each_entry(pdev, &pe->pbus->devices, bus_list) {
>>>>+		for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
>>>>+			res = &pdev->resource[i];
>>>>+			if (pnv_ioda_setup_one_res(hose, pe, res))
>>>>+				return;
>>>>+		}
>>>>+
>>>>+		/* If the PE contains all subordinate PCI buses, the
>>>>+		 * resources of the child bridges should be mapped
>>>>+		 * to the PE as well.
>>>>+		 */
>>>>+		if (!(pe->flags & PNV_IODA_PE_BUS_ALL) ||
>>>>+		    (pdev->class >> 8) != PCI_CLASS_BRIDGE_PCI)
>>>>+			continue;
>>>>
>>>>-			region.start += segsize;
>>>>-			index++;
>>>>+		for (i = 0; i <= PCI_BRIDGE_RESOURCE_NUM; i++) {
>>>>+			res = &pdev->resource[PCI_BRIDGE_RESOURCES + i];
>>>>+			if (pnv_ioda_setup_one_res(hose, pe, res))
>>>>+				return;
>>>>  		}
>>>>  	}
>>>>  }
>>>>
>>

Thanks,
Gavin

  reply	other threads:[~2015-08-12 23:42 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 [this message]
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
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=20150812234220.GB4240@gwshan \
    --to=gwshan@linux.vnet.ibm.com \
    --cc=aik@ozlabs.ru \
    --cc=benh@kernel.crashing.org \
    --cc=bhelgaas@google.com \
    --cc=devicetree@vger.kernel.org \
    --cc=grant.likely@linaro.org \
    --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