From patchwork Thu Apr 18 20:02:04 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Tokarev X-Patchwork-Id: 789855 Delivered-To: patch@linaro.org Received: by 2002:adf:e6ca:0:b0:346:15ad:a2a with SMTP id y10csp747227wrm; Thu, 18 Apr 2024 13:03:41 -0700 (PDT) X-Forwarded-Encrypted: i=2; AJvYcCV7Mx4j3wQzMzmvCqpvtFmoRo1nE7Pj8SdvmOiKjt3xg0yhzfseqYKGcl03Qqnod0qluidtZIFDjkVqYIkBxW/Z X-Google-Smtp-Source: AGHT+IGqVdeNeTjJ8i1sbh73gPQ+xj9wdDjeD768HihaXg1b6xDJPuVn7CIMAwSAWAHRzp3ca5Pg X-Received: by 2002:a05:6122:1825:b0:4d4:ef9:71b0 with SMTP id ay37-20020a056122182500b004d40ef971b0mr4348999vkb.7.1713470621723; Thu, 18 Apr 2024 13:03:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1713470621; cv=none; d=google.com; s=arc-20160816; b=PSdnLKm9aPKpTVgHLcQr1kUas0sle+KIWBl/nLxlzqTcnbubH6Ogrz/g/3keZpqfFw SWKyD6AJ/aGIK2HRS358GTx4pqd0HO9LhZsTG/I5aotcIpRTJnooWi50PJg+qbVFUnGM qWOCzqviC/Yt3ZpZj7Q1Txln1FbDPpA6Zbtk/sIv9hUcjZGmnf7tDp1LxqAwj0Danznm z7KeKTkwZM7bpKEqadAKSpJizulEeZqoG9Y6NsVqtxsLQ5Ozovo3Nlr58yr3MLmYjZ3k WNxAyUEuKj8sLXWbRuEB59I0n9TQo3u2c7AVnbzQiKIagBKlDRoZcdqaSzRbFTvWZjj0 2cYA== 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; bh=8cU0FLgU3hT/CvkzFHg80l8uR0pf1fRdgLt0JUXYiIY=; fh=PkL0BgRfEM9eqzQkbTyhz2VibunL6e7EEQCkTtdX0i8=; b=ZkI9P59jZrQTGj+aqsKCPZS1ozoly1Ol5k5k0Bc/xiVhGmwoAqi28POrxq39iiO9iA v4QlnJTyLHGDLaLSO+FSULjvVVcB3jOnh8m9bd+bUAa/FpycttW4eenr8BbMSLsVHDYZ f8bfPVihNB/ykL5gMGcH/VLYGsZjdJf2ZFqxenmbkg16p+kt0Xy+AD+PtTgJ0wSTEqTC b09oyFQtX/1zFgsSZcpdqkg2a0w0vqSMc1MuavKRkilTQT3FbUR1AonlnBGNFVV0AZLM VU06jzaB6YCEHCpJVZy/anJMub56jLIUQl4w3eo+bS5L/QTj7qA58A+JOhSZBt3A8urK Z4IA==; dara=google.com ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id s14-20020a056102370e00b0047b928fda45si597403vst.728.2024.04.18.13.03.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Thu, 18 Apr 2024 13:03:41 -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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1rxXyL-0001Zf-Fe; Thu, 18 Apr 2024 16:03:07 -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 1rxXxr-0001Uu-6r; Thu, 18 Apr 2024 16:02:35 -0400 Received: from isrv.corpit.ru ([86.62.121.231]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1rxXxp-0005GY-4X; Thu, 18 Apr 2024 16:02:34 -0400 Received: from tsrv.corpit.ru (tsrv.tls.msk.ru [192.168.177.2]) by isrv.corpit.ru (Postfix) with ESMTP id 56DFB5FE0B; Thu, 18 Apr 2024 23:02:27 +0300 (MSK) Received: from tls.msk.ru (mjt.wg.tls.msk.ru [192.168.177.130]) by tsrv.corpit.ru (Postfix) with SMTP id B6C8CB93F1; Thu, 18 Apr 2024 23:02:24 +0300 (MSK) Received: (nullmailer pid 952848 invoked by uid 1000); Thu, 18 Apr 2024 20:02:24 -0000 From: Michael Tokarev To: qemu-devel@nongnu.org Cc: qemu-stable@nongnu.org, =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= , Gerd Hoffmann , "Michael S . Tsirkin" , Michael Tokarev Subject: [Stable-7.2.11 44/59] hw/virtio: Introduce virtio_bh_new_guarded() helper Date: Thu, 18 Apr 2024 23:02:04 +0300 Message-Id: <20240418200224.952785-3-mjt@tls.msk.ru> X-Mailer: git-send-email 2.39.2 In-Reply-To: References: MIME-Version: 1.0 Received-SPF: pass client-ip=86.62.121.231; envelope-from=mjt@tls.msk.ru; helo=isrv.corpit.ru X-Spam_score_int: -68 X-Spam_score: -6.9 X-Spam_bar: ------ X-Spam_report: (-6.9 / 5.0 requ) BAYES_00=-1.9, RCVD_IN_DNSWL_HI=-5, 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: Philippe Mathieu-Daudé 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é Reviewed-by: Michael S. Tsirkin Message-Id: <20240409105537.18308-2-philmd@linaro.org> (cherry picked from commit ec0504b989ca61e03636384d3602b7bf07ffe4da) Signed-off-by: Michael Tokarev (Mjt: trivial #include context fixup in include/hw/virtio/virtio.h) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index e4f8ed1e63..4a35d7cb0c 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -5029,3 +5029,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); +} diff --git a/include/hw/virtio/virtio.h b/include/hw/virtio/virtio.h index 96a56430a6..c1a7c9bd3b 100644 --- a/include/hw/virtio/virtio.h +++ b/include/hw/virtio/virtio.h @@ -23,6 +23,7 @@ #include "standard-headers/linux/virtio_ring.h" #include "qom/object.h" #include "hw/virtio/vhost.h" +#include "block/aio.h" /* * A guest should never accept this. It implies negotiation is broken @@ -463,4 +464,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