From patchwork Mon Jul 12 06:11:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 476281 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-19.4 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER, INCLUDES_PATCH, MAILING_LIST_MULTI, SPF_HELO_NONE, SPF_PASS, URIBL_BLOCKED, USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C93A1C11F7C for ; Mon, 12 Jul 2021 06:28:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B0D1461156 for ; Mon, 12 Jul 2021 06:28:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234080AbhGLGbN (ORCPT ); Mon, 12 Jul 2021 02:31:13 -0400 Received: from mail.kernel.org ([198.145.29.99]:52652 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236666AbhGLGaU (ORCPT ); Mon, 12 Jul 2021 02:30:20 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 2D0C360238; Mon, 12 Jul 2021 06:27:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1626071251; bh=E8jrvBp7NQyVPO9QxXNVoK7M83EnFpEZZanD7Y8asMw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=n7hR5hrIXmnc9Fzw/KRAylvD98R9o5JDUnnw8jRBlUmkgZGjvHt4FK0GKTpu4hYT1 EwxPZJIsbnc9WAaAO8+urP7KBc+QCklCt+G/lZH+yoI9fpxKTWsPo99LqLTgpsxgkC DQ3odX89VJtUeqnuw14OGIHYVyd06W4oYfaPwKJg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Srinath Mannam , Robin Murphy , Sven Peter , Joerg Roedel , Sasha Levin Subject: [PATCH 5.4 302/348] iommu/dma: Fix IOVA reserve dma ranges Date: Mon, 12 Jul 2021 08:11:26 +0200 Message-Id: <20210712060743.708489154@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210712060659.886176320@linuxfoundation.org> References: <20210712060659.886176320@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Srinath Mannam [ Upstream commit 571f316074a203e979ea90211d9acf423dfe5f46 ] Fix IOVA reserve failure in the case when address of first memory region listed in dma-ranges is equal to 0x0. Fixes: aadad097cd46f ("iommu/dma: Reserve IOVA for PCIe inaccessible DMA address") Signed-off-by: Srinath Mannam Reviewed-by: Robin Murphy Tested-by: Sven Peter Link: https://lore.kernel.org/r/20200914072319.6091-1-srinath.mannam@broadcom.com Signed-off-by: Joerg Roedel Signed-off-by: Sasha Levin --- drivers/iommu/dma-iommu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/dma-iommu.c b/drivers/iommu/dma-iommu.c index 76bd2309e023..d3b6898626e7 100644 --- a/drivers/iommu/dma-iommu.c +++ b/drivers/iommu/dma-iommu.c @@ -216,9 +216,11 @@ resv_iova: lo = iova_pfn(iovad, start); hi = iova_pfn(iovad, end); reserve_iova(iovad, lo, hi); - } else { + } else if (end < start) { /* dma_ranges list should be sorted */ - dev_err(&dev->dev, "Failed to reserve IOVA\n"); + dev_err(&dev->dev, + "Failed to reserve IOVA [%#010llx-%#010llx]\n", + start, end); return -EINVAL; }