Re: [RFC PATCH 03/11] PCI/MSI: Refactor pci_dev_msi_enabled()

2014-08-05 Thread Yijing Wang
On 2014/8/6 6:35, Stuart Yoder wrote:
> On Fri, Jul 25, 2014 at 10:08 PM, Yijing Wang  wrote:
>> Pci_dev_msi_enabled() is used to check whether device
>> MSI/MSIX enabled. Refactor this function  to suuport
>> checking only device MSI or MSIX enabled.
>>
>> Signed-off-by: Yijing Wang 
> 
> So this patch refactors things so that checks like this:
>> -   if (!dev->msi_enabled)
> 
> are moved into a function:
>> +   if (!pci_dev_msi_enabled(dev, MSI_TYPE))
> 
> Can you explain a bit more why this  needed.   Is it just cleanup?

Hi Stuart, it's not just cleanup, because "[RFC PATCH 08/11] PCI/MSI: Introduce 
new struct msi_irqs and struct msi_ops"
introduced struct msi_irqs, so the code will change to
if (!dev->msi_irqs->msi_enabled)

I think driver should not need to know the details of MSI members.
So I try to rework the pci_dev_msi_enabled() to hide the detailed MSI info.


Thanks!
Yijing.


> 
> .
> 


-- 
Thanks!
Yijing

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: [RFC PATCH 03/11] PCI/MSI: Refactor pci_dev_msi_enabled()

2014-08-05 Thread Stuart Yoder
On Fri, Jul 25, 2014 at 10:08 PM, Yijing Wang  wrote:
> Pci_dev_msi_enabled() is used to check whether device
> MSI/MSIX enabled. Refactor this function  to suuport
> checking only device MSI or MSIX enabled.
>
> Signed-off-by: Yijing Wang 

So this patch refactors things so that checks like this:
   > -   if (!dev->msi_enabled)

are moved into a function:
   > +   if (!pci_dev_msi_enabled(dev, MSI_TYPE))

Can you explain a bit more why this  needed.   Is it just cleanup?

Thanks,
Stuart
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: When I boot two virtio-rng devices, guest will hang

2014-08-05 Thread Amos Kong
On Tue, Aug 05, 2014 at 06:28:54PM +0800, Amos Kong wrote:
> 3.16 (guest hangs with two rng devices)
> 3.16 + quick fix (can startup with two rng devices) (hotplug issue 1 + 
> hotplug issue 2 exist)
> lates torvalds/linux.git + amit 4 patches (can startup with two rng devices) 
> (only hotplug issue 2 exists)
> 
> However, the 4 patches also fixed the hang issue, the hotplug issue was fixed 
> a little.
> The hotplug issue is effected by the backend, or maybe it's not a real issue, 
> because
> the rng device can be hot-removed after dd process is killed.
> 
> 
> Hotplug issue 1:
>   1. boot up guest with two rng device (rng0 uses /dev/urandom, rng1 uses 
> /dev/random)
>   2. read data by dd in guest
>   3 (option 1). hot-remove rng0, then hot-remove rng1 -> result: _only rng1_ 
> can't be removed until dd process is killed
>   3 (option 2). hot-remove rng1, then hot-remove rng0 -> result: two devices 
> can be removed successfully, dd process will exit automatically.
> 
>   If we use /dev/urandom for rng0 and rng1, _rng0 & rng1_ can be removed, dd 
> process will exit automatically.
> 
> Hotplug issue 2:
>   If we use /dev/random for rng0 and rng1, _rng0 & rng1_ can't be removed 
> until dd process is killed.
> 
> Hotplug issue 3:
>   If we use /dev/random for rng0 and rng1, _only rng1_ can't be removed until 
> dd process is killed.

Hi Amit,

I finally found the root problem and posted a fix to upstream:
  
http://lists.linuxfoundation.org/pipermail/virtualization/2014-August/027049.html

It can help to fix the hotplug issues on 3.16 & latest kernel, so
stable kernel is CCed.

> (The difference between /dev/random and /dev/urandom is the speed.)
> 
> Thanks, Amos

-- 
Amos.
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


[PATCH] virtio-rng: complete have_data completion in removing device

2014-08-05 Thread Amos Kong
When we try to hot-remove a busy virtio-rng device from QEMU monitor,
the device can't be hot-removed. Because virtio-rng driver hangs at
wait_for_completion_killable().

This patch fixed the hang by completing have_data completion before
unregistering a virtio-rng device.

Signed-off-by: Amos Kong 
Cc: sta...@vger.kernel.org
---
 drivers/char/hw_random/virtio-rng.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/char/hw_random/virtio-rng.c 
b/drivers/char/hw_random/virtio-rng.c
index 0027137..416b15c 100644
--- a/drivers/char/hw_random/virtio-rng.c
+++ b/drivers/char/hw_random/virtio-rng.c
@@ -137,6 +137,7 @@ static void remove_common(struct virtio_device *vdev)
struct virtrng_info *vi = vdev->priv;
 
vdev->config->reset(vdev);
+   complete(&vi->have_data);
vi->busy = false;
if (vi->hwrng_register_done)
hwrng_unregister(&vi->hwrng);
-- 
1.9.3

___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization


Re: When I boot two virtio-rng devices, guest will hang

2014-08-05 Thread Amos Kong
3.16 (guest hangs with two rng devices)
3.16 + quick fix (can startup with two rng devices) (hotplug issue 1 + hotplug 
issue 2 exist)
lates torvalds/linux.git + amit 4 patches (can startup with two rng devices) 
(only hotplug issue 2 exists)

However, the 4 patches also fixed the hang issue, the hotplug issue was fixed a 
little.
The hotplug issue is effected by the backend, or maybe it's not a real issue, 
because
the rng device can be hot-removed after dd process is killed.


Hotplug issue 1:
  1. boot up guest with two rng device (rng0 uses /dev/urandom, rng1 uses 
/dev/random)
  2. read data by dd in guest
  3 (option 1). hot-remove rng0, then hot-remove rng1 -> result: _only rng1_ 
can't be removed until dd process is killed
  3 (option 2). hot-remove rng1, then hot-remove rng0 -> result: two devices 
can be removed successfully, dd process will exit automatically.

  If we use /dev/urandom for rng0 and rng1, _rng0 & rng1_ can be removed, dd 
process will exit automatically.

Hotplug issue 2:
  If we use /dev/random for rng0 and rng1, _rng0 & rng1_ can't be removed until 
dd process is killed.

Hotplug issue 3:
  If we use /dev/random for rng0 and rng1, _only rng1_ can't be removed until 
dd process is killed.


(The difference between /dev/random and /dev/urandom is the speed.)

Thanks, Amos
___
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization