Received: by 2002:a05:6a10:f347:0:0:0:0 with SMTP id d7csp3423152pxu; Mon, 30 Nov 2020 02:52:47 -0800 (PST) X-Google-Smtp-Source: ABdhPJz/oTb81CazZg6G7aQ3xcdE/K5LZUDlacPatXSD2nG0HmSmi40/MMDs3Gw4q9WPOfXJ12m8 X-Received: by 2002:a17:906:c345:: with SMTP id ci5mr12724445ejb.492.1606733567544; Mon, 30 Nov 2020 02:52:47 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1606733567; cv=none; d=google.com; s=arc-20160816; b=EBys2c7vHGdjKIVKVI2n37GdifJOaT72WOnQBuoJPeLi18YAYiGWRcFfNGS/XWVB3u FB8tSKt/ltVLtfABS5t+HddvOUfricoA0NuCYHxjtnPWvo/CM9pZoyjnPmTaZxQcgURv NRxS6Tfz0hik1HcvWRn+q4SKSqE6IhhuZibV6KcGrb0Yypv6NlVTgZZHdhEbtEXX04td Ox6C148Mir4fmOrCETYjxmlaVXm6licWt+AWvnnZ0AQ1NhnVVkWH+0tMWaBQMl0La0Rc 5SNud0Oe7LrOL1hv/OH/IOOFfkLANn3g2WyiOLuXUH5sVuqfbZTRFb7K5cfKmmyjIpuE u72w== 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=FrBQ+cllYh0Y6esR/SPkKcDu8fDsRwcNF9P9vUYZvL4=; b=nNArBZe6YOLFwdETvvHqv9rvRe4s+uUfDQ4r0jZMxKAiE02Jab0JqxjUCkx2upaYHb 9DuDsb63XphY4DM1xCXty5X8exygOyFxGm7JQKBG8sDty5kfXlGL9U9YuzpwG72Bw+mG Tgz9o9RZQtl+vpHwVfuLfpM+ngDjSObyi9ihXx2OxGzVUnFXD8iRKDZuEmsUhIKIniRw J1+hz8NCANN58ryDOEAlhsdki4JUhS7/2K+UJvRZWVDOmdfgiJB+lxVK/bsxHgpqRpMv i0i/59dIr+wk+hZVVrpV98PS7/2yazmY8hVKqZnpl4iUFF4PmvYOF3dTodumLPOrDv1J g4tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=EqEeBGdI; 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 w14si10040506ejz.314.2020.11.30.02.52.25; Mon, 30 Nov 2020 02:52: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; dkim=pass header.i=@chromium.org header.s=google header.b=EqEeBGdI; 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 S1725972AbgK3KuD (ORCPT + 99 others); Mon, 30 Nov 2020 05:50:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41388 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726828AbgK3KuC (ORCPT ); Mon, 30 Nov 2020 05:50:02 -0500 Received: from mail-il1-x143.google.com (mail-il1-x143.google.com [IPv6:2607:f8b0:4864:20::143]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 70966C0613D2 for ; Mon, 30 Nov 2020 02:49:22 -0800 (PST) Received: by mail-il1-x143.google.com with SMTP id g1so10789331ilk.7 for ; Mon, 30 Nov 2020 02:49:22 -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=FrBQ+cllYh0Y6esR/SPkKcDu8fDsRwcNF9P9vUYZvL4=; b=EqEeBGdID896KqQP2wGl3MacDZiftoQYvHOoa+q0ty3hiMysQXNvD+Cbzd5XWyH6oC /R/jipmJirrS7xxuCq09QfhPWJ6BcZs6J5DXml/OSDTep21CZvCNfFppev46/gu0R/Dp L8taqeCxff7s2jiuUfS1zwdg22lepLaEZGuQ0= 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=FrBQ+cllYh0Y6esR/SPkKcDu8fDsRwcNF9P9vUYZvL4=; b=XxinWuqLrTGcr5iUaKDJrvVDkrj5KpI0g9/lGuVdAtvzXWfU1she21Zg7YwScsjyk9 rWb9a+nkM6PsKrAr2lBo8QY1ysCYSgKcAuMTdUXMbQJEMcNB4nivkjluDXgITq6v5YDH jsfUEsYBumD9ZO6X2H6xCbmyCnuX5Cvgsx+EQvYuyvqcSP7tBX+mIk+em8WzORGLUsm2 4j4oPCageiHLxhpSFIlQl/7a3+mGCzM1NAczUxjYFbbYI4yrI/48qcaYXoBC3uZwm7DN CZbJGv4nWfKILXg/rw0OtVXa6TDY3dTi1cuooDpXMYO25NVqwCF3Vn983P4Hu6ix13Fk 4W6Q== X-Gm-Message-State: AOAM532j9Co02zoZ2YX9nU6HKnA8xMWEIQ0J49XKRXjZlYWPblZKRd5m 7XJ+AeGWSH6uv5xSSX8hcb99zXUMcZQ8Bw== X-Received: by 2002:a92:dc07:: with SMTP id t7mr17148700iln.189.1606733361596; Mon, 30 Nov 2020 02:49:21 -0800 (PST) Received: from mail-io1-f46.google.com (mail-io1-f46.google.com. [209.85.166.46]) by smtp.gmail.com with ESMTPSA id c14sm2762729ili.15.2020.11.30.02.49.20 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 30 Nov 2020 02:49:20 -0800 (PST) Received: by mail-io1-f46.google.com with SMTP id z5so11222249iob.11 for ; Mon, 30 Nov 2020 02:49:20 -0800 (PST) X-Received: by 2002:a02:c042:: with SMTP id u2mr12243455jam.32.1606733360204; Mon, 30 Nov 2020 02:49:20 -0800 (PST) MIME-Version: 1.0 References: <20201125221917.150463-1-ribalda@chromium.org> <20201130083410.GD32234@lst.de> In-Reply-To: <20201130083410.GD32234@lst.de> From: Ricardo Ribalda Date: Mon, 30 Nov 2020 11:49:09 +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: Marek Szyprowski , Robin Murphy , Mauro Carvalho Chehab , IOMMU DRIVERS , Joerg Roedel , Linux Doc Mailing List , Linux Kernel Mailing List , Linux Media Mailing List , Tomasz Figa , Sergey Senozhatsky Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Christoph On Mon, Nov 30, 2020 at 9:34 AM Christoph Hellwig wrote: > > > +#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. Probably Sergey has best opinion of this than mine. I only had to look into one driver, he has been working with the vb2, which uses the API much more. -- Ricardo Ribalda