From mboxrd@z Thu Jan 1 00:00:00 1970 Received: by 2002:ac2:4841:0:0:0:0:0 with SMTP id 1csp3721826lfy; Tue, 18 Aug 2020 04:03:04 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyZjVYU+zUDPpJTq1ytNZvm1sebFiLUv3VsZ/Bhbw7GmS6Nik/t6vyZI5LrYVi5uTEu0wAv X-Received: by 2002:a25:8491:: with SMTP id v17mr27282121ybk.227.1597748583997; Tue, 18 Aug 2020 04:03:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1597748583; cv=none; d=google.com; s=arc-20160816; b=ar26F1Rc9qdcTAG4X7orjIJr+WqGa0k/F9K7vZgvYj2jiqfI6mY4JxCygzg51MDTs3 MQ1hXLFu9RMg55Uk/7SKVbtK3X7HB8e3XqipChyP5fTm1vyQoodGaVngeut/mhdQkJz9 llgTfa4i2dVQkeh7UeacavgJyt8ieZtcHYzvSrJVfMTJYTR36SVE0HVW9GidNxDepBna IKmTmOh9MC6vxN97lJJ0GsyviUEZJM8//79cAvIAvJboWwtN7b7hk8B91SRX8ZUK95uH EZBI+aA/7KIs1g7xO8BDQCj5u+txal7/q/WZGUmMp38xaVB3SF7t64BI4XrJ0YOqnPiu XX9Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:subject:cc:to:from:date:dkim-signature; bh=VOsFZAgnz0eIAgMXTGDtTPSElQdXe0+Sudz5oXli/ac=; b=PU56hCz0K7WMqv412MG3resCAncOi41Xu6zAfIfaUm5YrPi6SZgEj+YEMqjWHDQNCZ hdWOwxTiSWRB5EKaTKantWpoQq075WKjADfY/kkONd0uks8cExcGWpf3wkMqBmOgEP86 jlkHDgzXAiE8LcLUb+YPWZ9TnoLxkHHJTOp2SXJq6mXocCHqeVGOZRXCaEpCoy9992U2 HS5OEWXZZRrpZarNNRSGjiwkDq8iSVH3jZ9abTQAv2K2TeyY1xB+mRZ4S450j0O96m/F fAFzGXX3BqJMfHBmY8GNjTswKy6fqecEbIivWxbYV4JFMdnW72D1lH4T9uN/mhAIUISZ X/Zw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VbJ2f7cj; spf=neutral (google.com: 205.139.110.61 is neither permitted nor denied by best guess record for domain of imammedo@redhat.com) smtp.mailfrom=imammedo@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com. [205.139.110.61]) by mx.google.com with ESMTPS id 3si20156516ybr.388.2020.08.18.04.03.03 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Aug 2020 04:03:03 -0700 (PDT) Received-SPF: neutral (google.com: 205.139.110.61 is neither permitted nor denied by best guess record for domain of imammedo@redhat.com) client-ip=205.139.110.61; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=VbJ2f7cj; spf=neutral (google.com: 205.139.110.61 is neither permitted nor denied by best guess record for domain of imammedo@redhat.com) smtp.mailfrom=imammedo@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597748583; 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=VOsFZAgnz0eIAgMXTGDtTPSElQdXe0+Sudz5oXli/ac=; b=VbJ2f7cjt3R/jg4y5VtQto30tnF3FqUWeWPvEE50gSSi9AeVFJ3JinLAuz7fo074LgAuhg ZZt7insIFKd+aLRs837uadv9A1CnQ64DBaNvE3Y1p67A1BpjNiea0peaIYDcP+kgkUyjns XB6xfOYLPF9AelfqKtR8p/CIoO49V64= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-NzrpHyNVNi6-5ml-e2xWUg-1; Tue, 18 Aug 2020 07:03:01 -0400 X-MC-Unique: NzrpHyNVNi6-5ml-e2xWUg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36FEE801AAE; Tue, 18 Aug 2020 11:02:58 +0000 (UTC) Received: from localhost (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5AD25C1DC; Tue, 18 Aug 2020 11:02:44 +0000 (UTC) Date: Tue, 18 Aug 2020 13:02:43 +0200 From: Igor Mammedov To: Thiago Jung Bauermann Cc: qemu-ppc@nongnu.org, Peter Maydell , David Hildenbrand , Mark Cave-Ayland , qemu-devel@nongnu.org, Aleksandar Markovic , Thomas Huth , David Gibson , Philippe =?UTF-8?B?TWF0aGlldS1EYXVk?= =?UTF-8?B?w6k=?= , Artyom Tarasenko , Aleksandar Rikalo , Eduardo Habkost , Greg Kurz , qemu-s390x@nongnu.org, qemu-arm@nongnu.org, Alex =?UTF-8?B?QmVubsOpZQ==?= , Richard Henderson , Cornelia Huck , Aurelien Jarno , Paolo Bonzini Subject: Re: [PATCH v4 4/8] ppc/e500: Use start-powered-off CPUState property Message-ID: <20200818130243.38d00c5d@redhat.com> In-Reply-To: <20200818033323.336912-5-bauerman@linux.ibm.com> References: <20200818033323.336912-1-bauerman@linux.ibm.com> <20200818033323.336912-5-bauerman@linux.ibm.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit X-TUID: EQipljXIxntt On Tue, 18 Aug 2020 00:33:19 -0300 Thiago Jung Bauermann wrote: [...] > Also change creation of CPU object from cpu_create() to object_new() and > qdev_realize() because cpu_create() realizes the CPU and it's not possible > to set a property after the object is realized. cpu_create was introduced to remove code duplication in simple cases where we do not need to set properties on created cpu. returning back to manual object_new + realize() is fine if it 's only small set of of boards. If it's tree-wide change then that would bring back all code duplication that cpu_create() got rid of. An alternative way is to use 'hotplug' callbacks to let board set additional properties before cpu's realize is called. example: hw/ppc/spapr.c: spapr_machine_class_init() mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug; ... static const TypeInfo spapr_machine_info = { ... { TYPE_HOTPLUG_HANDLER }, that might work in generic case if it is put into generic machine code, and existing users of mc->get_hotplug_handler/hc->pre_plug were taken care of. In which case board would only need to set MachineClass:cpu-start-powered-of to gate property setting. > Signed-off-by: Thiago Jung Bauermann > --- > hw/ppc/e500.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c > index ab9884e315..0077aca74d 100644 > --- a/hw/ppc/e500.c > +++ b/hw/ppc/e500.c > @@ -704,9 +704,6 @@ static void ppce500_cpu_reset_sec(void *opaque) > > cpu_reset(cs); > > - /* Secondary CPU starts in halted state for now. Needs to change when > - implementing non-kernel boot. */ > - cs->halted = 1; > cs->exception_index = EXCP_HLT; > } > > @@ -864,8 +861,9 @@ void ppce500_init(MachineState *machine) > PowerPCCPU *cpu; > CPUState *cs; > qemu_irq *input; > + Error *err = NULL; > > - cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); > + cpu = POWERPC_CPU(object_new(machine->cpu_type)); > env = &cpu->env; > cs = CPU(cpu); > > @@ -897,6 +895,19 @@ void ppce500_init(MachineState *machine) > } else { > /* Secondary CPUs */ > qemu_register_reset(ppce500_cpu_reset_sec, cpu); > + > + /* > + * Secondary CPU starts in halted state for now. Needs to change > + * when implementing non-kernel boot. > + */ > + object_property_set_bool(OBJECT(cs), "start-powered-off", true, > + &error_abort); > + } > + > + if (!qdev_realize(DEVICE(cs), NULL, &err)) { > + error_report_err(err); > + object_unref(OBJECT(cs)); > + exit(EXIT_FAILURE); > } btw: board leaks cpu reference (from cpu_create()/object_new()) since qdev_realize() adds it's own and the caller of object_new() is suposed to free the original one. in this case qdev_realize_and_unref() fits nicely. > } > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.6 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10A63C433E1 for ; Tue, 18 Aug 2020 11:03:49 +0000 (UTC) Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id D06B82067C for ; Tue, 18 Aug 2020 11:03:48 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="g63r9/71" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org D06B82067C Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Received: from localhost ([::1]:57220 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1k7zPA-0007RE-4Z for qemu-devel@archiver.kernel.org; Tue, 18 Aug 2020 07:03:48 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:32864) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1k7zOV-0006mg-PU for qemu-devel@nongnu.org; Tue, 18 Aug 2020 07:03:07 -0400 Received: from us-smtp-delivery-1.mimecast.com ([205.139.110.120]:29967 helo=us-smtp-1.mimecast.com) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1k7zOU-0006K8-9R for qemu-devel@nongnu.org; Tue, 18 Aug 2020 07:03:07 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1597748585; 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=VOsFZAgnz0eIAgMXTGDtTPSElQdXe0+Sudz5oXli/ac=; b=g63r9/71d+YU2iSwzcvqMcgG00dXjX2V7T5lKVN//gFTuMjR7yM9QWXx+7GPzQk23jaMs0 0qb+Wp6IdaK8eYjPyxNGup5MVp62xLZ7dGVGCqMePU1Uve498OStv3z+f9G2vhMjoVTUhJ 5tFNlXL16V/zpaE2zwdDSPRarYYgq0k= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-146-NzrpHyNVNi6-5ml-e2xWUg-1; Tue, 18 Aug 2020 07:03:01 -0400 X-MC-Unique: NzrpHyNVNi6-5ml-e2xWUg-1 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 36FEE801AAE; Tue, 18 Aug 2020 11:02:58 +0000 (UTC) Received: from localhost (unknown [10.43.2.114]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5AD25C1DC; Tue, 18 Aug 2020 11:02:44 +0000 (UTC) Date: Tue, 18 Aug 2020 13:02:43 +0200 From: Igor Mammedov To: Thiago Jung Bauermann Subject: Re: [PATCH v4 4/8] ppc/e500: Use start-powered-off CPUState property Message-ID: <20200818130243.38d00c5d@redhat.com> In-Reply-To: <20200818033323.336912-5-bauerman@linux.ibm.com> References: <20200818033323.336912-1-bauerman@linux.ibm.com> <20200818033323.336912-5-bauerman@linux.ibm.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=imammedo@redhat.com X-Mimecast-Spam-Score: 0.003 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Received-SPF: none client-ip=205.139.110.120; envelope-from=imammedo@redhat.com; helo=us-smtp-1.mimecast.com X-detected-operating-system: by eggs.gnu.org: First seen = 2020/08/18 03:19:25 X-ACL-Warn: Detected OS = Linux 2.2.x-3.x [generic] [fuzzy] X-Spam_score_int: -30 X-Spam_score: -3.1 X-Spam_bar: --- X-Spam_report: (-3.1 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, RCVD_IN_MSPIKE_H3=-0.01, RCVD_IN_MSPIKE_WL=-0.01, SPF_HELO_NONE=0.001, SPF_NONE=0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Maydell , Thomas Huth , Eduardo Habkost , David Hildenbrand , qemu-s390x@nongnu.org, Alex =?UTF-8?B?QmVubsOpZQ==?= , Aleksandar Rikalo , Cornelia Huck , Mark Cave-Ayland , qemu-devel@nongnu.org, Greg Kurz , Aleksandar Markovic , qemu-arm@nongnu.org, qemu-ppc@nongnu.org, Aurelien Jarno , Paolo Bonzini , Richard Henderson , Philippe =?UTF-8?B?TWF0aGlldS1EYXVk?= =?UTF-8?B?w6k=?= , Artyom Tarasenko , David Gibson Errors-To: qemu-devel-bounces+qemu-devel=archiver.kernel.org@nongnu.org Sender: "Qemu-devel" On Tue, 18 Aug 2020 00:33:19 -0300 Thiago Jung Bauermann wrote: [...] > Also change creation of CPU object from cpu_create() to object_new() and > qdev_realize() because cpu_create() realizes the CPU and it's not possible > to set a property after the object is realized. cpu_create was introduced to remove code duplication in simple cases where we do not need to set properties on created cpu. returning back to manual object_new + realize() is fine if it 's only small set of of boards. If it's tree-wide change then that would bring back all code duplication that cpu_create() got rid of. An alternative way is to use 'hotplug' callbacks to let board set additional properties before cpu's realize is called. example: hw/ppc/spapr.c: spapr_machine_class_init() mc->get_hotplug_handler = spapr_get_hotplug_handler; hc->pre_plug = spapr_machine_device_pre_plug; ... static const TypeInfo spapr_machine_info = { ... { TYPE_HOTPLUG_HANDLER }, that might work in generic case if it is put into generic machine code, and existing users of mc->get_hotplug_handler/hc->pre_plug were taken care of. In which case board would only need to set MachineClass:cpu-start-powered-of to gate property setting. > Signed-off-by: Thiago Jung Bauermann > --- > hw/ppc/e500.c | 19 +++++++++++++++---- > 1 file changed, 15 insertions(+), 4 deletions(-) > > diff --git a/hw/ppc/e500.c b/hw/ppc/e500.c > index ab9884e315..0077aca74d 100644 > --- a/hw/ppc/e500.c > +++ b/hw/ppc/e500.c > @@ -704,9 +704,6 @@ static void ppce500_cpu_reset_sec(void *opaque) > > cpu_reset(cs); > > - /* Secondary CPU starts in halted state for now. Needs to change when > - implementing non-kernel boot. */ > - cs->halted = 1; > cs->exception_index = EXCP_HLT; > } > > @@ -864,8 +861,9 @@ void ppce500_init(MachineState *machine) > PowerPCCPU *cpu; > CPUState *cs; > qemu_irq *input; > + Error *err = NULL; > > - cpu = POWERPC_CPU(cpu_create(machine->cpu_type)); > + cpu = POWERPC_CPU(object_new(machine->cpu_type)); > env = &cpu->env; > cs = CPU(cpu); > > @@ -897,6 +895,19 @@ void ppce500_init(MachineState *machine) > } else { > /* Secondary CPUs */ > qemu_register_reset(ppce500_cpu_reset_sec, cpu); > + > + /* > + * Secondary CPU starts in halted state for now. Needs to change > + * when implementing non-kernel boot. > + */ > + object_property_set_bool(OBJECT(cs), "start-powered-off", true, > + &error_abort); > + } > + > + if (!qdev_realize(DEVICE(cs), NULL, &err)) { > + error_report_err(err); > + object_unref(OBJECT(cs)); > + exit(EXIT_FAILURE); > } btw: board leaks cpu reference (from cpu_create()/object_new()) since qdev_realize() adds it's own and the caller of object_new() is suposed to free the original one. in this case qdev_realize_and_unref() fits nicely. > } > >