From nobody Sat Jan 22 19:36:23 2022 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 2AF20196B52B; Sat, 22 Jan 2022 19:36:27 +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 4Jh61j3Xd1z3R1L; Sat, 22 Jan 2022 19:36:25 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880187; 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=/8jbwzFXUEe+7m0ggzxaJtGDpfCTs8D0/RZI+eR5Abw=; b=Fmp64qepxrVwvLMcMvzPvHvVYyyBW3aBslqL8Y76JvC19x/RFiRdDsPHWZ/uasj6coOvhf Zbw7Ko91+0vWIvB+DQHGIS88okdCS+yJ13YF6i+4ubuAjBeZ1mmdNbcOB6M48Yu+54/pkd wPnwVTsiLJFyeJ+Zj1YbudKjLh1VTEqQATNfDal6QzNePIbWygBS1Ay52ApKPkrIoV+8Ly md9H2aZAOre4ROWVUzSE8lrd+sJVRDkGsQDlXGzMbD4PMPbabUTBX18wEke7r1Bc3fszI0 GdkEkgEIwKT86tf2w5c6W53KUnUb98bgcNO0n2xRJJh+wHJhm3tRxF/c2Gm5AA== 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 D26B215189; Sat, 22 Jan 2022 19:36:23 +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 20MJaNTo099968; Sat, 22 Jan 2022 19:36:23 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 20MJaNjf099967; Sat, 22 Jan 2022 19:36:23 GMT (envelope-from git) Date: Sat, 22 Jan 2022 19:36:23 GMT Message-Id: <202201221936.20MJaNjf099967@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Vladimir Kondratyev Subject: git: 8dc3f129c4c7 - stable/13 - LinuxKPI: Add support for XA_FLAGS_ALLOC1 xarray flag 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: wulf X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: 8dc3f129c4c7bf980bf744d7fa0aa2cb79c7234e Auto-Submitted: auto-generated ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1642880186; 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=/8jbwzFXUEe+7m0ggzxaJtGDpfCTs8D0/RZI+eR5Abw=; b=fIWNBJl0/dns3v8MzoSd2Aw6wv6R97XvFNlWdv6uHDxxD1BLkzLW1OW4LEOlRobicAWSna Pp+N8VwjH/M44RXYr0J/VRcdcszojlqHdJ65R/Adobcx8vESm4QqRn4+DzoC1u7/l5aZkD H66eQyCFweYSpm8wcDUrhSnLpdJ0/3GH09G4ejKhSkIUNlINnbDmj0Xy3dHF4c+uhhU9v2 urQdgdb4hWoehz1FgKaH4WkaorQhz02L6fdLG8dmOOUky/PvmGHMRAVpSCyc5bwMlnPuTR xsrOOa99VjwpGIZA4LELFx76hXOP+Hv3bF7SuoKGLY+u0Z0xM34821+qAX2zHw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1642880186; a=rsa-sha256; cv=none; b=KURKhSLbUbfNoCEBj6JI5h2r/1pqLq6FOB3530WlcUXeZ0dnXJCrULPgOfhjbHPvGgHlN7 JytuZ9/+FQRBPJAJ4A8yQLGZSL6jAShOw/uzMTb/DTsNY8jl73poDNBFn42xbvC97DL3sT lQcsGCHzDkktaicoFtui4Q0uT10ZDN7XiYDMp5J/oxTd/KqcVH10AgNjUijQtAfVPabL83 BE36Cd4Z5chTene2Gk42k6pHV42uHtdRpnK9pO6PKTLwad5eH+iKvFQ+bdkpCOvIJ+e/+I l9KpPh0HwAfP59yrCBby5KoCtR5TkQpoVz6fopWZcrvgd7YuJsVVCjq+2XrnkQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by wulf: URL: https://cgit.FreeBSD.org/src/commit/?id=8dc3f129c4c7bf980bf744d7fa0aa2cb79c7234e commit 8dc3f129c4c7bf980bf744d7fa0aa2cb79c7234e Author: Vladimir Kondratyev AuthorDate: 2021-11-24 00:05:40 +0000 Commit: Vladimir Kondratyev CommitDate: 2022-01-22 19:34:36 +0000 LinuxKPI: Add support for XA_FLAGS_ALLOC1 xarray flag XA_FLAGS_ALLOC1 causes allocation of xarray entries starting at 1 Required by drm-kmod 5.7 MFC after: 1 week Reviewed by: hselasky, manu Differential Revision: https://reviews.freebsd.org/D33293 (cherry picked from commit e705066cd87559831096f9638603f35d2fea635f) --- sys/compat/linuxkpi/common/include/linux/xarray.h | 2 ++ sys/compat/linuxkpi/common/src/linux_xarray.c | 15 +++++++++------ 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/sys/compat/linuxkpi/common/include/linux/xarray.h b/sys/compat/linuxkpi/common/include/linux/xarray.h index 7427f6e4f9f9..3d9041bf108d 100644 --- a/sys/compat/linuxkpi/common/include/linux/xarray.h +++ b/sys/compat/linuxkpi/common/include/linux/xarray.h @@ -40,6 +40,7 @@ #define XA_FLAGS_ALLOC (1U << 0) #define XA_FLAGS_LOCK_IRQ (1U << 1) +#define XA_FLAGS_ALLOC1 (1U << 2) #define XA_ERROR(x) \ ERR_PTR(x) @@ -53,6 +54,7 @@ struct xarray { struct radix_tree_root root; struct mtx mtx; /* internal mutex */ + uint32_t flags; /* see XA_FLAGS_XXX */ }; /* diff --git a/sys/compat/linuxkpi/common/src/linux_xarray.c b/sys/compat/linuxkpi/common/src/linux_xarray.c index 52be490c100e..c26a2af450e8 100644 --- a/sys/compat/linuxkpi/common/src/linux_xarray.c +++ b/sys/compat/linuxkpi/common/src/linux_xarray.c @@ -102,13 +102,13 @@ __xa_alloc(struct xarray *xa, uint32_t *pindex, void *ptr, uint32_t mask, gfp_t XA_ASSERT_LOCKED(xa); - /* mask cannot be zero */ - MPASS(mask != 0); + /* mask should allow to allocate at least one item */ + MPASS(mask > (xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0); /* mask can be any power of two value minus one */ MPASS((mask & (mask + 1)) == 0); - *pindex = 0; + *pindex = (xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0; retry: retval = radix_tree_insert(&xa->root, *pindex, ptr); @@ -159,13 +159,13 @@ __xa_alloc_cyclic(struct xarray *xa, uint32_t *pindex, void *ptr, uint32_t mask, XA_ASSERT_LOCKED(xa); - /* mask cannot be zero */ - MPASS(mask != 0); + /* mask should allow to allocate at least one item */ + MPASS(mask > (xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0); /* mask can be any power of two value minus one */ MPASS((mask & (mask + 1)) == 0); - *pnext_index = 0; + *pnext_index = (xa->flags & XA_FLAGS_ALLOC1) != 0 ? 1 : 0; retry: retval = radix_tree_insert(&xa->root, *pnext_index, ptr); @@ -177,6 +177,8 @@ retry: } (*pnext_index)++; (*pnext_index) &= mask; + if (*pnext_index == 0 && (xa->flags & XA_FLAGS_ALLOC1) != 0) + (*pnext_index)++; goto retry; case -ENOMEM: if (likely(gfp & M_WAITOK)) { @@ -302,6 +304,7 @@ xa_init_flags(struct xarray *xa, uint32_t flags) mtx_init(&xa->mtx, "lkpi-xarray", NULL, MTX_DEF | MTX_RECURSE); xa->root.gfp_mask = GFP_NOWAIT; + xa->flags = flags; } /*