Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp608417pxb; Wed, 27 Jan 2021 16:37:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJyefQlumkhIOF76O9PaRhrluZv7HOHI1R5Z/5DRUBndkTAhBsIz2F1PYA/sEQyW1nQSs6AH X-Received: by 2002:a17:906:9616:: with SMTP id s22mr8882550ejx.270.1611794226632; Wed, 27 Jan 2021 16:37:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611794226; cv=none; d=google.com; s=arc-20160816; b=o+SIK3evxuqv8r2qzpi8kEqdduHIubpDZnEWyPWhZAEzdgm1mJLlf1id9KHDHOl0R0 2cKJEw6EyldPRLaMC4dAWLXUVmRyw0a5bGEjqjbOaLg+lXNO2Lxv4z8kzsdjp6REbaRA t1+wHbPmaWdy8+FxcHM/cVeX+LG1z2ATSGDXUvumvgNffFpD8bYK92T3MeI7zVEhQfpW 9v64iJTDQUBWsWQafLdCu7MfbZ7qPaRhH4C71JmBddKOxYn6ItBSPa8ZTZWFGyqnd+rX 0QV1/Jp2lOtlsjVpA8v2VrbEq7XyIntbx2LElDG564m4bryxYYIkcngp9Y7VssbSp+P5 YMQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:cc:to:subject:message-id:date:from:in-reply-to :references:mime-version:dkim-signature; bh=B1OrPnRGym/IRixVkvzf03+5dttK+B+Ggd5w3Ge31lw=; b=GbkAKFhFQwgX23/TiV5ubpYgEgDvp8Ali+VSS+iA/PNahslsitB1HdBNLgUVW7zvry nqk91gKqktwCxt4v9KesKjXMngLnkwweC3hbGJkWj8MRkGCKzLkx3lnqJJQmzNiYdy3d hi8LJER1wozQjckHRMeVfH59Ky/iTvOzMvqNzXD5Ls+mHV5uBtrfoA6ERz+2hF2EORZy dUElZ4rY+V6faNO8gal5w4PvLOl0lzzkkiEEuRtKDRVNK+B83/a8kI83MgZ8MKMgqQSJ NpbnoBQ2HgzgHCBI+Ip4rvKLkrvYcRsUltuhC96tBSAWpcESwYGJmbVa4QoDUJGbG1er +xQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=WCzSGAO7; 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=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id gw11si1448043ejb.414.2021.01.27.16.36.42; Wed, 27 Jan 2021 16:37:06 -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=@chromium.org header.s=google header.b=WCzSGAO7; 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=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229872AbhA0Vib (ORCPT + 99 others); Wed, 27 Jan 2021 16:38:31 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51560 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236030AbhA0Vf4 (ORCPT ); Wed, 27 Jan 2021 16:35:56 -0500 Received: from mail-il1-x130.google.com (mail-il1-x130.google.com [IPv6:2607:f8b0:4864:20::130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 519E6C0613D6 for ; Wed, 27 Jan 2021 13:35:16 -0800 (PST) Received: by mail-il1-x130.google.com with SMTP id z18so3068219ile.9 for ; Wed, 27 Jan 2021 13:35:16 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=B1OrPnRGym/IRixVkvzf03+5dttK+B+Ggd5w3Ge31lw=; b=WCzSGAO7mjzX3wOjkJ8Xi+N96UOte29yYftfMjgzGN07dKBxV6KHe6Mgk00CEi1ttL 60aWRQW3pAzpzTDPTMn35ux/Qi8CBERZCGV0kWR2Tq7KcxKkkiycwEzw3bglvBpsUXa8 jpX/rB8VmbY4VBdDKdaML9sNTelm7OUgk3Lac= 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=B1OrPnRGym/IRixVkvzf03+5dttK+B+Ggd5w3Ge31lw=; b=cV/RVdMlm+mvTRoX0nkLI9aU5NFaHcdQuka5yX3SGV7SlDbBxJdumZaWRXEp01PUkX eFLgmogwmd8hLWta/96tYqV46C4cpOYE3COanYV0zca7siWR1IuPebDztVELM2+vK5UV Yav4SfGx+TN9MUnBVILhTvqegRenMqpavRTKZIiZwrnUnfv1uH3fChvSXp7O+5zIwV6C E3ydwkqBAWUypISua6CETEtdugTXXu6gNXYDwoIj9QqywR800zMzswbsZ4m6cQLDSQII Rbaxqx4/j8xFLXcIgvIE/3XxeY44ox6FcO6MVt4H45fNhzIDoLaY+nSElKeaIiIqODHB VgbQ== X-Gm-Message-State: AOAM532LGLawu5VH4Jn5EdlvwPPNN7ENUuk+cP9DA9FGmthzApGc/9qt IVR/BbJYAcpwOEMna5wrSTn1lEKOb5cFEn2I X-Received: by 2002:a92:2c06:: with SMTP id t6mr7568320ile.92.1611783315286; Wed, 27 Jan 2021 13:35:15 -0800 (PST) Received: from mail-il1-f176.google.com (mail-il1-f176.google.com. [209.85.166.176]) by smtp.gmail.com with ESMTPSA id g9sm1828309ilp.49.2021.01.27.13.35.13 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 27 Jan 2021 13:35:14 -0800 (PST) Received: by mail-il1-f176.google.com with SMTP id y17so3303487ili.12 for ; Wed, 27 Jan 2021 13:35:13 -0800 (PST) X-Received: by 2002:a05:6e02:194e:: with SMTP id x14mr10530200ilu.218.1611783313321; Wed, 27 Jan 2021 13:35:13 -0800 (PST) MIME-Version: 1.0 References: <20201201033658.GE3723071@google.com> <20201201144916.GA14682@lst.de> <20201208071320.GA1667627@google.com> <20201209111639.GB22806@lst.de> <20210111083614.GA27589@lst.de> <20210126170659.GA9104@lst.de> <20210127155608.GA20272@lst.de> In-Reply-To: <20210127155608.GA20272@lst.de> From: Ricardo Ribalda Date: Wed, 27 Jan 2021 22:35:02 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API To: ". Christoph Hellwig" Cc: Sergey Senozhatsky , Tomasz Figa , Marek Szyprowski , Robin Murphy , Mauro Carvalho Chehab , IOMMU DRIVERS , Joerg Roedel , Linux Doc Mailing List , Linux Kernel Mailing List , Linux Media Mailing List , Sergey Senozhatsky Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoph On Wed, Jan 27, 2021 at 4:56 PM . Christoph Hellwig wrote: > > On Wed, Jan 27, 2021 at 12:29:08AM +0100, Ricardo Ribalda wrote: > > - Is there any platform where dma_alloc_noncontiguos can fail? > > This is, !ops->alloc_noncontiguous and !dev->coherent_dma_mask > > If yes then we need to add a function to let the driver know in > > advance that it has to use the coherent allocator (usb_alloc_coherent > > for uvc) > > dev->coherent_dma_mask is set by the driver. So the only reason why > dma_alloc_noncontiguos will fail is because is because it can't > allocate any memory. > > > - In dma_alloc_noncontiguos, on the dma_alloc_pages fallback. If we > > have a device where the dma happens in only one direction, could not > > get more performance with DMA_FROM/TO_DEVICE instead of > > DMA_BIDIRECTIONAL ? > > Yes, we could probably do that. > > > > > > > Then I have tried to use the API, and I have encountered a problem: on > > uvcvideo the device passed to the memory allocator is different for > > DMA_PAGES and NON_CONTIGUOUS: > > https://github.com/ribalda/linux/blob/042cd497739f71c8d4a83a67ee970369e2baca4a/drivers/media/usb/uvc/uvc_video.c#L1236 > > > > I need to dig a bit tomorrow to figure out why this is, I have > > hardware to test both paths, so it should not be too difficult. > > I always found the USB dma alloc API a little weird, but we might have > to follow the scheme of the usb coherent wrappers there. I have used the current API here: https://git.kernel.org/pub/scm/linux/kernel/git/ribalda/linux.git/log/?h=uvc-noncontiguous And I think the result is very clean. Great work! I have tested it in X86 and in arm64, with similar performance as the previous patchset. Maybe you want to cherry pick that commit into your series I can also send the patch to the list for review if you prefer so. At least in 5.11 rc5 I the same dmadev worked in arm64 and x86. Best regards! -- Ricardo Ribalda