From patchwork Mon May 6 12:37:21 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 795015 Delivered-To: patch@linaro.org Received: by 2002:adf:a453:0:b0:34e:ceec:bfcd with SMTP id e19csp902273wra; Mon, 6 May 2024 05:41:36 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCX7rx1oY9DcnAF/rf4ytGA5+peZ0diSyKmdwysTUtLO86fAb5rcnlzpbua8tSKzJebhCrJQHiGbnuUVDJqjw/bQ X-Google-Smtp-Source: AGHT+IGm8m9vDpIHAKGhO6+g3vNtbmpwKSjwGofYMHZ3T8svfF5bGL3tGJO8DXFJ5Lntkf1PhxhU X-Received: by 2002:a05:620a:14bc:b0:792:9313:a65e with SMTP id x28-20020a05620a14bc00b007929313a65emr4194067qkj.46.1714999296213; Mon, 06 May 2024 05:41:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1714999296; cv=none; d=google.com; s=arc-20160816; b=q5SlVogLeZJ3ehtUn/AYyRRv0LnL8jurW6/QLM886StKAKhWeXKbXjikBuy73snYtK amWw3DuCJVtiAJneIVpcJhP07MZIzFmf2BILeSf2tVQO4cuDC/hKP+P1onKy73fpVXOP dI9Ob5RnAJsirzK2azOEtTJvgdF51uIGTPmnKJ+ZJ2vfiejUY0NabQOvhRWlNgHXZuCB 9vJyHv9jjojT1KgF+x9/ILAprxso2iVRQ9izLDZeKBBRCeGQ3o3DkcVot/V8jytHj4dG iuhAajdJPPB2B2/DpLb+iOE1zi7ZpX6ieG84S+0g2mH5ukSIliotpvPAKPndCNwgGwbF ORkA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=H4urpjGwVcUdPIyFtNL9dEzEEHSDiRFQ9VHY+BzuV2Y=; fh=t5ckFe1iifY1wq3g6za/3F2QK0Ucp01M/Pw5m9Xn0aU=; b=Ql5fQIJLjkHzNMCWbiQWC1jyZev7YOuQ4ygpiQagsKNpQLf9dPVHpZ3IAwto5WrHON DdgnVwcF65MBsIniHsFhXI3XH0oA1wgKp689/eoJ/21uTVTLAOqTgi+kS1cJWRgMu9hs wTkUU9RGNxPtTuWOxmUiKb2a6G5sGlv3/ENWH95XeMxUa9Dm9MfMw7OBCaFahOES8kQF hW8ITvvAbbb518tnwXOtm48Am1v63WAcQa6awiXMe/O89MwflAhCZbIPSRF8sGkd781q XkHaG2cr6iA6kWFM0oqc3ifWiUHqxQ2H3uNEPhxdMp6hReLRQxMiymgafP9I70Dz0cWa zT4w==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IVKtoWjq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id m21-20020a05620a215500b007929190b8c5si3824951qkm.713.2024.05.06.05.41.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 May 2024 05:41:36 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=IVKtoWjq; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1s3xdd-0001pw-8S; Mon, 06 May 2024 08:40:13 -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 1s3xdb-0001cS-A8 for qemu-devel@nongnu.org; Mon, 06 May 2024 08:40:11 -0400 Received: from mail-wm1-x32d.google.com ([2a00:1450:4864:20::32d]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1s3xdN-0002GC-33 for qemu-devel@nongnu.org; Mon, 06 May 2024 08:40:10 -0400 Received: by mail-wm1-x32d.google.com with SMTP id 5b1f17b1804b1-41ecffed96cso7453785e9.1 for ; Mon, 06 May 2024 05:39:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1714999195; x=1715603995; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=H4urpjGwVcUdPIyFtNL9dEzEEHSDiRFQ9VHY+BzuV2Y=; b=IVKtoWjqKtVktFcdAandzSSu+DFdycOSpfmuhQezv2PFoph5VPsV2SQ04GgDNRjjTq JWqjlJn79nnWxuEK/qyUXtDUuN9B4wDtTZYbo8zjVXZdya5sbYTGy58WcJOR0+8N0ATy np5MikktY13SNQLSY/XbMr9tHPYycNFikzNZEFfNe21KPQlbdrmg8kPNH7o3wIi6Xojc acAYDtziyJEbrdQFZxy2V5B9CI/LvviWx7w60+0XyIqZ9UoLVzGz9PyZ+k17+z9/CEy4 JTZ28IhPgw7N+qpWm0yABKasGheat43gfKk96dYDN6ZG2758138XWdq2W4CDJIhypZUT DgMw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1714999195; x=1715603995; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=H4urpjGwVcUdPIyFtNL9dEzEEHSDiRFQ9VHY+BzuV2Y=; b=Bdua9xNPbyYIlMkf0AgRd3oNwO4SlCr7LmoKgx49SJ/IlXGWdFTDBNxYef0f8F4zgi JG3i2sFqCtm3cyspRe7VNR7p++cSP+JvNOIOQAFdPfiJag8knadNknrd8/m+ail14iam Qm1p6CUy12oG9wAAPS02KhfaUjDmNgku2f/gFKDGyo2nLrtoelo6CPdKvXCjI3IJW5Az 7gnnZ8N37UWIVG1qrMIpe0PqH7WwcBjZal0tec1NS+EIZWrNJ6RDWUNP8O10URqlAHof pwUe4Wnc8KYubM3/HMIr5GZKLFsGhBIV2+rmWisaZnXnY/+jLi8ASVEhPI9zb/GWnVgq D9dA== X-Gm-Message-State: AOJu0YwDGob71BkwlkPRndC4ujPm+xItM6NdvVNtRAAxXVEzXFK8HlvZ zqc5EWf1GDYsKgYoMQs79varLRMQBB4WrmeFCh+hngo+PmKv1MU0RCYVQc5sqVaBQ4DYNKdeLnk X X-Received: by 2002:adf:f0cd:0:b0:34d:7cdf:7fb3 with SMTP id x13-20020adff0cd000000b0034d7cdf7fb3mr7038544wro.62.1714999195378; Mon, 06 May 2024 05:39:55 -0700 (PDT) Received: from m1x-phil.lan ([176.187.211.4]) by smtp.gmail.com with ESMTPSA id b12-20020a5d4d8c000000b0034e65b8b43fsm8616106wru.8.2024.05.06.05.39.54 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Mon, 06 May 2024 05:39:54 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , Stefano Stabellini , =?utf-8?q?Philippe_Mathieu-Dau?= =?utf-8?q?d=C3=A9?= Subject: [PULL 21/28] xen: mapcache: Break out xen_ram_addr_from_mapcache_single Date: Mon, 6 May 2024 14:37:21 +0200 Message-ID: <20240506123728.65278-22-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240506123728.65278-1-philmd@linaro.org> References: <20240506123728.65278-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::32d; envelope-from=philmd@linaro.org; helo=mail-wm1-x32d.google.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, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: "Edgar E. Iglesias" Break out xen_ram_addr_from_mapcache_single(), a multi-cache aware version of xen_ram_addr_from_mapcache. No functional changes. Signed-off-by: Edgar E. Iglesias Reviewed-by: Stefano Stabellini Reviewed-by: Philippe Mathieu-Daudé Message-ID: <20240430164939.925307-7-edgar.iglesias@gmail.com> Signed-off-by: Philippe Mathieu-Daudé --- hw/xen/xen-mapcache.c | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/hw/xen/xen-mapcache.c b/hw/xen/xen-mapcache.c index 6bb3e0b362..1927334e9f 100644 --- a/hw/xen/xen-mapcache.c +++ b/hw/xen/xen-mapcache.c @@ -377,7 +377,7 @@ uint8_t *xen_map_cache(hwaddr phys_addr, hwaddr size, return p; } -ram_addr_t xen_ram_addr_from_mapcache(void *ptr) +static ram_addr_t xen_ram_addr_from_mapcache_single(MapCache *mc, void *ptr) { MapCacheEntry *entry = NULL; MapCacheRev *reventry; @@ -386,8 +386,8 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) ram_addr_t raddr; int found = 0; - mapcache_lock(mapcache); - QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) { + mapcache_lock(mc); + QTAILQ_FOREACH(reventry, &mc->locked_entries, next) { if (reventry->vaddr_req == ptr) { paddr_index = reventry->paddr_index; size = reventry->size; @@ -397,11 +397,11 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) } if (!found) { trace_xen_ram_addr_from_mapcache_not_found(ptr); - mapcache_unlock(mapcache); + mapcache_unlock(mc); return RAM_ADDR_INVALID; } - entry = &mapcache->entry[paddr_index % mapcache->nr_buckets]; + entry = &mc->entry[paddr_index % mc->nr_buckets]; while (entry && (entry->paddr_index != paddr_index || entry->size != size)) { entry = entry->next; } @@ -412,10 +412,15 @@ ram_addr_t xen_ram_addr_from_mapcache(void *ptr) raddr = (reventry->paddr_index << MCACHE_BUCKET_SHIFT) + ((unsigned long) ptr - (unsigned long) entry->vaddr_base); } - mapcache_unlock(mapcache); + mapcache_unlock(mc); return raddr; } +ram_addr_t xen_ram_addr_from_mapcache(void *ptr) +{ + return xen_ram_addr_from_mapcache_single(mapcache, ptr); +} + static void xen_invalidate_map_cache_entry_unlocked(uint8_t *buffer) { MapCacheEntry *entry = NULL, *pentry = NULL;