From: Thomas Huth <thuth@redhat.com>
To: Mark Cave-Ayland <mark.cave-ayland@ilande.co.uk>,
Paolo Bonzini <pbonzini@redhat.com>,
qemu-devel@nongnu.org, Bernhard Beschow <shentey@gmail.com>
Cc: "Michael S Tsirkin" <mst@redhat.com>,
"Philippe Mathieu-Daudé" <philmd@linaro.org>,
"BALATON Zoltan" <balaton@eik.bme.hu>
Subject: Re: [PATCH v2 for-8.0] hw/rtc/mc146818rtc: Make this rtc device target independent
Date: Mon, 12 Dec 2022 08:51:58 +0100 [thread overview]
Message-ID: <b03e7084-54e5-4aa8-d089-2a5f9beb5639@redhat.com> (raw)
In-Reply-To: <a9e8d0ef-e4cb-2319-d8d3-f657e167c729@ilande.co.uk>
On 10/12/2022 14.48, Mark Cave-Ayland wrote:
> On 09/12/2022 11:15, Thomas Huth wrote:
>
>> The only reason for this code being target dependent is the apic-related
>> code in rtc_policy_slew_deliver_irq(). Since these apic functions are rather
>> simple, we can easily move them into a new, separate file (apic_irqcount.c)
>> which will always be compiled and linked if either APIC or the mc146818
>> device
>> are required. This way we can get rid of the #ifdef TARGET_I386 switches in
>> mc146818rtc.c and declare it in the softmmu_ss instead of specific_ss, so
>> that the code only gets compiled once for all targets.
[...]
>> diff --git a/hw/rtc/mc146818rtc.c b/hw/rtc/mc146818rtc.c
>> index 1ebb412479..afb1f385a3 100644
>> --- a/hw/rtc/mc146818rtc.c
>> +++ b/hw/rtc/mc146818rtc.c
>> @@ -43,11 +43,7 @@
>> #include "qapi/qapi-events-misc.h"
>> #include "qapi/visitor.h"
>> #include "hw/rtc/mc146818rtc_regs.h"
>> -
>> -#ifdef TARGET_I386
>> -#include "qapi/qapi-commands-misc-target.h"
>> #include "hw/i386/apic.h"
>> -#endif
>> //#define DEBUG_CMOS
>> //#define DEBUG_COALESCED
>> @@ -112,7 +108,6 @@ static void rtc_coalesced_timer_update(RTCState *s)
>> static QLIST_HEAD(, RTCState) rtc_devices =
>> QLIST_HEAD_INITIALIZER(rtc_devices);
>> -#ifdef TARGET_I386
>> void qmp_rtc_reset_reinjection(Error **errp)
>> {
>> RTCState *s;
>> @@ -145,13 +140,6 @@ static void rtc_coalesced_timer(void *opaque)
>> rtc_coalesced_timer_update(s);
>> }
>> -#else
>> -static bool rtc_policy_slew_deliver_irq(RTCState *s)
>> -{
>> - assert(0);
>> - return false;
>> -}
>> -#endif
>> static uint32_t rtc_periodic_clock_ticks(RTCState *s)
>> {
>> @@ -922,14 +910,15 @@ static void rtc_realizefn(DeviceState *dev, Error
>> **errp)
>> rtc_set_date_from_host(isadev);
>> switch (s->lost_tick_policy) {
>> -#ifdef TARGET_I386
>> - case LOST_TICK_POLICY_SLEW:
>> - s->coalesced_timer =
>> - timer_new_ns(rtc_clock, rtc_coalesced_timer, s);
>> - break;
>> -#endif
>> case LOST_TICK_POLICY_DISCARD:
>> break;
>> + case LOST_TICK_POLICY_SLEW:
>> + /* Slew tick policy is only available if the machine has an APIC */
>> + if (object_resolve_path_type("", "apic-common", NULL) != NULL) {
>
> Hmmm. These days we should be using TYPE_APIC_COMMON, however it seems that
> APICCommonState is defined in apic_internal.h rather than apic.h which seems
> wrong (it prevents you from passing an APICCommonState as an object link
> property as well as from using TYPE_APIC_COMMON).
>
>> + s->coalesced_timer = timer_new_ns(rtc_clock,
>> rtc_coalesced_timer, s);
>> + break;
>> + }
>> + /* fallthrough */
>> default:
>> error_setg(errp, "Invalid lost tick policy.");
>> return;
>> diff --git a/hw/intc/meson.build b/hw/intc/meson.build
>> index bcbf22ff51..036ad1936b 100644
>> --- a/hw/intc/meson.build
>> +++ b/hw/intc/meson.build
>> @@ -25,8 +25,12 @@ softmmu_ss.add(when: 'CONFIG_XILINX', if_true:
>> files('xilinx_intc.c'))
>> softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP', if_true:
>> files('xlnx-zynqmp-ipi.c'))
>> softmmu_ss.add(when: 'CONFIG_XLNX_ZYNQMP_PMU', if_true:
>> files('xlnx-pmu-iomod-intc.c'))
>> -specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true:
>> files('allwinner-a10-pic.c'))
>> +if config_all_devices.has_key('CONFIG_APIC') or
>> config_all_devices.has_key('CONFIG_MC146818RTC')
>> + softmmu_ss.add(files('apic_irqcount.c'))
>> +endif
>> specific_ss.add(when: 'CONFIG_APIC', if_true: files('apic.c',
>> 'apic_common.c'))
>> +
>> +specific_ss.add(when: 'CONFIG_ALLWINNER_A10_PIC', if_true:
>> files('allwinner-a10-pic.c'))
>> specific_ss.add(when: 'CONFIG_ARM_GIC', if_true:
>> files('arm_gicv3_cpuif_common.c'))
>> specific_ss.add(when: 'CONFIG_ARM_GICV3_TCG', if_true:
>> files('arm_gicv3_cpuif.c'))
>> specific_ss.add(when: 'CONFIG_ARM_GIC_KVM', if_true:
>> files('arm_gic_kvm.c'))
>> diff --git a/hw/rtc/meson.build b/hw/rtc/meson.build
>> index dc33973384..34a4d316fa 100644
>> --- a/hw/rtc/meson.build
>> +++ b/hw/rtc/meson.build
>> @@ -13,5 +13,4 @@ softmmu_ss.add(when: 'CONFIG_ASPEED_SOC', if_true:
>> files('aspeed_rtc.c'))
>> softmmu_ss.add(when: 'CONFIG_GOLDFISH_RTC', if_true:
>> files('goldfish_rtc.c'))
>> softmmu_ss.add(when: 'CONFIG_LS7A_RTC', if_true: files('ls7a_rtc.c'))
>> softmmu_ss.add(when: 'CONFIG_ALLWINNER_H3', if_true:
>> files('allwinner-rtc.c'))
>> -
>> -specific_ss.add(when: 'CONFIG_MC146818RTC', if_true: files('mc146818rtc.c'))
>> +softmmu_ss.add(when: 'CONFIG_MC146818RTC', if_true: files('mc146818rtc.c'))
>
> Fixing up the headers to allow TYPE_APIC_COMMON rather than hard-coding
> "apic-common" would be my preference, however there is a lot of legacy code
> here and the fear would be that once you pull on that string then more will
> keep unravelling...
I gave it a try now and it seems to be OK to move TYPE_APIC_COMMON from
apic_internal.h to apic.h ... so I'll add that change and send a v3.
Thanks!
Thomas
prev parent reply other threads:[~2022-12-12 7:53 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-09 11:15 [PATCH v2 for-8.0] hw/rtc/mc146818rtc: Make this rtc device target independent Thomas Huth
2022-12-09 14:26 ` Philippe Mathieu-Daudé
2022-12-10 13:48 ` Mark Cave-Ayland
2022-12-12 0:48 ` Bernhard Beschow
2022-12-12 7:51 ` Thomas Huth [this message]
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=b03e7084-54e5-4aa8-d089-2a5f9beb5639@redhat.com \
--to=thuth@redhat.com \
--cc=balaton@eik.bme.hu \
--cc=mark.cave-ayland@ilande.co.uk \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
--cc=shentey@gmail.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).