Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp591469pxb; Wed, 27 Jan 2021 16:05:10 -0800 (PST) X-Google-Smtp-Source: ABdhPJwwaRPxj79O5izNIcWKwmbBWJlgT0oxZ68vyXnCJk9nffQUuC0km46t87co31s9mZI2Uu+D X-Received: by 2002:aa7:d288:: with SMTP id w8mr11231245edq.241.1611792309998; Wed, 27 Jan 2021 16:05:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1611792309; cv=none; d=google.com; s=arc-20160816; b=r7hXKNmwtR0X0PksOoEPtQmGMDS9Q/0Ud6E2m68cJIecyOXXnRkyLplKLpHimZhotD g4b2lEuKqwU7vq0iorj5fP/c/2GQiTqgytZk2THPEC0+uY53+HpBAVxyKwyvnU7ciYJC kHn7UbYVxH7f7/ReNjj1CPyHz+SIPv8DzqE9BE/myXaOueeQfjHEgIvb53y67kfZxJLL nNK2sD8OErMkXAMInfexCMqeQ5DaelVy7Kjz9ZnIOPGrPB5bEBdTlYN8F+MuGuU0h+Sa bkgmrR5l1uHTK6fVE/1cCn2UO8XS98i2CcT/sNkpwd3ipv4A1lnzv/ZEywhU1CvaOv1k IMNw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=R+2E/3r+DfdxTFayTD2QlMSl/FdBZ7ZI3WblTnFWyUY=; b=dv/r6mf3EVIvcuzOzfA94R9iiyk4TIeayakTRjZ7SgQUK1DLQ17i3Al7EW0gy16Oib YK7lzl7S+cMA45RynbzdBnAgRY0tTlMXTIwA+YG5fTMmf+1VOASQFy7rwyC6vixDFj7g UsANiIdeIslXuo52w0r+Cec+I/Pby0UpGbtndQTLnpUO2+n6DjUJQufZV1XOSwWZ90Wu iMtX9I8n1reU8VzB1OK8z6UeZyttoADP48z+hzmDQr1UdMgIkmkb6tAW6R49R0tt+GYd MvXufhDCpCD0F+9m/PyGpSXLNtW3QcMVSYp3YBJCYmjvKFQh0mQ8mzqBVJX0hPGFx0I8 yquQ== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l22si1751371edr.554.2021.01.27.16.04.46; Wed, 27 Jan 2021 16:05:09 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236962AbhA0QCp (ORCPT + 99 others); Wed, 27 Jan 2021 11:02:45 -0500 Received: from verein.lst.de ([213.95.11.211]:53502 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236827AbhA0P4x (ORCPT ); Wed, 27 Jan 2021 10:56:53 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id 5554C68AFE; Wed, 27 Jan 2021 16:56:08 +0100 (CET) Date: Wed, 27 Jan 2021 16:56:08 +0100 From: ". Christoph Hellwig" To: Ricardo Ribalda Cc: ". Christoph Hellwig" , 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 Subject: Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API Message-ID: <20210127155608.GA20272@lst.de> 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> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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.