Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3351295pxu; Mon, 30 Nov 2020 00:36:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJzKUW2dxk6Yf22LQea+2x6BGFnQltj7iywYIGxwFBzLBTI+GOQ0ZeAu9TG2SSeQnjZIjmAm X-Received: by 2002:a05:6402:149a:: with SMTP id e26mr21005703edv.232.1606725407325; Mon, 30 Nov 2020 00:36:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606725407; cv=none; d=google.com; s=arc-20160816; b=Fp48KpG2QCKi70oHMfigtABtj7kMBmxak57Cr2gvtkbblZicJdnm193nkkP0teiG0z 2S8JooYuS13f671v05LyqWi8j4mSmdVHrlP7Hnztk3bgr5caRY5UAqUr3JYVzA8znzGp JR7V0XG9kDsEMgAwFVDcg2dYvQvBX3096cuhhrqjQXb9utyer1pQ7C+ngpbzo1J5T1aD C8tyMzH4cbkAeXsvabMDIuPgFGPy0CJXGpTm0IorUlRZBN14XydsNc7p37yCgHtJqG06 Ol+Dk2bvl+tpq9ZEJxPxbKE4w+ioH6IEVbUXfolyvD9/sZLHoMIpn/vLaORZLCn51MMN S/bw== 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=/eU7sO8bmB2CZhoO7Lfz5d3+5K5s6TVjr9h9pACYokk=; b=v07vKtjQKEOOfzVlXnFDw70P6EnN6H0v8+EpDcNvgagKftmYxeRcnm1JXeNkzAfWvS taHn6Lx5YKF/RXE5QBAV554qn5+pIeMAE2ubcgTyGk53rkdrcaLC7oQN/zJ8eMtP5xBb PpbX0qwJTFk3KSaR5/vISaC2p2syFDa2WOOILftE95gfXQpM1nQF4W2HbeZWtLigBqaO py8NJKckuvtGnXYmHHPQDHUN9SB+UvSeBsMXoPx6F4TCOfIa8Q/+/4t1fPhSOdF3sNBC Nr+ugpYtaTbMpiMUD722A3MVfhpxb26Y7giidEPUQhxo8K8z1SrmW0ZJSH4zTMeeaN17 0idw== 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 6si11258664edv.501.2020.11.30.00.36.24; Mon, 30 Nov 2020 00:36:47 -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 S1726754AbgK3Iey (ORCPT + 99 others); Mon, 30 Nov 2020 03:34:54 -0500 Received: from verein.lst.de ([213.95.11.211]:43398 "EHLO verein.lst.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726045AbgK3Iey (ORCPT ); Mon, 30 Nov 2020 03:34:54 -0500 Received: by verein.lst.de (Postfix, from userid 2407) id 8685868AFE; Mon, 30 Nov 2020 09:34:10 +0100 (CET) Date: Mon, 30 Nov 2020 09:34:10 +0100 From: Christoph Hellwig To: Ricardo Ribalda Cc: Marek Szyprowski , Robin Murphy , Christoph Hellwig , Mauro Carvalho Chehab , IOMMU DRIVERS , Joerg Roedel , Linux Doc Mailing List , Linux Kernel Mailing List , Linux Media Mailing List , Tomasz Figa , Sergey Senozhatsky Subject: Re: [PATCH v3 5/6] media: uvcvideo: Use dma_alloc_noncontiguos API Message-ID: <20201130083410.GD32234@lst.de> References: <20201125221917.150463-1-ribalda@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201125221917.150463-1-ribalda@chromium.org> User-Agent: Mutt/1.5.17 (2007-11-01) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > +#ifndef CONFIG_DMA_NONCOHERENT I think you need to drop this ifdef. This code should work just fine on noncoherent mips and sh platforms. > + uvc_urb->pages = dma_alloc_noncontiguous(dma_dev, stream->urb_size, > + &uvc_urb->dma, > + gfp_flags | __GFP_NOWARN, 0); > + if (!uvc_urb->pages) > + return false; > + > + uvc_urb->buffer = vmap(uvc_urb->pages, > + PAGE_ALIGN(stream->urb_size) >> PAGE_SHIFT, > + VM_DMA_COHERENT, PAGE_KERNEL); > + if (!uvc_urb->buffer) { > + dma_free_noncontiguous(dma_dev, stream->urb_size, > + uvc_urb->pages, uvc_urb->dma); > + return false; > + } > + > + if (sg_alloc_table_from_pages(&uvc_urb->sgt, uvc_urb->pages, > + PAGE_ALIGN(stream->urb_size) >> PAGE_SHIFT, 0, > + stream->urb_size, GFP_KERNEL)) { > + vunmap(uvc_urb->buffer); > + dma_free_noncontiguous(dma_dev, stream->urb_size, > + uvc_urb->pages, uvc_urb->dma); > + return false; > + } > + > + return true; > +} I wonder if we should lift this into a helper. On the one hand I had proliferating struct scatterlist usage, on the other hand it is all over the media and drm code anyway, and duplicating this doesn't help anyone. Possibly including the fallback to the coherent allocating.