Received: by 10.192.165.148 with SMTP id m20csp4162037imm; Mon, 30 Apr 2018 12:58:37 -0700 (PDT) X-Google-Smtp-Source: AB8JxZoQtz6fVhuCBZFxv/LbJD1VG0HApJQXuWofvuzDIe7I8ktFNG96fUxLx0qzv4vYHF/DgeFT X-Received: by 2002:a65:5244:: with SMTP id q4-v6mr10872712pgp.201.1525118317716; Mon, 30 Apr 2018 12:58:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525118317; cv=none; d=google.com; s=arc-20160816; b=x+NGKngiE8WNTRd19E+yuGHxqx6JH8P/tFZNcN+YpQgJ08rXhu1eh73iBiYx8HCRrm RVDIpqYl2Jq7sK2Qih0VXg/VXg9DV3OVOpipAQXxXYnHPK4XwVfpuAY0Cs71ajStO5RO AjRjCw1buck5zNRwKkUO6ds4aRYYH/mH9tSqn9QNlYX2Kngry/+KmtDa2FGMWG7bkmif O+YNLAl4iHuyTPj8UR2RAUOZ1I5CsrjXEukZq2Wuga09v1Jn9yMO1TJ24Pe70679xdpl vHIV3Au4iSzXc+Fa0lrKkCwOkKh+Irk2Nb/Veyo/hQbZX756dOCGjE2aIOKF3DzHu8z3 zjAQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:references :in-reply-to:message-id:date:subject:cc:to:from:dmarc-filter :arc-authentication-results; bh=s6TWoDpvM5j9oOuFexHwETeZGeGSizrvtZoNUHY0I34=; b=zUCbGg4xFnY1vqBTOesrxWv+ZSswL44PGoms3UsvNMGclJP7NUgDrof4hMKbM7VX2u UMgqd+vNYbxegZsu+jmcSLS8zYMc+/Uo7uxn5NcoudodzMWCpItMRBhozxUvKAzBRA2b QC+f/GpP+BTm7rtvd7vR4sAQhmW8qsf/TlOtnTwHFDBHHkfxccw6Pea/+g0gQ5PuhRN5 F2Y15wk2kgkm5cSeW3EwmYGWtlnE/l/MjUo5nyrJNvGcz/AtuOR7uY+yvOQhS+dFQWEs Rgz0mClKoqIF2FOV4YxqRaxDmsbqC6jN1Qf0EaGsB0Xy3KwGQj0IkZOjLnUVJcJyfxls klxA== 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 x10-v6si6484258pgt.109.2018.04.30.12.57.53; Mon, 30 Apr 2018 12:58:37 -0700 (PDT) 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 S932275AbeD3T5a (ORCPT + 99 others); Mon, 30 Apr 2018 15:57:30 -0400 Received: from mail.kernel.org ([198.145.29.99]:34720 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756065AbeD3T1t (ORCPT ); Mon, 30 Apr 2018 15:27:49 -0400 Received: from localhost (unknown [104.132.1.102]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 3218122DAC; Mon, 30 Apr 2018 19:27:49 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 3218122DAC Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=linuxfoundation.org Authentication-Results: mail.kernel.org; spf=fail smtp.mailfrom=gregkh@linuxfoundation.org From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Alistair Popple , Balbir Singh , Michael Ellerman Subject: [PATCH 4.14 70/91] powerpc/powernv/npu: Do a PID GPU TLB flush when invalidating a large address range Date: Mon, 30 Apr 2018 12:24:52 -0700 Message-Id: <20180430184007.897760550@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184004.216234025@linuxfoundation.org> References: <20180430184004.216234025@linuxfoundation.org> User-Agent: quilt/0.65 X-stable: review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 4.14-stable review patch. If anyone has any objections, please let me know. ------------------ From: Alistair Popple commit d0cf9b561ca97d5245bb9e0c4774b7fadd897d67 upstream. The NPU has a limited number of address translation shootdown (ATSD) registers and the GPU has limited bandwidth to process ATSDs. This can result in contention of ATSD registers leading to soft lockups on some threads, particularly when invalidating a large address range in pnv_npu2_mn_invalidate_range(). At some threshold it becomes more efficient to flush the entire GPU TLB for the given MM context (PID) than individually flushing each address in the range. This patch will result in ranges greater than 2MB being converted from 32+ ATSDs into a single ATSD which will flush the TLB for the given PID on each GPU. Fixes: 1ab66d1fbada ("powerpc/powernv: Introduce address translation services for Nvlink2") Cc: stable@vger.kernel.org # v4.12+ Signed-off-by: Alistair Popple Acked-by: Balbir Singh Tested-by: Balbir Singh Signed-off-by: Michael Ellerman Signed-off-by: Greg Kroah-Hartman --- arch/powerpc/platforms/powernv/npu-dma.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) --- a/arch/powerpc/platforms/powernv/npu-dma.c +++ b/arch/powerpc/platforms/powernv/npu-dma.c @@ -34,6 +34,13 @@ #define npu_to_phb(x) container_of(x, struct pnv_phb, npu) /* + * When an address shootdown range exceeds this threshold we invalidate the + * entire TLB on the GPU for the given PID rather than each specific address in + * the range. + */ +#define ATSD_THRESHOLD (2*1024*1024) + +/* * Other types of TCE cache invalidation are not functional in the * hardware. */ @@ -621,11 +628,19 @@ static void pnv_npu2_mn_invalidate_range struct npu_context *npu_context = mn_to_npu_context(mn); unsigned long address; - for (address = start; address < end; address += PAGE_SIZE) - mmio_invalidate(npu_context, 1, address, false); + if (end - start > ATSD_THRESHOLD) { + /* + * Just invalidate the entire PID if the address range is too + * large. + */ + mmio_invalidate(npu_context, 0, 0, true); + } else { + for (address = start; address < end; address += PAGE_SIZE) + mmio_invalidate(npu_context, 1, address, false); - /* Do the flush only on the final addess == end */ - mmio_invalidate(npu_context, 1, address, true); + /* Do the flush only on the final addess == end */ + mmio_invalidate(npu_context, 1, address, true); + } } static const struct mmu_notifier_ops nv_nmmu_notifier_ops = {