Received: by 2002:ab2:4a89:0:b0:1f4:a8b6:6e69 with SMTP id w9csp159625lqj; Wed, 10 Apr 2024 07:05:19 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUO5VRssz1oNqc8j2MR/fS+fb7AsPTQwbGUAKKD4VrBS6yxKdVpC8G+bKnHqAbU+DAk2jtF7VL9jHwDPt7PAHNOmdtYryDfPmnYsqkqdA== X-Google-Smtp-Source: AGHT+IG0MKq0t4KANWtsQJe2c68ComUCE13+M8KuiL6o/TktqBqWVUx/3KLVGbMD4jKOkGzndiHj X-Received: by 2002:a17:906:c1c2:b0:a51:af7d:4652 with SMTP id bw2-20020a170906c1c200b00a51af7d4652mr1781580ejb.32.1712757918988; Wed, 10 Apr 2024 07:05:18 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712757918; cv=pass; d=google.com; s=arc-20160816; b=RuLi4D4PGYnlOsOyszfQ2JZm4r2IrbhkPElwU/yTWJuN0+7K8JqRjoqTAChAQg6zIM 4My9va0uFFqURhOpK+JHiXqsv0dJFRwwqJL3eOJhWWDQa4tqEAN/pZrTmnY2TfCl9xd+ rGWldQJ2eLUOZ3OMtnAoLjVqqIBmrKN1gFSGkD7m7N7utYRmeRyR7k/tK4bVtyX5VirV S7bKPU9mtL07E9d+A7JO8bvL7CDeZgY/IZebBvjqvAq0jRnI3NOuqphWLi5L3lyhsXfE DS/qSKHSnpqALYk0Uc15e0SOyev8sGxxf4PYTjufE+LC8XCMpR5EFyU99pH5GLD3+Clj 1vZQ== 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=LRIF3E/X3Th7qLH/f1ml5/H5LIqNgItmvNfm9KSSj1I=; fh=li+nOTWR+R+c2QHViCtM9aHEBgqgbpW81MUCABMZkAY=; b=VOuRuguvLnBQWb0DFa3N9/aoGoWOULoIJnf/iXCLgV++OyYp/bCe8N8mNzN7Uj+tFj Kn/H3vz+QMK1vmiPDmVSxpAGOkqx6KyRORaM1LnoeHEcfRtUInLUQsAYJIvvSUcyWpMT /qk2G1hE/clQcW+Yc7sDSYSdac68GFntBVQ/R9ZwTnknfe68FeBdUx8crhsPhKTOgrwI Fj8bwRVxHPAzxgF5oILWEFMH7SKDXaS270VZVDSOzeXdFddjVora/s2ixBLzf2jOeR5M oopXpZLrHWoxxd6keg+J8SqNsDQK1X+PF4oE9i/t+wGUKrMQuwYiGaY4/lrbqUiPNV15 1kAg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PaHPCmp0; 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-138698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138698-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gb41-20020a170907962900b00a51b1db8839si5241476ejc.793.2024.04.10.07.05.18 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 Apr 2024 07:05:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-138698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=PaHPCmp0; 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-138698-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-138698-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 am.mirrors.kernel.org (Postfix) with ESMTPS id C3B861F286BA for ; Wed, 10 Apr 2024 14:01:52 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 777F116E875; Wed, 10 Apr 2024 13:59:53 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=ti.com header.i=@ti.com header.b="PaHPCmp0" 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 EF27E16D9CA; Wed, 10 Apr 2024 13:59:50 +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=1712757592; cv=none; b=DfrTL6npkQ959fUFXzz47S5PDFe5cjov6FMnIoFl6+SOXaZNs6BZ9aFesu7qccrxFUrOObBT22AXcWnbtQ2juKeS8DwIshOVKLE62IOFCcoaZcggA5pBwb4C5h7ea964uXqDDqRopQd6auP9YUimfe/yfC5+SSSczXw5YiKxgHk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712757592; c=relaxed/simple; bh=+4mYsDwEIK4ZWqyyDgyiPzXKtR3LJEx4RZaVrdGLE0Q=; h=From:To:CC:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=MehUJm8GJmBbsQgUhEFPjbLGXl09aoEBzP16Ynvg7SWMSlk60uEaE1I5X2iQkOoNfDO1hOCa8u+2cj0EDY3quZhr3Y74TTuPVMMVx0UyDlKfTjYFkwuYPW5ng5TxPznyYa8/cqP8gzN1cU2sUkA4aOJQbn2zNKQDklQ5ou65BhA= 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=PaHPCmp0; 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 lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id 43ADxjYL024573; Wed, 10 Apr 2024 08:59:45 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1712757585; bh=LRIF3E/X3Th7qLH/f1ml5/H5LIqNgItmvNfm9KSSj1I=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=PaHPCmp0vWk96rryVw3LARH9hXjb6Zud9xZiem+tgOWQy1N1HeYThY8pQMp1rKy7u TTJNWkMJcFxkF5hMV4FO2poJgpoGljd+U9SE5tArZi0zwWik/ATECTc9tjenPiudLn IQDnaFwQVYQV+hVoUFMJy39VXEJLsp/FEzPnZ1HA= Received: from DFLE115.ent.ti.com (dfle115.ent.ti.com [10.64.6.36]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id 43ADxjtd020060 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 10 Apr 2024 08:59:45 -0500 Received: from DFLE113.ent.ti.com (10.64.6.34) by DFLE115.ent.ti.com (10.64.6.36) 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:44 -0500 Received: from lelvsmtp6.itg.ti.com (10.180.75.249) by DFLE113.ent.ti.com (10.64.6.34) 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:45 -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 43ADxhao067183; Wed, 10 Apr 2024 08:59:44 -0500 From: Andrew Davis To: Jassi Brar , Hari Nagalla , Nick Saulnier , Bjorn Andersson , Mathieu Poirier CC: , , Andrew Davis Subject: [PATCH v2 04/13] mailbox: omap: Move fifo size check to point of use Date: Wed, 10 Apr 2024 08:59:33 -0500 Message-ID: <20240410135942.61667-5-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 The mbox_kfifo_size can be changed at runtime, the sanity check on it's value should be done when it is used, not only once at init time. Signed-off-by: Andrew Davis --- drivers/mailbox/omap-mailbox.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index c083734b6954c..167348fb1b33b 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -310,6 +310,7 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox, void (*work)(struct work_struct *)) { struct omap_mbox_queue *mq; + unsigned int size; if (!work) return NULL; @@ -320,7 +321,10 @@ static struct omap_mbox_queue *mbox_queue_alloc(struct omap_mbox *mbox, spin_lock_init(&mq->lock); - if (kfifo_alloc(&mq->fifo, mbox_kfifo_size, GFP_KERNEL)) + /* kfifo size sanity check: alignment and minimal size */ + size = ALIGN(mbox_kfifo_size, sizeof(u32)); + size = max_t(unsigned int, size, sizeof(u32)); + if (kfifo_alloc(&mq->fifo, size, GFP_KERNEL)) goto error; INIT_WORK(&mq->work, work); @@ -838,10 +842,6 @@ static int __init omap_mbox_init(void) if (err) return err; - /* kfifo size sanity check: alignment and minimal size */ - mbox_kfifo_size = ALIGN(mbox_kfifo_size, sizeof(u32)); - mbox_kfifo_size = max_t(unsigned int, mbox_kfifo_size, sizeof(u32)); - err = platform_driver_register(&omap_mbox_driver); if (err) class_unregister(&omap_mbox_class); -- 2.39.2