Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp2298761pxb; Fri, 5 Feb 2021 14:16:11 -0800 (PST) X-Google-Smtp-Source: ABdhPJz2THGg2wqS2EgnFKTAraJOES5cBx22MbphR+RQEJmH+xOD+Q8h8R8xEE6s92Lyx9qe5nNO X-Received: by 2002:a50:9f4e:: with SMTP id b72mr5836769edf.4.1612563371116; Fri, 05 Feb 2021 14:16:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612563371; cv=none; d=google.com; s=arc-20160816; b=HbXXbcK9I45+6BS1Crgta9ujVGYiwJ1h28DvFCWWV6wwAsEZArJp+ZLG591pydU8cR 2HVzml3qoaWWicYqZ707YYODFy74NotsnF7aYRWtKzMVNDgsTKFcjIYALEQiFbGfGezr x6QmKBAwuqULN6MKA4b0Pm5fzS9kp3WTrZS1jGx+Xqq7hAH8LN8MI4+7h/s7HjKiZJ3S HnpfkudCIAs4xm+VZ8CQQ2xUBhpdWG7tVuzw1E8D1aXGMeztcQM7Ic6r1vxvJRDTA1Bv swDpxKyZfQLFZ2ZMbU/vH/hISXXsTBcwqr/1cSZL2lf/+tmMMUoUUmBUazujCIj7r3Hk /XLA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=k7EpJt53fAmJ9oKQf9JPE+AaKIIMCZ+LXpFO9oon6HA=; b=eeTUna+3MaUB0hWfueG1SVMO2w0/TqEkX426jO8nw5Ic4Nrf3WyLlhL5uX03iagAEM MtIKXLrEZxtMnNqTSuLHfzRjTkWGhZWqpzM7lC3PFvqj9ZSJdOsxt0iJluU6LVIi6f5Q MSylfUv9cUD6htu641Ea7HHz57d7JmDf2XlqWGfBMmAv4NA5eqk77zTOoJy77HOnPsIC X/y/r2dyDEx41WkdWI6NfQXKDqA2EUF9BBU+jd6AqWVpJjh/eaw6/t4gimhMA0cP8rHy WWTNVJtVi6ilPlOLYelx1rO114j6oPb4Il/JnQX6t45TraPbcc045SXTXTqYitxN5p7n BUAA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v1rHChoo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id k3si7486626eds.167.2021.02.05.14.15.46; Fri, 05 Feb 2021 14:16:11 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=v1rHChoo; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233130AbhBEWNN (ORCPT + 99 others); Fri, 5 Feb 2021 17:13:13 -0500 Received: from mail.kernel.org ([198.145.29.99]:44986 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232937AbhBEO5T (ORCPT ); Fri, 5 Feb 2021 09:57:19 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C836B64FDE; Fri, 5 Feb 2021 14:09:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1612534196; bh=f8H6f5ryS0R55IIGx+krgZyIAR/f6vQiAqxDJbIVdYg=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=v1rHChooxDiGNlJDdowdiI7vpr5pGWvXzvrpKxt9wB95DdWaz8lWWVLDfb1MKkxzo QrEO7GTf1zYxBQyJKKOpIxrbboLR0VAH2kE0SHwUX86CkvBAMhIpkLorsK0pHh+yA6 EDzHRWjE8vhRIIzjj5ZahY4B+ipgIwAU1ER/rbeI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Oded Gabbay , Sasha Levin Subject: [PATCH 5.10 23/57] habanalabs: fix dma_addr passed to dma_mmap_coherent Date: Fri, 5 Feb 2021 15:06:49 +0100 Message-Id: <20210205140656.968808985@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210205140655.982616732@linuxfoundation.org> References: <20210205140655.982616732@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Oded Gabbay [ Upstream commit a9d4ef643430d638de1910377f50e0d492d85a43 ] When doing dma_alloc_coherent in the driver, we add a certain hard-coded offset to the DMA address before returning to the callee function. This offset is needed when our device use this DMA address to perform outbound transactions to the host. However, if we want to map the DMA'able memory to the user via dma_mmap_coherent(), we need to pass the original dma address, without this offset. Otherwise, we will get erronouos mapping. Signed-off-by: Oded Gabbay Signed-off-by: Sasha Levin --- drivers/misc/habanalabs/gaudi/gaudi.c | 3 ++- drivers/misc/habanalabs/goya/goya.c | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/drivers/misc/habanalabs/gaudi/gaudi.c b/drivers/misc/habanalabs/gaudi/gaudi.c index ed1bd41262ecd..68f661aca3ff2 100644 --- a/drivers/misc/habanalabs/gaudi/gaudi.c +++ b/drivers/misc/habanalabs/gaudi/gaudi.c @@ -3119,7 +3119,8 @@ static int gaudi_cb_mmap(struct hl_device *hdev, struct vm_area_struct *vma, vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_DONTCOPY | VM_NORESERVE; - rc = dma_mmap_coherent(hdev->dev, vma, cpu_addr, dma_addr, size); + rc = dma_mmap_coherent(hdev->dev, vma, cpu_addr, + (dma_addr - HOST_PHYS_BASE), size); if (rc) dev_err(hdev->dev, "dma_mmap_coherent error %d", rc); diff --git a/drivers/misc/habanalabs/goya/goya.c b/drivers/misc/habanalabs/goya/goya.c index 235d47b2420f5..986ed3c072088 100644 --- a/drivers/misc/habanalabs/goya/goya.c +++ b/drivers/misc/habanalabs/goya/goya.c @@ -2675,7 +2675,8 @@ static int goya_cb_mmap(struct hl_device *hdev, struct vm_area_struct *vma, vma->vm_flags |= VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP | VM_DONTCOPY | VM_NORESERVE; - rc = dma_mmap_coherent(hdev->dev, vma, cpu_addr, dma_addr, size); + rc = dma_mmap_coherent(hdev->dev, vma, cpu_addr, + (dma_addr - HOST_PHYS_BASE), size); if (rc) dev_err(hdev->dev, "dma_mmap_coherent error %d", rc); -- 2.27.0