Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

virtio: Features change to 64 bit in all virtio_dispatch #616

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion lib/include/openamp/rpmsg_virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ static inline uint8_t rpmsg_virtio_get_status(struct rpmsg_virtio_device *rvdev)
* @return The features supported by both the rpmsg driver and rpmsg device.
*/
__deprecated
static inline uint32_t
static inline uint64_t
rpmsg_virtio_get_features(struct rpmsg_virtio_device *rvdev)
{
return rvdev->vdev->func->get_features(rvdev->vdev);
Expand Down
20 changes: 10 additions & 10 deletions lib/include/openamp/virtio.h
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ struct virtio_dispatch;
/** @brief Device features. */
struct virtio_feature_desc {
/** Unique feature ID, defined in the virtio specification. */
uint32_t vfd_val;
uint64_t vfd_val;

/** Name of the feature (for debug). */
const char *vfd_str;
Expand Down Expand Up @@ -221,7 +221,7 @@ struct virtio_device {
const char *virtio_dev_name(uint16_t devid);

__deprecated void virtio_describe(struct virtio_device *dev, const char *msg,
uint32_t features,
uint64_t features,
struct virtio_feature_desc *feature_desc);

/**
Expand Down Expand Up @@ -249,17 +249,17 @@ struct virtio_dispatch {
void (*set_status)(struct virtio_device *dev, uint8_t status);

/** Get the feature exposed by the virtio device. */
uint32_t (*get_features)(struct virtio_device *dev);
uint64_t (*get_features)(struct virtio_device *dev);

/** Set the supported `feature` (virtio driver only). */
void (*set_features)(struct virtio_device *dev, uint32_t feature);
void (*set_features)(struct virtio_device *dev, uint64_t feature);

/**
* Set the supported features negotiate between the `features` parameter and features
* supported by the device (virtio driver only).
*/
uint32_t (*negotiate_features)(struct virtio_device *dev,
uint32_t features);
uint64_t (*negotiate_features)(struct virtio_device *dev,
uint64_t features);

/**
* Read a variable amount from the device specific (ie, network)
Expand Down Expand Up @@ -422,7 +422,7 @@ static inline int virtio_write_config(struct virtio_device *vdev,
* @return 0 on success, otherwise error code.
*/
static inline int virtio_get_features(struct virtio_device *vdev,
uint32_t *features)
uint64_t *features)
{
if (!vdev || !features)
return -EINVAL;
Expand All @@ -443,7 +443,7 @@ static inline int virtio_get_features(struct virtio_device *vdev,
* @return 0 on success, otherwise error code.
*/
static inline int virtio_set_features(struct virtio_device *vdev,
uint32_t features)
uint64_t features)
{
if (!vdev)
return -EINVAL;
Expand All @@ -465,8 +465,8 @@ static inline int virtio_set_features(struct virtio_device *vdev,
* @return 0 on success, otherwise error code.
*/
static inline int virtio_negotiate_features(struct virtio_device *vdev,
uint32_t features,
uint32_t *final_features)
uint64_t features,
uint64_t *final_features)
{
if (!vdev || !final_features)
return -EINVAL;
Expand Down
14 changes: 7 additions & 7 deletions lib/remoteproc/remoteproc_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ static uint32_t rproc_virtio_get_dfeatures(struct virtio_device *vdev)
return features;
}

static uint32_t rproc_virtio_get_features(struct virtio_device *vdev)
static uint64_t rproc_virtio_get_features(struct virtio_device *vdev)
{
struct remoteproc_virtio *rpvdev;
struct fw_rsc_vdev *vdev_rsc;
Expand All @@ -180,12 +180,12 @@ static uint32_t rproc_virtio_get_features(struct virtio_device *vdev)
metal_io_virt_to_offset(io, &vdev_rsc->gfeatures));
dfeatures = rproc_virtio_get_dfeatures(vdev);

return dfeatures & gfeatures;
return (uint64_t)(dfeatures & gfeatures);
}

#if VIRTIO_ENABLED(VIRTIO_DRIVER_SUPPORT)
static void rproc_virtio_set_features(struct virtio_device *vdev,
uint32_t features)
uint64_t features)
{
struct remoteproc_virtio *rpvdev;
struct fw_rsc_vdev *vdev_rsc;
Expand All @@ -196,17 +196,17 @@ static void rproc_virtio_set_features(struct virtio_device *vdev,
io = rpvdev->vdev_rsc_io;
metal_io_write32(io,
metal_io_virt_to_offset(io, &vdev_rsc->gfeatures),
features);
(uint32_t)features);
RSC_TABLE_FLUSH(vdev_rsc, sizeof(struct fw_rsc_vdev));
rpvdev->notify(rpvdev->priv, vdev->notifyid);
}

static uint32_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
uint32_t features)
static uint64_t rproc_virtio_negotiate_features(struct virtio_device *vdev,
uint64_t features)
{
uint32_t dfeatures = rproc_virtio_get_dfeatures(vdev);

rproc_virtio_set_features(vdev, dfeatures & features);
rproc_virtio_set_features(vdev, dfeatures & (uint32_t)features);

return 0;
}
Expand Down
2 changes: 1 addition & 1 deletion lib/rpmsg/rpmsg_virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -783,7 +783,7 @@ int rpmsg_init_vdev_with_config(struct rpmsg_virtio_device *rvdev,
struct rpmsg_device *rdev;
const char *vq_names[RPMSG_NUM_VRINGS];
vq_callback callback[RPMSG_NUM_VRINGS];
uint32_t features;
uint64_t features;
int status;
unsigned int i;

Expand Down
2 changes: 1 addition & 1 deletion lib/virtio/virtio.c
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ const char *virtio_dev_name(unsigned short devid)
}

__deprecated void virtio_describe(struct virtio_device *dev, const char *msg,
uint32_t features, struct virtio_feature_desc *desc)
uint64_t features, struct virtio_feature_desc *desc)
{
(void)dev;
(void)msg;
Expand Down
45 changes: 22 additions & 23 deletions lib/virtio_mmio/virtio_mmio_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -75,44 +75,43 @@ static void virtio_mmio_read_config(struct virtio_device *vdev,
d[i] = virtio_mmio_read8(vdev, VIRTIO_MMIO_CONFIG + i);
}

static uint32_t _virtio_mmio_get_features(struct virtio_device *vdev, int idx)
static uint64_t virtio_mmio_get_features(struct virtio_device *vdev)
{
uint32_t hfeatures;
uint32_t feature_hi;
uint32_t feature_lo;

/* Writing selection register VIRTIO_MMIO_DEVICE_FEATURES_SEL. In pure AMP
* mode this needs to be followed by a synchronization w/ the device
* before reading VIRTIO_MMIO_DEVICE_FEATURES
*/
virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, idx);
hfeatures = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
return hfeatures & vdev->features;
virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 0);
feature_lo = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 1);
feature_hi = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
return (((uint64_t)feature_hi << 32) | (uint64_t)feature_lo) &
vdev->features;
}

