Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751792AbeACDxv (ORCPT + 1 other); Tue, 2 Jan 2018 22:53:51 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:45084 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751001AbeACDxu (ORCPT ); Tue, 2 Jan 2018 22:53:50 -0500 Subject: Re: [PATCH 01/13] powerpc/powernv: Introduce new PHB type for opencapi links To: Frederic Barrat , linuxppc-dev@lists.ozlabs.org, linux-kernel@vger.kernel.org Cc: arnd@arndb.de, gregkh@linuxfoundation.org, mpe@ellerman.id.au, alastair@au1.ibm.com References: <6870a754d346e7d8a47325e5ba4327853aea9226.1513608243.git.fbarrat@linux.vnet.ibm.com> From: Andrew Donnellan Date: Wed, 3 Jan 2018 14:53:38 +1100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.5.2 MIME-Version: 1.0 In-Reply-To: <6870a754d346e7d8a47325e5ba4327853aea9226.1513608243.git.fbarrat@linux.vnet.ibm.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-AU Content-Transfer-Encoding: 7bit X-TM-AS-GCONF: 00 x-cbid: 18010303-0016-0000-0000-000005131AF2 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18010303-0017-0000-0000-0000284F623F Message-Id: X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-01-03_02:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=2 phishscore=0 bulkscore=0 spamscore=0 clxscore=1011 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1801030051 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Return-Path: On 19/12/17 02:21, Frederic Barrat wrote: > The NPU was already abstracted by opal as a virtual PHB for nvlink, > but it helps to be able to differentiate between a nvlink or opencapi > PHB, as it's not completely transparent to linux. In particular, PE > assignment differs and we'll also need the information in later > patches. > > So rename existing PNV_PHB_NPU type to PNV_PHB_NPU_NVLINK and add a > new type PNV_PHB_NPU_OCAPI. > > Signed-off-by: Frederic Barrat > Signed-off-by: Andrew Donnellan > --- > arch/powerpc/platforms/powernv/npu-dma.c | 2 +- > arch/powerpc/platforms/powernv/pci-ioda.c | 46 +++++++++++++++++++++++-------- > arch/powerpc/platforms/powernv/pci.c | 4 +++ > arch/powerpc/platforms/powernv/pci.h | 8 ++++-- > 4 files changed, 45 insertions(+), 15 deletions(-) > > diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c > index f6cbc1a71472..c5899c107d59 100644 > --- a/arch/powerpc/platforms/powernv/npu-dma.c > +++ b/arch/powerpc/platforms/powernv/npu-dma.c > @@ -277,7 +277,7 @@ static int pnv_npu_dma_set_bypass(struct pnv_ioda_pe *npe) > int64_t rc = 0; > phys_addr_t top = memblock_end_of_DRAM(); > > - if (phb->type != PNV_PHB_NPU || !npe->pdev) > + if (phb->type != PNV_PHB_NPU_NVLINK || !npe->pdev) > return -EINVAL; > > rc = pnv_npu_unset_window(npe, 0); > diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c > index 749055553064..c37b5d288f9c 100644 > --- a/arch/powerpc/platforms/powernv/pci-ioda.c > +++ b/arch/powerpc/platforms/powernv/pci-ioda.c > @@ -54,7 +54,8 @@ > #define POWERNV_IOMMU_DEFAULT_LEVELS 1 > #define POWERNV_IOMMU_MAX_LEVELS 5 > > -static const char * const pnv_phb_names[] = { "IODA1", "IODA2", "NPU" }; > +static const char * const pnv_phb_names[] = { "IODA1", "IODA2", "NPU_NVLINK", > + "NPU_OCAPI" }; > static void pnv_pci_ioda2_table_free_pages(struct iommu_table *tbl); > > void pe_level_printk(const struct pnv_ioda_pe *pe, const char *level, > @@ -924,7 +925,7 @@ static int pnv_ioda_configure_pe(struct pnv_phb *phb, struct pnv_ioda_pe *pe) > * Configure PELTV. NPUs don't have a PELTV table so skip > * configuration on them. > */ > - if (phb->type != PNV_PHB_NPU) > + if (phb->type != PNV_PHB_NPU_NVLINK && phb->type != PNV_PHB_NPU_OCAPI) > pnv_ioda_set_peltv(phb, pe, true); > > /* Setup reverse map */ > @@ -1260,12 +1261,13 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev) > return pe; > } > > -static void pnv_ioda_setup_npu_PEs(struct pci_bus *bus) > +static void pnv_ioda_setup_npu_PEs(struct pci_bus *bus, > + struct pnv_ioda_pe *fn(struct pci_dev *npu_pdev)) > { > struct pci_dev *pdev; > > list_for_each_entry(pdev, &bus->devices, bus_list) > - pnv_ioda_setup_npu_PE(pdev); > + fn(pdev); > } I think adding a function pointer here is rather ugly, at this point you might as well just do this directly in pnv_pci_ioda_setup_PEs() > > static void pnv_pci_ioda_setup_PEs(void) > @@ -1275,13 +1277,18 @@ static void pnv_pci_ioda_setup_PEs(void) > > list_for_each_entry_safe(hose, tmp, &hose_list, list_node) { > phb = hose->private_data; > - if (phb->type == PNV_PHB_NPU) { > + if (phb->type == PNV_PHB_NPU_NVLINK) { > /* PE#0 is needed for error reporting */ > pnv_ioda_reserve_pe(phb, 0); > - pnv_ioda_setup_npu_PEs(hose->bus); > + pnv_ioda_setup_npu_PEs(hose->bus, > + pnv_ioda_setup_npu_PE); > if (phb->model == PNV_PHB_MODEL_NPU2) > pnv_npu2_init(phb); > } > + if (phb->type == PNV_PHB_NPU_OCAPI) { > + pnv_ioda_setup_npu_PEs(hose->bus, > + pnv_ioda_setup_dev_PE); > + } > } > } > -- Andrew Donnellan OzLabs, ADL Canberra andrew.donnellan@au1.ibm.com IBM Australia Limited