From patchwork Tue Apr 9 10:55:34 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: 1921341 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=linaro.org header.i=@linaro.org header.a=rsa-sha256 header.s=google header.b=hai15fzD; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=patchwork.ozlabs.org) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4VDNDb4rQWz1yYd for ; Tue, 9 Apr 2024 20:56:15 +1000 (AEST) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1ru98p-0001N9-8o; Tue, 09 Apr 2024 06:55:51 -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 1ru98o-0001N0-HM for qemu-devel@nongnu.org; Tue, 09 Apr 2024 06:55:50 -0400 Received: from mail-lj1-x235.google.com ([2a00:1450:4864:20::235]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1ru98m-000355-RC for qemu-devel@nongnu.org; Tue, 09 Apr 2024 06:55:50 -0400 Received: by mail-lj1-x235.google.com with SMTP id 38308e7fff4ca-2d89346eb45so24329611fa.0 for ; Tue, 09 Apr 2024 03:55:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1712660146; x=1713264946; 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=3F/dkK0NgSzUFlZfqjm2SxtzBV4mhAilLiKtDZ6AMsk=; b=hai15fzDVniOa31ue0+WEPkcMx9keI8SAjNL3OMzI+jkzMW+8xJQ0m758TYrgBoub/ L7uoRgQMZKpeJ5wIwHaAE4uIBTmZzhFdBnzMRXF7fibkPNBO1wYVitzyueGyLP/6qiqO itNhZoUsNFfF3Gmzprd/s5YW7Rsv1LeF+DonuzwUd0bL6Glw35Pk6VVXu/ugi5mWhp+S 2hqussnqytvthybZ4DdW335DVe6vshzeykyw+N558wws3GUO0HpC7j9G+gj09D5OT1x8 c/vym+s+/b/RfSxwUdZMeKLlD3UzOGApas9YQFB8N3XMxQNfMbRA2kjEkUa8P3Nb3RVe W0ug== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712660146; x=1713264946; 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=3F/dkK0NgSzUFlZfqjm2SxtzBV4mhAilLiKtDZ6AMsk=; b=p4kMh429ibtafQTSHZDwqGupozhN81mF1Y45Cn8KpnWZ/Fuk0EHPWOtKW/6i15pAZ+ 0ES9pkENI48X2ZuA9YPzJY8YOX850vO/AQP1BPx10WFw89B+X0y6PvO/V3dem6+o2szd /Wl9Hm1rjudaumDB9cAgHRpip1PTuc2xqu7Fi0MwbbKXFs/2ILaIedMurVQ/LGn9CMYn 81PVlf40NJ2ZHU+wgIq9pI+pzpeVPCtwKqIU5Uw3J522aOdu+Fc/RXnM9WsYLGwkBe8N noJEA6FICy73FYvU4ZQoyF8Wl7a6ALW+tSAliGCvN3+bEmIrDHtfZ4VCNTEH5UiKZD22 d+pg== X-Gm-Message-State: AOJu0YxG/0zabUhqkSyF9D6zQybnuUcB2V77tHelj2NyzWaTc9sMS93k jbeNE9jNPuAhdC3IfsPBRZfnaH72oNnOI95Pb/NXCeTk6M3gSWj1JdF62F+Tu3cqX9IS08ZHkAR U X-Google-Smtp-Source: AGHT+IFv9lNv8ryZ8e0xrwprGE2PTFnQGFV/WKkA2sdjC4x+HQINVm5kvRblbB0Nb/FQaQZnjAm/QQ== X-Received: by 2002:a2e:924b:0:b0:2d8:5b34:b9ab with SMTP id v11-20020a2e924b000000b002d85b34b9abmr9692442ljg.34.1712660146429; Tue, 09 Apr 2024 03:55:46 -0700 (PDT) Received: from m1x-phil.lan ([176.176.160.134]) by smtp.gmail.com with ESMTPSA id el4-20020a170907284400b00a51b3410e46sm4525826ejc.7.2024.04.09.03.55.45 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Tue, 09 Apr 2024 03:55:46 -0700 (PDT) From: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Amit Shah , Paolo Bonzini , "Gonglei (Arei)" , Laurent Vivier , Gerd Hoffmann , "Michael S. Tsirkin" , =?utf-8?q?Marc-Andr=C3=A9_Lureau?= , =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= Subject: [PATCH-for-9.0 v2 1/4] hw/virtio: Introduce virtio_bh_new_guarded() helper Date: Tue, 9 Apr 2024 12:55:34 +0200 Message-ID: <20240409105537.18308-2-philmd@linaro.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20240409105537.18308-1-philmd@linaro.org> References: <20240409105537.18308-1-philmd@linaro.org> MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::235; envelope-from=philmd@linaro.org; helo=mail-lj1-x235.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 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+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Introduce virtio_bh_new_guarded(), similar to qemu_bh_new_guarded() but using the transport memory guard, instead of the device one (there can only be one virtio device per virtio bus). Inspired-by: Gerd Hoffmann Reviewed-by: Gerd Hoffmann Acked-by: Michael S. Tsirkin Signed-off-by: Philippe Mathieu-Daudé --- include/hw/virtio/virtio.h | 7 +++++++ hw/virtio/virtio.c | 10 ++++++++++ 2 files changed, 17 insertions(+) diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index b3c74a1bca..a4388c7db3 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -22,6 +22,7 @@ #include "standard-headers/linux/virtio_config.h" #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" +#include "block/aio.h" /* * A guest should never accept this. It implies negotiation is broken @@ -527,4 +528,10 @@ static inline bool virtio_device_disabled(VirtIODevice *vdev) bool virtio_legacy_allowed(VirtIODevice *vdev); bool virtio_legacy_check_disabled(VirtIODevice *vdev); +QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name); +#define virtio_bh_new_guarded(dev, cb, opaque) \ + virtio_bh_new_guarded_full((dev), (cb), (opaque), (stringify(cb))) + #endif diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index fb6b4ccd83..efe02deb77 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -4176,3 +4176,13 @@ static void virtio_register_types(void) } type_init(virtio_register_types) + +QEMUBH *virtio_bh_new_guarded_full(DeviceState *dev, + QEMUBHFunc *cb, void *opaque, + const char *name) +{ + DeviceState *transport = qdev_get_parent_bus(dev)->parent; + + return qemu_bh_new_full(cb, opaque, name, + &transport->mem_reentrancy_guard); +}