Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp160904lqj; Wed, 10 Apr 2024 07:06:50 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCW+LYW6uIC2VjBOk/KTfoBo+8hLYOQCZgvSDNWa7rdwWlJxHIc5Nxp905hM20eOFo0Zy6pYY7NsuiX+nnVMZ6DuWI74U75vEjU0c5Mumg== X-Google-Smtp-Source: AGHT+IEBmbjyVmJ4NqGowluyWWkB6inJx+Nxl80polBqWdYZ778Tg1SOmTAMPvNsZAT56jtCQiP+ X-Received: by 2002:a05:6a20:da9f:b0:1a7:74e4:efa5 with SMTP id iy31-20020a056a20da9f00b001a774e4efa5mr3390248pzb.2.1712758010612; Wed, 10 Apr 2024 07:06:50 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712758010; cv=pass; d=google.com; s=arc-20160816; b=pU0bInoKQMTwMprxRXwH4kgAeNyTAfkLR4VYdQCM3T/VSN5jdER5qPhFx4fb65E4X4 EZsI53pQZFOJKA27I0sjg2GOVo/7NIkewTzPgLosXjZk6O9M1XSYghE+PxFJTl2pOLB8 sJxKW8KeK+Q3Z2rw9ovA75nT/MWff1+jJkCCSqKkRiMC1SG2eZO4UZdt/zNlKgcMX44p mZnVNIzgbzFBQCatc5Pyzjg3KUR8fbgl7EsJneqvIZmYZ2x93ekTJeuZkuwnpBlnxnzn nVShfsKwqxZzHVN3R2Gg5SgNPJbWqh+ZZP2bqs5NHAAEE00+XB7n7gtxZFf/QXlD56Yw 4Jjw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=BSjhEIQgB4xQ5LpqF3Ho5CnJ8F2Hjtf+UQHpF8YH8Vg=; fh=li+nOTWR+R+c2QHViCtM9aHEBgqgbpW81MUCABMZkAY=; b=NiOvswoD6RfZp1BgVe1RRdRhFh3pWgxa3nWqwiKAW5jKvrD/Mf3iA08Fg+Dm9dpePA CSs3tDsiY6ynQevaMe7snvWdR3uw6Qf6akwmqbEjZT6YK4LOtUrR45kJaKMPM7W4Xtvs gg/ObYjVLj4ZVrd88KC5fnvTRRYi8pcRoHFBc5obaaDhzUXVjfzmizoCP9zwTgp78zW7 ZnD2L37corB7qQUwOfAF+ZnDJacxt5hJYLUSwvZFvTrG/HPX1c4bKvtpcRp3i16/q+a4 mYbJXyOVDQWljWSZwxzBnAgSn5Ywl72UzBLkiFirGUcFZiUgygqkwFgEk/hw7TUqv52v H7/g==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="D6AG8/Yz"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-138701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id l16-20020a635b50000000b005cf588da70fsi1194196pgm.643.2024.04.10.07.06.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 07:06:50 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b="D6AG8/Yz"; arc=pass (i=1 spf=pass spfdomain=ti.com dkim=pass dkdomain=ti.com dmarc=pass fromdomain=ti.com); spf=pass (google.com: domain of linux-kernel+bounces-138701-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138701-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sv.mirrors.kernel.org (Postfix) with ESMTPS id 4622428D176 for ; Wed, 10 Apr 2024 14:02:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9343216F0E5; Wed, 10 Apr 2024 13:59:55 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="D6AG8/Yz" Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C992016DEDA; Wed, 10 Apr 2024 13:59:52 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=198.47.19.141 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712757594; cv=none; b=FEd+S3qvP+ECHBMrSRPgtH+/m8lPRO5AI1KK3HsUGbdt8gE4w48N2xMU+v++YXrmfej57+ay/vWqe4UF2UewsUsuFUS6cwPCpgNM8/4y+271meVvmFdO/5MaPLNAZ4jzYKYddFqDNerLzZrKolW5sRzNQ4nwsO0W+g8koykHKh4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712757594; c=relaxed/simple; bh=R1WUXZH6NvJXZIW+AVDPYVj8JHUdfaLxcMfuJ+Z3tRM=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=F6jUIuTO6b0puTDbROy8dN6jhv4t+b68JOu7EiL6bLnAF8abUwAge5REf+70r9Tk+vBQ6zXaU3TxReJqOqhBsjustVdUgrK3F7rJADz0PQ2Nq/5sli2GpI7BxfoTKJaITo4oEWQvtvoBmOz8wJYtW7i3hg0Wru5boNqZSKTgjiQ= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com; spf=pass smtp.mailfrom=ti.com; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b=D6AG8/Yz; arc=none smtp.client-ip=198.47.19.141 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=ti.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ti.com Received: from fllv0035.itg.ti.com ([10.64.41.0]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43ADxlho024595; Wed, 10 Apr 2024 08:59:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1712757587; bh=BSjhEIQgB4xQ5LpqF3Ho5CnJ8F2Hjtf+UQHpF8YH8Vg=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=D6AG8/YzMJRYBsRYtEkYlGfs2CUP1EwG13PzGBjiQ0KWhmDs3GGCli5iC9GDjdV+i 27Del0igCuZt6CXm3MI0dbt14dvqbAmiv57fguluQQnSMmesCoUnFIO07E2Yliu+Xm Q+l0GNmCmNGrLyUgIbioruDskJXtZEFdbSxvzLBE= Received: from DLEE114.ent.ti.com (dlee114.ent.ti.com [157.170.170.25]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43ADxlSW072427 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Apr 2024 08:59:47 -0500 Received: from DLEE113.ent.ti.com (157.170.170.24) by DLEE114.ent.ti.com (157.170.170.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23; Wed, 10 Apr 2024 08:59:47 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DLEE113.ent.ti.com (157.170.170.24) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.2507.23 via Frontend Transport; Wed, 10 Apr 2024 08:59:47 -0500 Received: from fllvsmtp8.itg.ti.com ([10.249.42.149]) by lelvsmtp6.itg.ti.com (8.15.2/8.15.2) with ESMTP id 43ADxhaw067183; Wed, 10 Apr 2024 08:59:47 -0500 From: Andrew Davis To: Jassi Brar , Hari Nagalla , Nick Saulnier , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH v2 12/13] mailbox: omap: Reverse FIFO busy check logic Date: Wed, 10 Apr 2024 08:59:41 -0500 Message-ID: <20240410135942.61667-13-afd@ti.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20240410135942.61667-1-afd@ti.com> References: <20240410135942.61667-1-afd@ti.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 It is much more clear to check if the hardware FIFO is full and return EBUSY if true. This allows us to also remove one level of indention from the core of this function. It also makes the similarities between omap_mbox_chan_send_noirq() and omap_mbox_chan_send() more obvious. Signed-off-by: Andrew Davis --- drivers/mailbox/omap-mailbox.c | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index 8e2760d2c5b0c..c5d4083125856 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -375,34 +375,33 @@ static void omap_mbox_chan_shutdown(struct mbox_chan *chan) static int omap_mbox_chan_send_noirq(struct omap_mbox *mbox, u32 msg) { - int ret = -EBUSY; + if (mbox_fifo_full(mbox)) + return -EBUSY; - if (!mbox_fifo_full(mbox)) { - omap_mbox_enable_irq(mbox, IRQ_RX); - mbox_fifo_write(mbox, msg); - ret = 0; - omap_mbox_disable_irq(mbox, IRQ_RX); + omap_mbox_enable_irq(mbox, IRQ_RX); + mbox_fifo_write(mbox, msg); + omap_mbox_disable_irq(mbox, IRQ_RX); - /* we must read and ack the interrupt directly from here */ - mbox_fifo_read(mbox); - ack_mbox_irq(mbox, IRQ_RX); - } + /* we must read and ack the interrupt directly from here */ + mbox_fifo_read(mbox); + ack_mbox_irq(mbox, IRQ_RX); - return ret; + return 0; } static int omap_mbox_chan_send(struct omap_mbox *mbox, u32 msg) { - int ret = -EBUSY; - - if (!mbox_fifo_full(mbox)) { - mbox_fifo_write(mbox, msg); - ret = 0; + if (mbox_fifo_full(mbox)) { + /* always enable the interrupt */ + omap_mbox_enable_irq(mbox, IRQ_TX); + return -EBUSY; } + mbox_fifo_write(mbox, msg); + /* always enable the interrupt */ omap_mbox_enable_irq(mbox, IRQ_TX); - return ret; + return 0; } static int omap_mbox_chan_send_data(struct mbox_chan *chan, void *data) -- 2.39.2