From: Markus Armbruster <armbru@redhat.com>
To: Akihiko Odaki <akihiko.odaki@daynix.com>
Cc: Alex Williamson <alex.williamson@redhat.com>,
qemu-devel@nongnu.org, qemu-block@nongnu.org,
qemu-arm@nongnu.org, "Michael S . Tsirkin" <mst@redhat.com>,
Marcel Apfelbaum <marcel.apfelbaum@gmail.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Richard Henderson <richard.henderson@linaro.org>,
Eduardo Habkost <eduardo@habkost.net>,
John Snow <jsnow@redhat.com>,
Dmitry Fleytman <dmitry.fleytman@gmail.com>,
Jason Wang <jasowang@redhat.com>, Stefan Weil <sw@weilnetz.de>,
Keith Busch <kbusch@kernel.org>,
Klaus Jensen <its@irrelevant.dk>,
Peter Maydell <peter.maydell@linaro.org>,
Andrey Smirnov <andrew.smirnov@gmail.com>,
Paul Burton <paulburton@kernel.org>,
Aleksandar Rikalo <aleksandar.rikalo@syrmia.com>,
Yan Vugenfirer <yan@daynix.com>,
Yuri Benditovich <yuri.benditovich@daynix.com>
Subject: Re: [PATCH v2 02/17] hw/i386/amd_iommu: Omit errp for pci_add_capability
Date: Tue, 25 Oct 2022 14:23:11 +0200 [thread overview]
Message-ID: <874jvs149c.fsf@pond.sub.org> (raw)
In-Reply-To: <20221022044053.81650-3-akihiko.odaki@daynix.com> (Akihiko Odaki's message of "Sat, 22 Oct 2022 13:40:38 +0900")
Akihiko Odaki <akihiko.odaki@daynix.com> writes:
> Signed-off-by: Akihiko Odaki <akihiko.odaki@daynix.com>
> ---
> hw/i386/amd_iommu.c | 21 ++++-----------------
> 1 file changed, 4 insertions(+), 17 deletions(-)
>
> diff --git a/hw/i386/amd_iommu.c b/hw/i386/amd_iommu.c
> index 725f69095b..8a88cbea0a 100644
> --- a/hw/i386/amd_iommu.c
> +++ b/hw/i386/amd_iommu.c
> @@ -1539,7 +1539,6 @@ static void amdvi_sysbus_reset(DeviceState *dev)
>
> static void amdvi_sysbus_realize(DeviceState *dev, Error **errp)
> {
> - int ret = 0;
> AMDVIState *s = AMD_IOMMU_DEVICE(dev);
> MachineState *ms = MACHINE(qdev_get_machine());
> PCMachineState *pcms = PC_MACHINE(ms);
X86MachineState *x86ms = X86_MACHINE(ms);
PCIBus *bus = pcms->bus;
s->iotlb = g_hash_table_new_full(amdvi_uint64_hash,
amdvi_uint64_equal, g_free, g_free);
> @@ -1553,23 +1552,11 @@ static void amdvi_sysbus_realize(DeviceState *dev, Error **errp)
> if (!qdev_realize(DEVICE(&s->pci), &bus->qbus, errp)) {
> return;
> }
> - ret = pci_add_capability(&s->pci.dev, AMDVI_CAPAB_ID_SEC, 0,
> - AMDVI_CAPAB_SIZE, errp);
> - if (ret < 0) {
> - return;
> - }
> - s->capab_offset = ret;
> + s->capab_offset = pci_add_capability(&s->pci.dev, AMDVI_CAPAB_ID_SEC, 0,
> + AMDVI_CAPAB_SIZE);
>
> - ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_MSI, 0,
> - AMDVI_CAPAB_REG_SIZE, errp);
> - if (ret < 0) {
> - return;
> - }
> - ret = pci_add_capability(&s->pci.dev, PCI_CAP_ID_HT, 0,
> - AMDVI_CAPAB_REG_SIZE, errp);
> - if (ret < 0) {
> - return;
> - }
> + pci_add_capability(&s->pci.dev, PCI_CAP_ID_MSI, 0, AMDVI_CAPAB_REG_SIZE);
> + pci_add_capability(&s->pci.dev, PCI_CAP_ID_HT, 0, AMDVI_CAPAB_REG_SIZE);
>
> /* Pseudo address space under root PCI bus. */
> x86ms->ioapic_as = amdvi_host_dma_iommu(bus, s, AMDVI_IOAPIC_SB_DEVID);
Your patch replaces error handling by abort(). The commit message
should explain why this is okay.
It is, because these are programming errors, and aborting on programming
errors is appropriate.
Moreover, the error handling is incorrect: it leaks s->iotlb. To be clear:
replacing it would be okay even if it cleaned up properly.
The other patches also need to explain. Yes, this repetitive, but
anyone looking at one of these commits later will be grateful. Yes,
they could find an explanation in PATCH 01. If they find it in git
history. Each commit should make sense on its own whenever practical.
The explanation will be a bit more involved for device assignment (PATCH
15, maybe more), where we need to point out that the caller guards
against these errors.
next prev parent reply other threads:[~2022-10-25 12:25 UTC|newest]
Thread overview: 22+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-10-22 4:40 [PATCH v2 00/17] pci: Abort if pci_add_capability fails Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 01/17] pci: Allow to omit errp for pci_add_capability Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 02/17] hw/i386/amd_iommu: Omit " Akihiko Odaki
2022-10-25 12:23 ` Markus Armbruster [this message]
2022-10-22 4:40 ` [PATCH v2 03/17] ahci: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 04/17] e1000e: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 05/17] eepro100: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 06/17] hw/nvme: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 07/17] msi: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 08/17] hw/pci/pci_bridge: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 09/17] pcie: " Akihiko Odaki
2022-10-24 16:17 ` Jonathan Cameron via
2022-10-24 16:17 ` Jonathan Cameron via
2022-10-22 4:40 ` [PATCH v2 10/17] pci/shpc: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 11/17] msix: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 12/17] pci/slotid: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 13/17] hw/pci-bridge/pcie_pci_bridge: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 14/17] hw/vfio/pci-quirks: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 15/17] hw/vfio/pci: " Akihiko Odaki
2022-10-22 4:40 ` [PATCH v2 16/17] virtio-pci: " Akihiko Odaki
2022-10-25 11:54 ` Markus Armbruster
2022-10-22 4:40 ` [PATCH v2 17/17] pci: Remove legacy errp from pci_add_capability Akihiko Odaki
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=874jvs149c.fsf@pond.sub.org \
--to=armbru@redhat.com \
--cc=akihiko.odaki@daynix.com \
--cc=aleksandar.rikalo@syrmia.com \
--cc=alex.williamson@redhat.com \
--cc=andrew.smirnov@gmail.com \
--cc=dmitry.fleytman@gmail.com \
--cc=eduardo@habkost.net \
--cc=its@irrelevant.dk \
--cc=jasowang@redhat.com \
--cc=jsnow@redhat.com \
--cc=kbusch@kernel.org \
--cc=kraxel@redhat.com \
--cc=marcel.apfelbaum@gmail.com \
--cc=mst@redhat.com \
--cc=paulburton@kernel.org \
--cc=pbonzini@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-arm@nongnu.org \
--cc=qemu-block@nongnu.org \
--cc=qemu-devel@nongnu.org \
--cc=richard.henderson@linaro.org \
--cc=sw@weilnetz.de \
--cc=yan@daynix.com \
--cc=yuri.benditovich@daynix.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.