Received: by 10.223.164.202 with SMTP id h10csp220993wrb; Mon, 13 Nov 2017 05:30:05 -0800 (PST) X-Google-Smtp-Source: AGs4zMbq/HA1RGX6TNuDTURSVjtOuUEPIgEtyMwlyJxo3e5In8YuP4S8k+2r83vB36xihVvXtEg9 X-Received: by 10.159.231.15 with SMTP id w15mr9141429plq.436.1510579805795; Mon, 13 Nov 2017 05:30:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510579805; cv=none; d=google.com; s=arc-20160816; b=RyqziMNTc3yq0Te5vgOvXkWx1smt09ae1eo6OuNOS3v+j5UvaP3s5Wp6eqf90X8RbN jB+yGUssM8lS9Ijib+Mcj31G0X3QYkHOzUzlhmr9lqVtFSzD9KmgNQeM34Qs4jzhK6GK vIj14DvYtmhMG58ktKEWmWS+yGovDgGfVLoufxDZnE0r3HIzRMm3HX9PsG9wRszc7a6M a5mXsyXNWSxhul30FLrcjJUX1sVetP5zh/HofpBeOY7t0X6GAMnK3Z5z4g0lYAmzwmDC l/sShIyZo2cv/IwXer5Re35MoEwETNyunWr2B5MbK8qH5wbQvifW3LwKQidW2uSm3l9E CD6A== 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 :arc-authentication-results; bh=JFR6oGvOwQ1ShYwbGS7jcCd548ozg0wLE7wbsyVKXM0=; b=ec93TY3Ddh5HFrMvMJaXm9UsczvWiApfhiPG9OU0cCrCvXbUhWCfRFJIzI9xWMKeHv L3U2FPTnrtws4u/U2y2khg3+yeTNWLoTmDO6vilGHZ7wk7zTMfm9JgCdUDfxFxWHw38r DlL2kDGIl3qNg/cKlxPnFcwwf0HlssT9AbBDOT/hnhYx1wsf/m3pNFHTiSa461sPBnqk lqEAvoiG4OlGcdEd4O3Z+CXxA/T0bXEp6ufWRXYliXdXryzABUldF0nuLFGvZ2ymxg0m QXqJ7Hj08mEr8BXkG8uyB6RySvXIf0+Fp7+5c5hjvEUg0KX1xP5X9Yph7jiDqsOFzJrd O4/w== 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 p20si3400421pgc.387.2017.11.13.05.29.52; Mon, 13 Nov 2017 05:30:05 -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 S1754178AbdKMN2u (ORCPT + 95 others); Mon, 13 Nov 2017 08:28:50 -0500 Received: from mail.linuxfoundation.org ([140.211.169.12]:49818 "EHLO mail.linuxfoundation.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754109AbdKMM7q (ORCPT ); Mon, 13 Nov 2017 07:59:46 -0500 Received: from localhost (LFbn-1-12253-150.w90-92.abo.wanadoo.fr [90.92.67.150]) by mail.linuxfoundation.org (Postfix) with ESMTPSA id 08EF1AA6; Mon, 13 Nov 2017 12:59:45 +0000 (UTC) From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Robin Murphy , Will Deacon , Sasha Levin Subject: [PATCH 4.9 18/87] arm64: dma-mapping: Only swizzle DMA ops for IOMMU_DOMAIN_DMA Date: Mon, 13 Nov 2017 13:55:35 +0100 Message-Id: <20171113125616.960529058@linuxfoundation.org> X-Mailer: git-send-email 2.15.0 In-Reply-To: <20171113125615.304035578@linuxfoundation.org> References: <20171113125615.304035578@linuxfoundation.org> User-Agent: quilt/0.65 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.9-stable review patch. If anyone has any objections, please let me know. ------------------ From: Will Deacon [ Upstream commit 4a8d8a14c0d08c2437cb80c05e88f6cc1ca3fb2c ] The arm64 DMA-mapping implementation sets the DMA ops to the IOMMU DMA ops if we detect that an IOMMU is present for the master and the DMA ranges are valid. In the case when the IOMMU domain for the device is not of type IOMMU_DOMAIN_DMA, then we have no business swizzling the ops, since we're not in control of the underlying address space. This patch leaves the DMA ops alone for masters attached to non-DMA IOMMU domains. Reviewed-by: Robin Murphy Signed-off-by: Will Deacon Signed-off-by: Sasha Levin Signed-off-by: Greg Kroah-Hartman --- arch/arm64/mm/dma-mapping.c | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -836,14 +836,21 @@ static bool do_iommu_attach(struct devic * then the IOMMU core will have already configured a group for this * device, and allocated the default domain for that group. */ - if (!domain || iommu_dma_init_domain(domain, dma_base, size, dev)) { - pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", - dev_name(dev)); - return false; + if (!domain) + goto out_err; + + if (domain->type == IOMMU_DOMAIN_DMA) { + if (iommu_dma_init_domain(domain, dma_base, size, dev)) + goto out_err; + + dev->archdata.dma_ops = &iommu_dma_ops; } - dev->archdata.dma_ops = &iommu_dma_ops; return true; +out_err: + pr_warn("Failed to set up IOMMU for device %s; retaining platform DMA ops\n", + dev_name(dev)); + return false; } static void queue_iommu_attach(struct device *dev, const struct iommu_ops *ops, From 1584920619405369560@xxx Fri Nov 24 04:34:48 +0000 2017 X-GM-THRID: 1584920619405369560 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread