Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752824AbbFHHup (ORCPT ); Mon, 8 Jun 2015 03:50:45 -0400 Received: from mail.skyhub.de ([78.46.96.112]:54011 "EHLO mail.skyhub.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752521AbbFHHt6 (ORCPT ); Mon, 8 Jun 2015 03:49:58 -0400 From: Borislav Petkov To: Ingo Molnar Cc: LKML Subject: [PATCH 1/3] swiotlb: Warn on allocation failure in swiotlb_alloc_coherent() Date: Mon, 8 Jun 2015 09:49:53 +0200 Message-Id: <1433749795-5796-2-git-send-email-bp@alien8.de> X-Mailer: git-send-email 2.3.5 In-Reply-To: <1433749795-5796-1-git-send-email-bp@alien8.de> References: <1433749795-5796-1-git-send-email-bp@alien8.de> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 2174 Lines: 70 From: Joerg Roedel Print a warning when all allocation tries have been failed and the function is about to return NULL. This prepares for calling the function with __GFP_NOWARN to suppress allocation failure warnings before all fall-backs have failed. Signed-off-by: Joerg Roedel Acked-by: Konrad Rzeszutek Wilk Acked-by: Baoquan He Cc: Baoquan He Cc: Dave Young Cc: "H. Peter Anvin" Cc: Ingo Molnar Cc: Jörg Rödel Cc: Thomas Gleixner Cc: Vivek Goyal Cc: kexec@lists.infradead.org Cc: x86-ml Link: http://lkml.kernel.org/r/1433500202-25531-2-git-send-email-joro@8bytes.org Signed-off-by: Borislav Petkov --- lib/swiotlb.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/swiotlb.c b/lib/swiotlb.c index 4abda074ea45..e0e921218f0b 100644 --- a/lib/swiotlb.c +++ b/lib/swiotlb.c @@ -655,7 +655,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, */ phys_addr_t paddr = map_single(hwdev, 0, size, DMA_FROM_DEVICE); if (paddr == SWIOTLB_MAP_ERROR) - return NULL; + goto err_warn; ret = phys_to_virt(paddr); dev_addr = phys_to_dma(hwdev, paddr); @@ -669,7 +669,7 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, /* DMA_TO_DEVICE to avoid memcpy in unmap_single */ swiotlb_tbl_unmap_single(hwdev, paddr, size, DMA_TO_DEVICE); - return NULL; + goto err_warn; } } @@ -677,6 +677,13 @@ swiotlb_alloc_coherent(struct device *hwdev, size_t size, memset(ret, 0, size); return ret; + +err_warn: + pr_warn("swiotlb: coherent allocation failed for device %s size=%zu\n", + dev_name(hwdev), size); + dump_stack(); + + return NULL; } EXPORT_SYMBOL(swiotlb_alloc_coherent); -- 2.3.5 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/