From mboxrd@z Thu Jan 1 00:00:00 1970 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=2.4 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,HTML_MESSAGE,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=no 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 4764DC3815B for ; Mon, 20 Apr 2020 15:54:55 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 04341206DD for ; Mon, 20 Apr 2020 15:54:54 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="fa8CzRTL" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 04341206DD Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=gmail.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=owner-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix) id 8FD0F8E0005; Mon, 20 Apr 2020 11:54:54 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 8AD638E0003; Mon, 20 Apr 2020 11:54:54 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 7C3358E0005; Mon, 20 Apr 2020 11:54:54 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0238.hostedemail.com [216.40.44.238]) by kanga.kvack.org (Postfix) with ESMTP id 619E48E0003 for ; Mon, 20 Apr 2020 11:54:54 -0400 (EDT) Received: from smtpin20.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay04.hostedemail.com (Postfix) with ESMTP id 2032A4DCB for ; Mon, 20 Apr 2020 15:54:54 +0000 (UTC) X-FDA: 76728681708.20.sign68_da9a5fc82a33 X-HE-Tag: sign68_da9a5fc82a33 X-Filterd-Recvd-Size: 6635 Received: from mail-yb1-f178.google.com (mail-yb1-f178.google.com [209.85.219.178]) by imf30.hostedemail.com (Postfix) with ESMTP for ; Mon, 20 Apr 2020 15:54:53 +0000 (UTC) Received: by mail-yb1-f178.google.com with SMTP id h205so5667859ybg.6 for ; Mon, 20 Apr 2020 08:54:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:from:date:message-id:subject:to:cc; bh=w3gwnOvN7lPW/9Irv4LBkALcZF5SMNb/5bjU+tsZvxI=; b=fa8CzRTLQUEzwwpZGicQ3mcterHo/a6XLZoquGPXJYLG6ZLNsMYMSO2W2fcKeoQCnT 15Udr+Xp9R3yT8y0b2aEicCGMN6rZ63CpdYH1ByF5OLy8q0gMPVQ4vW/MBt2tgL5Clqm n29Z7jgAtNzTbgW8wyCndW/2NEjXuAWDmIQwKGHGUJS2xQlpewCx9Qgn6bImF1wPybjc c+AFQ+3SjWe2vaDp31Q8aGroKeyEYMk4r7H3jFTtEQwZ2i5SlvaiqfUk0/OoKN/Y+mXp 6Wqx3HN3OI69MOI08FDqO/rEnz2uW2arXVYWZBa0ZUQ3eiSZw9j17CTeGhD6RrNcgUy1 yoYQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to:cc; bh=w3gwnOvN7lPW/9Irv4LBkALcZF5SMNb/5bjU+tsZvxI=; b=b4Z1NjrgsorbRDmvUYatT0o6ZbpS/1Ljd2zgUGYBdLTOhoz4Cd4P9WXrNnXgsYrFVA pmwoatcWZNlb+kHKuJBbgjFGdEfvpdA857AX1TuLKPJUk0avwNr6bt0mg8+HUU8b5Cf/ kpWF8HfhYbN0PdPmD1hUSb7xPmcyDFRZeHquB95St/rPKJ6BbSxGsh5Fy7v4iYs/ASU/ /h+KBnTAGHYvZ9sp0hXh7JluIwTMVuOUlis9bx8SVmBHs2nl262PAYPyQ1IpE6P0qJnX /Njborta6DGcSHfiY5s7uXWm6DFNcSNzEWPhUGLDWVlD3iMvcPR1Rjo7H8cot3G0hxku 0eTQ== X-Gm-Message-State: AGi0PuaZO2eljNCY1B504gbUOl6FUiYvHDAZ8fwTL7uMH9Czjqpc2LK9 pNIATE6BgbpMzQfpvK+VvRL8eLEXGybWJR0/RGU= X-Google-Smtp-Source: APiQypKDDO805xi8TiSZlqO9x9hUEm5golTh8A/BDNvQJ6FHCcDOCh2oQIIlSjh3jiULfSlE1egVQqSUzEGuoBgd+Ls= X-Received: by 2002:a25:b294:: with SMTP id k20mr18170480ybj.394.1587398092987; Mon, 20 Apr 2020 08:54:52 -0700 (PDT) MIME-Version: 1.0 From: Ajay kumar Date: Mon, 20 Apr 2020 21:24:40 +0530 Message-ID: Subject: IOVA allocation dependency between firmware buffer and remaining buffers To: iommu@lists.linux-foundation.org, "linux-arm-kernel@lists.infradead.org" , linux-mm@kvack.org Cc: shaik.ameer@samsung.com, shaik.samsung@gmail.com Content-Type: multipart/alternative; boundary="0000000000007321b805a3baebaf" X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: --0000000000007321b805a3baebaf Content-Type: text/plain; charset="UTF-8" Hi All, I have an IOMMU master which has limitations as mentioned below: 1) The IOMMU master internally executes a firmware, and the firmware memory is allocated by the same master driver. The firmware buffer address should be of the lowest range than other address allocated by the device, or in other words, all the remaining buffer addresses should always be in a higher range than the firmware address. 2) None of the buffer addresses should go beyond 0xC000_0000 example: If firmware buffer address is buf_fw = 0x8000_5000; All other addresses given to the device should be greater than (0x8000_5000 + firmware size) and less than 0xC000_0000 Currently, this is being handled with one of the below hacks: 1) By keeping dma_mask in lower range while allocating firmware buffer, and then increasing the dma_mask to higher range for other buffers. 2) By reserving IOVA for firmware at the lowest range and creating direct mappings for the same. I want to know if there is a better way this can be handled with current framework, or if anybody is facing similar problems with their devices, please share how it is taken care. I also think there should be some way the masters can specify the IOVA range they want to limit to for current allocation. Something like a new iommu_ops callback like below: limit_iova_alloc_range(dev, iova_start, iova_end) And, in my driver, the sequence will be: limit_iova_alloc_range(dev, 0x0000_0000, 0x1000_0000); /* via helpers */ alloc( ) firmware buffer using DMA API limit_iova_alloc_range(dev, 0x1000_0000, 0xC000_0000); /* via helpers */ alloc( ) other buffers using DMA API Thanks, Ajay Kumar --0000000000007321b805a3baebaf Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
Hi All,

