Received: by 2002:a17:906:fcb7:b0:974:3dd3:6e73 with SMTP id qw23csp2904417ejb; Mon, 5 Jun 2023 09:21:56 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7ipqCT5t/zY2c89qWwWByNct1NUSW2fqjXc99IVotQZMKLU9w04xyptiK3C33+Ocp8+Alq X-Received: by 2002:ac8:5746:0:b0:3f8:14:58e9 with SMTP id 6-20020ac85746000000b003f8001458e9mr10139415qtx.13.1685982116611; Mon, 05 Jun 2023 09:21:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1685982116; cv=none; d=google.com; s=arc-20160816; b=nR1FPFZKa3X7uNlEBC94LHT7ia4nhEiIWlqB6JDhtdwwEq+tKk1DJy1HSHXG0y2xW0 VpknackC7qrwyzKsOmd4acnKm6qQ9QYmDksIpjd43NvuJcVZwKmpjDSC55V6opClsNN2 DYDtXr4O3tH38ND7BZg+NzAh7EoEdQl0Fwq6fpP17BmHismZJrr5/SjKV8hND6MNqer1 UiAJa0s2gCrQFEBPL7xjXCS+141ZrP3pufmYNiKJle7bw1urtQHIrZWwaFUd4PtDxvum FEF9SDSMY8qxX53sY44hAFpqO+56/2PQYG0eRBvxsYYsJZnKBZEWOFluL+DTO7TNcWRt oiLQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :in-reply-to:from:references:cc:to:content-language:subject :user-agent:mime-version:date:message-id; bh=XnMtzO69TponQ6ZqDZam1EzWNSgGbuomWltlO03386E=; b=Uurb1ymlouXSIwz/LEUdraaPQbGN6JNiBDY0u0NXfEUGXKYtA7W1xyseu4urTuxXMW D32WTmlDoSJ+SvfB6g1N1q2DxQFFQU8HwngEvPmSiUKpTt0Qc/jhz3bC4dbWta8NtCS+ kTWXIvXFlsLTqdsSBtMRCvucVFROlBeu2vIZGJBdxY81mj5qan/9fq+AREGJaaHhlpoZ qIwteER2Ph6Ck5C2RZ96nPXbz30XU0bFyA0csprIqC3nr5LCAFAtttaLZ3xDoqN5qxmE 9PoA7Yh13kcIyScy60meZa4SoZ93Dt+mBpN6qeKrmALvBDAfN2DI7bBsz2rOTDsxbaXC ArBw== ARC-Authentication-Results: i=1; mx.google.com; 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" Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id j13-20020a05622a038d00b003ef5008333bsi4800784qtx.431.2023.06.05.09.21.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 05 Jun 2023 09:21:56 -0700 (PDT) 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; 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" Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1q6Cxp-0008HK-7C; Mon, 05 Jun 2023 12:21:49 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6Cxn-0008Go-Tm; Mon, 05 Jun 2023 12:21:47 -0400 Received: from gandalf.ozlabs.org ([150.107.74.76]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1q6Cxl-0000i4-Rr; Mon, 05 Jun 2023 12:21:47 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by gandalf.ozlabs.org (Postfix) with ESMTP id 4QZf4g4xpQz4x4G; Tue, 6 Jun 2023 02:21:39 +1000 (AEST) Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4QZf4X6WX5z4x4C; Tue, 6 Jun 2023 02:21:32 +1000 (AEST) Message-ID: Date: Mon, 5 Jun 2023 18:21:27 +0200 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.10.0 Subject: Re: [PATCH 05/12] hw/ssi: Introduce a ssi_get_cs() helper Content-Language: en-US To: Bernhard Beschow , =?UTF-8?Q?Philippe_Mathieu-Daud=c3=a9?= , qemu-arm@nongnu.org Cc: qemu-devel@nongnu.org, Peter Maydell , Joel Stanley , Andrew Jeffery , Alistair Francis , Mark Cave-Ayland , Eduardo Habkost , Markus Armbruster , Thomas Huth References: <20230508075859.3326566-1-clg@kaod.org> <20230508075859.3326566-6-clg@kaod.org> <40c8647d-201e-3ceb-97ca-ec98bdc84e88@linaro.org> <0d11b78e-56f7-553a-3e85-0edef9b649ac@linaro.org> <523179dd-7842-7f03-14d6-678ed680a017@kaod.org> <6bfba08e-ce3e-539b-952d-697c8791fab2@linaro.org> <54d781f8-35d0-9e68-c2ec-743dd8f6a88e@kaod.org> <36c9bda8-3af2-ebf5-f8b9-599cafea0735@linaro.org> <467372F8-7DB7-41FB-8BA0-6CF12EC3AC50@gmail.com> From: =?UTF-8?Q?C=c3=a9dric_Le_Goater?= In-Reply-To: <467372F8-7DB7-41FB-8BA0-6CF12EC3AC50@gmail.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit Received-SPF: pass client-ip=150.107.74.76; envelope-from=SRS0=6mOa=BZ=kaod.org=clg@ozlabs.org; helo=gandalf.ozlabs.org X-Spam_score_int: -17 X-Spam_score: -1.8 X-Spam_bar: - X-Spam_report: (-1.8 / 5.0 requ) BAYES_00=-1.9, HEADER_FROM_DIFFERENT_DOMAINS=0.25, NICE_REPLY_A=-0.09, SPF_HELO_PASS=-0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=no 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: , Errors-To: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org Sender: qemu-arm-bounces+alex.bennee=linaro.org@nongnu.org X-TUID: a5GtQ3TkjZdY On 6/5/23 07:57, Bernhard Beschow wrote: > > > Am 31. Mai 2023 07:39:32 UTC schrieb "Philippe Mathieu-Daudé" : >> On 31/5/23 08:36, Cédric Le Goater wrote: >>> On 5/31/23 08:17, Philippe Mathieu-Daudé wrote: >>>> +QOM tinkerers >>>> >>>> On 31/5/23 07:59, Cédric Le Goater wrote: >>>>> On 5/30/23 23:15, Philippe Mathieu-Daudé wrote: >>>>>> On 30/5/23 22:34, Philippe Mathieu-Daudé wrote: >>>>>>> On 8/5/23 09:58, Cédric Le Goater wrote: >>>>>>>> Simple routine to retrieve a DeviceState object on a SPI bus using its >>>>>>>> address/cs. It will be useful for the board to wire the CS lines. >>>>>>>> >>>>>>>> Cc: Alistair Francis >>>>>>>> Signed-off-by: Cédric Le Goater >>>>>>>> --- >>>>>>>>   include/hw/ssi/ssi.h |  2 ++ >>>>>>>>   hw/ssi/ssi.c         | 15 +++++++++++++++ >>>>>>>>   2 files changed, 17 insertions(+) >>>>>>>> >>>>>>>> diff --git a/include/hw/ssi/ssi.h b/include/hw/ssi/ssi.h >>>>>>>> index ffd3a34ba4..c7beabdb09 100644 >>>>>>>> --- a/include/hw/ssi/ssi.h >>>>>>>> +++ b/include/hw/ssi/ssi.h >>>>>>>> @@ -112,4 +112,6 @@ SSIBus *ssi_create_bus(DeviceState *parent, const char *name); >>>>>>>>   uint32_t ssi_transfer(SSIBus *bus, uint32_t val); >>>>>>>> +DeviceState *ssi_get_cs(SSIBus *bus, int addr); >>>>>> >>>>>> Also, this helper should (preferably) return a SSIPeripheral type. >>>>> >>>>> Well, having a DeviceState is handy for the callers (today) and >>>>> ssi_create_peripheral() returns a DeviceState. Let's keep it that >>>>> way. >>>> >>>> Yes I know it is handy :) I'm not against your patch; besides other >>>> APIs do that. I'm wondering about QOM design here. Having Foo device, >>>> should FOO API return the common qdev abstract type (DeviceState) or >>>> a Foo type? Either ways we keep QOM-casting around, but I still tend >>>> to consider FOO API returning Foo pointer provides some type check >>>> safety, and also provides the API user hints about what is used. >>>> Need more coffee. >>> >>> It is used in two code paths today: >>> >>>     ... >>>         DeviceState *dev = ssi_get_cs(bmc->soc.fmc.spi, 0); >>>         BlockBackend *fmc0 = dev ? m25p80_get_blk(dev) : NULL; > > Looks like m25p80_get_blk() should take a more specific argument as well, like Phil suggested already. Wouldn't that avoid the QOM cast here? Exposing the m25p80 internals could be painful. I'd rather keep the definitions where they are under m25p80.c. Thanks, C. > > Best regards, > Bernhard > >>>     ... >>> and >>>     ... >>>         DeviceState *dev = ssi_get_cs(s->spi, i); >>>         if (dev) { >>>             qemu_irq cs_line = qdev_get_gpio_in_named(dev, SSI_GPIO_CS, 0); >>>     ... >>> >>> >>> Changing the interface is not a radical change, it will add two QOM-casts. >>> I can give it a try in v2. >> >> Hold on, lets see what others think first.