From: Zhou Furong <furong.zhou@linux.intel.com>
To: "Zhu, Lingshan" <lingshan.zhu@intel.com>,
jasowang@redhat.com, mst@redhat.com
Cc: virtualization@lists.linux-foundation.org, netdev@vger.kernel.org
Subject: Re: [PATCH] vDPA/ifcvf: allow userspace to suspend a queue
Date: Thu, 21 Apr 2022 22:27:04 +0800 [thread overview]
Message-ID: <097bbe19-82a7-91ed-cdb3-2becdc4051d4@linux.intel.com> (raw)
In-Reply-To: <f224fc38-327c-6dac-d2cb-93f8b4ac5b82@intel.com>
On 2022/4/21 19:05, Zhu, Lingshan wrote:
>
>
> On 4/12/2022 2:55 PM, Zhou Furong wrote:
>> Hi,
>>
>>> +bool ifcvf_get_vq_ready(struct ifcvf_hw *hw, u16 qid)
>>> +{
>>> + struct virtio_pci_common_cfg __iomem *cfg = hw->common_cfg;
>>> + bool queue_enable;
>>> +
>>> + vp_iowrite16(qid, &cfg->queue_select);
>>> + queue_enable = vp_ioread16(&cfg->queue_enable);
>>> +
>>> + return (bool)queue_enable;
>> queue_enable is bool, why cast? looks like remove the variable is better.
>> return vp_ioread16(&cfg->queue_enable);
> Hi, thanks for your comments. This cast tries to make some static
> checkers happy.
> Please correct me if I misunderstood it:
> vp_ioread16() returns an u16, and bool is not an one bit variable, it is
> C99 _Bool.
> C99 defines _Bool to be true(expends to int 1) or false(expends to int 0).
> I think this implies a bool is actually capable to store an u16.
> so I am afraid some checkers may complain about "queue_enable =
> vp_ioread16(&cfg->queue_enable);",
> a cast here can help us silence the checkers.
>
> see http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1256.pdf section 7.16
> and https://www.kernel.org/doc/Documentation/process/coding-style.rst
> section 17
>
> Thanks,
> Zhu Lingshan
>>
bool type contains 1 bit 1/0 only, any number assign to a boolean
variable will auto cast to 1 or 0.
if you want make static checker happy(if there is)
queue_enable = (bool)vp_ioread16(&cfg->queue_enable);
return queue_enable;
or
return (bool)vp_ioread16(&cfg->queue_enable);
>>> static bool ifcvf_vdpa_get_vq_ready(struct vdpa_device *vdpa_dev,
>>> u16 qid)
>>> {
>>> struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
>>> + bool ready;
>>> - return vf->vring[qid].ready;
>>> + ready = ifcvf_get_vq_ready(vf, qid);
>>> +
>>> + return ready;
>> remove ready looks better
>> return ifcvf_get_vq_ready(vf, qid);
>>
>>
>> Best regards,
>> Furong
>
next prev parent reply other threads:[~2022-04-21 14:27 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-11 3:10 [PATCH] vDPA/ifcvf: allow userspace to suspend a queue Zhu Lingshan
2022-04-12 6:55 ` Zhou Furong
2022-04-21 11:05 ` Zhu, Lingshan
2022-04-21 14:27 ` Zhou Furong [this message]
2022-04-13 8:25 ` Jason Wang
2022-04-13 8:25 ` Jason Wang
2022-04-13 8:54 ` Michael S. Tsirkin
2022-04-13 8:54 ` Michael S. Tsirkin
2022-04-21 11:13 ` Zhu, Lingshan
2022-04-21 11:11 ` Zhu, Lingshan
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=097bbe19-82a7-91ed-cdb3-2becdc4051d4@linux.intel.com \
--to=furong.zhou@linux.intel.com \
--cc=jasowang@redhat.com \
--cc=lingshan.zhu@intel.com \
--cc=mst@redhat.com \
--cc=netdev@vger.kernel.org \
--cc=virtualization@lists.linux-foundation.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.