get:
Show a patch.

patch:
Update a patch.

put:
Update a patch.

GET /api/patches/2217314/?format=api
HTTP 200 OK
Allow: GET, PUT, PATCH, HEAD, OPTIONS
Content-Type: application/json
Vary: Accept

{
    "id": 2217314,
    "url": "http://patchwork.ozlabs.org/api/patches/2217314/?format=api",
    "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260327212547.460420-16-pbonzini@redhat.com/",
    "project": {
        "id": 14,
        "url": "http://patchwork.ozlabs.org/api/projects/14/?format=api",
        "name": "QEMU Development",
        "link_name": "qemu-devel",
        "list_id": "qemu-devel.nongnu.org",
        "list_email": "qemu-devel@nongnu.org",
        "web_url": "",
        "scm_url": "",
        "webscm_url": "",
        "list_archive_url": "",
        "list_archive_url_format": "",
        "commit_url_format": ""
    },
    "msgid": "<20260327212547.460420-16-pbonzini@redhat.com>",
    "list_archive_url": null,
    "date": "2026-03-27T21:25:46",
    "name": "[15/16] ncr710: copy reference counting fixes over from lsi53c895a",
    "commit_ref": null,
    "pull_url": null,
    "state": "new",
    "archived": false,
    "hash": "bd452beb80fd20318d2f675b5a7efbaa1ac84b15",
    "submitter": {
        "id": 2701,
        "url": "http://patchwork.ozlabs.org/api/people/2701/?format=api",
        "name": "Paolo Bonzini",
        "email": "pbonzini@redhat.com"
    },
    "delegate": null,
    "mbox": "http://patchwork.ozlabs.org/project/qemu-devel/patch/20260327212547.460420-16-pbonzini@redhat.com/mbox/",
    "series": [
        {
            "id": 497830,
            "url": "http://patchwork.ozlabs.org/api/series/497830/?format=api",
            "web_url": "http://patchwork.ozlabs.org/project/qemu-devel/list/?series=497830",
            "date": "2026-03-27T21:25:35",
            "name": "Reentrancy fixes for lsi53c895a, and cleanups to ncr710",
            "version": 1,
            "mbox": "http://patchwork.ozlabs.org/series/497830/mbox/"
        }
    ],
    "comments": "http://patchwork.ozlabs.org/api/patches/2217314/comments/",
    "check": "pending",
    "checks": "http://patchwork.ozlabs.org/api/patches/2217314/checks/",
    "tags": {},
    "related": [],
    "headers": {
        "Return-Path": "<qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org>",
        "X-Original-To": "incoming@patchwork.ozlabs.org",
        "Delivered-To": "patchwork-incoming@legolas.ozlabs.org",
        "Authentication-Results": [
            "legolas.ozlabs.org;\n\tdkim=pass (1024-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=mimecast20190719 header.b=WkN5nqro;\n\tdkim=pass (2048-bit key;\n unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256\n header.s=google header.b=G2LLFIsQ;\n\tdkim-atps=neutral",
            "legolas.ozlabs.org;\n spf=pass (sender SPF authorized) smtp.mailfrom=nongnu.org\n (client-ip=209.51.188.17; helo=lists.gnu.org;\n envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org;\n receiver=patchwork.ozlabs.org)"
        ],
        "Received": [
            "from lists.gnu.org (lists.gnu.org [209.51.188.17])\n\t(using TLSv1.2 with cipher ECDHE-ECDSA-AES256-GCM-SHA384 (256/256 bits))\n\t(No client certificate requested)\n\tby legolas.ozlabs.org (Postfix) with ESMTPS id 4fjDJt5K0tz1y1x\n\tfor <incoming@patchwork.ozlabs.org>; Sat, 28 Mar 2026 08:28:14 +1100 (AEDT)",
            "from localhost ([::1] helo=lists1p.gnu.org)\n\tby lists.gnu.org with esmtp (Exim 4.90_1)\n\t(envelope-from <qemu-devel-bounces@nongnu.org>)\n\tid 1w6EiR-0006jf-GN; Fri, 27 Mar 2026 17:27:39 -0400",
            "from eggs.gnu.org ([2001:470:142:3::10])\n by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pbonzini@redhat.com>)\n id 1w6EiP-0006Sg-CV\n for qemu-devel@nongnu.org; Fri, 27 Mar 2026 17:27:37 -0400",
            "from us-smtp-delivery-124.mimecast.com ([170.10.133.124])\n by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256)\n (Exim 4.90_1) (envelope-from <pbonzini@redhat.com>)\n id 1w6EiN-0003rI-Ho\n for qemu-devel@nongnu.org; Fri, 27 Mar 2026 17:27:37 -0400",
            "from mail-wm1-f72.google.com (mail-wm1-f72.google.com\n [209.85.128.72]) by relay.mimecast.com with ESMTP with STARTTLS\n (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id\n us-mta-230-cps7H3i9MPSJMSaccNPM_Q-1; Fri, 27 Mar 2026 17:27:32 -0400",
            "by mail-wm1-f72.google.com with SMTP id\n 5b1f17b1804b1-486fcc05b20so17776225e9.3\n for <qemu-devel@nongnu.org>; Fri, 27 Mar 2026 14:27:32 -0700 (PDT)",
            "from [192.168.10.48] ([151.49.85.67])\n by smtp.gmail.com with ESMTPSA id\n 5b1f17b1804b1-48722c9506dsm112708875e9.7.2026.03.27.14.27.21\n (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n Fri, 27 Mar 2026 14:27:21 -0700 (PDT)"
        ],
        "DKIM-Signature": [
            "v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com;\n s=mimecast20190719; t=1774646855;\n h=from:from:reply-to:subject:subject:date:date:message-id:message-id:\n to:to:cc:cc:mime-version:mime-version:\n content-transfer-encoding:content-transfer-encoding:\n in-reply-to:in-reply-to:references:references;\n bh=64HjyIw3YSOllArTTqZkAithVHrT5AIrg1J84ohe30s=;\n b=WkN5nqrokkzpOkXW63o0+n92FCI8yIsFnaXDZhjUywfNpX+ov4SQHjxSsOpbwy5ME/sWRN\n LpSepOMQ5G4BZJOP+beqV81jtzHl+KO25m8j/7myuXooO8ZE9zeL50GFIPkI6zK/clDyt1\n HgvAXRRW6EG/B5XSltb/Rh/AqzQyJGA=",
            "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=redhat.com; s=google; t=1774646848; x=1775251648; darn=nongnu.org;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:from:to:cc:subject:date\n :message-id:reply-to;\n bh=64HjyIw3YSOllArTTqZkAithVHrT5AIrg1J84ohe30s=;\n b=G2LLFIsQFMR4a0rGW510A8gngRubwYeBlrvDeGfdvD3K4yP5I3p+HCIFeQZY0cbGGL\n 16v3zfsSD/EIM/uGaI/1NSPc913Bl4wqXWsKbJdvwth6Yk1ykZZMDXBu3hQ9Zuy61tMX\n ObB7u9RN8/WPDYWg7zNw/nFSc1INbJw3+rSZtI5g+oqgaoDZzbN7jxChn4IhuT4RuXg5\n lg8wRTnRsXmdXmlQWyQv6iEepGDDtfUbrGFynRlIrptzZxqHXreKfsRjHGE2nx/VMFIN\n nqbmGJhi1dkfGB6R5di+gyNHOxQf9d8gguM//fCBVisNcN4lLjQmCMOpdVFYIcxHxfvY\n akhg=="
        ],
        "X-MC-Unique": "cps7H3i9MPSJMSaccNPM_Q-1",
        "X-Mimecast-MFC-AGG-ID": "cps7H3i9MPSJMSaccNPM_Q_1774646851",
        "X-Google-DKIM-Signature": "v=1; a=rsa-sha256; c=relaxed/relaxed;\n d=1e100.net; s=20251104; t=1774646848; x=1775251648;\n h=content-transfer-encoding:mime-version:references:in-reply-to\n :message-id:date:subject:cc:to:from:x-gm-gg:x-gm-message-state:from\n :to:cc:subject:date:message-id:reply-to;\n bh=64HjyIw3YSOllArTTqZkAithVHrT5AIrg1J84ohe30s=;\n b=dF7ie5M4cknNWoxrWAWNlYDV+OdNx5GJDNL59CIxTHXGo6CDUFGwHgnuVPFrBBKY56\n 1ogMKkTji6CSvlU3ITmzFsMeySxDLPOdZOLNAT7JxXu613NbDLT8y74D8xNeKZgJnUBh\n /Bg0olY53nmgMod9hs23mGnNmBYHQliOyP3RTdlveDohXUtPDmiBMgmLFxO8RM0iB7Sc\n o/K/1bOGeg3yPH7/BG3tYR8jY+Twb+euUiFr49JOprAcskRgDddse1pW/obHRhbq5PVm\n of3w638ktBuxBdlgebUUVQ+xBOjswMxrOPzRFar8YtnKIwb2GDMUeoFJ0XSOtA2RQ2Lp\n D9ZA==",
        "X-Gm-Message-State": "AOJu0Yxk4adozl7ytqtdRTOz8TtELwQmp16fRnC7IL6w0v5cyV6iMAls\n D3HiZ2nUOlnXuGw35+A5vhk/YJ7lCQKVjxX6sRV8ZChJDTkHD7b2rohTNToDftx0RUI6aIp5msh\n UmLgHVcIFO0m3CDdUZV42PFZPPT41mcNhTldFPlMUlrsuLYv7w/Xz653heHwBL/Rja3nQlkAId6\n sdEVJbSARkxpUROc5JzNaqRLZuMPxPccBLXcI5z2J1",
        "X-Gm-Gg": "ATEYQzzPSEFWlfAmDwz43tz4uDmtqzoC2z1gUUFRMaY048raIH35LI07XMCwx0OkQKm\n exqwsILPFUdpmNrICTs0sqDHyANjSOSzXr71j3b3X1cNF8B0r3+qlcNB+YgEaYQp1cuLIMLwxxm\n QveItue50b82TNPp3PCDuDeZRrs5m14Xoy6RHl+1RN5kS1XRCrSn8z/tM2/kbTncNI4Tjvxj9MR\n ZUcGXNdsQd6TOb9PqTckBu+HcfrJze8dIzZso+VXiOvTAEJxqeWbELC85cM2Y9Eu+gVhC4RVrUk\n SSyKT+RN/MdRORowN/ynXFhVYkyLiKYa29Tot13a2vw7wCMo99LwDHZcP6YJRPiEoB7hG9NhWdQ\n T/+L0z1jRnGl3DRwOKEKOrl3bjoeNpNTKTGijuVbKm+cQpECGmEa159zJwQhuRbcVd4te+e2ADS\n oEuBhgdpA73e7vwPuWq6nu90NK",
        "X-Received": [
            "by 2002:a05:600c:3e88:b0:487:1108:48b8 with SMTP id\n 5b1f17b1804b1-48727ee9897mr62252185e9.2.1774646848459;\n Fri, 27 Mar 2026 14:27:28 -0700 (PDT)",
            "by 2002:a05:600c:3e88:b0:487:1108:48b8 with SMTP id\n 5b1f17b1804b1-48727ee9897mr62251915e9.2.1774646847953;\n Fri, 27 Mar 2026 14:27:27 -0700 (PDT)"
        ],
        "From": "Paolo Bonzini <pbonzini@redhat.com>",
        "To": "qemu-devel@nongnu.org",
        "Cc": "Helge Deller <deller@gmx.de>",
        "Subject": "[PATCH 15/16] ncr710: copy reference counting fixes over from\n lsi53c895a",
        "Date": "Fri, 27 Mar 2026 22:25:46 +0100",
        "Message-ID": "<20260327212547.460420-16-pbonzini@redhat.com>",
        "X-Mailer": "git-send-email 2.53.0",
        "In-Reply-To": "<20260327212547.460420-1-pbonzini@redhat.com>",
        "References": "<20260327212547.460420-1-pbonzini@redhat.com>",
        "MIME-Version": "1.0",
        "Content-Transfer-Encoding": "8bit",
        "Received-SPF": "pass client-ip=170.10.133.124;\n envelope-from=pbonzini@redhat.com;\n helo=us-smtp-delivery-124.mimecast.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, DKIMWL_WL_HIGH=-0.001,\n DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1,\n RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H2=0.001,\n RCVD_IN_VALIDITY_RPBL_BLOCKED=0.001, RCVD_IN_VALIDITY_SAFE_BLOCKED=0.001,\n SPF_HELO_PASS=-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": "qemu development <qemu-devel.nongnu.org>",
        "List-Unsubscribe": "<https://lists.nongnu.org/mailman/options/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=unsubscribe>",
        "List-Archive": "<https://lists.nongnu.org/archive/html/qemu-devel>",
        "List-Post": "<mailto:qemu-devel@nongnu.org>",
        "List-Help": "<mailto:qemu-devel-request@nongnu.org?subject=help>",
        "List-Subscribe": "<https://lists.nongnu.org/mailman/listinfo/qemu-devel>,\n <mailto:qemu-devel-request@nongnu.org?subject=subscribe>",
        "Errors-To": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org",
        "Sender": "qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org"
    },
    "content": "These are mostly the smae, with only the \"if (p == s->current) case of\nncr710_command_complete needing some care to check that it's safe to\nremove.\n\ns->current is dereferenced:\n- in ncr710_clear_pending_irq - guarded by if (s->current), just to free it\n- in ncr710_do_dma - guarded by assert (s->current); only called from\n  Data In/Data Out phases, which are entered after scsi_req_new and\n  left after scsi_req_cancel\n- in ncr710_command_complete - guarded by if (p), command is not complete\n- in ncr710_transfer_data - coming from the req field of NCR710Request,\n  with assertion that !p->orphan\n- in ncr710_transfer_data, later - guarded by if (!s->current) return\n- in ncr710_do_command, after assignment\n- in ncr710_do_msgout - guarded by if (current_req), would be bad if\n  the request is already complete\n- in ncr710_reselection_retry_callback - guarded by short-circuiting\n  s->current check\n- in ncr710_execute_script - guarded by if (s->current)\n- in ncr710_reg_readb - guarded by short-circuiting s->current check\n\nNothing relies on the post-completion s->current being alive, so get rid\nof this case and clear s->current immediately as in the lsi53c895a device.\n\nSigned-off-by: Paolo Bonzini <pbonzini@redhat.com>\n---\n hw/scsi/ncr53c710.h |  1 +\n hw/scsi/ncr53c710.c | 65 ++++++++++++++++++++++++++-------------------\n 2 files changed, 39 insertions(+), 27 deletions(-)",
    "diff": "diff --git a/hw/scsi/ncr53c710.h b/hw/scsi/ncr53c710.h\nindex ee6980753d5..b15e331f060 100644\n--- a/hw/scsi/ncr53c710.h\n+++ b/hw/scsi/ncr53c710.h\n@@ -133,6 +133,7 @@ struct NCR710Request {\n     bool active;\n     uint8_t *dma_buf;\n     bool out;\n+    bool orphan;\n     uint32_t resume_offset;\n     uint32_t saved_dnad;\n };\ndiff --git a/hw/scsi/ncr53c710.c b/hw/scsi/ncr53c710.c\nindex ea114a0cb40..f7b1e153960 100644\n--- a/hw/scsi/ncr53c710.c\n+++ b/hw/scsi/ncr53c710.c\n@@ -299,7 +299,7 @@ static const char *ncr710_reg_name(int offset);\n static void ncr710_script_scsi_interrupt(NCR710State *s, int stat0);\n static void ncr710_update_irq(NCR710State *s);\n static void ncr710_script_dma_interrupt(NCR710State *s, int stat);\n-static void ncr710_request_free(NCR710State *s, NCR710Request *p);\n+static void ncr710_request_orphan(NCR710State *s, NCR710Request *p);\n static inline void ncr710_dma_read(NCR710State *s, uint32_t addr,\n                                    void *buf, uint32_t len);\n static inline void ncr710_dma_write(NCR710State *s, uint32_t addr,\n@@ -316,7 +316,7 @@ static inline int ncr710_irq_on_rsl(NCR710State *s)\n static void ncr710_clear_pending_irq(NCR710State *s)\n {\n     if (s->current) {\n-        ncr710_request_free(s, s->current);\n+        ncr710_request_orphan(s, s->current);\n     }\n }\n \n@@ -683,42 +683,52 @@ static void ncr710_do_dma(NCR710State *s, int out)\n     uint32_t count;\n     uint32_t addr;\n     SCSIDevice *dev;\n+    SCSIRequest *req;\n+    NCR710Request *p;\n+\n     assert(s->current);\n     if (!s->current->dma_len) {\n         /* We wait until data is available.  */\n         return;\n     }\n \n-    dev = s->current->req->dev;\n+    p = s->current;\n+    req = scsi_req_ref(p->req);\n+    dev = req->dev;\n     assert(dev);\n \n     count = s->dbc;\n-    if (count > s->current->dma_len) {\n-        count = s->current->dma_len;\n+    if (count > p->dma_len) {\n+        count = p->dma_len;\n     }\n \n     addr = s->dnad;\n \n     s->dnad += count;\n     s->dbc -= count;\n-    if (s->current->dma_buf == NULL) {\n-        s->current->dma_buf = scsi_req_get_buf(s->current->req);\n+    if (p->dma_buf == NULL) {\n+        p->dma_buf = scsi_req_get_buf(req);\n     }\n     /* ??? Set SFBR to first data byte.  */\n     if (out) {\n-        ncr710_dma_read(s, addr, s->current->dma_buf, count);\n+        ncr710_dma_read(s, addr, p->dma_buf, count);\n     } else {\n-        ncr710_dma_write(s, addr, s->current->dma_buf, count);\n+        ncr710_dma_write(s, addr, p->dma_buf, count);\n     }\n-    s->current->dma_len -= count;\n-    if (s->current->dma_len == 0) {\n-        s->current->dma_buf = NULL;\n-        s->current->pending = 0;\n-        s->waiting = NCR710_WAIT_DMA;\n-        scsi_req_continue(s->current->req);\n+    if (p->orphan) {\n+        scsi_req_unref(req);\n         return;\n+    }\n+    scsi_req_unref(req);\n+\n+    p->dma_len -= count;\n+    if (p->dma_len == 0) {\n+        p->dma_buf = NULL;\n+        p->pending = 0;\n+        s->waiting = NCR710_WAIT_DMA;\n+        scsi_req_continue(req);\n     } else {\n-        s->current->dma_buf += count;\n+        p->dma_buf += count;\n         s->waiting = NCR710_WAIT_NONE;\n         ncr710_execute_script(s);\n     }\n@@ -733,14 +743,18 @@ static void ncr710_add_msg_byte(NCR710State *s, uint8_t data)\n     }\n }\n \n-static void ncr710_request_free(NCR710State *s, NCR710Request *p)\n+static void ncr710_request_orphan(NCR710State *s, NCR710Request *p)\n {\n-    p->req->hba_private = NULL;\n+    p->orphan = true;\n     if (p == s->current) {\n         s->current = NULL;\n     }\n     scsi_req_unref(p->req);\n-    g_free(p);\n+}\n+\n+static void ncr710_free_request(SCSIBus *bus, void *priv)\n+{\n+    g_free(priv);\n }\n \n void ncr710_request_cancelled(SCSIRequest *req)\n@@ -748,7 +762,7 @@ void ncr710_request_cancelled(SCSIRequest *req)\n     NCR710State *s = ncr710_from_scsi_bus(req->bus);\n     NCR710Request *p = (NCR710Request *)req->hba_private;\n     if (p) {\n-        ncr710_request_free(s, p);\n+        ncr710_request_orphan(s, p);\n     }\n }\n \n@@ -790,11 +804,7 @@ void ncr710_command_complete(SCSIRequest *req, size_t resid)\n     ncr710_set_phase(s, PHASE_ST);\n \n     if (p) {\n-        if (p == s->current) {\n-            req->hba_private = NULL;\n-        } else {\n-            ncr710_request_free(s, p);\n-        }\n+        ncr710_request_orphan(s, p);\n     }\n \n     if (s->waiting == NCR710_WAIT_RESELECT || s->waiting == NCR710_WAIT_DMA) {\n@@ -806,11 +816,11 @@ void ncr710_command_complete(SCSIRequest *req, size_t resid)\n void ncr710_transfer_data(SCSIRequest *req, uint32_t len)\n {\n     NCR710State *s = ncr710_from_scsi_bus(req->bus);\n+    NCR710Request *p = (NCR710Request *)req->hba_private;\n \n-    assert(req->hba_private);\n+    assert(!p->orphan);\n \n     if (s->waiting == NCR710_WAIT_DMA) {\n-        NCR710Request *p = (NCR710Request *)req->hba_private;\n         if (p) {\n             p->dma_len = len;\n         }\n@@ -2248,6 +2258,7 @@ static const struct SCSIBusInfo ncr710_scsi_info = {\n     .transfer_data = ncr710_transfer_data,\n     .complete = ncr710_command_complete,\n     .cancel = ncr710_request_cancelled,\n+    .free_request = ncr710_free_request,\n };\n \n static const MemoryRegionOps ncr710_mmio_ops = {\n",
    "prefixes": [
        "15/16"
    ]
}