From patchwork Mon Jul 17 12:47:46 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 703721 Delivered-To: patch@linaro.org Received: by 2002:a5d:4e4d:0:b0:314:25da:8dc4 with SMTP id r13csp981106wrt; Mon, 17 Jul 2023 05:56:33 -0700 (PDT) X-Google-Smtp-Source: APBJJlFYEvgWbqI8lkZvQ0jyAPC+wFIUtxW0vFprPbQHiOJ8uao0R3l6sfIlsHQuuD3J9AEogciK X-Received: by 2002:ac8:4e94:0:b0:403:b88d:1e60 with SMTP id 20-20020ac84e94000000b00403b88d1e60mr18290249qtp.51.1689598593460; Mon, 17 Jul 2023 05:56:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689598593; cv=none; d=google.com; s=arc-20160816; b=jnbi0orE5rlszr4uhYHIyp8nOuzSnoXv4taKc/ra3Cb6+8FNlFAQVJhYDrK0a7hjjB ALpc7uZflwbPjEG3FGlNNESSpArM3FghUZUux907u4R9Ai6Py06t3nYZurQm26ZLGIEg N9gRBRimLcCXAK6HSgLuhxPxZPg2/kYEC/Cyq7RAc9/0nxCm3LvMTVruBgbLAusZhU9K h29xdjN9G4fV4jhFhJPwe5cE+t7s8n1l5z+nEGyANnelX6yz8h75omfXUSUvB71T872D YaevnKwfGEovHpw6NQY1UhOZXufJId2pXjLfwVGM3AS2jKMf+IPDRuIJyx0/BgW6DXAG vGZw== 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:to:from :dkim-signature; bh=fm7KSG5NrB8kIIZoFYKUbYE9OkMwBur5haFqwy0lLuU=; fh=bFDrUYhlTVi/QyetgXx/byg2+yO/22Hp9SjwoefyKLk=; b=p5f+qPtXPknEmBqDZhn7DoaLwoFUpfXLVQvX7MWyISj5gmRfLRaTmyWSVAcQ5rv9Xj jkuoKQyk8j3jrAXCJC+zoJgzO7G7dH0Cx1u4LJvlP0lyLYzII3ynFjBbN5VKmk+/MwE6 2Das6pNQ0FoYUpjRce8e1IWA4rNbsABQNphqgAErbN2EmChXwyJ382hAlR8+c00DUW4r oDx64XXzzgT96JlNLFNotCGhE5Ch4D+ni++yp+A7/FHstZkZaXUe/XhQOw9wX0TQuqWM 8wg22hZMS4kmUMlGZTovENjScYmBnwpMU2Mgm9OdvgU1TLYOGEQqlNhJBc/KoO+oL0Jl I27A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LBJBrnKH; 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 c4-20020ac85a84000000b00403c2d440e3si6972499qtc.535.2023.07.17.05.56.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 17 Jul 2023 05:56:33 -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=LBJBrnKH; 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 1qLNgp-0002Wx-9o; Mon, 17 Jul 2023 08:50:59 -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 1qLNdu-0008Th-94 for qemu-devel@nongnu.org; Mon, 17 Jul 2023 08:48:03 -0400 Received: from mail-wr1-x430.google.com ([2a00:1450:4864:20::430]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1qLNdp-0008TZ-Nh for qemu-devel@nongnu.org; Mon, 17 Jul 2023 08:47:57 -0400 Received: by mail-wr1-x430.google.com with SMTP id ffacd0b85a97d-31590e4e27aso4023989f8f.1 for ; Mon, 17 Jul 2023 05:47:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1689598071; x=1692190071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=fm7KSG5NrB8kIIZoFYKUbYE9OkMwBur5haFqwy0lLuU=; b=LBJBrnKHnBJ7Jkw/hZ3RoZkFVs/VVlV7w4myj8JMR/OTdeBvq0DGXU5/EPp41o3moW w/nYN3onsfgiCWPhIJ018C5usmnrjOf1O25YZMl1nyFp7Ug1wLxLm2V3i3geehqmIxt1 3xmjFWZgq5pmXjK+xH/dh0XcWNgU3KEMSvdpchZFMm1TXBUD+/XgRbV9P0Nk194K9us6 Uh97KEkYdQM3ujjIj8bMAzsfwADv7Z/vtJ5BvQjFyhY77ND5U4RtYjyRjbSK3g9MABM3 mFp4XWU0nHCYKLqNaMByINTbMkH9+bG4kn1iMLO2f53uZzfMaLlRkqxxiJDlTdDqhvRM HrnQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689598071; x=1692190071; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=fm7KSG5NrB8kIIZoFYKUbYE9OkMwBur5haFqwy0lLuU=; b=GLGWefEueG6SVPtl+vHQHZCeFlmN6OZb7Ev4O+jqMKFbdkJvQ3J2ITouueDhBpzfpF WyzYo3HbBQSEp6ct2cergfZHMT0ylwqCT0u+1wCyiSQ6An6XvLJ/UiRX7RQuyCxkjgPr xV5xJ4I9S6eUc2cHMC8r7ioIm+K+kam4aw0B2+1X5y6DxL3Y2/+rLt8bbVKV/EiY2OFT uvqEVMFNqSOAtZJyaVNKAIxtuuoGDgnT7LT3CocFmMB5tj2JQxPcz4ttNVwDasgbMZ1y 4eBJjZGZYc23aenQ89PKw4lhFfEanlCpAQrOzDjxp0qx3iTKGtHYJkdMVVOHQoL2p1WY 96ig== X-Gm-Message-State: ABy/qLbb8Uxis9d1hXkVH/c2P356pl9n4U1xKbgrJtfpCEDUdYmJ2IVe Z2BKKngSJtFUS3TVxgZMYCajDXQ5f+OFOGVl8po= X-Received: by 2002:adf:d4c4:0:b0:313:e953:65d0 with SMTP id w4-20020adfd4c4000000b00313e95365d0mr9147896wrk.28.1689598070913; Mon, 17 Jul 2023 05:47:50 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id v16-20020a5d6790000000b003112ab916cdsm19337737wru.73.2023.07.17.05.47.50 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Jul 2023 05:47:50 -0700 (PDT) From: Peter Maydell To: qemu-devel@nongnu.org Subject: [PULL 7/7] hw/nvram: Avoid unnecessary Xilinx eFuse backstore write Date: Mon, 17 Jul 2023 13:47:46 +0100 Message-Id: <20230717124746.759085-8-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230717124746.759085-1-peter.maydell@linaro.org> References: <20230717124746.759085-1-peter.maydell@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::430; envelope-from=peter.maydell@linaro.org; helo=mail-wr1-x430.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, RCVD_IN_DNSWL_NONE=-0.0001, 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org From: Tong Ho Add a check in the bit-set operation to write the backstore only if the affected bit is 0 before. With this in place, there will be no need for callers to do the checking in order to avoid unnecessary writes. Signed-off-by: Tong Ho Reviewed-by: Alistair Francis Reviewed-by: Francisco Iglesias Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Peter Maydell --- hw/nvram/xlnx-efuse.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/hw/nvram/xlnx-efuse.c b/hw/nvram/xlnx-efuse.c index fdfffaab99c..655c40b8d1e 100644 --- a/hw/nvram/xlnx-efuse.c +++ b/hw/nvram/xlnx-efuse.c @@ -143,6 +143,8 @@ static bool efuse_ro_bits_find(XlnxEFuse *s, uint32_t k) bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) { + uint32_t set, *row; + if (efuse_ro_bits_find(s, bit)) { g_autofree char *path = object_get_canonical_path(OBJECT(s)); @@ -152,8 +154,13 @@ bool xlnx_efuse_set_bit(XlnxEFuse *s, unsigned int bit) return false; } - s->fuse32[bit / 32] |= 1 << (bit % 32); - efuse_bdrv_sync(s, bit); + /* Avoid back-end write unless there is a real update */ + row = &s->fuse32[bit / 32]; + set = 1 << (bit % 32); + if (!(set & *row)) { + *row |= set; + efuse_bdrv_sync(s, bit); + } return true; }