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=-0.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,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 D5769C54FCB for ; Fri, 24 Apr 2020 15:04:39 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id 91F0B20706 for ; Fri, 24 Apr 2020 15:04:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="sgBQmibu" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 91F0B20706 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 41C5E8E0005; Fri, 24 Apr 2020 11:04:39 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 3CD0C8E0003; Fri, 24 Apr 2020 11:04:39 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 2BB798E0005; Fri, 24 Apr 2020 11:04:39 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0099.hostedemail.com [216.40.44.99]) by kanga.kvack.org (Postfix) with ESMTP id 137768E0003 for ; Fri, 24 Apr 2020 11:04:39 -0400 (EDT) Received: from smtpin24.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay01.hostedemail.com (Postfix) with ESMTP id B6A5E180AD817 for ; Fri, 24 Apr 2020 15:04:38 +0000 (UTC) X-FDA: 76743070236.24.jar07_62b2f98960b1e X-HE-Tag: jar07_62b2f98960b1e X-Filterd-Recvd-Size: 4715 Received: from mail-yb1-f194.google.com (mail-yb1-f194.google.com [209.85.219.194]) by imf48.hostedemail.com (Postfix) with ESMTP for ; Fri, 24 Apr 2020 15:04:38 +0000 (UTC) Received: by mail-yb1-f194.google.com with SMTP id i2so5199130ybk.2 for ; Fri, 24 Apr 2020 08:04:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=A+ucTA2Mbv2lYIGS5FEH5Sl6pFWw26bVTDXGHUVYRAE=; b=sgBQmibuRnJmjww+L4H5xM7w7wDhbwWMduWLdm3XhZuLtEwPS4lbCXLOBlNB9v/Zth I++xpd4rsw9thQ6fTDjU4GEiFu7dkgh1tqOTfBLbCe9gVFs9ZDLzOy/dH5DjoTWSHn9I XsGRlie3YKHhicloJOjhoha8rZpdyeSOUZudbf7k51gw9JgbehvWyrMn969UHFq8I890 4e3Y6JONTouLGTWBdzdhUzbp5w6wBPSbYFAWDX2YFLKF470+2IzZs4cysP1Vt2XgZ8Ii dRB1KzxZp3HcOywqmYa67tmvNtjMHVa8SCB1KhVWfqytfBjMwRLy/k+P9Z0CEzO9/4wk vr8A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=A+ucTA2Mbv2lYIGS5FEH5Sl6pFWw26bVTDXGHUVYRAE=; b=k0fHJf8PJhluT9fXgiDEekQUEEH7wwQ3tvk2DICnfzk3sVlxMWhe7wm737C5+ujTpn 92lr0MJ3S96RvD7wZjO4esv8MycHTDJ+AyStdVZcV1h1Z6YzKyF1Pmi1TGBzc15IfLAn Y6W1yh3xdubXiRjiYu4qtmpbAio3cDoK3kCazLO5IvNRfcCGgIQnDq5fyF6joZfVjeq/ LL+cF9wEJNuiFO6kyAGfS6GTwnPy1RVkT+Jcp6zMYX0vHtxnHS0znOpXOvXbD1nOgUpr 0T9+Zz+x+axv++zo/2U+15hDg1oDtshQ555m2dmth1xlVblJFwrtVkBQNYlXWS+f2AI2 0kiQ== X-Gm-Message-State: AGi0PuYDmmgTz/puIIZlSi3D8Q/Ylww+3QYAKf7d2ZrMYd6UT4batVuJ XhyuAAzwLQBiiVvv1w6vELVLOctvZVxI9w8xDUY= X-Google-Smtp-Source: APiQypJeUhbDwX7H5LQGqajOKcFUw24FdkW7pGVKNJIfLxOQdu5tHx1Vh+4tJUj6JZqDJbn12oG+IReDHJIib4PmLlw= X-Received: by 2002:a25:3b08:: with SMTP id i8mr16270926yba.402.1587740677348; Fri, 24 Apr 2020 08:04:37 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Ajay kumar Date: Fri, 24 Apr 2020 20:34:26 +0530 Message-ID: Subject: Re: IOVA allocation dependency between firmware buffer and remaining buffers To: iommu@lists.linux-foundation.org, linux-mm@kvack.org, joro@8bytes.org, Marek Szyprowski , Rob Clark , Thierry Reding , jean-philippe@linaro.org, will@kernel.org, robin.murphy@arm.com, hch@lst.de, baolu.lu@linux.intel.com Cc: shaik.ameer@samsung.com, shaik.samsung@gmail.com Content-Type: text/plain; charset="UTF-8" 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: Can someone check this? On Mon, Apr 20, 2020 at 9:24 PM Ajay kumar wrote: > > 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