From patchwork Mon Nov 12 15:18:44 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10678799 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C8358139B for ; Mon, 12 Nov 2018 15:19:47 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B3AD229BDF for ; Mon, 12 Nov 2018 15:19:47 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A765929D0B; Mon, 12 Nov 2018 15:19:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 4800A29BDF for ; Mon, 12 Nov 2018 15:19:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=4mxxIJFm4Hxy3a4gFYbQ6Kpmqb8JFLEF7DQlqXNbzzM=; b=G8BlFbbg19VDR3 mlkzil/+6fuIUGNArvtyHhOzHg88kmjURmhxbsfpDXYsfdFcGvc/Pc2jhua5KOR/bfjtnBPscpnji C4+i3scdIZe9r2YW6wYSKsH3SgXaY1dFiiR5LN8xuPi2RpVCOmVj3J3DZp72pFlagm2j4eQaxAOch uk/WB/18vhkg310uIQXvK+11Xy/n3qiLW2dNrzmUtXHdVifM/mxjh0EHSmE1CLhM6H5gzSD6mS0iV RUzmS1kOo0ZWuaAVqwVSI8PvPKp7naZpqrX1o/cJho7QxObVP/YHRTch/GwTwA6aVCkfj2dNun8Ht qvTW8rPBvwfrva6s3CTg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMDzy-00063F-NX; Mon, 12 Nov 2018 15:19:34 +0000 Received: from mail-ed1-x541.google.com ([2a00:1450:4864:20::541]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gMDzZ-0005Zb-6l for linux-arm-kernel@lists.infradead.org; Mon, 12 Nov 2018 15:19:11 +0000 Received: by mail-ed1-x541.google.com with SMTP id c25-v6so7678118edt.8 for ; Mon, 12 Nov 2018 07:18:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=UzI7QItBboJycH/HpslvTFG94WVjeSBxpsz6zXZa7wE=; b=iBXgZ8CzGcK6Z4IAwmgQZF+n+el0Kchck8L0NZMQ8lQs0OVmOIR+Qx4xx+SJiNIRIP WMKHcWYojcDEqUkc99JYn+AIhwTNaNjwH9LBPIjjIb5UNmm+2li76cJOG3Mph7CDLAd7 71h5Zo1kOQ2dI/3TgvoeXIHIQBra5bmOB2GFbF1XzDCte9tLeWgBmf8GDvOHJcHNzza3 afGOYfmnx3qGODEnwzbsP8bpBjOOUIJeYhUptduoIpwMXor6n1C1mP50xdKirwUeZh68 +nDqXmKEj8Uoj05IFyitPe/WXPfd9kdsPdAvmdCAV/3JOMuYHzYVwcp0Tt6FCclIaf54 0SXw== 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=UzI7QItBboJycH/HpslvTFG94WVjeSBxpsz6zXZa7wE=; b=n4pW0WqU88tC+IoxKINRPfNJC9deorLcXi4OmOyBxVV5eXLeB2R1KzHGgsoJI2nknj lADazMUBiHI4QP0NLG9jgrV13os2MVkmtN2CBZ7NQJspV4SGCJUmOqIaWTlt2GrHqKrf 7IS6X0L8TfqmihYRjpKREHsU4YlARBtqBvvzThPgAGXoid7ia+UWjXK1yyFk+ljXzskZ JgWhf/pTqQAB93DEYbdyZuKwvpmH+6gnNXHcefdArbINsyMtJLGHceNrzqN003Pq26XV ZvwbLuWiEqv0GR4EyPJK5Glh0hO9DfBEMnQ6llP2JA83ZSDFydBAx3oCv5jzyZie2v0d SCQA== X-Gm-Message-State: AGRZ1gJWt1Dv+YgWcZ1BCJdi/UEinswXvXToMtCYmZ8ky8zgCb9g3pia URMOMaewSXWyINWscH9EdAM= X-Google-Smtp-Source: AJdET5dWj6hZvnuwkvzovvkxCw3BpZVHWPCUBW8bwGFsS5NoRr4JzGHmCMpW1mhOLLnhc98kleGtrg== X-Received: by 2002:a50:a985:: with SMTP id n5-v6mr13033559edc.120.1542035937258; Mon, 12 Nov 2018 07:18:57 -0800 (PST) Received: from localhost (pD9E511F8.dip0.t-ipconnect.de. [217.229.17.248]) by smtp.gmail.com with ESMTPSA id s9-v6sm2396809ejf.27.2018.11.12.07.18.56 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 12 Nov 2018 07:18:56 -0800 (PST) From: Thierry Reding To: Thierry Reding , Jassi Brar , Greg Kroah-Hartman Subject: [PATCH v2 01/10] mailbox: Support blocking transfers in atomic context Date: Mon, 12 Nov 2018 16:18:44 +0100 Message-Id: <20181112151853.29289-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181112151853.29289-1-thierry.reding@gmail.com> References: <20181112151853.29289-1-thierry.reding@gmail.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181112_071909_241861_18A9413A X-CRM114-Status: GOOD ( 15.91 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, Mika Liljeberg , Mikko Perttunen , Timo Alho , linux-serial@vger.kernel.org, Jiri Slaby , linux-tegra@vger.kernel.org, Pekka Pessi , Jon Hunter , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Thierry Reding The mailbox framework supports blocking transfers via completions for clients that can sleep. In order to support blocking transfers in cases where the transmission is not permitted to sleep, add a new ->flush() callback that controller drivers can implement to busy loop until the transmission has been completed. This will automatically be called when available and interrupts are disabled for clients that request blocking transfers. Signed-off-by: Thierry Reding --- drivers/mailbox/mailbox.c | 8 ++++++++ include/linux/mailbox_controller.h | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/drivers/mailbox/mailbox.c b/drivers/mailbox/mailbox.c index 674b35f402f5..0eaf21259874 100644 --- a/drivers/mailbox/mailbox.c +++ b/drivers/mailbox/mailbox.c @@ -267,6 +267,14 @@ int mbox_send_message(struct mbox_chan *chan, void *mssg) unsigned long wait; int ret; + if (irqs_disabled() && chan->mbox->ops->flush) { + ret = chan->mbox->ops->flush(chan, chan->cl->tx_tout); + if (ret < 0) + tx_tick(chan, ret); + + return ret; + } + if (!chan->cl->tx_tout) /* wait forever */ wait = msecs_to_jiffies(3600000); else diff --git a/include/linux/mailbox_controller.h b/include/linux/mailbox_controller.h index 74deadb42d76..2a07d93f781a 100644 --- a/include/linux/mailbox_controller.h +++ b/include/linux/mailbox_controller.h @@ -24,6 +24,9 @@ struct mbox_chan; * transmission of data is reported by the controller via * mbox_chan_txdone (if it has some TX ACK irq). It must not * sleep. + * @flush: Called when a client requests transmissions to be blocking but + * the context doesn't allow sleeping. Typically the controller + * will implement a busy loop waiting for the data to flush out. * @startup: Called when a client requests the chan. The controller * could ask clients for additional parameters of communication * to be provided via client's chan_data. This call may @@ -46,6 +49,7 @@ struct mbox_chan; */ struct mbox_chan_ops { int (*send_data)(struct mbox_chan *chan, void *data); + int (*flush)(struct mbox_chan *chan, unsigned long timeout); int (*startup)(struct mbox_chan *chan); void (*shutdown)(struct mbox_chan *chan); bool (*last_tx_done)(struct mbox_chan *chan);