Received: by 2002:ab2:7a55:0:b0:1f4:4a7d:290d with SMTP id u21csp500162lqp; Thu, 4 Apr 2024 23:09:38 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVBmiRTJwr5vipabJDlWTW5itnxZbkcu4VT5NoIOf2R3kCA1WNxa+zZM3pGl+jFltRNNV60kw8HJRJ1+0c0N7/QbGQ/ZXa2A6qAzVFXhQ== X-Google-Smtp-Source: AGHT+IH495QU9VOaxBe1Tq/IBYexrUgnt0pK2g9ta7LsdSYMESWOKiCIJlyjGudwAmWf5awE+TAM X-Received: by 2002:a50:9e48:0:b0:56e:2464:7c4b with SMTP id z66-20020a509e48000000b0056e24647c4bmr277957ede.10.1712297378208; Thu, 04 Apr 2024 23:09:38 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712297378; cv=pass; d=google.com; s=arc-20160816; b=mnxbta7ZnMIPjdro/u0WGJEM/BKRdY1EUeeOCP5i5f2lOPdZmHDfmfuv4+vRYcTHyO e5og5rOgIMYQsrSKWi6SsF/QePUpp8wJnPCSZI2B3BUyDDNqzbpCe0/dlVnvacJfoQ7V 6DAe2dGvvvhdtzvCQZNPwUrgK5y8waYissx+7OfOo/+MTeeXA3w7lcu6q57SLbS3Vmki WKU9i/mB3FKHZzAGgq4Tojx6jhzT+GjPtKzrwuOsxVR7XWjE1SB0TKVRw0aKhd2akPLf bj47dArbxLEMFeLowHnLn9552VE/8bhDDtpvNafTdJR23Y9h3HD+uA++c7eCNUNx+8Ac cbzA== 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=pdVRMZEhFHGvBODw3XaHaAkw4HrdlbuRCNXM+QLCNNs=; fh=1bW5EWNCBCDW08TNeYqg+DykFtZHx6wA/3cN31rPlao=; b=d3CW+mWVCvM5yNUkSBfLiqB8RWoa+OU8wq/Uczo4vqPdUhNgtfiixh8ZE1ZsEYGbrn D9z3L5z8OGCGYymtcxCNEZWVjIIhslgjFf8u39rUeh9vxJrkO93R4SFlMJ16OBBSwcLZ Wi6lLUru8yRpCDPO/WalyScPGTTb6lQahts+QXJ/2fkH2MuBQpmEgDbRSSs147ri18oy +9OtZ8pA9A5B07RwvDl92Etsk7zCjoD9R6F/7XntnQxygrELFgCS7kGQKFpJtvXCmF42 2/LuNEfpuF1ArCTvXHEreguAXkuw9DEP1B5tdVJwBXW00VeYC8vk2weICrT79z45MJA9 UH8A==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=GzfuGQBz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132440-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132440-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id t11-20020a50d70b000000b0056bd9adc7b7si394188edi.525.2024.04.04.23.09.38 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 04 Apr 2024 23:09:38 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-132440-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=@kernel.org header.s=k20201202 header.b=GzfuGQBz; arc=pass (i=1 dkim=pass dkdomain=kernel.org); spf=pass (google.com: domain of linux-kernel+bounces-132440-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-132440-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org 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 E940C1F23951 for ; Fri, 5 Apr 2024 06:09:37 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 8EB882C69D; Fri, 5 Apr 2024 06:08:47 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="GzfuGQBz" Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (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 B2C992C1B6; Fri, 5 Apr 2024 06:08:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=10.30.226.201 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297326; cv=none; b=qZlUg2hN9P/aS6qB0T0MFQW324r2+Y/9XCMtwfLmqkxQ3OjFJe3pm6o3SmyfUHnV7YoTTopmmIQm1cWmH/Ce/pOsu9P3Y2WnrgO2C3w9YTZcmnJNIjy4p4eljOfQWkzFWvj2QwpHkBzsQzYCNN0mfr2eleD1Zo55Lj05tvp+0qQ= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712297326; c=relaxed/simple; bh=eLFz8uhtcnkr+mmr2mJCW7abChfFurz5pgm0LRWZQB4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=f+b2QoyVJVUvQPZ7O4LIjQQc8T3RaIXxr/KOd+1+iWIvL0CSzBWX4vfBtABg/0SUkmTEoCiEvgbC6e1kKVuQE0Tgo07fxFLvcT1oWBfAZmNhfuWrnHLPDmUtaFGNW4Xf35luISBHG4RWaS57l34914TFdA9gHSa746E4Co2p21k= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=GzfuGQBz; arc=none smtp.client-ip=10.30.226.201 Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2D70EC43390; Fri, 5 Apr 2024 06:08:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1712297326; bh=eLFz8uhtcnkr+mmr2mJCW7abChfFurz5pgm0LRWZQB4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=GzfuGQBzmLL+POZxHTP2DAorvhpY4UPzoC2rpot1rpECWEcHLV5ob+fllk1vGfne3 DOVFqB9dJSoW016vy7pgo6c+mrMsM0SbXCA+vAlV9fmCyd+5jVbHd/APjW2u4nSIR2 Q6T/o4dIVKglkUmY/h+rpTk57A1m+r5JaxENwkMxAH+bMlutDjDRFxB9r3xr80n1mh 07alDoPIMRu7FvhEfE/1a5yhnb5sz/FGl80YqL47Amp0jB2PRXEkm4z1+zCRra7TEx mbtO8sgSeHNzIMmWNVm9vpRDMiLQ/fn/p/wxSF8h2ddYTr1ltjslLlxc5ip69Kn9ks RqWHtrV2X0Pag== From: "Jiri Slaby (SUSE)" To: gregkh@linuxfoundation.org Cc: linux-serial@vger.kernel.org, linux-kernel@vger.kernel.org, "Jiri Slaby (SUSE)" , Andrew Morton , Stefani Seibold Subject: [PATCH 04/15] kfifo: remove support for physically non-contiguous memory Date: Fri, 5 Apr 2024 08:08:15 +0200 Message-ID: <20240405060826.2521-5-jirislaby@kernel.org> X-Mailer: git-send-email 2.44.0 In-Reply-To: <20240405060826.2521-1-jirislaby@kernel.org> References: <20240405060826.2521-1-jirislaby@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit First, there is no such user. The only user of this interface is caam_rng_fill_async() and that uses kfifo_alloc() -> kmalloc(). Second, the implementation does not allow anything else than direct mapping and kmalloc() (due to virt_to_phys()), anyway. Therefore, there is no point in having this dead (and complex) code in the kernel. Note the setup_sgl_buf() function now boils down to simple sg_set_buf(). That is called twice from setup_sgl() to take care of kfifo buffer wrap-around. setup_sgl_buf() will be extended shortly, so keeping it in place. Signed-off-by: Jiri Slaby (SUSE) Cc: Andrew Morton Cc: Stefani Seibold --- lib/kfifo.c | 38 +++++--------------------------------- 1 file changed, 5 insertions(+), 33 deletions(-) diff --git a/lib/kfifo.c b/lib/kfifo.c index a36bfdbdb17d..d5830960ab87 100644 --- a/lib/kfifo.c +++ b/lib/kfifo.c @@ -305,43 +305,15 @@ int __kfifo_to_user(struct __kfifo *fifo, void __user *to, } EXPORT_SYMBOL(__kfifo_to_user); -static int setup_sgl_buf(struct scatterlist *sgl, void *buf, - int nents, unsigned int len) +static unsigned int setup_sgl_buf(struct scatterlist *sgl, void *buf, + int nents, unsigned int len) { - int n; - unsigned int l; - unsigned int off; - struct page *page; - - if (!nents) + if (!nents || !len) return 0; - if (!len) - return 0; + sg_set_buf(sgl, buf, len); - n = 0; - page = virt_to_page(buf); - off = offset_in_page(buf); - l = 0; - - while (len >= l + PAGE_SIZE - off) { - struct page *npage; - - l += PAGE_SIZE; - buf += PAGE_SIZE; - npage = virt_to_page(buf); - if (page_to_phys(page) != page_to_phys(npage) - l) { - sg_set_page(sgl, page, l - off, off); - sgl = sg_next(sgl); - if (++n == nents || sgl == NULL) - return n; - page = npage; - len -= l - off; - l = off = 0; - } - } - sg_set_page(sgl, page, len, off); - return n + 1; + return 1; } static unsigned int setup_sgl(struct __kfifo *fifo, struct scatterlist *sgl, -- 2.44.0