Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2975850rwb; Fri, 16 Dec 2022 08:38:57 -0800 (PST) X-Google-Smtp-Source: AA0mqf5ih09lkcg3omzze7C3R/hTgIr+DLVOOLlulaRGs5evaCQ23idmYyZeK419ur7Z8+Vdj181 X-Received: by 2002:a17:90b:300b:b0:21a:a0e:4a8b with SMTP id hg11-20020a17090b300b00b0021a0a0e4a8bmr33192052pjb.2.1671208737435; Fri, 16 Dec 2022 08:38:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671208737; cv=none; d=google.com; s=arc-20160816; b=wT2O3o07U6Gt2Ku3tbDni1szNb/xsNjeQIF7RFkB7c2VupCcNf6LRT/pBeD68N/V8P zSEL6s9hCdhSb5ARuWBT4XcCSpyTNa8ZrA9ChlUOcZ6PLsabWUJMxFKhYoSF6hxGaK0T CGZZa4fHhkjLdeSCcGMTEsyvr4v11MM8WZgtJnEQ6eCrQYjck5/7E6JfzKZoS3nf3UVO tkI3ng00DmlL8zrMX9Vsj7DDRL95QNuyDdZHuFZJGDFyy2vnNo9WnjM3IfuNMeuKZbYR 3X7R4O4qRUXXoFNlfLirWQJAJZ+0sbrG9OXprcboDyyeVkpPZGof5in0+PojgHad/4a+ oC+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=9teFekfvYnVeofKmWyq4f5Ln5pjd12M7Sq1CtUtkfQo=; b=0C4eSqJSyRLklRVcZVxqXLmaueBajE9uUsXN2kz1fTPZ3VJ8ePjmOa0p24rJF6116y Mh2pCmGXsO98HGeQxivNuAMX+KKDXCqxCjplqI4DmKHArw7mDoDMOqR34/TeFFd4fBVJ eeGjg3maOUp0EPOpF3RhT34POXwd/SMs8Qs7ChojKvxSCvVT7wIu0Os4nJdEg1RRNWA4 QG46TnuPz+lDSWIYBqd1A+Sug3N96X4b+7yEAKezEG07YrF9i+2GJThJ8QPXAAuahwaC 0GUrLAKOouT1A5X4CA43WtK5VcBKbupSwAOYNQ8nZToDgFzhM0aJgVt3WmxICpnDVIYB uCVQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id mq7-20020a17090b380700b001ed40b70436si3186489pjb.155.2022.12.16.08.38.48; Fri, 16 Dec 2022 08:38:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230309AbiLPPpX (ORCPT + 68 others); Fri, 16 Dec 2022 10:45:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54484 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbiLPPpV (ORCPT ); Fri, 16 Dec 2022 10:45:21 -0500 Received: from netrider.rowland.org (netrider.rowland.org [192.131.102.5]) by lindbergh.monkeyblade.net (Postfix) with SMTP id 9BFCB50D6B for ; Fri, 16 Dec 2022 07:45:20 -0800 (PST) Received: (qmail 997666 invoked by uid 1000); 16 Dec 2022 10:45:19 -0500 Date: Fri, 16 Dec 2022 10:45:19 -0500 From: Alan Stern To: Ricardo Ribalda Cc: Max Staudt , Jonathan Cameron , Sergey Senozhatsky , Ming Lei , Mauro Carvalho Chehab , Laurent Pinchart , Yunke Cao , Christoph Hellwig , linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org, linux-media@vger.kernel.org Subject: Re: [PATCH v3 0/2] media: uvcvideo: Code cleanup for dev->status Message-ID: References: <20221214-uvc-status-alloc-v3-0-9a67616cc549@chromium.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,SPF_HELO_PASS,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Dec 16, 2022 at 09:55:09AM +0100, Ricardo Ribalda wrote: > Hi Alan > > On Thu, 15 Dec 2022 at 16:34, Alan Stern wrote: > > > > On Thu, Dec 15, 2022 at 11:57:17AM +0100, Ricardo Ribalda wrote: > > > There is no need to make a kzalloc just for 16 bytes. Let's embed the data > > > into the main data structure. > > > > > > Now that we are at it, lets remove all the castings and open coding of > > > offsets for it. > > > > > > [Christoph, do you think dma wise we are violating any non written rules? :) thanks] > > > > There _is_ a rule, and it is not exactly unwritten. The kerneldoc for > > the transfer_buffer member of struct urb says: > > > > This buffer must be suitable for DMA; allocate it with > > kmalloc() or equivalent. > > > > Which in general means that the buffer must not be part of a larger > > structure -- not unless the driver can guarantee that the structure will > > _never_ be accessed while a USB transfer to/from the buffer is taking > > place. > > > > Thanks a lot for the clarification. I was mainly looking at the kerneldoc from: > https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/include/linux/usb.h#n1687 > > and I could not see any reference to the DMA requirements. > > Mind if I send a patch to add a reference there? Not at all. But if you change the documentation for usb_fill_int_urb() then you should also change it for usb_fill_control_urb() and usb_fill_bulk_urb(). Alan Stern > > There are examples all over the USB subsystem where buffers as small as > > one or two bytes get kmalloc'ed in order to obey this rule. 16 bytes is > > certainly big enough that you shouldn't worry about it being allocated > > separately. > > > Yep, we should keep it malloced. Thanks a lot for looking into this :) > > > > Alan Stern > > > > -- > Ricardo Ribalda