Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp520671imu; Thu, 20 Dec 2018 00:30:47 -0800 (PST) X-Google-Smtp-Source: AFSGD/WRObgwwn0o3qEs0WleC47khBiBYoGXBwol2VNv/vD+WT2M8EgE2E8L0mdnDw3tZrDhh/BQ X-Received: by 2002:a62:ca9c:: with SMTP id y28mr23260623pfk.236.1545294647523; Thu, 20 Dec 2018 00:30:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545294647; cv=none; d=google.com; s=arc-20160816; b=zyq+V8fzOq/1JS4osrqntb5in7dwWRCTF63+Br4WNuFXYMDNMmKlsbd6u3cE+SX+jY CI9FJ2umJ6MWsIShI45s1Hh6tAvySIX/BC+/mynsCSxgw6wF/XrF5la4x9TrYL9/hsiT SO8IEi/MA+ecwVILyaILhReoPwDfxQAhV0SFigLUkMVbJIaSpJOtvpvDTyaikR34Iqy9 90kqpmQM4raYCWZBsnKMF7Acs5VGNefK/sKiTmk/gGCGNrhzjr/wyI+t96Xq+I4ze364 9JdGjZx5XR8vXcFuigaFE+APTmYKjkQhWZ4w3uflVaIpAXW5Rome8OZbIzRD8Eap4285 xyEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=A9nXP3IeN/kC0ttfqdJMe/GkHCwVo2f038WKxdiK68s=; b=T9BU1ZeaZEu9JKznYfI4fEXYiOrR+xDrs1/kzgucMLXv9ui7Uwylqth6SsTOBNdRMz pPgUwyp1C1dL7cZFaMhP4A0QF3Sc4ufqrgekonQbtz/5j85LlrK4REc9gniTY2JAhXSZ X2O6TnHLrYdBg0t4zBIqOa62CFDVCiciK22zcZvs9yhyhUI/uXXT4/G9JLeQeHKc81H6 vdotuNQQl0+XAeUS/N5HdhyvLuxOMMqKS8QwYieSJmA/rmZhqwtKm13CqknAA5CY1gOz oiEGKRLb9fBkHqZ4c2ffcqQDY7PD+19SaHUA0H5M2YswH3/+0HY7wRQT5qZEM/C3+Wt6 r1jA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id p12si18304759pgj.56.2018.12.20.00.30.31; Thu, 20 Dec 2018 00:30:47 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731004AbeLTIYn (ORCPT + 99 others); Thu, 20 Dec 2018 03:24:43 -0500 Received: from ozlabs.ru ([107.173.13.209]:54572 "EHLO ozlabs.ru" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730982AbeLTIYl (ORCPT ); Thu, 20 Dec 2018 03:24:41 -0500 Received: from fstn1-p1.ozlabs.ibm.com (localhost [IPv6:::1]) by ozlabs.ru (Postfix) with ESMTP id 23C12AE80336; Thu, 20 Dec 2018 03:24:36 -0500 (EST) From: Alexey Kardashevskiy To: linuxppc-dev@lists.ozlabs.org Cc: Alexey Kardashevskiy , David Gibson , kvm-ppc@vger.kernel.org, kvm@vger.kernel.org, Alistair Popple , Reza Arbab , Sam Bobroff , Piotr Jaroszynski , =?UTF-8?q?Leonardo=20Augusto=20Guimar=C3=A3es=20Garcia?= , Jose Ricardo Ziviani , Daniel Henrique Barboza , Alex Williamson , Paul Mackerras , linux-kernel@vger.kernel.org, Christoph Hellwig Subject: [PATCH kernel v7 12/20] powerpc/powernv/npu: Move single TVE handling to NPU PE Date: Thu, 20 Dec 2018 19:23:42 +1100 Message-Id: <20181220082350.58113-13-aik@ozlabs.ru> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20181220082350.58113-1-aik@ozlabs.ru> References: <20181220082350.58113-1-aik@ozlabs.ru> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Normal PCI PEs have 2 TVEs, one per a DMA window; however NPU PE has only one which points to one of two tables of the corresponding PCI PE. So whenever a new DMA window is programmed to PEs, the NPU PE needs to release old table in order to use the new one. Commit d41ce7b1bcc3e ("powerpc/powernv/npu: Do not try invalidating 32bit table when 64bit table is enabled") did just that but in pci-ioda.c while it actually belongs to npu-dma.c. This moves the single TVE handling to npu-dma.c. This does not implement restoring though as it is highly unlikely that we can set the table to PCI PE and cannot to NPU PE and if that fails, we could only set 32bit table to NPU PE and this configuration is not really supported or wanted. Signed-off-by: Alexey Kardashevskiy --- arch/powerpc/platforms/powernv/npu-dma.c | 8 +++++++ arch/powerpc/platforms/powernv/pci-ioda.c | 27 +++-------------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/arch/powerpc/platforms/powernv/npu-dma.c b/arch/powerpc/platforms/powernv/npu-dma.c index ef1457f..26063fb 100644 --- a/arch/powerpc/platforms/powernv/npu-dma.c +++ b/arch/powerpc/platforms/powernv/npu-dma.c @@ -130,6 +130,11 @@ long pnv_npu_set_window(struct pnv_ioda_pe *npe, int num, tbl->it_level_size : tbl->it_size; const __u64 start_addr = tbl->it_offset << tbl->it_page_shift; const __u64 win_size = tbl->it_size << tbl->it_page_shift; + int num2 = (num == 0) ? 1 : 0; + + /* NPU has just one TVE so if there is another table, remove it first */ + if (npe->table_group.tables[num2]) + pnv_npu_unset_window(npe, num2); pe_info(npe, "Setting up window %llx..%llx pg=%lx\n", start_addr, start_addr + win_size - 1, @@ -160,6 +165,9 @@ long pnv_npu_unset_window(struct pnv_ioda_pe *npe, int num) struct pnv_phb *phb = npe->phb; int64_t rc; + if (!npe->table_group.tables[num]) + return 0; + pe_info(npe, "Removing DMA window\n"); rc = opal_pci_map_pe_dma_window(phb->opal_id, npe->pe_number, diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c index a5879ab..1ee3c5d6 100644 --- a/arch/powerpc/platforms/powernv/pci-ioda.c +++ b/arch/powerpc/platforms/powernv/pci-ioda.c @@ -2672,23 +2672,14 @@ static struct pnv_ioda_pe *gpe_table_group_to_npe( static long pnv_pci_ioda2_npu_set_window(struct iommu_table_group *table_group, int num, struct iommu_table *tbl) { - struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group); - int num2 = (num == 0) ? 1 : 0; long ret = pnv_pci_ioda2_set_window(table_group, num, tbl); if (ret) return ret; - if (table_group->tables[num2]) - pnv_npu_unset_window(npe, num2); - - ret = pnv_npu_set_window(npe, num, tbl); - if (ret) { + ret = pnv_npu_set_window(gpe_table_group_to_npe(table_group), num, tbl); + if (ret) pnv_pci_ioda2_unset_window(table_group, num); - if (table_group->tables[num2]) - pnv_npu_set_window(npe, num2, - table_group->tables[num2]); - } return ret; } @@ -2697,24 +2688,12 @@ static long pnv_pci_ioda2_npu_unset_window( struct iommu_table_group *table_group, int num) { - struct pnv_ioda_pe *npe = gpe_table_group_to_npe(table_group); - int num2 = (num == 0) ? 1 : 0; long ret = pnv_pci_ioda2_unset_window(table_group, num); if (ret) return ret; - if (!npe->table_group.tables[num]) - return 0; - - ret = pnv_npu_unset_window(npe, num); - if (ret) - return ret; - - if (table_group->tables[num2]) - ret = pnv_npu_set_window(npe, num2, table_group->tables[num2]); - - return ret; + return pnv_npu_unset_window(gpe_table_group_to_npe(table_group), num); } static void pnv_ioda2_npu_take_ownership(struct iommu_table_group *table_group) -- 2.17.1