From nobody Mon Nov 25 04:34:02 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1717528304; cv=none; d=zohomail.com; s=zohoarc; b=DazhknWP1EAlK5uaAranE4L2RToVrj04VKhQr+tF3hItuVw1Tv2T8hhXOI0vrNNFtjEuYOPfugWUYiAN5lSrwl+wtTXjp8tZ6A7G3DD73ZmOfEcy/NgxDAfpM0kfgltOMCC1MR5qWwIDggPx2KgZHjsd3ln8hckvrtriqiyl8w8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1717528304; h=Content-Type:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To; bh=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=THXWiEHd8rC/FhC5il2+ldaTKolcdffQ1eHiASCzGvB4Q8NKnTgusQW6F+c5mR+kKXCuMgpsPhy8pcKF/5BmvGeSNexV2eh5AdJIBU9rp3k7RG1lK/aZVkEo5xFI8NCXNnMnyEQ1I6m4OXZg8M+8f9f0rQ+aKVBe9uVZWsGuyvU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 171752830418850.53645458484948; Tue, 4 Jun 2024 12:11:44 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sEZVh-0003JU-Mt; Tue, 04 Jun 2024 15:07:53 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVf-00038A-J6 for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:51 -0400 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sEZVc-0000xN-RM for qemu-devel@nongnu.org; Tue, 04 Jun 2024 15:07:51 -0400 Received: from mail-wr1-f69.google.com (mail-wr1-f69.google.com [209.85.221.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-655-Nk49qZM-PT6Y9Oc_tM6-Hw-1; Tue, 04 Jun 2024 15:07:46 -0400 Received: by mail-wr1-f69.google.com with SMTP id ffacd0b85a97d-35e83bf3294so109121f8f.1 for ; Tue, 04 Jun 2024 12:07:46 -0700 (PDT) Received: from redhat.com ([2a0d:6fc7:552:cf5c:2b13:215c:b9df:f231]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-35dd064dfd1sm12517936f8f.108.2024.06.04.12.07.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 04 Jun 2024 12:07:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1717528067; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: in-reply-to:in-reply-to:references:references; bh=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=iUXB58ddxQrLbPfIsxzZ1RFuR8gLgm/iBBfe/QeTwjeAnVCopH6pN36dEqrneG6lfr/q9+ tsHbPzyqb1pWYmmLZdVj1fM6xT08lzNig5LZQPRaNud0U5o0YP1L2SnRF6jA0d9Z/OYGoq g/vns8ElI0MvLs4H6PEE1SKiqVx/YqA= X-MC-Unique: Nk49qZM-PT6Y9Oc_tM6-Hw-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1717528064; x=1718132864; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=QuE+o0AC9wdLKXlzVTnODsdNe5/ti8zXK/7OKFfOYUM=; b=lJFy6l4lXr/Id8b1wQIHw60ODcTU2AgdibpVaX9qevJ0SgdNNfi6vbGGVDV8fDc4x/ gSiR3KXJi6xCamZfrms9peQp1u7ighKgo3Tsa7BFC3R70lbeAIzpmUY+JE5TwWKYfJ03 hZ+oFFCkklSPdRg02nHEH2T9vc3DcLSgqxGD3LXaL5D3Eobm2goeKfdVBHEfGJRnWeLF if9oz8O2yg4DgYm/AK4o+YFNtZifd1TlOEQj4etakOJpaJvIAyA8CWLhkr8r2WA77kCP EvPpOECzyIZilo7zAhETzA1B5vRXgtk13lKUtacrXunMJyKeMtL1hco/GgRJ0X3l0fP8 yAHA== X-Gm-Message-State: AOJu0Yw9chj85trDM31bEb3rNRgky89IvPltUMMCUf5zY0W2RBtGnE7d ZXT5abIWkCU0Autij3MAG5Pjl+V3Qph+cmZhCk+JbNKZxTNJcTySe8DVEtNRAiB1fu2K5YPu+FS tkRXuMn0kQ8w0qcWCB9sFtECcuppbXaAJ0U81ll6ljaOOnTQwK5S8A4CkC8USYfxTBroyNKs9u1 AYuSmWJ2+cdlwJfrKfHVj1UNf/iSSWvw== X-Received: by 2002:a5d:5402:0:b0:358:ffe5:dce3 with SMTP id ffacd0b85a97d-35e8ef8fea6mr213463f8f.49.1717528064435; Tue, 04 Jun 2024 12:07:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGATLlSHlwkWNmGeRAzWO9VcJJgOUCRml/Ahfdmheos3UF4mb5mBUCEiwLLJ9rG91wT/RnEIQ== X-Received: by 2002:a5d:5402:0:b0:358:ffe5:dce3 with SMTP id ffacd0b85a97d-35e8ef8fea6mr213446f8f.49.1717528063974; Tue, 04 Jun 2024 12:07:43 -0700 (PDT) Date: Tue, 4 Jun 2024 15:07:40 -0400 From: "Michael S. Tsirkin" To: qemu-devel@nongnu.org Cc: Peter Maydell , Fan Ni , Svetly Todorov , Gregory Price , Jonathan Cameron Subject: [PULL 29/46] hw/cxl/cxl-mailbox-utils: Add superset extent release mailbox support Message-ID: <1fd233748ea9aeff3b88478cf106ad3bd32a1df2.1717527933.git.mst@redhat.com> References: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: X-Mailer: git-send-email 2.27.0.106.g8ac3dc51b1 X-Mutt-Fcc: =sent Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Received-SPF: pass client-ip=170.10.129.124; envelope-from=mst@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.001, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1717528305140100006 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Fan Ni With the change, we extend the extent release mailbox command processing to allow more flexible release. As long as the DPA range of the extent to release is covered by accepted extent(s) in the device, the release can be performed. Tested-by: Svetly Todorov Reviewed-by: Gregory Price Signed-off-by: Fan Ni Message-Id: <20240523174651.1089554-14-nifan.cxl@gmail.com> Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/cxl/cxl-mailbox-utils.c | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/hw/cxl/cxl-mailbox-utils.c b/hw/cxl/cxl-mailbox-utils.c index c4852112fe..74eeb6fde7 100644 --- a/hw/cxl/cxl-mailbox-utils.c +++ b/hw/cxl/cxl-mailbox-utils.c @@ -1704,6 +1704,13 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLT= ype3Dev *ct3d, dpa =3D in->updated_entries[i].start_dpa; len =3D in->updated_entries[i].len; =20 + /* Check if the DPA range is not fully backed with valid extents */ + if (!ct3_test_region_block_backed(ct3d, dpa, len)) { + ret =3D CXL_MBOX_INVALID_PA; + goto free_and_exit; + } + + /* After this point, extent overflow is the only error can happen = */ while (len > 0) { QTAILQ_FOREACH(ent, updated_list, node) { range_init_nofail(&range, ent->start_dpa, ent->len); @@ -1718,14 +1725,7 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLT= ype3Dev *ct3d, if (range_contains(&range, dpa + len - 1)) { len2 =3D ent_start_dpa + ent_len - dpa - len; } else { - /* - * TODO: we reject the attempt to remove an extent - * that overlaps with multiple extents in the devi= ce - * for now. We will allow it once superset release - * support is added. - */ - ret =3D CXL_MBOX_INVALID_PA; - goto free_and_exit; + dpa =3D ent_start_dpa + ent_len; } len_done =3D ent_len - len1 - len2; =20 @@ -1752,14 +1752,9 @@ static CXLRetCode cxl_dc_extent_release_dry_run(CXLT= ype3Dev *ct3d, } =20 len -=3D len_done; - /* len =3D=3D 0 here until superset release is added */ break; } } - if (len) { - ret =3D CXL_MBOX_INVALID_PA; - goto free_and_exit; - } } } free_and_exit: --=20 MST