From nobody Mon Feb 9 09:22:30 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.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; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1563666514; cv=none; d=zoho.com; s=zohoarc; b=kgCJtF4qnMfGNzteKHHoCTTdfq9DjFr90rEIT/cICPc/bb5TrJhNT2p8Ank572WqEkJsdcEd2RbulsvLhoe5ZLAvsDeKhm36doMeFe1nHwUxdx3zQyUFdreLGfxtiC3BabEGRMIl9n1txOjHmxA5LbE4/eEnfSS2itdmUtSghbg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1563666514; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=YfW1aH+Wpw10vSj+L0zxMi7E9GI7IXk5GtJx8ieye+k=; b=PmAIv1lRvi/N9G3aNZhhfZd8KQMU8S8wfCXospZkf7wbpvKuppHyQSMJHKHjq6CB7Z5IzxeqOKtUte78jSs1JvAyZ8JS0k95SgIHHxr/GcTZwdc4nzpo4j+zT3G1B7jvSObAolLf0IuuRRjmLCui3XGglwZhtgiZvCEnASbhRCY= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (209.51.188.17 [209.51.188.17]) by mx.zohomail.com with SMTPS id 1563666514128716.1758958753443; Sat, 20 Jul 2019 16:48:34 -0700 (PDT) Received: from localhost ([::1]:53942 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoz5Y-0004Wr-9z for importer@patchew.org; Sat, 20 Jul 2019 19:48:28 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:35460) by lists.gnu.org with esmtp (Exim 4.86_2) (envelope-from ) id 1hoz5H-0003eB-S2 for qemu-devel@nongnu.org; Sat, 20 Jul 2019 19:48:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hoz5G-0002we-SB for qemu-devel@nongnu.org; Sat, 20 Jul 2019 19:48:11 -0400 Received: from mail-pl1-x644.google.com ([2607:f8b0:4864:20::644]:41243) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hoz5G-0002vd-Lw for qemu-devel@nongnu.org; Sat, 20 Jul 2019 19:48:10 -0400 Received: by mail-pl1-x644.google.com with SMTP id m9so17288751pls.8 for ; Sat, 20 Jul 2019 16:48:10 -0700 (PDT) Received: from beta.cse.iitb.ac.in ([2405:204:20e:f16f:2a5b:d596:9ab:8e05]) by smtp.gmail.com with ESMTPSA id b6sm31229151pgq.26.2019.07.20.16.48.06 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sat, 20 Jul 2019 16:48:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YfW1aH+Wpw10vSj+L0zxMi7E9GI7IXk5GtJx8ieye+k=; b=cYh9rdYJVQF9qlBb+UYRb4LF9xub5bGioGf3vFC4vh4ZzNUTiYGeoHKXOm2jexX5pz H3sZOLnVeSI9UVlXZJahQyfNep3BGpTvJuih5YdELTXYKU3z5QBSbrm+l9XMrA+jJZee ooCX8dwI6klYkhmZDHEMg4k6erUlddRGrPrdxAHF5mf7OUeVg6nWaTs5Gw22mGBxxmpu ZXbDjUgvSmvTHF79VtJqPEut2GFcOHEqL9Q/xRcFDykBTL38yAj9cboLy+AEaU0X5eZc ztBtaEPlrLQRfHx1d7etfQl1ou8R4Larrw4tl72/tMhfuCEVx+8c7JN7bN/wccrpeswZ VaVA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YfW1aH+Wpw10vSj+L0zxMi7E9GI7IXk5GtJx8ieye+k=; b=mHuXq0/EhOLmvGottslKCbGDbY+GNUULhddp831rGkFf8nM4KyEoR/OgoYHYN1f+jM 46Nt0szmLW78MVsWk57zG9n/HALeMpixj46m5um6NzD8X5OCLMkOvc6hyDj0m473HF8p 2jjGjmoHYtS3ZV5WXP5U1gEr3VYZ0Jjz0hxRjYE4IoEoAzxy1FlLIEUFjygzhkCnJ3iP VmikhfQHoVpwZ0colsk42Z/5T1f0vG0snzhN+g7P8DOJUr/Sx4/USoB5+88+yRYjKe4z K82aDljRZdmLXKi5xc6zIZX7PADWQsRuql47Cb6wIHiiC+Gk7LgppLV6kUaJ1BE94QMX q3nQ== X-Gm-Message-State: APjAAAWen5ULaNe3gdFhzH1FOqKkAeLPcTFedoCf/FMEBMjolZBlX5dT c9BHiHbyyhZ/Djh8ZjfkJL4FDO/N X-Google-Smtp-Source: APXvYqwOrfgQg8AI3I1OzcLDcPrbV5MoptZ4cy7hbLjQ/JH4+5Qti3dzGvOEgCW+FEseUIXJWCPQGQ== X-Received: by 2002:a17:902:7448:: with SMTP id e8mr66062080plt.85.1563666489452; Sat, 20 Jul 2019 16:48:09 -0700 (PDT) From: Sukrit Bhatnagar To: qemu-devel@nongnu.org Date: Sun, 21 Jul 2019 05:18:02 +0530 Message-Id: <20190720234803.18938-2-skrtbhtngr@gmail.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20190720234803.18938-1-skrtbhtngr@gmail.com> References: <20190720234803.18938-1-skrtbhtngr@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:4864:20::644 Subject: [Qemu-devel] [RFC v3 1/2] hw/pvrdma: make DSR mapping idempotent in load_dsr() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Yuval Shaia Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Map to DSR only when there is no mapping done already i.e., when dev->dsr_info.dsr is NULL. This allows the rest of mappings and ring inits to be done by calling load_dsr() when DSR has already been mapped to, somewhere else. Move free_dsr() out of load_dsr() and call it before the latter as and when needed. This aids the case where load_dsr() is called having DSR mapping already done, but the rest of map and init operations are pending, and prevents an unmap of the DSR. Cc: Marcel Apfelbaum Cc: Yuval Shaia Signed-off-by: Sukrit Bhatnagar --- hw/rdma/vmw/pvrdma_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/hw/rdma/vmw/pvrdma_main.c b/hw/rdma/vmw/pvrdma_main.c index adcf79cd63..6c90db96f9 100644 --- a/hw/rdma/vmw/pvrdma_main.c +++ b/hw/rdma/vmw/pvrdma_main.c @@ -172,15 +172,15 @@ static int load_dsr(PVRDMADev *dev) DSRInfo *dsr_info; struct pvrdma_device_shared_region *dsr; =20 - free_dsr(dev); - - /* Map to DSR */ - dev->dsr_info.dsr =3D rdma_pci_dma_map(pci_dev, dev->dsr_info.dma, - sizeof(struct pvrdma_device_shared_region)); if (!dev->dsr_info.dsr) { - rdma_error_report("Failed to map to DSR"); - rc =3D -ENOMEM; - goto out; + /* Map to DSR */ + dev->dsr_info.dsr =3D rdma_pci_dma_map(pci_dev, dev->dsr_info.dma, + sizeof(struct pvrdma_device_shared_regio= n)); + if (!dev->dsr_info.dsr) { + rdma_error_report("Failed to map to DSR"); + rc =3D -ENOMEM; + goto out; + } } =20 /* Shortcuts */ @@ -402,6 +402,7 @@ static void pvrdma_regs_write(void *opaque, hwaddr addr= , uint64_t val, case PVRDMA_REG_DSRHIGH: trace_pvrdma_regs_write(addr, val, "DSRHIGH", ""); dev->dsr_info.dma |=3D val << 32; + free_dsr(dev); load_dsr(dev); init_dsr_dev_caps(dev); break; --=20 2.21.0