From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from list by lists.gnu.org with archive (Exim 4.90_1) id 1muDDE-0001pR-IJ for mharc-qemu-riscv@gnu.org; Mon, 06 Dec 2021 07:35:21 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49190) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDD4-0001lZ-Aa for qemu-riscv@nongnu.org; Mon, 06 Dec 2021 07:35:13 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:53215) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDCz-0003bB-BE for qemu-riscv@nongnu.org; Mon, 06 Dec 2021 07:35:08 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638794101; 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=NUtrJqK3wUAMb5eiBVNGE5aHlgdymb6vCYIWJKCdnTw=; b=f0x5UE/z/DEGDCDrkhlZjDpPDr5v5oVfx8slKi4VT2ZEZQwH2gPXYt64WuLk9KE6WiVFB/ 6JKohL1gXg0gXd229Pe2K+lztlG88wqAK6nmpnY/9fFIQcunvmmE+OSOaZcePISxHpC7gh c6kbeNJxuQ7lTniVRP9Tvre5kifoYAA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-190-Fw2eJf1SPqO-9RiMdOFL-w-1; Mon, 06 Dec 2021 07:34:58 -0500 X-MC-Unique: Fw2eJf1SPqO-9RiMdOFL-w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58D9010168C3; Mon, 6 Dec 2021 12:34:56 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D56CD694BF; Mon, 6 Dec 2021 12:34:55 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 61FE1113865F; Mon, 6 Dec 2021 13:34:54 +0100 (CET) From: Markus Armbruster To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Cc: qemu-devel@nongnu.org, Peter Maydell , qemu-riscv@nongnu.org, qemu-block@nongnu.org, Bin Meng , qemu-arm@nongnu.org, Alistair Francis , Palmer Dabbelt Subject: Re: [PATCH v2 01/13] hw/sd/ssi-sd: Do not create SD card within controller's realize References: <20211117163409.3587705-1-armbru@redhat.com> <20211117163409.3587705-2-armbru@redhat.com> <575fcf95-f4f0-3d88-ab08-b4d21f2da354@amsat.org> Date: Mon, 06 Dec 2021 13:34:54 +0100 In-Reply-To: <575fcf95-f4f0-3d88-ab08-b4d21f2da354@amsat.org> ("Philippe =?utf-8?Q?Mathieu-Daud=C3=A9=22's?= message of "Wed, 17 Nov 2021 20:45:15 +0100") Message-ID: <87tufllxn5.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.619, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-riscv@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 Dec 2021 12:35:14 -0000 Philippe Mathieu-Daud=C3=A9 writes: > Hi Markus, Peter, > > On 11/17/21 17:33, Markus Armbruster wrote: >> ssi_sd_realize() creates an "sd-card" device. This is inappropriate, >> and marked FIXME. >>=20 >> Move it to the boards that create these devices. Prior art: commit >> eb4f566bbb for device "generic-sdhci", and commit 26c607b86b for >> device "pl181". >>=20 >> The device remains not user-creatable, because its users should (and >> do) wire up its GPIO chip-select line. >>=20 >> Cc: Peter Maydell >> Cc: Alistair Francis >> Cc: Bin Meng >> Cc: Palmer Dabbelt >> Cc: "Philippe Mathieu-Daud=C3=A9" >> Cc: qemu-arm@nongnu.org >> Cc: qemu-riscv@nongnu.org >> Signed-off-by: Markus Armbruster > > Reviewed-by: Philippe Mathieu-Daud=C3=A9 > >> --- >> hw/arm/stellaris.c | 15 ++++++++++++++- >> hw/riscv/sifive_u.c | 13 ++++++++++++- >> hw/sd/ssi-sd.c | 29 +---------------------------- >> 3 files changed, 27 insertions(+), 30 deletions(-) >>=20 >> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c >> index 78827ace6b..b6c8a5d609 100644 >> --- a/hw/arm/stellaris.c >> +++ b/hw/arm/stellaris.c >> @@ -10,6 +10,7 @@ >> #include "qemu/osdep.h" >> #include "qapi/error.h" >> #include "hw/sysbus.h" >> +#include "hw/sd/sd.h" >> #include "hw/ssi/ssi.h" >> #include "hw/arm/boot.h" >> #include "qemu/timer.h" >> @@ -1157,6 +1158,9 @@ static void stellaris_init(MachineState *ms, stell= aris_board_info *board) >> void *bus; >> DeviceState *sddev; >> DeviceState *ssddev; >> + DriveInfo *dinfo; >> + DeviceState *carddev; >> + BlockBackend *blk; >> =20 >> /* >> * Some boards have both an OLED controller and SD card con= nected to >> @@ -1221,8 +1225,17 @@ static void stellaris_init(MachineState *ms, stel= laris_board_info *board) >> * - Make the ssd0323 OLED controller chipselect active-lo= w >> */ >> bus =3D qdev_get_child_bus(dev, "ssi"); >> - >> sddev =3D ssi_create_peripheral(bus, "ssi-sd"); >> + >> + dinfo =3D drive_get(IF_SD, 0, 0); >> + blk =3D dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; >> + carddev =3D qdev_new(TYPE_SD_CARD); >> + qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal= ); > > I guess a already asked this once but don't remember now... What is the > point of creating a SD card without drive? Is this due to the old design > issue we hotplug the drive to the SD card and not the SD card on the SD > bus? Device model "sd-card" implements BlockdevOps method change_media_cb(). This menas it models a device with a removable medium. No drive behaves like no medium. I guess it's an SD card reader. > >> + qdev_prop_set_bit(carddev, "spi", true); >> + qdev_realize_and_unref(carddev, >> + qdev_get_child_bus(sddev, "sd-bus"), >> + &error_fatal); >> + From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:ac2:5544:0:0:0:0:0 with SMTP id l4csp3192025lfk; Mon, 6 Dec 2021 04:35:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJxAYBbppitqtRQ58+oLGMidkik9PLpKse32ZHfyo52+BFkIWd5gE5vzSP13tcZsndOWSW9Z X-Received: by 2002:a05:6122:1803:: with SMTP id ay3mr41234858vkb.24.1638794148164; Mon, 06 Dec 2021 04:35:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1638794148; cv=none; d=google.com; s=arc-20160816; b=gPUZRmr2fDUkHviVCXOeSzj0bp8bVqXeb7Qz9VFqHle/WUniWLl20WXwd0JZF26/dA 5Tv2bcFhUVd+TZEq1hRT+8AUzVrffkRacDSkYGrDpmi5yImeNikFRLrJNiv6JdvGtjXd 1Nr/V3ZUmwkhge//bkKyPS8KhIJXagKjvXEyShfzBkrdxQnCMukNqyCCmz6IYenYHSfM /iJIb7CKOWW+3cyzY6hofQtYov2oJIOfOntRWBhaNwonM4AnsrCgTm+OwfcCx9eFtKdm oXgIjbetnHTGQu5RHMwxXPaRvCnhxjLFyg3k+cvTE4Zr9maViPGok3X8lLUWGStLFAgA 3lwQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:user-agent:message-id:in-reply-to:date:references :subject:to:from:dkim-signature; bh=NUtrJqK3wUAMb5eiBVNGE5aHlgdymb6vCYIWJKCdnTw=; b=DMrNI0/OXiwFtyCvJxrTl/5Mzfv//HAbDCVvBL51J4OXadrx+2DyqyIfhvymtgSe8o DbFxeeD0LNsNQkBLnktkSiQMshagrq6cxfrFGKt4O8OaaAXw0Xnx1r0NtpWQpnmFytWm RNT9yAN8VHwFfUS8cwZAdFZY0yIkY5UldBsx9GJS+opbkeqi4wa+y5+Fi2R3YDwX0Ahb HvS/GpOrGtPTXpNv/HZ/VOOIBblIkLJ4mN3Q9ZjnCBMJkUBoAOR9XUw0ABq9YZ93hwRA WN1MN7vCvwTFx3U0+L086VcOkHSA+XAYHnPTv/KY5NJPNHBk8c8NhwIgY77qUbMeiq6Z QlXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=csXI52B4; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id 4si10107501vko.132.2021.12.06.04.35.48 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 06 Dec 2021 04:35:48 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=fail header.i=@redhat.com header.s=mimecast20190719 header.b=csXI52B4; spf=pass (google.com: domain of qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from localhost ([::1]:50204 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1muDDf-00023F-HR for alex.bennee@linaro.org; Mon, 06 Dec 2021 07:35:47 -0500 Received: from eggs.gnu.org ([209.51.188.92]:49196) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDD3-0001la-95 for qemu-arm@nongnu.org; Mon, 06 Dec 2021 07:35:10 -0500 Received: from us-smtp-delivery-124.mimecast.com ([170.10.133.124]:31821) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1muDCz-0003be-BL for qemu-arm@nongnu.org; Mon, 06 Dec 2021 07:35:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1638794103; 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=NUtrJqK3wUAMb5eiBVNGE5aHlgdymb6vCYIWJKCdnTw=; b=csXI52B4naVCZ0HWT6cbaohbVLnceZaDfhN6sfp7yuh8atSnICWUVXpCGzc6jeO/2jlPWJ kKtBw9gubSLExoLcxBiJedEjnlIWNs7VIML+68/WWCdgbzoUG/pr1L70P44x75sUq/dfbe fxJj23AMJEjdGXnW/uq5OBVo3sTGCrA= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-190-Fw2eJf1SPqO-9RiMdOFL-w-1; Mon, 06 Dec 2021 07:34:58 -0500 X-MC-Unique: Fw2eJf1SPqO-9RiMdOFL-w-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 58D9010168C3; Mon, 6 Dec 2021 12:34:56 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-112-7.ams2.redhat.com [10.36.112.7]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D56CD694BF; Mon, 6 Dec 2021 12:34:55 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id 61FE1113865F; Mon, 6 Dec 2021 13:34:54 +0100 (CET) From: Markus Armbruster To: Philippe =?utf-8?Q?Mathieu-Daud=C3=A9?= Subject: Re: [PATCH v2 01/13] hw/sd/ssi-sd: Do not create SD card within controller's realize References: <20211117163409.3587705-1-armbru@redhat.com> <20211117163409.3587705-2-armbru@redhat.com> <575fcf95-f4f0-3d88-ab08-b4d21f2da354@amsat.org> Date: Mon, 06 Dec 2021 13:34:54 +0100 In-Reply-To: <575fcf95-f4f0-3d88-ab08-b4d21f2da354@amsat.org> ("Philippe =?utf-8?Q?Mathieu-Daud=C3=A9=22's?= message of "Wed, 17 Nov 2021 20:45:15 +0100") Message-ID: <87tufllxn5.fsf@dusky.pond.sub.org> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux) MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=armbru@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Received-SPF: pass client-ip=170.10.133.124; envelope-from=armbru@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.619, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H2=-0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-arm@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , qemu-riscv@nongnu.org, qemu-block@nongnu.org, Bin Meng , qemu-devel@nongnu.org, qemu-arm@nongnu.org, Alistair Francis , Palmer Dabbelt Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: "Qemu-arm" X-TUID: IoS77553qox8 Philippe Mathieu-Daud=C3=A9 writes: > Hi Markus, Peter, > > On 11/17/21 17:33, Markus Armbruster wrote: >> ssi_sd_realize() creates an "sd-card" device. This is inappropriate, >> and marked FIXME. >>=20 >> Move it to the boards that create these devices. Prior art: commit >> eb4f566bbb for device "generic-sdhci", and commit 26c607b86b for >> device "pl181". >>=20 >> The device remains not user-creatable, because its users should (and >> do) wire up its GPIO chip-select line. >>=20 >> Cc: Peter Maydell >> Cc: Alistair Francis >> Cc: Bin Meng >> Cc: Palmer Dabbelt >> Cc: "Philippe Mathieu-Daud=C3=A9" >> Cc: qemu-arm@nongnu.org >> Cc: qemu-riscv@nongnu.org >> Signed-off-by: Markus Armbruster > > Reviewed-by: Philippe Mathieu-Daud=C3=A9 > >> --- >> hw/arm/stellaris.c | 15 ++++++++++++++- >> hw/riscv/sifive_u.c | 13 ++++++++++++- >> hw/sd/ssi-sd.c | 29 +---------------------------- >> 3 files changed, 27 insertions(+), 30 deletions(-) >>=20 >> diff --git a/hw/arm/stellaris.c b/hw/arm/stellaris.c >> index 78827ace6b..b6c8a5d609 100644 >> --- a/hw/arm/stellaris.c >> +++ b/hw/arm/stellaris.c >> @@ -10,6 +10,7 @@ >> #include "qemu/osdep.h" >> #include "qapi/error.h" >> #include "hw/sysbus.h" >> +#include "hw/sd/sd.h" >> #include "hw/ssi/ssi.h" >> #include "hw/arm/boot.h" >> #include "qemu/timer.h" >> @@ -1157,6 +1158,9 @@ static void stellaris_init(MachineState *ms, stell= aris_board_info *board) >> void *bus; >> DeviceState *sddev; >> DeviceState *ssddev; >> + DriveInfo *dinfo; >> + DeviceState *carddev; >> + BlockBackend *blk; >> =20 >> /* >> * Some boards have both an OLED controller and SD card con= nected to >> @@ -1221,8 +1225,17 @@ static void stellaris_init(MachineState *ms, stel= laris_board_info *board) >> * - Make the ssd0323 OLED controller chipselect active-lo= w >> */ >> bus =3D qdev_get_child_bus(dev, "ssi"); >> - >> sddev =3D ssi_create_peripheral(bus, "ssi-sd"); >> + >> + dinfo =3D drive_get(IF_SD, 0, 0); >> + blk =3D dinfo ? blk_by_legacy_dinfo(dinfo) : NULL; >> + carddev =3D qdev_new(TYPE_SD_CARD); >> + qdev_prop_set_drive_err(carddev, "drive", blk, &error_fatal= ); > > I guess a already asked this once but don't remember now... What is the > point of creating a SD card without drive? Is this due to the old design > issue we hotplug the drive to the SD card and not the SD card on the SD > bus? Device model "sd-card" implements BlockdevOps method change_media_cb(). This menas it models a device with a removable medium. No drive behaves like no medium. I guess it's an SD card reader. > >> + qdev_prop_set_bit(carddev, "spi", true); >> + qdev_realize_and_unref(carddev, >> + qdev_get_child_bus(sddev, "sd-bus"), >> + &error_fatal); >> +