Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp2394367rwb; Fri, 16 Dec 2022 01:10:52 -0800 (PST) X-Google-Smtp-Source: AA0mqf6Of8TojU/r4GK5dcq5w0jjTioQJDSrAVJBVQpD6Zn20kU5D7zewzWfngxwFyjt73AA9Gv2 X-Received: by 2002:a05:6402:4511:b0:461:e5d1:73c5 with SMTP id ez17-20020a056402451100b00461e5d173c5mr25454665edb.32.1671181852329; Fri, 16 Dec 2022 01:10:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671181852; cv=none; d=google.com; s=arc-20160816; b=x0iukAMtrovKJA8cjfax8EhV1HnbnnuGLzO9XcQlGaJKLfpMqjV+RTG7yS4GtVCrZD uyn+hM7LP+gBZE2Gwj5uqfeKuwY+cZVs+7goerCZ5PybhE/3aoGnIXCFoRLvy8+/4XFy bimBWpmGELguagzwOUn++pwfPexsq6Pg6b6xruXP+qGmNOYcRSLifyNyPMv3yHl8bW16 AePPmOZ7aCNAfoqbwzgon0Cqv6mEG9itGtEgL7E5i0nA2fOqauie83gD9/BOSXuALMa8 g6DDVi3EEKdXwb/EUbRV+7Y2UuE7VF1GdcpBVUoXbtzOPxoSNkWYZsUEWtdSwmEtw7+A 2HBQ== 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=KIfEz81U3HVJ4JhGoBJFjs00sIawE7R6JvvebcBdLcA=; b=vLG3JK+Yn27Obe8HZkSMtj+K1R7dokS2kdpCVaMqSM6gGm+9355CKxsVeLJMakBU7P rWBG4LSRsyThFucuGdpOCdl7ZNaKR9+OfiByjqARUERG/21kf1IOGZLn9bR/k5CsLGxc sl1/sxW7qoRU6kUbe1gLXlKKpqWa3pAugTQfp5k8lAoN1nQeNWGyU6aOambCkw0UnZbQ FfFzRwp+xbn/XuNPAEFtitmKJPJaxxz4wtRyVHN2jVaMns7CdYR0XJjbj5qHTOixuQR1 YMNXHQXF7eunGVG04wMk5FvF227qM1ZQS0CHFrO6mIR5rBertxECaFAIlY1JMG13UGF9 kAzg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=b3xVmZlR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id m4-20020a056402430400b0045d5b83114esi2433004edc.112.2022.12.16.01.10.35; Fri, 16 Dec 2022 01:10:52 -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; dkim=pass header.i=@chromium.org header.s=google header.b=b3xVmZlR; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229583AbiLPIz3 (ORCPT + 68 others); Fri, 16 Dec 2022 03:55:29 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48226 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229955AbiLPIz0 (ORCPT ); Fri, 16 Dec 2022 03:55:26 -0500 Received: from mail-pl1-x630.google.com (mail-pl1-x630.google.com [IPv6:2607:f8b0:4864:20::630]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8AEEF37205 for ; Fri, 16 Dec 2022 00:55:25 -0800 (PST) Received: by mail-pl1-x630.google.com with SMTP id x2so1630680plb.13 for ; Fri, 16 Dec 2022 00:55:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:from:to:cc:subject:date:message-id:reply-to; bh=KIfEz81U3HVJ4JhGoBJFjs00sIawE7R6JvvebcBdLcA=; b=b3xVmZlRg/35qPV3zrDnmMxZkqYqnSqQ92eIj7WqDRIoee+cdDAs4Ul/3HBALrIqqK ubUyl/4ZMRICi20VLa/qyvnIhVeNsUPHmnSesSDprBIlo+BBr5vWDWITYMiGY9Au1vCQ HSSzbuGh0EU0goHPY7eXRo96OHIB0DXuXTeNE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:subject:message-id:date:from:in-reply-to:references :mime-version:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=KIfEz81U3HVJ4JhGoBJFjs00sIawE7R6JvvebcBdLcA=; b=eHdYqeG4r5jEg5Vt7GMTbD/+tG03noZsKY9YmRXsT36dG3qqZ4iMKYq13tcEz4vQCc hw3ESJJtMIDXfoPF3I0h3Y7QyHyVj/CqhK8AnNbzu/LNIGOkNGq2jSqn3WHHtfGKLkF+ JHOr7UEBKqA0Amf6v9QT++r5N9a6FNODyuhoexZ51CryrAHCxQr3kcy4hHmhVn0qlw1T DS1B1ZCmeR9ffeKEulaBgVO259kr58ARrrVJZstRqglZbzmziBGSw+GgSmrisPBpCns0 F/cqH0EDrcDhrN7yyMAsNAMtpbVXtziz02jUiiW7BTMFFjNCUBOZ9YHGC1hLIRqO4P2L GNXg== X-Gm-Message-State: ANoB5plW4ZI/xBoJwFoqB0BaeCEzS0F/HuHy6zRcp0uafpC9N7gBpAy9 wibYRd3dSjAodbPDGy7Gd+Lum+o6yBm2k2XbcIA= X-Received: by 2002:a17:903:2481:b0:189:b0ff:e316 with SMTP id p1-20020a170903248100b00189b0ffe316mr29049793plw.38.1671180924773; Fri, 16 Dec 2022 00:55:24 -0800 (PST) Received: from mail-pl1-f169.google.com (mail-pl1-f169.google.com. [209.85.214.169]) by smtp.gmail.com with ESMTPSA id cp12-20020a170902e78c00b00189502c8c8bsm1050871plb.87.2022.12.16.00.55.21 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 16 Dec 2022 00:55:22 -0800 (PST) Received: by mail-pl1-f169.google.com with SMTP id w23so1635163ply.12 for ; Fri, 16 Dec 2022 00:55:21 -0800 (PST) X-Received: by 2002:a17:90b:1489:b0:219:8132:70db with SMTP id js9-20020a17090b148900b00219813270dbmr697624pjb.183.1671180920433; Fri, 16 Dec 2022 00:55:20 -0800 (PST) MIME-Version: 1.0 References: <20221214-uvc-status-alloc-v3-0-9a67616cc549@chromium.org> In-Reply-To: From: Ricardo Ribalda Date: Fri, 16 Dec 2022 09:55:09 +0100 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH v3 0/2] media: uvcvideo: Code cleanup for dev->status To: Alan Stern 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 Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 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? > 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