From nobody Sun May 19 01:26:50 2024 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=1629390873; cv=none; d=zohomail.com; s=zohoarc; b=Ex5JaTm4qB43aSqFkwaUQItVhqrswuD5AURc9XCv/hloeYUtww0FXIS3gkpZscV1HQ84OwmDim9t5PgsPbK6ZKZD0c65MF/cNi0dgrY6CPdJIUV/vMSFEsAKqrrvUZLscAxgPpJXAm+buHEQzS0LcP8Y9nGWuM8dDhfz3HZx7Gg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629390873; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=5KRt8FFWQDNryBvxaWuh5UmPga4sUXhUn48F2GiPqnI=; b=dilk+PGcvwNt8iYstYN3/j2gxxmvpXX5P+UNJ7lvxGTl1CTPQYpgv/Az1rLMrPecmExgTPz8JMEHJC1PpE7qdqIQ4fI8AJNEKZsw1r6uu+jwNOJl8e9eeD80M5PWFWSYQWrn8OVEcKghHnwdL7NTiTWOcX1RxFwxtl7lZkM93Xg= 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 1629390873529871.8096866403972; Thu, 19 Aug 2021 09:34:33 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-518-_a9uIS_2MMKacV-YX1OT6Q-1; Thu, 19 Aug 2021 12:34:31 -0400 Received: by mail-wm1-f69.google.com with SMTP id y23-20020a7bcd97000000b002e6e4a2a332so1472515wmj.0 for ; Thu, 19 Aug 2021 09:34:31 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id g12sm3428397wru.85.2021.08.19.09.34.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 09:34:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629390872; 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=5KRt8FFWQDNryBvxaWuh5UmPga4sUXhUn48F2GiPqnI=; b=SXVwcAbvv3mTaiFWzjB9W4NG4xOQZqQyC14F63uPJ+74LSk+Y+QXD83RwCVncEswK02dzs GYVFFdzpwTfoEtSJpU2vlATPDtELY6YbunG902UOquebyE30bpnorKuj5bfQphtcPYlL7E JVDLIIDZUMinxv5bmfIaEGfolKAbMgk= X-MC-Unique: _a9uIS_2MMKacV-YX1OT6Q-1 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=5KRt8FFWQDNryBvxaWuh5UmPga4sUXhUn48F2GiPqnI=; b=VKAv4K42L0Z8O3HTQVKZSq3d1edDYm2jU6LdhNHAkl8Bk+1udNPJlNDB4JLbNaLoIa Br06qhHmdvRLJd6xKjYG70io4ukdA+QFcfOfwkHw3hqRplABgr92LnQgsdDUHKBsRXTF VbUZeyEO1jKGAqeonqK90mKfmW8isqz73uKeItAhQsEcVgppElwwrwvdOcfo9ihlKlEG QagENleager9xvFscEZvsT9oCVshgyvTiIsUJvlVVuHLiK4x1Foo+8KvYCj4Vij8JuTF NfQbjF1EN7Knt0J8MncTvAct1X6jFB5igVMey1JslvO68i00k1HiuE/o7ydoTIiMpkUc amdQ== X-Gm-Message-State: AOAM5316PG/2H/10Rz9vnyit+KFdJ1AQzkb8OOWtxVP1UAa6U4kOQvfb bQ9pc2WnMr7Cep6kOvhpNUYqYMLdkigZaM7gF5LfDSDxTJ6RrLYVISQnslK56YOAgnfwWBcHuet lPTOWD4zwskFpHA== X-Received: by 2002:a7b:c922:: with SMTP id h2mr14674974wml.186.1629390869266; Thu, 19 Aug 2021 09:34:29 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwqKcNY1FOh0ukMsOtP0UhSpQZFxtKmP96wwq0bTs5RqvwNgO4p2IMMQHtiYfiUoDJ7+kGTSQ== X-Received: by 2002:a7b:c922:: with SMTP id h2mr14674964wml.186.1629390869134; Thu, 19 Aug 2021 09:34:29 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , Peter Maydell , qemu-arm@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 1/4] hw/arm/xlnx-zynqmp: Realize qspi controller *after* qspi_dma Date: Thu, 19 Aug 2021 18:34:19 +0200 Message-Id: <20210819163422.2863447-2-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819163422.2863447-1-philmd@redhat.com> References: <20210819163422.2863447-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: 1629390875394100001 If we link QOM object (a) as a property of QOM object (b), we must set the property *before* (b) is realized. Move QSPI realization *after* QSPI DMA. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/arm/xlnx-zynqmp.c | 42 ++++++++++++++++++++---------------------- 1 file changed, 20 insertions(+), 22 deletions(-) diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 3597e8db4de..9724978761b 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -570,26 +570,6 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Erro= r **errp) g_free(bus_name); } =20 - if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi), errp)) { - return; - } - sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR); - sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 1, LQSPI_ADDR); - sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi), 0, gic_spi[QSPI_IRQ]); - - for (i =3D 0; i < XLNX_ZYNQMP_NUM_QSPI_BUS; i++) { - gchar *bus_name; - gchar *target_bus; - - /* Alias controller SPI bus to the SoC itself */ - bus_name =3D g_strdup_printf("qspi%d", i); - target_bus =3D g_strdup_printf("spi%d", i); - object_property_add_alias(OBJECT(s), bus_name, - OBJECT(&s->qspi), target_bus); - g_free(bus_name); - g_free(target_bus); - } - if (!sysbus_realize(SYS_BUS_DEVICE(&s->dp), errp)) { return; } @@ -646,8 +626,26 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Erro= r **errp) =20 sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi_dma), 0, QSPI_DMA_ADDR); sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi_dma), 0, gic_spi[QSPI_IRQ]); - object_property_set_link(OBJECT(&s->qspi), "stream-connected-dma", - OBJECT(&s->qspi_dma), errp); + + if (!object_property_set_link(OBJECT(&s->qspi), "stream-connected-dma", + OBJECT(&s->qspi_dma), errp)) { + return; + } + if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi), errp)) { + return; + } + sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 0, QSPI_ADDR); + sysbus_mmio_map(SYS_BUS_DEVICE(&s->qspi), 1, LQSPI_ADDR); + sysbus_connect_irq(SYS_BUS_DEVICE(&s->qspi), 0, gic_spi[QSPI_IRQ]); + + for (i =3D 0; i < XLNX_ZYNQMP_NUM_QSPI_BUS; i++) { + g_autofree gchar *bus_name =3D g_strdup_printf("qspi%d", i); + g_autofree gchar *target_bus =3D g_strdup_printf("spi%d", i); + + /* Alias controller SPI bus to the SoC itself */ + object_property_add_alias(OBJECT(s), bus_name, + OBJECT(&s->qspi), target_bus); + } } =20 static Property xlnx_zynqmp_props[] =3D { --=20 2.31.1 From nobody Sun May 19 01:26:50 2024 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=1629390877; cv=none; d=zohomail.com; s=zohoarc; b=fh90E3jX4ZvgevfX7y6XQ9CcwRTaorN9djdX8KqkQVaMVjj8BpyOQOd7nXr6BQ5pkc8wybfMX7kS6a7c2WpZKYqLIo4OnvAmJhrE8beI3OmvsCKjsYGXrSFPDcqqFA5reBmlrKfjONAo6AFxUkhwsUmWzt98isqINYxISRoKVYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629390877; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=b1BcV5WiBp8LKmmxTl7tfHXLESegIF/jg2cb6jvljSI=; b=LJB01dM81mTF07hzp1nDWEuGuo+foxv/3wsZgIQOARPLLr2qi9M+wgahb1Keyow6NWuB5KFIeK8QXakv4gZT7R5IDw0BW+h4pqrc0OfGre7O0IdGgrFwjDoYQ9nBO/FsF2OOBB4XvE/cQiStRBD5q33j7Lq3Bt2DpgaZwTxGqZ4= 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 1629390877476302.93318051954486; Thu, 19 Aug 2021 09:34:37 -0700 (PDT) Received: from mail-wm1-f69.google.com (mail-wm1-f69.google.com [209.85.128.69]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-542-iC2hkR5BMsCk9bi-YigtBQ-1; Thu, 19 Aug 2021 12:34:35 -0400 Received: by mail-wm1-f69.google.com with SMTP id b196-20020a1c80cd0000b02902e677003785so3679150wmd.7 for ; Thu, 19 Aug 2021 09:34:34 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id o10sm3316911wrq.51.2021.08.19.09.34.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 09:34:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629390876; 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=b1BcV5WiBp8LKmmxTl7tfHXLESegIF/jg2cb6jvljSI=; b=eArMVfWEfQYqAi7b7OT6B+k9tkJBpgC+Q5YEevfrWDDlyq8PMFMyQcjrZp2sRYRORIht9N 0Bi9C51NxhZyNSQ+hq7KK4lpm6nj+AVS3VTpL0/Rt/RDEGnhgzrXwE/ZwD1Kb6BjYiVI/w jQesQVUgpy/R3dR6g7GYq669ao5yedw= X-MC-Unique: iC2hkR5BMsCk9bi-YigtBQ-1 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=b1BcV5WiBp8LKmmxTl7tfHXLESegIF/jg2cb6jvljSI=; b=t95A5+LzpQ8rbV9ZK3YsBMPTqMa7PD9/8YRVcHnmrpaDisCZkIv2dYd7c+z/0qVjG9 3Ccp8T/VLUeVp5paeiRIpGgKbiLHCASQ8mwfi5R0RnK7giLQYoaZPWeucxaITnLMozv6 LyL8Gv9m4QrskCUxRynQ50dL/FWw5pbBUWBfqXxKTs37OW9iYvthH6NCq32QSRAWECGs 1ir3p9SNs1WVdodl8nXcprjqtRTalu+6MoxrJBEjIonoYGMhF3371Lv2BWfL+fcyImJu rnGjs2lkI8D6vcQoTk05whETT4/ILCdiZuLj/0wdqX0FRZLfeEaQ87AWTSzroju0jfC6 ZzCw== X-Gm-Message-State: AOAM531klEvc/QiKcfJTAGghP5Np0cjPFKUCr3eFfWZNkVNlo9arbnDH 4nKrlngJ07SSLPtfU4B765hKkW2in+dHRjvuY8McdtBJDjHRvk7jAzZNnjKnJDbTS1J+SyjlBsY gzUQ75qZti0Xehw== X-Received: by 2002:adf:a3c6:: with SMTP id m6mr4852196wrb.32.1629390873922; Thu, 19 Aug 2021 09:34:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAp9Aue44zgaObYaItnGDCL+p5AUvxyiRGrLr2qY4HusiLTcG2fL/Ee3HcZTMJnUL7aBvEGg== X-Received: by 2002:adf:a3c6:: with SMTP id m6mr4852182wrb.32.1629390873808; Thu, 19 Aug 2021 09:34:33 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , Peter Maydell , qemu-arm@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 2/4] hw/dma/xlnx_csu_dma: Run trivial checks early in realize() Date: Thu, 19 Aug 2021 18:34:20 +0200 Message-Id: <20210819163422.2863447-3-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819163422.2863447-1-philmd@redhat.com> References: <20210819163422.2863447-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: 1629390879153100001 If some property are not set, we'll return indicating a failure, so it is pointless to allocate / initialize some fields too early. Move the trivial checks earlier in realize(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Alistair Francis --- hw/dma/xlnx_csu_dma.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c index 797b4fed8f5..2d19f415ef3 100644 --- a/hw/dma/xlnx_csu_dma.c +++ b/hw/dma/xlnx_csu_dma.c @@ -626,6 +626,11 @@ static void xlnx_csu_dma_realize(DeviceState *dev, Err= or **errp) XlnxCSUDMA *s =3D XLNX_CSU_DMA(dev); RegisterInfoArray *reg_array; =20 + if (!s->is_dst && !s->tx_dev) { + error_setg(errp, "zynqmp.csu-dma: Stream not connected"); + return; + } + reg_array =3D register_init_block32(dev, xlnx_csu_dma_regs_info[!!s->is_dst], XLNX_CSU_DMA_R_MAX, @@ -640,11 +645,6 @@ static void xlnx_csu_dma_realize(DeviceState *dev, Err= or **errp) sysbus_init_mmio(SYS_BUS_DEVICE(dev), &s->iomem); sysbus_init_irq(SYS_BUS_DEVICE(dev), &s->irq); =20 - if (!s->is_dst && !s->tx_dev) { - error_setg(errp, "zynqmp.csu-dma: Stream not connected"); - return; - } - s->src_timer =3D ptimer_init(xlnx_csu_dma_src_timeout_hit, s, PTIMER_POLICY_DEFAULT); =20 --=20 2.31.1 From nobody Sun May 19 01:26:50 2024 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=1629390882; cv=none; d=zohomail.com; s=zohoarc; b=E4qbfsOeadCqGjzabtFPtp1nFOzyavA3+vI8H4hvTxm2szW2qJIoe/nKp0utgAO2r3q+sEtUlIwMGI5Dab6CqY3HiZKEG7vqUO6n7nB3to4iIRzA/9NKGAOKmBjF6g2TZhCf8YjssOnOvmNIxFTSByCzvZCbn8cgiOrTgDyyQ7o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629390882; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=zypsqy4bbbHKSJYTV7SCgvLzNsZfKZVVCMytHeZVqM4=; b=MZE+c2RYY4S41bv3ro4YviTH/8QHnPm+8L3pRRW2BP/DT9FG5Eh3HYem3D8Bj3sjVvXQ5kfHDfvLzUpRq/89gBWy5kJ5a0gY2qM74zEY1H6EyFV5ECoTvDf+yDvjtnTKowxk6xsymgnBb/6NhUpbauOUb3YQHzX1og8Yl6rzaMU= 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 1629390882514801.6491260261872; Thu, 19 Aug 2021 09:34:42 -0700 (PDT) Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-470-x83_LyBjOUmmlk6_kkqqTQ-1; Thu, 19 Aug 2021 12:34:40 -0400 Received: by mail-wr1-f72.google.com with SMTP id v18-20020adfe2920000b029013bbfb19640so1867627wri.17 for ; Thu, 19 Aug 2021 09:34:40 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id m7sm7733487wmq.29.2021.08.19.09.34.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 09:34:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629390881; 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=zypsqy4bbbHKSJYTV7SCgvLzNsZfKZVVCMytHeZVqM4=; b=ZqlA+ED5+kphrIR+MLKQQwoC5Uq+Rn9dyo2BuKOuVf2BgZtf+Ks/w3UCMTr5pX7U/mE4n8 AOCQd0RviwyNdnY5Fx0QbSar0vj4qVe33DJAxyKWzAcWGH/mI+zU708xg3js+3Iw08p459 7hK55CY8aR7VuXGPpgn1rVpXyBI/cR4= X-MC-Unique: x83_LyBjOUmmlk6_kkqqTQ-1 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=zypsqy4bbbHKSJYTV7SCgvLzNsZfKZVVCMytHeZVqM4=; b=V0HnK+w/ld9knH/xA3ggNOLRr0khP3JM4B+PMsE+4q37abZhOAgSd3DY7eEQykLCiN T13jl4Z7AvQ38Z1YEsIgq4rt28iXyGY2bvu9AGKncjD8DWwScTwz0RXGgtsgtOtPd+Ni lt5nA0KKfase3ruvaiYFIuLEx3Oe8AgiqrDo0bgRXOyclJhzKNIGHQ04u/3pooTO7w12 Hi3G3u0nd2FA1qO52h6hoezbM7wd6ZYSkcFTliPNx601lTp27CVO42gK9ySS1yJSyHp1 dgfCLyEpMgTf59/X+tVTc8w66EQ/S3Y7yCeJMX6v48P5GAQ2U9xiyi4fbXAVngI3xTMp umeg== X-Gm-Message-State: AOAM5331oXzC0VWXUB9hqw7WlacX/lKA3DeXOE8ndyOWOyrAzYYouxNY nHIFyHCDzTJhNYyDVoa4Z2rdbKN0LLtjocSBBugWi4NWCKlOJM8sxqk0ttGFMvEAqwF8zNAqzIC yhb1UzcWiM4T/3w== X-Received: by 2002:a7b:c2f0:: with SMTP id e16mr14558479wmk.144.1629390878549; Thu, 19 Aug 2021 09:34:38 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwAGPWSpgOnH0JBICXXHKKK05Tc60a5QFPC80BT4Z+hHxsrm06VfU/mKBdnX2nLXrsyvcnTFg== X-Received: by 2002:a7b:c2f0:: with SMTP id e16mr14558463wmk.144.1629390878399; Thu, 19 Aug 2021 09:34:38 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , Peter Maydell , qemu-arm@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 3/4] hw/dma/xlnx_csu_dma: Always expect 'dma' link property to be set Date: Thu, 19 Aug 2021 18:34:21 +0200 Message-Id: <20210819163422.2863447-4-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819163422.2863447-1-philmd@redhat.com> References: <20210819163422.2863447-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: 1629390883772100001 Simplify by always passing a MemoryRegion property to the device. Doing so we can move the AddressSpace field to the device struct, removing need for heap allocation. Update the Xilinx ZynqMP SoC model to pass the default system memory instead of a NULL value. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell --- include/hw/dma/xlnx_csu_dma.h | 2 +- hw/arm/xlnx-zynqmp.c | 4 ++++ hw/dma/xlnx_csu_dma.c | 21 ++++++++++----------- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/include/hw/dma/xlnx_csu_dma.h b/include/hw/dma/xlnx_csu_dma.h index 204d94c6737..9e9dc551e99 100644 --- a/include/hw/dma/xlnx_csu_dma.h +++ b/include/hw/dma/xlnx_csu_dma.h @@ -30,7 +30,7 @@ typedef struct XlnxCSUDMA { MemoryRegion iomem; MemTxAttrs attr; MemoryRegion *dma_mr; - AddressSpace *dma_as; + AddressSpace dma_as; qemu_irq irq; StreamSink *tx_dev; /* Used as generic StreamSink */ ptimer_state *src_timer; diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 9724978761b..4344e223f2d 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -620,6 +620,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Erro= r **errp) gic_spi[adma_ch_intr[i]]); } =20 + if (!object_property_set_link(OBJECT(&s->qspi_dma), "dma", + OBJECT(system_memory), errp)) { + return; + } if (!sysbus_realize(SYS_BUS_DEVICE(&s->qspi_dma), errp)) { return; } diff --git a/hw/dma/xlnx_csu_dma.c b/hw/dma/xlnx_csu_dma.c index 2d19f415ef3..896bb3574dd 100644 --- a/hw/dma/xlnx_csu_dma.c +++ b/hw/dma/xlnx_csu_dma.c @@ -201,11 +201,11 @@ static uint32_t xlnx_csu_dma_read(XlnxCSUDMA *s, uint= 8_t *buf, uint32_t len) for (i =3D 0; i < len && (result =3D=3D MEMTX_OK); i +=3D s->width= ) { uint32_t mlen =3D MIN(len - i, s->width); =20 - result =3D address_space_rw(s->dma_as, addr, s->attr, + result =3D address_space_rw(&s->dma_as, addr, s->attr, buf + i, mlen, false); } } else { - result =3D address_space_rw(s->dma_as, addr, s->attr, buf, len, fa= lse); + result =3D address_space_rw(&s->dma_as, addr, s->attr, buf, len, f= alse); } =20 if (result =3D=3D MEMTX_OK) { @@ -232,12 +232,12 @@ static uint32_t xlnx_csu_dma_write(XlnxCSUDMA *s, uin= t8_t *buf, uint32_t len) for (i =3D 0; i < len && (result =3D=3D MEMTX_OK); i +=3D s->width= ) { uint32_t mlen =3D MIN(len - i, s->width); =20 - result =3D address_space_rw(s->dma_as, addr, s->attr, + result =3D address_space_rw(&s->dma_as, addr, s->attr, buf, mlen, true); buf +=3D mlen; } } else { - result =3D address_space_rw(s->dma_as, addr, s->attr, buf, len, tr= ue); + result =3D address_space_rw(&s->dma_as, addr, s->attr, buf, len, t= rue); } =20 if (result !=3D MEMTX_OK) { @@ -631,6 +631,12 @@ static void xlnx_csu_dma_realize(DeviceState *dev, Err= or **errp) return; } =20 + if (!s->dma_mr) { + error_setg(errp, TYPE_XLNX_CSU_DMA " 'dma' link not set"); + return; + } + address_space_init(&s->dma_as, s->dma_mr, "csu-dma"); + reg_array =3D register_init_block32(dev, xlnx_csu_dma_regs_info[!!s->is_dst], XLNX_CSU_DMA_R_MAX, @@ -648,13 +654,6 @@ static void xlnx_csu_dma_realize(DeviceState *dev, Err= or **errp) s->src_timer =3D ptimer_init(xlnx_csu_dma_src_timeout_hit, s, PTIMER_POLICY_DEFAULT); =20 - if (s->dma_mr) { - s->dma_as =3D g_malloc0(sizeof(AddressSpace)); - address_space_init(s->dma_as, s->dma_mr, NULL); - } else { - s->dma_as =3D &address_space_memory; - } - s->attr =3D MEMTXATTRS_UNSPECIFIED; =20 s->r_size_last_word =3D 0; --=20 2.31.1 From nobody Sun May 19 01:26:50 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.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 216.205.24.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=1629390886; cv=none; d=zohomail.com; s=zohoarc; b=eRY6TejCjJunK9VixSYzmBdRrr36moPy1PexeOOkT9O6dr/nkGDHalmUlSXLEiFi/qlnKcUzYnl1+fzA0nsl85k40BIixQOpQpETa+2HX5cOuL8Fj2lK1iBHBT9kLr4Qe+IhWbbMl6Rh7YefxGpDwoycSy6n5El2ZtAfFZFIam0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1629390886; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:To; bh=UUbBguyXCVYJjhJZ+w9myvvn9hfolADVgWzdBMV8UY0=; b=cNlvb8k6qIUHY1EQ9vBQP3RR0vr+/4PKcutHagM/GSew5tR37ygGT/W8dIqZ6vqDxVRKFm51QA8Pvg4/f65jPT+fifUbjPim8wCYljJF0jNBumCpj01Xy6HLqarESjZBVqShI3ZDMuTg+3WeiqH3dmZ8AhaKwnfoL9HZn75i+tw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.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 [216.205.24.124]) by mx.zohomail.com with SMTPS id 1629390886541483.3127053725176; Thu, 19 Aug 2021 09:34:46 -0700 (PDT) Received: from mail-wr1-f71.google.com (mail-wr1-f71.google.com [209.85.221.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-23-cREQ0Oc6N5e24nN1szuCLw-1; Thu, 19 Aug 2021 12:34:44 -0400 Received: by mail-wr1-f71.google.com with SMTP id m2-20020a0560000082b0290154f6e2e51fso1877148wrx.12 for ; Thu, 19 Aug 2021 09:34:44 -0700 (PDT) Return-Path: Return-Path: Received: from x1w.. (163.red-83-52-55.dynamicip.rima-tde.net. [83.52.55.163]) by smtp.gmail.com with ESMTPSA id b20sm3035140wmj.48.2021.08.19.09.34.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Aug 2021 09:34:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1629390885; 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=UUbBguyXCVYJjhJZ+w9myvvn9hfolADVgWzdBMV8UY0=; b=KWNfi7kioYTuFjci9olhb9aLIm7ytT2zkS9mhWXBmM3kaqIey7T1sjem5H7HHizwkL7qsi 4brTMFTzcteDfJhFVIDy+Nbwt0FzqwYmptcIS2dC8WZrtNrEhV3tISWgLrQGINe9OlP7Uh TVwvCzDY5dO8cCS1jVXm5/2ICRkpNL4= X-MC-Unique: cREQ0Oc6N5e24nN1szuCLw-1 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=UUbBguyXCVYJjhJZ+w9myvvn9hfolADVgWzdBMV8UY0=; b=X6tpTIjsxHXCLoiOBT6QWAajJIjHFcLYpGsNY3+JdGXROyXTQXQkVplWfczGM4ON/l 2wgBNWufFaWzhktzLT3dQAZ0ocPCWERg+rHMOehKsjzhsdNnMqnHwyyvFHLfVP6Yd8V0 7vfMQ+Yi7pizhvg98maRs8fagSDvWmoDdxKEiGgqEI/Lzvp6QbqXooUdt2FEjvr45lV2 O5hc+RBUV6IS57GWncCdLnm9katkl03vIO7U25dajf0oYNmJFgD2KewXSek44FIEE3VF kTR8PAOA+MfBXhIE42tKmHO1Jdru1ZzYmKq/31L0uWHnDnMHXZPut77kSETqBZHpBapG FEog== X-Gm-Message-State: AOAM532zT0hQaO2/WbQhKFi/UntyFctx/XGJpejwGPN/M2djm1cluwbI OfPxN0CyddJYoFMHuwKgwefTnHUqIrvqnmeUg6LxQr5Pr1rhmt2KAFcYJ/4f82Y5d33NMSJjMn0 VWDK52zR9euu1SQ== X-Received: by 2002:a5d:610d:: with SMTP id v13mr4999044wrt.199.1629390882948; Thu, 19 Aug 2021 09:34:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwmaEtnCEXhfyBtiG7sklsRZFxJHkJPBiuZL3RTfmR91Y7klbwLTOR6Lg0tS+Od/Q+PGWTGyg== X-Received: by 2002:a5d:610d:: with SMTP id v13mr4999028wrt.199.1629390882797; Thu, 19 Aug 2021 09:34:42 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org Cc: "Edgar E. Iglesias" , Peter Maydell , qemu-arm@nongnu.org, Alistair Francis , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Subject: [PATCH v2 4/4] hw/dma/xlnx-zdma Always expect 'dma' link property to be set Date: Thu, 19 Aug 2021 18:34:22 +0200 Message-Id: <20210819163422.2863447-5-philmd@redhat.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210819163422.2863447-1-philmd@redhat.com> References: <20210819163422.2863447-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: 1629390888475100001 Simplify by always passing a MemoryRegion property to the device. Doing so we can move the AddressSpace field to the device struct, removing need for heap allocation. Update the Xilinx ZynqMP / Versal SoC models to pass the default system memory instead of a NULL value. Suggested-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Peter Maydell --- include/hw/dma/xlnx-zdma.h | 2 +- hw/arm/xlnx-versal.c | 2 ++ hw/arm/xlnx-zynqmp.c | 8 ++++++++ hw/dma/xlnx-zdma.c | 24 ++++++++++++------------ 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/include/hw/dma/xlnx-zdma.h b/include/hw/dma/xlnx-zdma.h index 6602e7ffa72..efc75217d59 100644 --- a/include/hw/dma/xlnx-zdma.h +++ b/include/hw/dma/xlnx-zdma.h @@ -56,7 +56,7 @@ struct XlnxZDMA { MemoryRegion iomem; MemTxAttrs attr; MemoryRegion *dma_mr; - AddressSpace *dma_as; + AddressSpace dma_as; qemu_irq irq_zdma_ch_imr; =20 struct { diff --git a/hw/arm/xlnx-versal.c b/hw/arm/xlnx-versal.c index fb776834f7e..d60eb4fb184 100644 --- a/hw/arm/xlnx-versal.c +++ b/hw/arm/xlnx-versal.c @@ -218,6 +218,8 @@ static void versal_create_admas(Versal *s, qemu_irq *pi= c) TYPE_XLNX_ZDMA); dev =3D DEVICE(&s->lpd.iou.adma[i]); object_property_set_int(OBJECT(dev), "bus-width", 128, &error_abor= t); + object_property_set_link(OBJECT(dev), "dma", + OBJECT(get_system_memory()), &error_fatal= ); sysbus_realize(SYS_BUS_DEVICE(dev), &error_fatal); =20 mr =3D sysbus_mmio_get_region(SYS_BUS_DEVICE(dev), 0); diff --git a/hw/arm/xlnx-zynqmp.c b/hw/arm/xlnx-zynqmp.c index 4344e223f2d..6cfce26210d 100644 --- a/hw/arm/xlnx-zynqmp.c +++ b/hw/arm/xlnx-zynqmp.c @@ -601,6 +601,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Erro= r **errp) errp)) { return; } + if (!object_property_set_link(OBJECT(&s->gdma[i]), "dma", + OBJECT(system_memory), errp)) { + return; + } if (!sysbus_realize(SYS_BUS_DEVICE(&s->gdma[i]), errp)) { return; } @@ -611,6 +615,10 @@ static void xlnx_zynqmp_realize(DeviceState *dev, Erro= r **errp) } =20 for (i =3D 0; i < XLNX_ZYNQMP_NUM_ADMA_CH; i++) { + if (!object_property_set_link(OBJECT(&s->adma[i]), "dma", + OBJECT(system_memory), errp)) { + return; + } if (!sysbus_realize(SYS_BUS_DEVICE(&s->adma[i]), errp)) { return; } diff --git a/hw/dma/xlnx-zdma.c b/hw/dma/xlnx-zdma.c index fa38a556341..a5a92b4ff8c 100644 --- a/hw/dma/xlnx-zdma.c +++ b/hw/dma/xlnx-zdma.c @@ -320,9 +320,9 @@ static bool zdma_load_descriptor(XlnxZDMA *s, uint64_t = addr, return false; } =20 - descr->addr =3D address_space_ldq_le(s->dma_as, addr, s->attr, NULL); - descr->size =3D address_space_ldl_le(s->dma_as, addr + 8, s->attr, NUL= L); - descr->attr =3D address_space_ldl_le(s->dma_as, addr + 12, s->attr, NU= LL); + descr->addr =3D address_space_ldq_le(&s->dma_as, addr, s->attr, NULL); + descr->size =3D address_space_ldl_le(&s->dma_as, addr + 8, s->attr, NU= LL); + descr->attr =3D address_space_ldl_le(&s->dma_as, addr + 12, s->attr, N= ULL); return true; } =20 @@ -354,7 +354,7 @@ static void zdma_update_descr_addr(XlnxZDMA *s, bool ty= pe, } else { addr =3D zdma_get_regaddr64(s, basereg); addr +=3D sizeof(s->dsc_dst); - next =3D address_space_ldq_le(s->dma_as, addr, s->attr, NULL); + next =3D address_space_ldq_le(&s->dma_as, addr, s->attr, NULL); } =20 zdma_put_regaddr64(s, basereg, next); @@ -421,7 +421,7 @@ static void zdma_write_dst(XlnxZDMA *s, uint8_t *buf, u= int32_t len) } } =20 - address_space_write(s->dma_as, s->dsc_dst.addr, s->attr, buf, dlen= ); + address_space_write(&s->dma_as, s->dsc_dst.addr, s->attr, buf, dle= n); if (burst_type =3D=3D AXI_BURST_INCR) { s->dsc_dst.addr +=3D dlen; } @@ -497,7 +497,7 @@ static void zdma_process_descr(XlnxZDMA *s) len =3D s->cfg.bus_width / 8; } } else { - address_space_read(s->dma_as, src_addr, s->attr, s->buf, len); + address_space_read(&s->dma_as, src_addr, s->attr, s->buf, len); if (burst_type =3D=3D AXI_BURST_INCR) { src_addr +=3D len; } @@ -765,6 +765,12 @@ static void zdma_realize(DeviceState *dev, Error **err= p) XlnxZDMA *s =3D XLNX_ZDMA(dev); unsigned int i; =20 + if (!s->dma_mr) { + error_setg(errp, TYPE_XLNX_ZDMA " 'dma' link not set"); + return; + } + address_space_init(&s->dma_as, s->dma_mr, "zdma-dma"); + for (i =3D 0; i < ARRAY_SIZE(zdma_regs_info); ++i) { RegisterInfo *r =3D &s->regs_info[zdma_regs_info[i].addr / 4]; =20 @@ -777,12 +783,6 @@ static void zdma_realize(DeviceState *dev, Error **err= p) }; } =20 - if (s->dma_mr) { - s->dma_as =3D g_malloc0(sizeof(AddressSpace)); - address_space_init(s->dma_as, s->dma_mr, NULL); - } else { - s->dma_as =3D &address_space_memory; - } s->attr =3D MEMTXATTRS_UNSPECIFIED; } =20 --=20 2.31.1