From patchwork Fri Oct 26 11:16:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Thierry Reding X-Patchwork-Id: 10657239 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 DBD08109C for ; Fri, 26 Oct 2018 11:18:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C69372C1DC for ; Fri, 26 Oct 2018 11:18:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id B81272C216; Fri, 26 Oct 2018 11:18:04 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED,DKIM_VALID,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE 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 E8C2E2C1DC for ; Fri, 26 Oct 2018 11:18:03 +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=D+TGL3CrG/aEOb VF7II1FcBQAVkwKUGMurk6sKlys8/ECzuTtCWO8/oLyLcQ6cGvnSSc7qw0cA9Ld3tD/G37F6AxZ3P /jCFYQ0fTC/0ZdDw+jb+gZVdHcSKvqyJZovM43zAlhj0kODqS1cJkyajuW7j1JbBfsZO0aGx0hSOM NjF509+JDVhY4k78PyG36lmkmGWLZDLd5us/wfAsRdJoy+ThDgFN7E1y9rhQKoxC5IVduDeaOHJ2t SvKZ1A1hR38c+gZF3clLzrgh+/c5c3Ak8JwrJ8b5ndGvVgQodlaKNswoU/L0zI3uEPTv6wPVyoPGk PejdpbNmRI3K88innGew==; 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 1gG07d-0003xt-R6; Fri, 26 Oct 2018 11:17:45 +0000 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gG06p-0003eB-5i for linux-arm-kernel@lists.infradead.org; Fri, 26 Oct 2018 11:16:56 +0000 Received: by mail-wr1-x444.google.com with SMTP id i4-v6so908781wrr.13 for ; Fri, 26 Oct 2018 04:16:44 -0700 (PDT) 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=M5D30HprenHJK/ckhe7p0gHlRpkigXk2QIUfgYl0OD7y0Yljv0vqeSAB+jkuu6coMx zD1y2f3GjYPoBnidp1pr2g2etACqgr3rnhd8GwLIhUcVgmtWwT7imeDZHvuaUbb5V49Z UHyF3TiDqxtaSPSPYmpTA7VKdz7YgU7WyfG1FFuVF8FSBHi0PObynPCiwpyhWOg/wWY7 EgU8xV5/ZYlY2PWO58RD7wBa1nbJRGbAWujtn0i6iARr18WR6ddPppzejkoKZQHroeqt jJeac8iTZdOduzi0Z0n5ZfhJzv82RozYt/E+FH0vZ5tig98m+bkMWF7gEe18OaE4ikod 69DQ== 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=frrRrvjqQfPMgLyjVr1Slb8hul0R/cKQRqZf6BrAJ0xFtLYrlpx/WVK2YhefDFYIQJ VhMxWBxaE5/n2SBnzBfRVcP+lGEJATUhdJ6zxOEY+dRVQPAJyg6kZZabVxWhz3grH/cJ RtW9yiwUnAjw/o3PJEp8oS+gmO6H10/vvTW3e2d3m2i/bp+xtPGREy/cRAy7U8YMcWTw dbfqa4N1q7ft250aT/wGFKf6NMnZtosLk2XFDqPkUlVgOp/0sI+tVtDnVQ7pqnsdE10n zUFxogZ7yqXxuj85p4opZ/aUgsDihqmJPV45ANadkcRL2KEPmu/0819fwcC5xompfvnY 6Rsg== X-Gm-Message-State: AGRZ1gLAOAh+82uQFto1xhiZEP+9ht2AUW47LtxvkAeVycM1N1R+4Rae ApUHjKnAYhQgIfTJuONkHxs= X-Google-Smtp-Source: AJdET5cdQ/3a1bsJOFPGEEIX2i/kqhKCshjOa85p5giWBZN1TxTH9euVtLC4lDAq4MzoNmSnwpEakw== X-Received: by 2002:adf:fa92:: with SMTP id h18-v6mr5369795wrr.74.1540552603274; Fri, 26 Oct 2018 04:16:43 -0700 (PDT) Received: from localhost (pD9E511F8.dip0.t-ipconnect.de. [217.229.17.248]) by smtp.gmail.com with ESMTPSA id t66-v6sm3224263wmt.5.2018.10.26.04.16.42 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 26 Oct 2018 04:16:42 -0700 (PDT) From: Thierry Reding To: Thierry Reding , Jassi Brar , Greg Kroah-Hartman Subject: [PATCH 1/9] mailbox: Support blocking transfers in atomic context Date: Fri, 26 Oct 2018 13:16:30 +0200 Message-Id: <20181026111638.10759-2-thierry.reding@gmail.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20181026111638.10759-1-thierry.reding@gmail.com> References: <20181026111638.10759-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-20181026_041655_281201_EBD341F4 X-CRM114-Status: GOOD ( 15.72 ) 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, linux-kernel@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);