From nobody Tue Feb 10 05:41:25 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=philmd@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1640260836; cv=none; d=zohomail.com; s=zohoarc; b=P+62R3pKkYSm/CuMML0vm0x9Ejk2nXCnZki9Hm+H4I5Rhq3bGytVL/RYeQ2RNXhzvF95/nFxKkaiSyzLoMdJhsTnFtW2W+eq71U3onXgq9puCgCZrSU38b2pXFKo/F/4af+zRbBtmewywKF8oMxfFhQy+2g+jYxoDrynm898OkE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1640260836; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=9pReE1QJ5vxBRMRDloIuGc8yeeo3MgjkQ39UWuGBPOY=; b=gj3A9a3VM30XyeWC8maCCvp9GXxi1tVyNmkBfox1I3nTTa1p7fQLPmw6v78P8hPJdSnkx3dR/MqFomzSnOaRX+fyTs5Y0HpG+O9y++GY81b4VKkPrV8Sk2WtNyLSqgZfeii/fW4SYfvpjMeZSgFxNfxujGZWcnGJ+AZ4ZzQ2YPI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=philmd@redhat.com; dmarc=pass header.from= (p=none dis=none) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 1640260836632667.2408646217156; Thu, 23 Dec 2021 04:00:36 -0800 (PST) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-670-OI3_NMJyP9ihisTSqPOOnA-1; Thu, 23 Dec 2021 07:00:34 -0500 Received: by mail-wm1-f69.google.com with SMTP id v190-20020a1cacc7000000b003456d598510so4547391wme.6 for ; Thu, 23 Dec 2021 04:00:34 -0800 (PST) Return-Path: Return-Path: Received: from x1w.. (33.red-193-152-124.dynamicip.rima-tde.net. [193.152.124.33]) by smtp.gmail.com with ESMTPSA id w6sm4601783wrs.52.2021.12.23.04.00.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Dec 2021 04:00:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1640260835; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=9pReE1QJ5vxBRMRDloIuGc8yeeo3MgjkQ39UWuGBPOY=; b=RBwwbjlhFo+Q8shguLRHnCtBBxMHErq1LNDudc98l91R8K4EtCzDlzg618Cj8sQwJep2YC GYVJoHypiA5ShOC2ytSiKGbDlXu1Wd+iFKlxhK1SzSzPwe1gEp8wbP54nFtdmrX98n2nMe etEhacYE2HAFiw3tfGiG6vCNsCYC1r4= X-MC-Unique: OI3_NMJyP9ihisTSqPOOnA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=9pReE1QJ5vxBRMRDloIuGc8yeeo3MgjkQ39UWuGBPOY=; b=X5ceHh752XJndApiYroEALbBpx0To3WhpS2/jr/9Di4EcxxIneP/NoxAt9g4ITzBKC XIkNRPzHdPxxCSgI8NpPTfW5jxsdLYyLRvk3RDqImbp2NzKCDRulcObFgejJIie6DuI1 JOBn+s6q4VzAQZq1cn2fIM2TkWYSUy0Xvg5QjiHWt95tIfsFDvY7ehnfEg/5PmUWaG1e oQI6+uaW4norwdBHj3HIl3n7oKli6DE1RFJaP45ZQ9p6DScIiQSXkKy2LbMIVCm9+sC0 S/3YFVhtXEQ/FLUDAqIqjMAJUGvJdyjsThFdVoEKWofsOKE78KI/xE55UsOIaYP9mipb dhjw== X-Gm-Message-State: AOAM5338RRRoSRb88EXg22F1oia6mkl8fNEi2knJ3297AXIR+wQotnei az3s1Z7NwUfOi1KO22wntMr5HDG1gPLFoWd50hFL+9Tc3s1MNE9YdzHEFkthc+9i7y5FqUhR/PS T9mQ3juNmfIHXOw== X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr1584926wrg.31.1640260832810; Thu, 23 Dec 2021 04:00:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJw/DQ1hWR9qyFgUiRX1uFPfeDojVvudgj5ZvN6Va5wfFpZgZ/IESAYpz2iKee/YDWNEagse0A== X-Received: by 2002:a05:6000:1787:: with SMTP id e7mr1584902wrg.31.1640260832570; Thu, 23 Dec 2021 04:00:32 -0800 (PST) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: Joel Stanley , Richard Henderson , qemu-block@nongnu.org, Jason Wang , Keith Busch , "Michael S. Tsirkin" , Fam Zheng , Alistair Francis , David Hildenbrand , Eduardo Habkost , Havard Skinnemoen , Sven Schnelle , Tyrone Ting , Gerd Hoffmann , Peter Maydell , Beniamino Galvani , Daniel Henrique Barboza , Dmitry Fleytman , John Snow , Bin Meng , Greg Kurz , Eric Auger , Mark Cave-Ayland , "Edgar E. Iglesias" , Andrew Jeffery , =?UTF-8?q?C=C3=A9dric=20Le=20Goater?= , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Marcel Apfelbaum , Andrew Baumann , Hannes Reinecke , Paolo Bonzini , Peter Xu , qemu-arm@nongnu.org, Klaus Jensen , Stefan Weil , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-ppc@nongnu.org, Jan Kiszka , David Gibson Subject: [PATCH v2 20/23] pci: Let st*_pci_dma() take MemTxAttrs argument Date: Thu, 23 Dec 2021 12:55:51 +0100 Message-Id: <20211223115554.3155328-21-philmd@redhat.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211223115554.3155328-1-philmd@redhat.com> References: <20211223115554.3155328-1-philmd@redhat.com> MIME-Version: 1.0 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=philmd@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1640260837141100001 Let devices specify transaction attributes when calling st*_pci_dma(). Keep the default MEMTXATTRS_UNSPECIFIED in the few callers. Reviewed-by: Richard Henderson Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/pci/pci.h | 11 ++++++----- hw/audio/intel-hda.c | 10 ++++++---- hw/net/eepro100.c | 29 ++++++++++++++++++----------- hw/net/tulip.c | 18 ++++++++++-------- hw/scsi/megasas.c | 15 ++++++++++----- hw/scsi/vmw_pvscsi.c | 3 ++- 6 files changed, 52 insertions(+), 34 deletions(-) diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 8c5f2ed5054..9f51ef2c3c2 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -859,11 +859,12 @@ static inline MemTxResult pci_dma_write(PCIDevice *de= v, dma_addr_t addr, MEMTXATTRS_UNSPECIFIED); \ return val; \ } \ - static inline void st##_s##_pci_dma(PCIDevice *dev, \ - dma_addr_t addr, uint##_bits##_t v= al) \ - { \ - st##_s##_dma(pci_get_address_space(dev), addr, val, \ - MEMTXATTRS_UNSPECIFIED); \ + static inline void st##_s##_pci_dma(PCIDevice *dev, \ + dma_addr_t addr, \ + uint##_bits##_t val, \ + MemTxAttrs attrs) \ + { \ + st##_s##_dma(pci_get_address_space(dev), addr, val, attrs); \ } =20 PCI_DMA_DEFINE_LDST(ub, b, 8); diff --git a/hw/audio/intel-hda.c b/hw/audio/intel-hda.c index fb3d34a4a0c..3309ae0ea18 100644 --- a/hw/audio/intel-hda.c +++ b/hw/audio/intel-hda.c @@ -345,6 +345,7 @@ static void intel_hda_corb_run(IntelHDAState *d) =20 static void intel_hda_response(HDACodecDevice *dev, bool solicited, uint32= _t response) { + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; HDACodecBus *bus =3D HDA_BUS(dev->qdev.parent_bus); IntelHDAState *d =3D container_of(bus, IntelHDAState, codecs); hwaddr addr; @@ -367,8 +368,8 @@ static void intel_hda_response(HDACodecDevice *dev, boo= l solicited, uint32_t res ex =3D (solicited ? 0 : (1 << 4)) | dev->cad; wp =3D (d->rirb_wp + 1) & 0xff; addr =3D intel_hda_addr(d->rirb_lbase, d->rirb_ubase); - stl_le_pci_dma(&d->pci, addr + 8*wp, response); - stl_le_pci_dma(&d->pci, addr + 8*wp + 4, ex); + stl_le_pci_dma(&d->pci, addr + 8 * wp, response, attrs); + stl_le_pci_dma(&d->pci, addr + 8 * wp + 4, ex, attrs); d->rirb_wp =3D wp; =20 dprint(d, 2, "%s: [wp 0x%x] response 0x%x, extra 0x%x\n", @@ -394,6 +395,7 @@ static void intel_hda_response(HDACodecDevice *dev, boo= l solicited, uint32_t res static bool intel_hda_xfer(HDACodecDevice *dev, uint32_t stnr, bool output, uint8_t *buf, uint32_t len) { + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; HDACodecBus *bus =3D HDA_BUS(dev->qdev.parent_bus); IntelHDAState *d =3D container_of(bus, IntelHDAState, codecs); hwaddr addr; @@ -428,7 +430,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_= t stnr, bool output, st->be, st->bp, st->bpl[st->be].len, copy); =20 pci_dma_rw(&d->pci, st->bpl[st->be].addr + st->bp, buf, copy, !out= put, - MEMTXATTRS_UNSPECIFIED); + attrs); st->lpib +=3D copy; st->bp +=3D copy; buf +=3D copy; @@ -451,7 +453,7 @@ static bool intel_hda_xfer(HDACodecDevice *dev, uint32_= t stnr, bool output, if (d->dp_lbase & 0x01) { s =3D st - d->st; addr =3D intel_hda_addr(d->dp_lbase & ~0x01, d->dp_ubase); - stl_le_pci_dma(&d->pci, addr + 8*s, st->lpib); + stl_le_pci_dma(&d->pci, addr + 8 * s, st->lpib, attrs); } dprint(d, 3, "dma: --\n"); =20 diff --git a/hw/net/eepro100.c b/hw/net/eepro100.c index 16e95ef9cc9..83c4431b1ad 100644 --- a/hw/net/eepro100.c +++ b/hw/net/eepro100.c @@ -700,6 +700,8 @@ static void set_ru_state(EEPRO100State * s, ru_state_t = state) =20 static void dump_statistics(EEPRO100State * s) { + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; + /* Dump statistical data. Most data is never changed by the emulation * and always 0, so we first just copy the whole block and then those * values which really matter. @@ -707,16 +709,18 @@ static void dump_statistics(EEPRO100State * s) */ pci_dma_write(&s->dev, s->statsaddr, &s->statistics, s->stats_size); stl_le_pci_dma(&s->dev, s->statsaddr + 0, - s->statistics.tx_good_frames); + s->statistics.tx_good_frames, attrs); stl_le_pci_dma(&s->dev, s->statsaddr + 36, - s->statistics.rx_good_frames); + s->statistics.rx_good_frames, attrs); stl_le_pci_dma(&s->dev, s->statsaddr + 48, - s->statistics.rx_resource_errors); + s->statistics.rx_resource_errors, attrs); stl_le_pci_dma(&s->dev, s->statsaddr + 60, - s->statistics.rx_short_frame_errors); + s->statistics.rx_short_frame_errors, attrs); #if 0 - stw_le_pci_dma(&s->dev, s->statsaddr + 76, s->statistics.xmt_tco_frame= s); - stw_le_pci_dma(&s->dev, s->statsaddr + 78, s->statistics.rcv_tco_frame= s); + stw_le_pci_dma(&s->dev, s->statsaddr + 76, + s->statistics.xmt_tco_frames, attrs); + stw_le_pci_dma(&s->dev, s->statsaddr + 78, + s->statistics.rcv_tco_frames, attrs); missing("CU dump statistical counters"); #endif } @@ -833,6 +837,7 @@ static void set_multicast_list(EEPRO100State *s) =20 static void action_command(EEPRO100State *s) { + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; /* The loop below won't stop if it gets special handcrafted data. Therefore we limit the number of iterations. */ unsigned max_loop_count =3D 16; @@ -911,7 +916,7 @@ static void action_command(EEPRO100State *s) } /* Write new status. */ stw_le_pci_dma(&s->dev, s->cb_address, - s->tx.status | ok_status | STATUS_C); + s->tx.status | ok_status | STATUS_C, attrs); if (bit_i) { /* CU completed action. */ eepro100_cx_interrupt(s); @@ -937,6 +942,7 @@ static void action_command(EEPRO100State *s) =20 static void eepro100_cu_command(EEPRO100State * s, uint8_t val) { + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; cu_state_t cu_state; switch (val) { case CU_NOP: @@ -986,7 +992,7 @@ static void eepro100_cu_command(EEPRO100State * s, uint= 8_t val) /* Dump statistical counters. */ TRACE(OTHER, logout("val=3D0x%02x (dump stats)\n", val)); dump_statistics(s); - stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa005); + stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa005, attr= s); break; case CU_CMD_BASE: /* Load CU base. */ @@ -997,7 +1003,7 @@ static void eepro100_cu_command(EEPRO100State * s, uin= t8_t val) /* Dump and reset statistical counters. */ TRACE(OTHER, logout("val=3D0x%02x (dump stats and reset)\n", val)); dump_statistics(s); - stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa007); + stl_le_pci_dma(&s->dev, s->statsaddr + s->stats_size, 0xa007, attr= s); memset(&s->statistics, 0, sizeof(s->statistics)); break; case CU_SRESUME: @@ -1612,6 +1618,7 @@ static ssize_t nic_receive(NetClientState *nc, const = uint8_t * buf, size_t size) * - Magic packets should set bit 30 in power management driver regist= er. * - Interesting packets should set bit 29 in power management driver = register. */ + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; EEPRO100State *s =3D qemu_get_nic_opaque(nc); uint16_t rfd_status =3D 0xa000; #if defined(CONFIG_PAD_RECEIVED_FRAMES) @@ -1726,9 +1733,9 @@ static ssize_t nic_receive(NetClientState *nc, const = uint8_t * buf, size_t size) TRACE(OTHER, logout("command 0x%04x, link 0x%08x, addr 0x%08x, size %u= \n", rfd_command, rx.link, rx.rx_buf_addr, rfd_size)); stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset + - offsetof(eepro100_rx_t, status), rfd_status); + offsetof(eepro100_rx_t, status), rfd_status, attrs); stw_le_pci_dma(&s->dev, s->ru_base + s->ru_offset + - offsetof(eepro100_rx_t, count), size); + offsetof(eepro100_rx_t, count), size, attrs); /* Early receive interrupt not supported. */ #if 0 eepro100_er_interrupt(s); diff --git a/hw/net/tulip.c b/hw/net/tulip.c index ca69f7ea5e1..1f2c79dd58b 100644 --- a/hw/net/tulip.c +++ b/hw/net/tulip.c @@ -86,16 +86,18 @@ static void tulip_desc_read(TULIPState *s, hwaddr p, static void tulip_desc_write(TULIPState *s, hwaddr p, struct tulip_descriptor *desc) { + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; + if (s->csr[0] & CSR0_DBO) { - stl_be_pci_dma(&s->dev, p, desc->status); - stl_be_pci_dma(&s->dev, p + 4, desc->control); - stl_be_pci_dma(&s->dev, p + 8, desc->buf_addr1); - stl_be_pci_dma(&s->dev, p + 12, desc->buf_addr2); + stl_be_pci_dma(&s->dev, p, desc->status, attrs); + stl_be_pci_dma(&s->dev, p + 4, desc->control, attrs); + stl_be_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs); + stl_be_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs); } else { - stl_le_pci_dma(&s->dev, p, desc->status); - stl_le_pci_dma(&s->dev, p + 4, desc->control); - stl_le_pci_dma(&s->dev, p + 8, desc->buf_addr1); - stl_le_pci_dma(&s->dev, p + 12, desc->buf_addr2); + stl_le_pci_dma(&s->dev, p, desc->status, attrs); + stl_le_pci_dma(&s->dev, p + 4, desc->control, attrs); + stl_le_pci_dma(&s->dev, p + 8, desc->buf_addr1, attrs); + stl_le_pci_dma(&s->dev, p + 12, desc->buf_addr2, attrs); } } =20 diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c index 266c3d38003..65451d34e64 100644 --- a/hw/scsi/megasas.c +++ b/hw/scsi/megasas.c @@ -168,14 +168,16 @@ static void megasas_frame_set_cmd_status(MegasasState= *s, unsigned long frame, uint8_t v) { PCIDevice *pci =3D &s->parent_obj; - stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, cmd_status)= , v); + stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, cmd_status), + v, MEMTXATTRS_UNSPECIFIED); } =20 static void megasas_frame_set_scsi_status(MegasasState *s, unsigned long frame, uint8_t v) { PCIDevice *pci =3D &s->parent_obj; - stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, scsi_status= ), v); + stb_pci_dma(pci, frame + offsetof(struct mfi_frame_header, scsi_status= ), + v, MEMTXATTRS_UNSPECIFIED); } =20 static inline const char *mfi_frame_desc(unsigned int cmd) @@ -542,6 +544,7 @@ static MegasasCmd *megasas_enqueue_frame(MegasasState *= s, =20 static void megasas_complete_frame(MegasasState *s, uint64_t context) { + const MemTxAttrs attrs =3D MEMTXATTRS_UNSPECIFIED; PCIDevice *pci_dev =3D PCI_DEVICE(s); int tail, queue_offset; =20 @@ -555,10 +558,12 @@ static void megasas_complete_frame(MegasasState *s, u= int64_t context) */ if (megasas_use_queue64(s)) { queue_offset =3D s->reply_queue_head * sizeof(uint64_t); - stq_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, cont= ext); + stq_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, + context, attrs); } else { queue_offset =3D s->reply_queue_head * sizeof(uint32_t); - stl_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, cont= ext); + stl_le_pci_dma(pci_dev, s->reply_queue_pa + queue_offset, + context, attrs); } s->reply_queue_tail =3D ldl_le_pci_dma(pci_dev, s->consumer_pa); trace_megasas_qf_complete(context, s->reply_queue_head, @@ -572,7 +577,7 @@ static void megasas_complete_frame(MegasasState *s, uin= t64_t context) s->reply_queue_head =3D megasas_next_index(s, tail, s->fw_cmds); trace_megasas_qf_update(s->reply_queue_head, s->reply_queue_tail, s->busy); - stl_le_pci_dma(pci_dev, s->producer_pa, s->reply_queue_head); + stl_le_pci_dma(pci_dev, s->producer_pa, s->reply_queue_head, attrs= ); /* Notify HBA */ if (msix_enabled(pci_dev)) { trace_megasas_msix_raise(0); diff --git a/hw/scsi/vmw_pvscsi.c b/hw/scsi/vmw_pvscsi.c index cd76bd67ab7..59c3e8ba048 100644 --- a/hw/scsi/vmw_pvscsi.c +++ b/hw/scsi/vmw_pvscsi.c @@ -55,7 +55,8 @@ (m)->rs_pa + offsetof(struct PVSCSIRingsState, field))) #define RS_SET_FIELD(m, field, val) \ (stl_le_pci_dma(&container_of(m, PVSCSIState, rings)->parent_obj, \ - (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), va= l)) + (m)->rs_pa + offsetof(struct PVSCSIRingsState, field), va= l, \ + MEMTXATTRS_UNSPECIFIED)) =20 struct PVSCSIClass { PCIDeviceClass parent_class; --=20 2.33.1