Received: by 10.223.176.5 with SMTP id f5csp428830wra; Thu, 1 Feb 2018 23:44:29 -0800 (PST) X-Google-Smtp-Source: AH8x226MCoALvd7uQQ8dKDMt1ncmFFEJu3+6lSshqIQmdJx2XMBVqyAl1u/zVvigYYk1KF7+urbK X-Received: by 10.98.138.21 with SMTP id y21mr39574130pfd.147.1517557469462; Thu, 01 Feb 2018 23:44:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1517557469; cv=none; d=google.com; s=arc-20160816; b=fQfShYtBKbfXZX/3lLJVVvIx0qy4gtCvPyWjEbVAs5dXvHQqlrKQrMbfecGMpzDMFE sWDhFWH9efOOHIQIQ7+s4fBkSmC2jZZdUE8Uph7whlmhjZvslIr4LpJ/rogFp8OqYLFM cY2wO3Nkp9boHsytmC2RdfE1oXF5hkfFXqQbrrM2zTCmNF3WmWkYMmag8iQ/WUqi+Ity FDnVnVMtmZCEY/ETsFTgZg/35/UMKgynZCX1zB8155a3zPxrEUQzZAgXrI7kN12ZO0wJ 33oO7Kwq9FtDStiOgvVJHHinxVmtn653efV5l4h+GRQPAlm+1QNy2zanGUePRWXgOT5e XYIg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=YhOFGcmC5kzPDkS7gj9sZafS/5trdhD/wtkBeS9m2vU=; b=Hqn2fPBNVNOF/SO5LulJPO20hk2oFMnVweI5sW7JE1n0gaSi1JgGcEwXITrCY4/doJ ZKdgloixlTeTw4/eeKShqgPj5uzMIl9AxLNS9dQCsVLGbqOq2QUXZsZ5NuSaqw5Oqh1R ec+7CYM0zSp/aQj98LfxGMQH3NZUNnuicVk4OPWUOqic71l7IPq5StZU8VQsYECd4sLI pXIryC7QRy1sRP9cQF9fxVcsFWtY9KUjIqOWxzAGxQDIZ1IWz00ogy5QUIqhEpAmNaKA RiiFW/Z1LdqHCOEC3Bj8BhPjuD3hGKzIsS+2gW510/3DNYpqQxMfGg3Ge13BdXAJsxJv wCdg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MqZOcUUQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id r3-v6si1296335plb.232.2018.02.01.23.44.13; Thu, 01 Feb 2018 23:44:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=MqZOcUUQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S1751544AbeBBHmQ (ORCPT + 99 others); Fri, 2 Feb 2018 02:42:16 -0500 Received: from mail-ua0-f194.google.com ([209.85.217.194]:33926 "EHLO mail-ua0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750805AbeBBHmK (ORCPT ); Fri, 2 Feb 2018 02:42:10 -0500 Received: by mail-ua0-f194.google.com with SMTP id g5so1833797uac.1 for ; Thu, 01 Feb 2018 23:42:09 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=YhOFGcmC5kzPDkS7gj9sZafS/5trdhD/wtkBeS9m2vU=; b=MqZOcUUQAm73EMQStnp/1pXmlDpUszpISuMBgqhaWQfZc9sl9wp+fcRSq1Cx3wZjrW T6X8lpZvN8t4ukAqcGkQEeHhuB3qsdTIwseokOwHvrFvLw44HsPFB9nF2gY/cMr4uq5G hmOPUI6ZLS+ydEacM74drHMNh0o+hQ2mRJhsE= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=YhOFGcmC5kzPDkS7gj9sZafS/5trdhD/wtkBeS9m2vU=; b=re8Fr1ai7ZyP+QSPhsqW2vhCnss3Hfx7+/ysl9jHxymJlDFixo1104+CWrqYHVPskM PqFk3A4ZM96DnnJ1BWv72iEO4mgWTHFcOAWw/adQiH1ArAGoJC/ULSkjjJdsMWChOMkf kthFZSFSjCsczDEQS0fdxHybB2GM84EaaR5khkFF7lnLOMJCPL4yGrHkDvSjfuzl0DJx Yso/QoHjQMDCdhqW3CC0lFNzXohV5VotZbwvtVaRaeg5dKne11xfFaIdmn/GAM4JR7X3 d9Ys0347VeUtj5xjDespJhe1AIsYE+gyKE8eOljAxegG9uwZJe51NUHphINkWeBEQGDV 993Q== X-Gm-Message-State: AKwxytcvxcgCMwB7QB/xMRAghZG3IFAhv2BbkcASyjlXk+ID88vuMqKH VsZxhC0M8aJb7m00uLe2PcHyzT3Spc8= X-Received: by 10.176.70.78 with SMTP id z14mr31511222uab.178.1517557329014; Thu, 01 Feb 2018 23:42:09 -0800 (PST) Received: from mail-ua0-f181.google.com (mail-ua0-f181.google.com. [209.85.217.181]) by smtp.gmail.com with ESMTPSA id f9sm687782uad.21.2018.02.01.23.42.06 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Feb 2018 23:42:06 -0800 (PST) Received: by mail-ua0-f181.google.com with SMTP id j23so13595029uak.13 for ; Thu, 01 Feb 2018 23:42:06 -0800 (PST) X-Received: by 10.159.48.195 with SMTP id k3mr32222369uab.4.1517557326111; Thu, 01 Feb 2018 23:42:06 -0800 (PST) MIME-Version: 1.0 Received: by 10.159.45.142 with HTTP; Thu, 1 Feb 2018 23:41:45 -0800 (PST) In-Reply-To: <20180202073316.ovee5fbe45npksnt@paasikivi.fi.intel.com> References: <20171215075625.27028-1-acourbot@chromium.org> <20171215075625.27028-2-acourbot@chromium.org> <20180126083936.5qxacbdprm6j7pcc@valkosipuli.retiisi.org.uk> <20180202073316.ovee5fbe45npksnt@paasikivi.fi.intel.com> From: Tomasz Figa Date: Fri, 2 Feb 2018 16:41:45 +0900 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [RFC PATCH 1/9] media: add request API core and UAPI To: Sakari Ailus Cc: Alexandre Courbot , Sakari Ailus , Mauro Carvalho Chehab , Hans Verkuil , Laurent Pinchart , Pawel Osciak , Marek Szyprowski , Gustavo Padovan , Linux Media Mailing List , linux-kernel@vger.kernel.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Feb 2, 2018 at 4:33 PM, Sakari Ailus wrote: >> >> +/** >> >> + * struct media_request_queue - queue of requests >> >> + * >> >> + * @mdev: media_device that manages this queue >> >> + * @ops: implementation of the queue >> >> + * @mutex: protects requests, active_request, req_id, and all members of >> >> + * struct media_request >> >> + * @active_request: request being currently run by this queue >> >> + * @requests: list of requests (not in any particular order) that this >> >> + * queue owns. >> >> + * @req_id: counter used to identify requests for debugging purposes >> >> + */ >> >> +struct media_request_queue { >> >> + struct media_device *mdev; >> >> + const struct media_request_queue_ops *ops; >> >> + >> >> + struct mutex mutex; >> > >> > Any particular reason for using a mutex? The request queue lock will need >> > to be acquired from interrupts, too, so this should be changed to a >> > spinlock. >> >> Will it be acquired from interrupts? In any case it should be possible >> to change this to a spinlock. > > Using mutexes will effectively make this impossible, and I don't think we > can safely say there's not going to be a need for that. So spinlocks, > please. > IMHO whether a mutex or spinlock is the right thing depends on what kind of critical section it is used for. If it only protects data (and according to the comment, this one seems to do so), spinlock might actually have better properties, e.g. not introducing the need to reschedule, if another CPU is accessing the data at the moment. It might also depend on how heavy the data accesses are, though. We shouldn't need to spin for too long time. Best regards, Tomasz