From: Cao jin <caoj.fnst@cn.fujitsu.com>
To: Markus Armbruster <armbru@redhat.com>
Cc: qemu-devel@nongnu.org, Jiri Pirko <jiri@resnulli.us>,
"Michael S. Tsirkin" <mst@redhat.com>,
Jason Wang <jasowang@redhat.com>,
Marcel Apfelbaum <marcel@redhat.com>,
Alex Williamson <alex.williamson@redhat.com>,
Hannes Reinecke <hare@suse.de>,
Dmitry Fleytman <dmitry@daynix.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Gerd Hoffmann <kraxel@redhat.com>
Subject: Re: [Qemu-devel] [PATCH 2/6] pci: Convert msix_init() to Error and fix callers to check it
Date: Fri, 19 Aug 2016 16:11:17 +0800 [thread overview]
Message-ID: <57B6BF25.7000605@cn.fujitsu.com> (raw)
In-Reply-To: <87y43uecjm.fsf@dusky.pond.sub.org>
On 08/18/2016 03:55 PM, Markus Armbruster wrote:
> Cao jin <caoj.fnst@cn.fujitsu.com> writes:
>
>>
>> diff --git a/hw/misc/ivshmem.c b/hw/misc/ivshmem.c
>> index 40a2ebc..b8511ee 100644
>> --- a/hw/misc/ivshmem.c
>> +++ b/hw/misc/ivshmem.c
>> @@ -899,6 +899,7 @@ static void ivshmem_common_realize(PCIDevice *dev, Error **errp)
>>
>> if (ivshmem_setup_interrupts(s) < 0) {
>> error_setg(errp, "failed to initialize interrupts");
>> + error_append_hint(errp, "MSI-X is not supported by interrupt controller");
>> return;
>> }
>> }
>
> How is this related to the stated purpose of the patch?
>
Because I don't propagate error via msix_init_exclusive_bar(), so add
this to show the detail error message to user.(Please also see my
comment on msix_init_exclusive_bar(), then come back to this comment)
>> diff --git a/hw/net/e1000e.c b/hw/net/e1000e.c
>> index d001c96..82a7be1 100644
>> --- a/hw/net/e1000e.c
>> +++ b/hw/net/e1000e.c
>> @@ -295,7 +295,7 @@ e1000e_init_msix(E1000EState *s)
> int res = msix_init(PCI_DEVICE(s), E1000E_MSIX_VEC_NUM,
> &s->msix,
>> E1000E_MSIX_IDX, E1000E_MSIX_TABLE,
>> &s->msix,
>> E1000E_MSIX_IDX, E1000E_MSIX_PBA,
>> - 0xA0);
>> + 0xA0, NULL);
>
> Further down, you convert msix_init() from error_report() to
> error_setg(). It now relies on its callers to report errors. However,
> this caller doesn't. Suppressing error reports like that may be
> appropriate, since the function doesn't fail. But such a change
> shouldn't be hidden in a larger patch without at least a mention in the
> commit message.
>
For this device, I was planning 1)make this patch as small as possible
for reviewer's convenience sake(so suppressed error report here), then
2) drop this function as another patch, and then 3) convert this device
to .realize(), error report or setting error could be placed at one of
last two steps. For other devices, the plan is basically the same.
> Here's how I'd skin this cat. First convert msix_init() without
> changing behavior, by having every caller of msix_init() immediately
> pass the error received to error_report_err(). Then clean up the
> callers one after the other. The ones that are running within a
> realize() method should propagate the error to the realize() method.
> The ones that are still running within an init() method keep the
> error_report_err(). e1000e_init_msix() may want to ignore the error.
> Separaring the cleanups that way lets you explain each actual change
> neatly in a commit message.
>
>>
>> if (res < 0) {
>> trace_e1000e_msix_init_fail(res);
>> diff --git a/hw/net/rocker/rocker.c b/hw/net/rocker/rocker.c
>> index 30f2ce4..769b1fd 100644
>> --- a/hw/net/rocker/rocker.c
>> +++ b/hw/net/rocker/rocker.c
>> @@ -1262,7 +1262,7 @@ static int rocker_msix_init(Rocker *r)
> err = msix_init(dev, ROCKER_MSIX_VEC_COUNT(r->fp_ports),
> &r->msix_bar,
>> ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_TABLE_OFFSET,
>> &r->msix_bar,
>> ROCKER_PCI_MSIX_BAR_IDX, ROCKER_PCI_MSIX_PBA_OFFSET,
>> - 0);
>> + 0, NULL);
>> if (err) {
>> return err;
>> }
>
> This one runs in an init() method. You're losing an error message here.
Indeed... planned to propagate or set error object when convert the
device to realize because the only failure is -ENOTSUP
>> @@ -336,7 +340,7 @@ int msix_init_exclusive_bar(PCIDevice *dev, unsigned short nentries,
>> ret = msix_init(dev, nentries, &dev->msix_exclusive_bar, bar_nr,
>> 0, &dev->msix_exclusive_bar,
>> bar_nr, bar_pba_offset,
>> - 0);
>> + 0, NULL);
>> if (ret) {
>> return ret;
>> }
>
> This is a case where you have to propagate the error. First step:
> convert msix_exclusive_bar() to Error, too.
I was thinking: all devices call msix_init_exclusive_bar() will only see
-ENOTSUP on failure, so, to make this patch short and simple, we could
set error or report error in the caller(or caller's caller, that is what
I have done in ivshmem_common_realize() at the top of this patch).
>
>> @@ -445,8 +449,10 @@ void msix_notify(PCIDevice *dev, unsigned vector)
>> {
>> MSIMessage msg;
>>
>> - if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector])
>> + if (vector >= dev->msix_entries_nr || !dev->msix_entry_used[vector]) {
>> return;
>> + }
>> +
>> if (msix_is_masked(dev, vector)) {
>> msix_set_pending(dev, vector);
>> return;
>
> Let's drop this hunk.
>
Sorry, I forget to make the coding style changes into a separated one.
--
Yours Sincerely,
Cao jin
next prev parent reply other threads:[~2016-08-19 8:03 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-08-17 14:39 [Qemu-devel] [PATCH 0/6] Convert msix_init() to error Cao jin
2016-08-17 14:39 ` [Qemu-devel] [PATCH 1/6] msix_init: assert programming error Cao jin
2016-08-18 7:14 ` Markus Armbruster
2016-08-18 7:46 ` Cao jin
2016-08-17 14:39 ` [Qemu-devel] [PATCH 2/6] pci: Convert msix_init() to Error and fix callers to check it Cao jin
2016-08-18 7:55 ` Markus Armbruster
2016-08-19 8:11 ` Cao jin [this message]
2016-08-17 14:39 ` [Qemu-devel] [PATCH 3/6] e1000e: fix for migration compatibility Cao jin
2016-08-18 5:25 ` Dmitry Fleytman
2016-08-18 10:47 ` Paolo Bonzini
2016-08-18 13:11 ` Cao jin
2016-08-18 13:04 ` Paolo Bonzini
2016-08-18 13:25 ` Cao jin
2016-08-18 13:22 ` Paolo Bonzini
2016-08-17 14:39 ` [Qemu-devel] [PATCH 4/6] e1000e: drop unnecessary funtions Cao jin
2016-08-18 5:23 ` Dmitry Fleytman
2016-08-18 7:38 ` Cao jin
2016-08-17 14:39 ` [Qemu-devel] [PATCH 5/6] megasas: remove unnecessary megasas_use_msix() Cao jin
2016-08-17 14:39 ` [Qemu-devel] [PATCH 6/6] megasas: undo the overwrites of user configuration Cao jin
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=57B6BF25.7000605@cn.fujitsu.com \
--to=caoj.fnst@cn.fujitsu.com \
--cc=alex.williamson@redhat.com \
--cc=armbru@redhat.com \
--cc=dmitry@daynix.com \
--cc=hare@suse.de \
--cc=jasowang@redhat.com \
--cc=jiri@resnulli.us \
--cc=kraxel@redhat.com \
--cc=marcel@redhat.com \
--cc=mst@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.