Received: by 2002:a25:7ec1:0:0:0:0:0 with SMTP id z184csp6040308ybc; Wed, 27 Nov 2019 13:56:28 -0800 (PST) X-Google-Smtp-Source: APXvYqwQJ4F1DVrMbJhaDZyWUdOEsYJcxJkMW2u/IZm2mNBveGnAiNItEiHxe1KvWwnTwHrYeJpr X-Received: by 2002:aa7:c694:: with SMTP id n20mr34787041edq.87.1574891788507; Wed, 27 Nov 2019 13:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1574891788; cv=none; d=google.com; s=arc-20160816; b=DhXsaWoVkY0ceXVX3mLM/TRb8CDQ1LRpTru0dtCBGqWexM0/ypeqzHeL/mdSVoeRID AxKQW10ob3IK6icscJrpEBNJGd2TZW/NIOq+1t2SihqRwpC6Ee09+OJ8srgsa6BDQgqK MgCB4y3CKmZiI+4D2BVOQDSp+UVYHpUJmCBpO3m3TU9W1UtV9e4p/FkmHH2Jgokp/AVw eqQ2G0krvDmcrmkURG5qDRZtBIKSO0PrgFWFXqfynVDDWcm3O7g98hFeGf+Rv8lShnfQ TfWCYmDF7jxFqq4q7eXd2oXEI6gBwwpYlb9OYghJiHFyjYPsCcv8LrRNGq+LkJMAD6jM xtcg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H3qMSIiwMCzKpZflKupIgKFaByQgvSo78J+QZZ0uFcM=; b=0pJRnBlapASuLzMuK3MtVkUvaYAoFQtXsEdlmftbouNWM6NPWVzKxdVMIKjhOXTyif fN1UaaYfxlodyhPgfHYd/Q+hK2EhPnPrDPwFujGVZqf0Pcddj1jrjTGVHx5M24BESrWV 3NrwwqL/jy2ySEjeDneMsJ+dgPK60TPnRDHG4Aw7GUp+zBsX3ytGlD+pbdZ8JSjnHzT0 j/fxosDzXmwTFAELzYILXsZRPDHKMnzufjQ6qUQl3mxtb3hVpMFZ+SDpFTCazzy699DH JyzmJxnZF8P6ryjn+pK12zwGCLfmKhvGZLJ3HyU5YtdXt9b4j6YHYrHSdgxNGR33zfuD YPAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=lZj98cSb; 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 v20si10804117ejq.189.2019.11.27.13.56.05; Wed, 27 Nov 2019 13:56:28 -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; dkim=pass header.i=@kernel.org header.s=default header.b=lZj98cSb; 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 S1731687AbfK0VBQ (ORCPT + 99 others); Wed, 27 Nov 2019 16:01:16 -0500 Received: from mail.kernel.org ([198.145.29.99]:53326 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727327AbfK0VBO (ORCPT ); Wed, 27 Nov 2019 16:01:14 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (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 4DEC020862; Wed, 27 Nov 2019 21:01:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1574888473; bh=sgtYBds0vlLgYVSZg75gyqmnkTu5AZWC7qxCtXuwRSU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=lZj98cSbR3ZxhV4SezhQsJPt6MmzkCOKTn63KErh2qeH1L4air0MlGP6eO5NOs6YA 3k/r90rjG08IfBqf4Du002bYq+aBwtybWTiW6R0O9QIlqEkRLIBKNOBF23YQM5uBXI q6iCH/skxMcBafGAMIBBo2AxBd3fBxI0pdL5p540= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Christoph Hellwig , Robin Murphy , Sasha Levin Subject: [PATCH 4.19 105/306] swiotlb: do not panic on mapping failures Date: Wed, 27 Nov 2019 21:29:15 +0100 Message-Id: <20191127203123.013432076@linuxfoundation.org> X-Mailer: git-send-email 2.24.0 In-Reply-To: <20191127203114.766709977@linuxfoundation.org> References: <20191127203114.766709977@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Christoph Hellwig [ Upstream commit 8088546832aa2c0d8f99dd56edf6384f8a9b63b3 ] All properly written drivers now have error handling in the dma_map_single / dma_map_page callers. As swiotlb_tbl_map_single already prints a useful warning when running out of swiotlb pool space we can also remove swiotlb_full entirely as it serves no purpose now. Signed-off-by: Christoph Hellwig Reviewed-by: Robin Murphy Signed-off-by: Sasha Levin --- kernel/dma/swiotlb.c | 33 +-------------------------------- 1 file changed, 1 insertion(+), 32 deletions(-) diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c index 4f8a6dbf0b609..2a8c41f12d450 100644 --- a/kernel/dma/swiotlb.c +++ b/kernel/dma/swiotlb.c @@ -761,34 +761,6 @@ static bool swiotlb_free_buffer(struct device *dev, size_t size, return true; } -static void -swiotlb_full(struct device *dev, size_t size, enum dma_data_direction dir, - int do_panic) -{ - if (swiotlb_force == SWIOTLB_NO_FORCE) - return; - - /* - * Ran out of IOMMU space for this operation. This is very bad. - * Unfortunately the drivers cannot handle this operation properly. - * unless they check for dma_mapping_error (most don't) - * When the mapping is small enough return a static buffer to limit - * the damage, or panic when the transfer is too big. - */ - dev_err_ratelimited(dev, "DMA: Out of SW-IOMMU space for %zu bytes\n", - size); - - if (size <= io_tlb_overflow || !do_panic) - return; - - if (dir == DMA_BIDIRECTIONAL) - panic("DMA: Random memory could be DMA accessed\n"); - if (dir == DMA_FROM_DEVICE) - panic("DMA: Random memory could be DMA written\n"); - if (dir == DMA_TO_DEVICE) - panic("DMA: Random memory could be DMA read\n"); -} - /* * Map a single buffer of the indicated size for DMA in streaming mode. The * physical address to use is returned. @@ -817,10 +789,8 @@ dma_addr_t swiotlb_map_page(struct device *dev, struct page *page, /* Oh well, have to allocate and map a bounce buffer. */ map = map_single(dev, phys, size, dir, attrs); - if (map == SWIOTLB_MAP_ERROR) { - swiotlb_full(dev, size, dir, 1); + if (map == SWIOTLB_MAP_ERROR) return __phys_to_dma(dev, io_tlb_overflow_buffer); - } dev_addr = __phys_to_dma(dev, map); @@ -954,7 +924,6 @@ swiotlb_map_sg_attrs(struct device *hwdev, struct scatterlist *sgl, int nelems, if (map == SWIOTLB_MAP_ERROR) { /* Don't panic here, we expect map_sg users to do proper error handling. */ - swiotlb_full(hwdev, sg->length, dir, 0); attrs |= DMA_ATTR_SKIP_CPU_SYNC; swiotlb_unmap_sg_attrs(hwdev, sgl, i, dir, attrs); -- 2.20.1