From patchwork Tue Sep 30 20:15:21 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sean Paul X-Patchwork-Id: 5006831 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id EB1E9BEEA6 for ; Tue, 30 Sep 2014 20:18:21 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id F32C5201C7 for ; Tue, 30 Sep 2014 20:18:20 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.9]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 3DCF220165 for ; Tue, 30 Sep 2014 20:18:20 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1XZ3q1-00042v-8e; Tue, 30 Sep 2014 20:15:57 +0000 Received: from mail-yh0-x230.google.com ([2607:f8b0:4002:c01::230]) by bombadil.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1XZ3pz-0003zb-4P for linux-arm-kernel@lists.infradead.org; Tue, 30 Sep 2014 20:15:55 +0000 Received: by mail-yh0-f48.google.com with SMTP id v1so554144yhn.35 for ; Tue, 30 Sep 2014 13:15:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id; bh=Wnk74m78egTlz1BmpnxtLlo0kKht9D8iF/jioCGiZ4g=; b=YyrN+eLmicdnwPMRcgCmgfhPcGRDRcYQj/qBkfAY9WQa3/ixCoy41zFvVEbmzWhO+Z 43SzDGEi2rPH1WHBM5URTTT7cMdbF3Fhu+4xbRs+SMmj17hFPEzGEGUJCAuclHgKmPIi 12E52xeX7RUT4TLwVC+vM01oiujrwMk1YK9UA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Wnk74m78egTlz1BmpnxtLlo0kKht9D8iF/jioCGiZ4g=; b=e64uM2MdG92RTj2sO9nKoI5tur0AQ1BVUeHxGJkoPqhR6n/a8rtzxb6ff7Ff2nhcU2 7ME78l54eHIruGjgd6cm/o+Zia1zXHzwS6ZoWJyT65vLukPsT9WFtJuZO+lz/axM7vM4 6gdjGig6VaIbpHPF/ss+1SYpRkTHOVWo6DjFaMf1yabZeVqgMqNMNRGQIO5hJhZrzQIJ hRFIq6ahqB0TpRBggB72uW4r5FiwlaRKVr010MWog+RxB4xgvWRsuWuJJ1fo9OGPnI32 2cKbkOEfJLfNf19IoPPoWh4yn0UIVwUGYtAA3LLFXhqi5+Ktn4YHgUhU8rQe+w3XasAY gmUQ== X-Gm-Message-State: ALoCoQniRA6zY23cfGk9bXGsvqRcPjtsg2mKAjYa6nBxyWH8jN0p7/yFDejJaq4PHFnljyHFFanb X-Received: by 10.236.89.113 with SMTP id b77mr29614575yhf.87.1412108132612; Tue, 30 Sep 2014 13:15:32 -0700 (PDT) Received: from localhost.localdomain (cpe-173-095-180-236.nc.res.rr.com. [173.95.180.236]) by mx.google.com with ESMTPSA id y42sm8819376yhy.55.2014.09.30.13.15.31 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 30 Sep 2014 13:15:32 -0700 (PDT) From: Sean Paul To: catalin.marinas@arm.com, will.deacon@arm.com, lauraa@codeaurora.org, ritesh.harjani@gmail.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] arm64: Use and error-check DMA_ERROR_CODE Date: Tue, 30 Sep 2014 16:15:21 -0400 Message-Id: <1412108121-19262-1-git-send-email-seanpaul@chromium.org> X-Mailer: git-send-email 2.1.1 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20140930_131555_231676_C7526C27 X-CRM114-Status: GOOD ( 11.69 ) X-Spam-Score: -0.1 (/) Cc: olof@lixom.net, seanpaul@chromium.org X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Spam-Status: No, score=-2.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_NONE,RP_MATCHES_RCVD,T_DKIM_INVALID,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP This patch replaces the static assignment of ~0 to dma_handle with DMA_ERROR_CODE to be consistent with other platforms. In addition to that, it also adds a check for DMA_ERROR_CODE before calling __dma_free_coherent with an invalid dma_handle. Signed-off-by: Sean Paul --- arch/arm64/mm/dma-mapping.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/arch/arm64/mm/dma-mapping.c b/arch/arm64/mm/dma-mapping.c index 4164c5a..69fd2c4 100644 --- a/arch/arm64/mm/dma-mapping.c +++ b/arch/arm64/mm/dma-mapping.c @@ -125,7 +125,7 @@ static void *__dma_alloc_noncoherent(struct device *dev, size_t size, no_map: __dma_free_coherent(dev, size, ptr, *dma_handle, attrs); no_mem: - *dma_handle = ~0; + *dma_handle = DMA_ERROR_CODE; return NULL; } @@ -136,7 +136,9 @@ static void __dma_free_noncoherent(struct device *dev, size_t size, void *swiotlb_addr = phys_to_virt(dma_to_phys(dev, dma_handle)); vunmap(vaddr); - __dma_free_coherent(dev, size, swiotlb_addr, dma_handle, attrs); + + if (dma_handle != DMA_ERROR_CODE) + __dma_free_coherent(dev, size, swiotlb_addr, dma_handle, attrs); } static dma_addr_t __swiotlb_map_page(struct device *dev, struct page *page,