static uint32_t virtio_mmio_get_features(struct virtio_device *vdev)
static void virtio_mmio_set_features(struct virtio_device *vdev, uint64_t features)
{
return _virtio_mmio_get_features(vdev, 0);
}

/* This is more like negotiate_features */
static void _virtio_mmio_set_features(struct virtio_device *vdev,
uint32_t features, int idx)
{
uint32_t hfeatures;
uint32_t feature_hi;
uint32_t feature_lo;

/* Writing selection register VIRTIO_MMIO_DEVICE_FEATURES_SEL. In pure AMP
* mode this needs to be followed by a synchronization w/ the device
* before reading VIRTIO_MMIO_DEVICE_FEATURES
*/
virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, idx);
hfeatures = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES);
features &= hfeatures;
virtio_mmio_write32(vdev, VIRTIO_MMIO_DRIVER_FEATURES, features);
vdev->features = features;
}
virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 0);
feature_lo = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES) &
(uint32_t)features;
virtio_mmio_write32(vdev, VIRTIO_MMIO_DRIVER_FEATURES, feature_lo);

static void virtio_mmio_set_features(struct virtio_device *vdev, uint32_t features)
{
_virtio_mmio_set_features(vdev, features, 0);
virtio_mmio_write32(vdev, VIRTIO_MMIO_DEVICE_FEATURES_SEL, 1);
feature_hi = virtio_mmio_read32(vdev, VIRTIO_MMIO_DEVICE_FEATURES) &
(uint32_t)(features >> 32);
virtio_mmio_write32(vdev, VIRTIO_MMIO_DRIVER_FEATURES, feature_hi);

vdev->features = ((uint64_t)feature_hi << 32) | (uint64_t)feature_lo;
}

static void virtio_mmio_reset_device(struct virtio_device *vdev)
Expand Down
Loading