Received: by 10.192.165.148 with SMTP id m20csp4143718imm; Mon, 30 Apr 2018 12:34:22 -0700 (PDT) X-Google-Smtp-Source: AB8JxZpBa2xU9YzX2YKX0R87BEyA0j3i7sE5SphS5/uj1vmqzv/LLZnKRniIusvz17QluPHNmJPn X-Received: by 2002:a17:902:5481:: with SMTP id e1-v6mr13342160pli.137.1525116862747; Mon, 30 Apr 2018 12:34:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525116862; cv=none; d=google.com; s=arc-20160816; b=gM6Ace7SQtUZHXZDXt/MYJEUOe7TZHg8tiVgZ6633XCGc9sdqYtSPr9J5dMXlpX2/k zdjTvZQULpUEQNkrnxlb5R/kP6KwQ+BhJfq5TQ8529gjSorh5xvaNWn4DrHElZd849wP NNd1aHP85ywCtBnKFncLOEaFQguiRLDL4nviR/ZTzF1eQLcG+aE2CxyEEGEzbHhdZkl3 5P2B3mokmMy2H4s/gZXAf/hHvdrQP7UWDRrqmGQKenpyFUAU0qUa3yRe8Jg+zrdv+1RA m1dCX3pk3Pw8A3ksUbovTXW55EtHs2dEuZxYTHbRPlB7svX10aii03riyAu29l9LzrdY Uzjg== 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=picRc/ofA9i4Ig6fJOzSQD860iVzkWlBhjPP7mxUyV4=; b=0Ca/ye6f+MxLlfqzwDR4kmDWnSZ4AvGSCdQ38UWu7tU+vtTlQGKDDN6ErTrdy06/Hf xK1XBvs6JPiwrplHfvbn4kxmP0yKdVcOE2ahQ3uIG0DODW8Hdpb21GBB9GW6/jfZo1w7 3kT6Eo9N/s6Hyw8k6jxDpEP/hJNK2IvglnBVZnqA5Moaxmp73i5tGsiftnhvIMoXQCO0 kYoBT666hVIesm1NkyLsvTAh36C5Shj3t6xWr7RlN69Riltt9X3rBuQc1LLiYtpeS4NU De9rJgdwakTBQrtBz+xYTif99czmNCO63RJQp1kGiM9li8vAy/en2TN6GIKk9CDDn1ro J65g== 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 h10si8018046pfh.278.2018.04.30.12.34.08; Mon, 30 Apr 2018 12:34:22 -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 S1756549AbeD3Tb4 (ORCPT + 99 others); Mon, 30 Apr 2018 15:31:56 -0400 Received: from mail.kernel.org ([198.145.29.99]:37410 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932429AbeD3T3A (ORCPT ); Mon, 30 Apr 2018 15:29:00 -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 C146B2344C; Mon, 30 Apr 2018 19:28:59 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org C146B2344C 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.16 082/113] powerpc/powernv/npu: Do a PID GPU TLB flush when invalidating a large address range Date: Mon, 30 Apr 2018 12:24:53 -0700 Message-Id: <20180430184018.652944439@linuxfoundation.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180430184015.043892819@linuxfoundation.org> References: <20180430184015.043892819@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.16-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. */ @@ -627,11 +634,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 = {