I have an IOMMU master which has limitations as mentioned below:
1) The IOMMU master internally executes a firmware, and the firmwar= e memory
is allocated by the same master driver.
The fi= rmware buffer address should be of the lowest range than other address
allocated by the device, or in other words, all the remaining buffer = addresses
should=C2=A0always be in a higher range than the firmwa= re address.
2) None of the buffer addresses should go beyond 0xC0= 00_0000

example:
If firmware buffer addr= ess is buf_fw =3D 0x8000_5000;
All other addresses given to the d= evice should be greater than
(0x8000_5000 + firmware size) and le= ss than 0xC000_0000

Currently, this is being handl= ed with one of the below hacks:
1) By keeping=C2=A0dma_mask in lo= wer range while allocating firmware buffer,
and then increasing t= he dma_mask to higher range for other buffers.
2) By reserving IO= VA for firmware at the lowest range and creating direct mappings for the sa= me.=C2=A0

I want to know if there is a better way = this can be handled with current framework, or if anybody is facing similar= problems with their devices,
please share how it is taken care.<= /div>

I also think there should be some way the masters = can specify the IOVA
range they want to limit to for current = allocation.
Something like a new iommu_ops callback like below:
limit_iova_alloc_range(dev, iova_start, iova_end)

And, in my driver, the sequence will be:
limit_iova_alloc_range= (dev, 0x0000_0000, 0x1000_0000); /* via helpers */
alloc( ) f= irmware buffer using DMA API
limit_iova_alloc_range(dev, 0x1= 000_0000, 0xC000_0000); /* via helpers */
alloc( ) other buff= ers using DMA API

Thanks,
Aj= ay Kumar
--0000000000007321b805a3baebaf--