From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id BCE81C3B186 for ; Tue, 11 Feb 2020 09:19:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 9308A20842 for ; Tue, 11 Feb 2020 09:19:53 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=bgdev-pl.20150623.gappssmtp.com header.i=@bgdev-pl.20150623.gappssmtp.com header.b="IvdQYrmB" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727991AbgBKJTw (ORCPT ); Tue, 11 Feb 2020 04:19:52 -0500 Received: from mail-wr1-f68.google.com ([209.85.221.68]:35628 "EHLO mail-wr1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727815AbgBKJTu (ORCPT ); Tue, 11 Feb 2020 04:19:50 -0500 Received: by mail-wr1-f68.google.com with SMTP id w12so11321493wrt.2 for ; Tue, 11 Feb 2020 01:19:46 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=WZf3facF4s50NdwT8mwrLucdo4f673o12D7A+cRaFS4=; b=IvdQYrmBc9pJK1TFywFWWBon6C3UYYo+0C2PyXm3fgAbkHa/V/N7P0gAxHRuNqaaLL qjNb39/QlJoRBTimOXL0nwfosIjpXJSWhrjqu3qXLuXOztCwo3wffvlc3DQ87HYtEr8e M56GeY5qHdNA01Qk3ILJPnZERnGevP2YR6QBQsj8u0ivUT2khiri4+m8Dwgx7UZDs0F8 oKOFpjyMkoP2uV4SIclRWqUu91ieIvdWd9mSsV5mSFzGoraZLQjH6h5QgjdYVBZxQuEx drRnW1GZW7ifFN9C29KfMrCysXrQHbczd6gZyhWwuAhb5MGB0GkVSMVVY6DofoVjy1XM foZw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=WZf3facF4s50NdwT8mwrLucdo4f673o12D7A+cRaFS4=; b=sG9achtY+zyejjdvJmB27/+xxucFyScM0G4UzvOUFTXx7x2MrPYMVbggwtSIhY8QSG 2Mh/TArd+Qw3IRmHcjmleiPH3rcisa1zv1GVJv14mmUPJpnxjfOwFx32bo+KkdfuFLWQ XL7mGcHLZSin2oxXbMEkk2meGH1LCTrOyvp8EVEZzX5GoCxRjxx3Taah1CW2wqpFuL0e XVgyE1PmuVBXGFcUB9JXWvVucgKvbK90/ZmJc5YJ9628YOclbaLe0B1B+9WAJZxiLewZ zlEbpk5rKi63swQo/P2/3irCLtCC2P19p2g73tg+iAxVcttQ2Nh6tz7BDcrlLh5CLYVH zh/A== X-Gm-Message-State: APjAAAXBRjg5IfglA2adEn8OqQszgtQx59DXoNrjNH86JKJMDFsF7xDJ 4/V7PKlk0CbDl62d7tEJfQ+Gcw== X-Google-Smtp-Source: APXvYqwutVR+gFaAhKhVYXjzYXV7b9kfdsaXOaxB5Y1QN8HLZ3rZPL2yGSDwb3FjpQ6923RvxHXGFA== X-Received: by 2002:adf:f850:: with SMTP id d16mr7267259wrq.161.1581412786180; Tue, 11 Feb 2020 01:19:46 -0800 (PST) Received: from localhost.localdomain (lfbn-nic-1-65-232.w2-15.abo.wanadoo.fr. [2.15.156.232]) by smtp.gmail.com with ESMTPSA id y131sm2958622wmc.13.2020.02.11.01.19.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 11 Feb 2020 01:19:45 -0800 (PST) From: Bartosz Golaszewski To: Kent Gibson , Linus Walleij , Andy Shevchenko Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org, Bartosz Golaszewski , Stefani Seibold Subject: [RESEND PATCH v6 1/7] kfifo: provide noirqsave variants of spinlocked in and out helpers Date: Tue, 11 Feb 2020 10:19:31 +0100 Message-Id: <20200211091937.29558-2-brgl@bgdev.pl> X-Mailer: git-send-email 2.25.0 In-Reply-To: <20200211091937.29558-1-brgl@bgdev.pl> References: <20200211091937.29558-1-brgl@bgdev.pl> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Bartosz Golaszewski Provide variants of spinlocked kfifo_in() and kfifo_out() routines which don't disable interrupts. Signed-off-by: Bartosz Golaszewski Acked-by: Stefani Seibold --- include/linux/kfifo.h | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/include/linux/kfifo.h b/include/linux/kfifo.h index fc4b0b10210f..123c200ed7cb 100644 --- a/include/linux/kfifo.h +++ b/include/linux/kfifo.h @@ -517,6 +517,26 @@ __kfifo_uint_must_check_helper( \ __ret; \ }) +/** + * kfifo_in_spinlocked_noirqsave - put data into fifo using a spinlock for + * locking, don't disable interrupts + * @fifo: address of the fifo to be used + * @buf: the data to be added + * @n: number of elements to be added + * @lock: pointer to the spinlock to use for locking + * + * This is a variant of kfifo_in_spinlocked() but uses spin_lock/unlock() + * for locking and doesn't disable interrupts. + */ +#define kfifo_in_spinlocked_noirqsave(fifo, buf, n, lock) \ +({ \ + unsigned int __ret; \ + spin_lock(lock); \ + __ret = kfifo_in(fifo, buf, n); \ + spin_unlock(lock); \ + __ret; \ +}) + /* alias for kfifo_in_spinlocked, will be removed in a future release */ #define kfifo_in_locked(fifo, buf, n, lock) \ kfifo_in_spinlocked(fifo, buf, n, lock) @@ -569,6 +589,28 @@ __kfifo_uint_must_check_helper( \ }) \ ) +/** + * kfifo_out_spinlocked_noirqsave - get data from the fifo using a spinlock + * for locking, don't disable interrupts + * @fifo: address of the fifo to be used + * @buf: pointer to the storage buffer + * @n: max. number of elements to get + * @lock: pointer to the spinlock to use for locking + * + * This is a variant of kfifo_out_spinlocked() which uses spin_lock/unlock() + * for locking and doesn't disable interrupts. + */ +#define kfifo_out_spinlocked_noirqsave(fifo, buf, n, lock) \ +__kfifo_uint_must_check_helper( \ +({ \ + unsigned int __ret; \ + spin_lock(lock); \ + __ret = kfifo_out(fifo, buf, n); \ + spin_unlock(lock); \ + __ret; \ +}) \ +) + /* alias for kfifo_out_spinlocked, will be removed in a future release */ #define kfifo_out_locked(fifo, buf, n, lock) \ kfifo_out_spinlocked(fifo, buf, n, lock) -- 2.25.0