From nobody Thu Feb 16 11:56:07 2023 X-Original-To: dev-commits-src-all@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 4PHYLc6FYfz3q5fw; Thu, 16 Feb 2023 11:56:08 +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 4PHYLc2m1lz49W1; Thu, 16 Feb 2023 11:56:08 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548568; 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=FbEK7mdQsNw2isBIgVzKVTNMudTiSl2WRwDrp0qKEWM=; b=GkGJZ6eZivmp2k0X7Hk5ivJtaBtI9cF3RuxXBLN1wDLLP8bUa4Fy/pmz06TrbOe/+DNX1q Jv0Z9K2ybpJuMXJn0EyWCQWZ5AuM2CO1DXnSrct/8NcDckpz1hss+PGiEu82PaKf1VhloE gW1IVymhVw8RQy1WetsQ4bT1Ux+zs3GNPTC/STGlrZvDvKSky7wfoGitGYLP9l7/gis9c9 /ZtArfMdkrnh2mQiD3yv6p+FLVr6P0SNwm5MqS7YJkHX/DKQAcvZ+lLHgDytXRMQ3Rqtwo ZujUOvytXs/LQN+NRuWo0F4Zg2pMwkuvxcafN8p9s5V1oLs+Nx5tR9V1uJo0lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1676548568; 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=FbEK7mdQsNw2isBIgVzKVTNMudTiSl2WRwDrp0qKEWM=; b=rQxUr6FWFxnHpkAURQ8qPOPDGjxmG5b3PDvVvNa64GCIfh+kQWHRvbgtFLBbF4qsTFfldg pJfGSBFYxDaWvf9sedWYyLX8g0ZLGNMS5bO7lUJszy8GyvZat7aWheMwCykBMg6DkCNtdb tEH+ZwFzinp+qAMV6kVaC6x6062NXpTS1TRYAqdkpwqw51qMUOQqZGFOMG0nL/CP9xBn95 N80LdLJ1k+OTJS/fSNBY5KbmSkDd5uZ72SYoR3Sgg1mzejl9XWXms2eNXlH2+sLFuXupfz dInTXAfj3bmybaEqqVCHh/f3ys9kFBCdyZR96ss0V0iY8BjhCNg+zZ2vewP8lw== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1676548568; a=rsa-sha256; cv=none; b=DsNkmc52Hc2eZZxnkG24HNm1uJsBXuhS+WKaMZgiPm5qLn/kLXx7CqyuF6gWtTiNNmQVb5 IBt1oa9stk/eVIdnOFyrquq2ICF2nKNEJ7744dTsXogijoaMOuGPT6gV0bY6QdpZ6SmDjc m289JcnamXlT3BhONEfGsr0R0bJW8TLYjkuJgSC5x+9IZ8zJFKUgBXxgQRKDnCZhBEMdO8 mjngc/OVx2k90qn4yrjwJMdh+4J2tA5nsyoJOQ0vmv2+KNFOwFx6oG9A/7+WSjRAWKj/zL TKStr1iePeqfcpIbP9jGSn2t54b6h4YYI5oELrBwYAB6eLTMWPt7eHZyYYtaQg== 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 4PHYLc0Zrpz12W6; Thu, 16 Feb 2023 11:56:08 +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 31GBu7b6055649; Thu, 16 Feb 2023 11:56:07 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31GBu7cC055648; Thu, 16 Feb 2023 11:56:07 GMT (envelope-from git) Date: Thu, 16 Feb 2023 11:56:07 GMT Message-Id: <202302161156.31GBu7cC055648@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien=20P=C3=A9dron?= Subject: git: 71e12e26417f - stable/13 - linuxkpi: Fix `sg_alloc_table_from_pages()` to have the same API as Linux List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@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/stable/13 X-Git-Reftype: branch X-Git-Commit: 71e12e26417f9af8824b1cd544391d3fc7d74478 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by dumbbell (ports committer): URL: https://cgit.FreeBSD.org/src/commit/?id=71e12e26417f9af8824b1cd544391d3fc7d74478 commit 71e12e26417f9af8824b1cd544391d3fc7d74478 Author: Jean-Sébastien Pédron AuthorDate: 2023-01-10 10:10:30 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2023-02-16 11:55:16 +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 (cherry picked from commit 3e0856b63fe0e375a0951e05c2ef98bb2ebd9421) --- .../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