From nobody Fri Jan 27 21:27:48 2023 X-Original-To: dev-commits-src-main@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4P3VzS67Ccz3c8N6; Fri, 27 Jan 2023 21:27:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4P3VzS5MrSz4NYD; Fri, 27 Jan 2023 21:27:48 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674854868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tKcTPVnFjH3lfLApZU2awB5KMgSRZAPbsb7IB6ilbW4=; b=eY8M/YJu9q2nzpe1nfHVYSnqh6aCFv5kGZ5N0R5FOqvfEG2b6UNlEPHa5n3XToZDA8q8nQ n0O9EBvPPKZwL3Ukx2oqnDY137GLgUejx9JhesEEsmE2htGigxSozANeS51/cOUCF3wAE7 jHbsiP+JTXCCzO5Odu4ZOIMOPVbbKInwaNs1e0Wec74wigJxQWC8dBkeUq2KlW+Flf6VgY EyRahbYmL3MNuAQ3o/b3B7FG5QtBYpAJ7M26gTgnR8wtEZdAFL1y95lkcQSoXcFGjyPGpM K4/gH1E/Xb7vXc0kj4rli9Cr/V545XEjHmFjvxtGOlJAIcp1iLUSykU5VLfE8g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674854868; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=tKcTPVnFjH3lfLApZU2awB5KMgSRZAPbsb7IB6ilbW4=; b=KG10B+KXT/T9JADrPrUm/I42nzZMIbFSHzPNoxpLLvZ5RFXsTbwjpyWYeY0bJ6/PL/xwL9 4cWCoX6rIUK1HR7lMdU7/MWw9pM9rVxBlHdLD5m2CySmRfKEg4GR9QIJcO2Zx0X1QSppuf Zi0xzV624VhBrZkLOuRhKceEc+spm6CkxUmlhVPRZ7QmkDBrnKcBGGvNE2alZ+ng9pUXV4 u82NtWJfPJuHm8Exk9xSD+ZLkcor/yj5ZBT8UCWALzmhosqYgyjSHCBUz3bZTdHhBddiP4 ekyiY0rD/Ubohvr2OGsctdpjmzHJuPpxInMQ6+ssnwkeyTaqdAjaY523uD2sTg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674854868; a=rsa-sha256; cv=none; b=joWmD+y/6QJ6oRevQ/S/5cDb3RYaoI0r0gG0R+35SvLW7xZUAMn4SNaQqdgWwXf0EeOzil /wyYSLPpN42LLKaM3pV5Azc1oxup2jcAhzEhYcAusXgWOnKLfQ31Z5pMmmpxIjJO7mJ9x0 uQ/K/BsWTdlTTGYuNpe7DbnXrLufN4r82tMSA1UnCmp4cwnKLJDaQU2Zu4Zn2M19hgVC6w RjiK10QpmEbvl+1VaupOPz2s0hQIcvi4w2EDwMqzvtKpl87SnYFP561+qqLc5xBQLadgXq +cyRki4agrspJSg0qDSDkd6xGR3O3T5xHYmDiudayomHB7LOj3lqY8EhRXpHrw== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4P3VzS46hSzNx0; Fri, 27 Jan 2023 21:27:48 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30RLRmC6000508; Fri, 27 Jan 2023 21:27:48 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30RLRm6K000507; Fri, 27 Jan 2023 21:27:48 GMT (envelope-from git) Date: Fri, 27 Jan 2023 21:27:48 GMT Message-Id: <202301272127.30RLRm6K000507@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 3e0856b63fe0 - main - linuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-main@freebsd.org X-BeenThere: dev-commits-src-main@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 3e0856b63fe0e375a0951e05c2ef98bb2ebd9421 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=3e0856b63fe0e375a0951e05c2ef98bb2ebd9421 commit 3e0856b63fe0e375a0951e05c2ef98bb2ebd9421 Author: Jean-Sébastien Pédron AuthorDate: 2023-01-10 10:10:30 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-01-27 20:53:59 +0000 linuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux It now returns a `struct scatterlist *` pointer instead of an error code only. The implementation is incomplete because it doesn't use the `prv` argument. Reviewed by: manu Approved by: manu Differential Revision: https://reviews.freebsd.org/D38077 --- .../linuxkpi/common/include/linux/scatterlist.h | 44 +++++++++++++++++++++- 1 file changed, 43 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/scatterlist.h b/sys/compat/linuxkpi/common/include/linux/scatterlist.h index 86aeefafb501..d1a71258c27d 100644 --- a/sys/compat/linuxkpi/common/include/linux/scatterlist.h +++ b/sys/compat/linuxkpi/common/include/linux/scatterlist.h @@ -327,18 +327,40 @@ sg_alloc_table(struct sg_table *table, unsigned int nents, gfp_t gfp_mask) return (ret); } +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 +static inline struct scatterlist * +__sg_alloc_table_from_pages(struct sg_table *sgt, + struct page **pages, unsigned int count, + unsigned long off, unsigned long size, + unsigned int max_segment, + struct scatterlist *prv, unsigned int left_pages, + gfp_t gfp_mask) +#else static inline int __sg_alloc_table_from_pages(struct sg_table *sgt, struct page **pages, unsigned int count, unsigned long off, unsigned long size, unsigned int max_segment, gfp_t gfp_mask) +#endif { unsigned int i, segs, cur, len; int rc; struct scatterlist *s; +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 + if (prv != NULL) { + panic( + "Support for prv != NULL not implemented in " + "__sg_alloc_table_from_pages()"); + } +#endif + if (__predict_false(!max_segment || offset_in_page(max_segment))) +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 + return (ERR_PTR(-EINVAL)); +#else return (-EINVAL); +#endif len = 0; for (segs = i = 1; i < count; ++i) { @@ -350,13 +372,19 @@ __sg_alloc_table_from_pages(struct sg_table *sgt, } } if (__predict_false((rc = sg_alloc_table(sgt, segs, gfp_mask)))) +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 + return (ERR_PTR(rc)); +#else return (rc); +#endif cur = 0; - for_each_sg(sgt->sgl, s, sgt->orig_nents, i) { + for (i = 0, s = sgt->sgl; i < sgt->orig_nents; i++) { unsigned long seg_size; unsigned int j; + s = sg_next(s); + len = 0; for (j = cur + 1; j < count; ++j) { len += PAGE_SIZE; @@ -371,7 +399,16 @@ __sg_alloc_table_from_pages(struct sg_table *sgt, off = 0; cur = j; } + KASSERT(s != NULL, ("s is NULL after loop in __sg_alloc_table_from_pages()")); + +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 + if (left_pages == 0) + sg_mark_end(s); + + return (s); +#else return (0); +#endif } static inline int @@ -381,8 +418,13 @@ sg_alloc_table_from_pages(struct sg_table *sgt, gfp_t gfp_mask) { +#if defined(LINUXKPI_VERSION) && LINUXKPI_VERSION >= 51300 + return (PTR_ERR_OR_ZERO(__sg_alloc_table_from_pages(sgt, pages, count, off, size, + SCATTERLIST_MAX_SEGMENT, NULL, 0, gfp_mask))); +#else return (__sg_alloc_table_from_pages(sgt, pages, count, off, size, SCATTERLIST_MAX_SEGMENT, gfp_mask)); +#endif } static inline int