forked from nuttx/nuttx-update
virtio-pci/mmio: Features change to 64 bit in all virtio_dispatch and fix compile warning
virtio/virtio-pci-legacy.c:399:48: warning: passing argument 2 of ‘pci_bus_write_io_dword’ makes integer from pointer without a cast [-Wint-con> 399 | pci_write_io_dword(vpdev->dev, vpdev->ioaddr + VIRTIO_PCI_GUEST_FEATURES, | ^ | | | void * /home/wyr/work/code/project/vela/nuttx/include/nuttx/pci/pci.h:559:65: note: expected ‘uintptr_t’ {aka ‘long unsigned int’} but argument is of > 559 | int pci_bus_write_io_dword(FAR struct pci_bus_s *bus, uintptr_t where, | ~~~~~~~~~~^~~~~ Signed-off-by: Yongrong Wang <wangyongrong@xiaomi.com>
This commit is contained in:
parent
5aeb644bc5
commit
1b24139020
6 changed files with 47 additions and 27 deletions
|
@ -221,11 +221,11 @@ static void virtio_mmio_write_config(FAR struct virtio_device *vdev,
|
|||
static void virtio_mmio_read_config(FAR struct virtio_device *vdev,
|
||||
uint32_t offset, FAR void *dst,
|
||||
int length);
|
||||
static uint32_t virtio_mmio_get_features(FAR struct virtio_device *vdev);
|
||||
static uint64_t virtio_mmio_get_features(FAR struct virtio_device *vdev);
|
||||
static void virtio_mmio_set_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features);
|
||||
static uint32_t virtio_mmio_negotiate_features(struct virtio_device *vdev,
|
||||
uint32_t features);
|
||||
uint64_t features);
|
||||
static uint64_t virtio_mmio_negotiate_features(struct virtio_device *vdev,
|
||||
uint64_t features);
|
||||
static void virtio_mmio_reset_device(FAR struct virtio_device *vdev);
|
||||
static void virtio_mmio_notify(FAR struct virtqueue *vq);
|
||||
|
||||
|
@ -652,13 +652,18 @@ byte_read:
|
|||
* Name: virtio_mmio_get_features
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t virtio_mmio_get_features(FAR struct virtio_device *vdev)
|
||||
static uint64_t virtio_mmio_get_features(FAR struct virtio_device *vdev)
|
||||
{
|
||||
FAR struct virtio_mmio_device_s *vmdev =
|
||||
(FAR struct virtio_mmio_device_s *)vdev;
|
||||
uint32_t feature_lo;
|
||||
uint32_t feature_hi;
|
||||
|
||||
metal_io_write32(&vmdev->cfg_io, VIRTIO_MMIO_DRIVER_FEATURES_SEL, 0);
|
||||
return metal_io_read32(&vmdev->cfg_io, VIRTIO_MMIO_DEVICE_FEATURES);
|
||||
feature_lo = metal_io_read32(&vmdev->cfg_io, VIRTIO_MMIO_DEVICE_FEATURES);
|
||||
metal_io_write32(&vmdev->cfg_io, VIRTIO_MMIO_DRIVER_FEATURES_SEL, 1);
|
||||
feature_hi = metal_io_read32(&vmdev->cfg_io, VIRTIO_MMIO_DEVICE_FEATURES);
|
||||
return ((uint64_t)feature_hi << 32) | (uint64_t)feature_lo;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -666,13 +671,16 @@ static uint32_t virtio_mmio_get_features(FAR struct virtio_device *vdev)
|
|||
****************************************************************************/
|
||||
|
||||
static void virtio_mmio_set_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features)
|
||||
uint64_t features)
|
||||
{
|
||||
FAR struct virtio_mmio_device_s *vmdev =
|
||||
(FAR struct virtio_mmio_device_s *)vdev;
|
||||
|
||||
metal_io_write32(&vmdev->cfg_io, VIRTIO_MMIO_DRIVER_FEATURES_SEL, 0);
|
||||
metal_io_write32(&vmdev->cfg_io, VIRTIO_MMIO_DRIVER_FEATURES, features);
|
||||
metal_io_write32(&vmdev->cfg_io, VIRTIO_MMIO_DRIVER_FEATURES_SEL, 1);
|
||||
metal_io_write32(&vmdev->cfg_io, VIRTIO_MMIO_DRIVER_FEATURES,
|
||||
features >> 32);
|
||||
vdev->features = features;
|
||||
}
|
||||
|
||||
|
@ -680,8 +688,8 @@ static void virtio_mmio_set_features(FAR struct virtio_device *vdev,
|
|||
* Name: virtio_mmio_negotiate_features
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t virtio_mmio_negotiate_features(struct virtio_device *vdev,
|
||||
uint32_t features)
|
||||
static uint64_t virtio_mmio_negotiate_features(struct virtio_device *vdev,
|
||||
uint64_t features)
|
||||
{
|
||||
features = features & virtio_mmio_get_features(vdev);
|
||||
virtio_mmio_set_features(vdev, features);
|
||||
|
|
|
@ -122,10 +122,10 @@ static void virtio_pci_legacy_write_config(FAR struct virtio_device *vdev,
|
|||
static void virtio_pci_legacy_read_config(FAR struct virtio_device *vdev,
|
||||
uint32_t offset, FAR void *dst,
|
||||
int length);
|
||||
static uint32_t
|
||||
static uint64_t
|
||||
virtio_pci_legacy_get_features(FAR struct virtio_device *vdev);
|
||||
static void virtio_pci_legacy_set_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features);
|
||||
uint64_t features);
|
||||
static void virtio_pci_legacy_notify(FAR struct virtqueue *vq);
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -367,7 +367,7 @@ static void virtio_pci_legacy_read_config(FAR struct virtio_device *vdev,
|
|||
* Name: virtio_pci_legacy_get_features
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t
|
||||
static uint64_t
|
||||
virtio_pci_legacy_get_features(FAR struct virtio_device *vdev)
|
||||
{
|
||||
FAR struct virtio_pci_device_s *vpdev =
|
||||
|
@ -385,14 +385,20 @@ virtio_pci_legacy_get_features(FAR struct virtio_device *vdev)
|
|||
****************************************************************************/
|
||||
|
||||
static void virtio_pci_legacy_set_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features)
|
||||
uint64_t features)
|
||||
{
|
||||
FAR struct virtio_pci_device_s *vpdev =
|
||||
(FAR struct virtio_pci_device_s *)vdev;
|
||||
|
||||
if ((features >> 32) != 0)
|
||||
{
|
||||
features = (uint64_t)((uint32_t)features);
|
||||
vrtwarn("Virtio pci legacy not support feature bits larger than 32\n");
|
||||
}
|
||||
|
||||
pci_write_io_dword(vpdev->dev,
|
||||
(uintptr_t)(vpdev->ioaddr + VIRTIO_PCI_GUEST_FEATURES),
|
||||
vdev->features);
|
||||
features);
|
||||
vdev->features = features;
|
||||
}
|
||||
|
||||
|
|
|
@ -176,10 +176,10 @@ static void virtio_pci_modern_write_config(FAR struct virtio_device *vdev,
|
|||
static void virtio_pci_modern_read_config(FAR struct virtio_device *vdev,
|
||||
uint32_t offset, FAR void *dst,
|
||||
int length);
|
||||
static uint32_t
|
||||
static uint64_t
|
||||
virtio_pci_modern_get_features(FAR struct virtio_device *vdev);
|
||||
static void virtio_pci_modern_set_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features);
|
||||
uint64_t features);
|
||||
static void virtio_pci_modern_notify(FAR struct virtqueue *vq);
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -560,17 +560,22 @@ static void virtio_pci_modern_read_config(FAR struct virtio_device *vdev,
|
|||
* Name: virtio_pci_modern_get_features
|
||||
****************************************************************************/
|
||||
|
||||
static uint32_t
|
||||
static uint64_t
|
||||
virtio_pci_modern_get_features(FAR struct virtio_device *vdev)
|
||||
{
|
||||
FAR struct virtio_pci_device_s *vpdev =
|
||||
(FAR struct virtio_pci_device_s *)vdev;
|
||||
FAR struct virtio_pci_common_cfg_s *cfg = vpdev->common;
|
||||
uint32_t feature;
|
||||
uint32_t feature_lo;
|
||||
uint32_t feature_hi;
|
||||
|
||||
pci_write_io_dword(vpdev->dev, (uintptr_t)&cfg->device_feature_select, 0);
|
||||
pci_read_io_dword(vpdev->dev, (uintptr_t)&cfg->device_feature, &feature);
|
||||
return feature;
|
||||
pci_read_io_dword(vpdev->dev, (uintptr_t)&cfg->device_feature,
|
||||
&feature_lo);
|
||||
pci_write_io_dword(vpdev->dev, (uintptr_t)&cfg->device_feature_select, 1);
|
||||
pci_read_io_dword(vpdev->dev, (uintptr_t)&cfg->device_feature,
|
||||
&feature_hi);
|
||||
return ((uint64_t)feature_hi << 32) | (uint64_t)feature_lo;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -578,7 +583,7 @@ virtio_pci_modern_get_features(FAR struct virtio_device *vdev)
|
|||
****************************************************************************/
|
||||
|
||||
static void virtio_pci_modern_set_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features)
|
||||
uint64_t features)
|
||||
{
|
||||
FAR struct virtio_pci_device_s *vpdev =
|
||||
(FAR struct virtio_pci_device_s *)vdev;
|
||||
|
@ -587,7 +592,8 @@ static void virtio_pci_modern_set_features(FAR struct virtio_device *vdev,
|
|||
pci_write_io_dword(vpdev->dev, (uintptr_t)&cfg->driver_feature_select, 0);
|
||||
pci_write_io_dword(vpdev->dev, (uintptr_t)&cfg->driver_feature, features);
|
||||
pci_write_io_dword(vpdev->dev, (uintptr_t)&cfg->driver_feature_select, 1);
|
||||
pci_write_io_dword(vpdev->dev, (uintptr_t)&cfg->driver_feature, 0);
|
||||
pci_write_io_dword(vpdev->dev, (uintptr_t)&cfg->driver_feature,
|
||||
features >> 32);
|
||||
vdev->features = features;
|
||||
}
|
||||
|
||||
|
|
|
@ -448,9 +448,9 @@ void virtio_pci_delete_virtqueues(FAR struct virtio_device *vdev)
|
|||
* Name: virtio_pci_negotiate_features
|
||||
****************************************************************************/
|
||||
|
||||
uint32_t
|
||||
uint64_t
|
||||
virtio_pci_negotiate_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features)
|
||||
uint64_t features)
|
||||
{
|
||||
features = features & vdev->func->get_features(vdev);
|
||||
vdev->func->set_features(vdev, features);
|
||||
|
|
|
@ -108,9 +108,9 @@ struct virtio_pci_device_s
|
|||
****************************************************************************/
|
||||
|
||||
void virtio_pci_reset_device(FAR struct virtio_device *vdev);
|
||||
uint32_t
|
||||
uint64_t
|
||||
virtio_pci_negotiate_features(FAR struct virtio_device *vdev,
|
||||
uint32_t features);
|
||||
uint64_t features);
|
||||
int virtio_pci_create_virtqueues(FAR struct virtio_device *vdev,
|
||||
unsigned int flags,
|
||||
unsigned int nvqs,
|
||||
|
|
|
@ -48,7 +48,7 @@
|
|||
/* Virtio helper functions */
|
||||
|
||||
#define virtio_has_feature(vdev, fbit) \
|
||||
(((vdev)->features & (1UL << (fbit))) != 0)
|
||||
(((vdev)->features & (1ULL << (fbit))) != 0)
|
||||
|
||||
#define virtio_read_config_member(vdev, structname, member, ptr) \
|
||||
virtio_read_config((vdev), offsetof(structname, member), \
|
||||
|
|
Loading…
Reference in a new issue