Message ID | 20250107070209epcms2p8b39b26cf5a32a7b66246f2d122005f29@epcms2p8 (mailing list archive) |
---|---|
State | New |
Headers | show |
Series | hw/ufs: Adjust value to match CPU's endian format | expand |
On 7/1/25 08:02, Keoseong Park wrote: > In ufs_write_attr_value(), the value parameter is handled in the CPU's > endian format but provided in big-endian format by the caller. Thus, it > is converted accordingly. > Fixes: 7c85332a2b3 ("hw/ufs: minor bug fixes related to ufs-test") > Signed-off-by: Keoseong Park <keosung.park@samsung.com> > --- > hw/ufs/ufs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c > index 8d26d13791..428fe927ad 100644 > --- a/hw/ufs/ufs.c > +++ b/hw/ufs/ufs.c > @@ -1164,7 +1164,7 @@ static QueryRespCode ufs_exec_query_attr(UfsRequest *req, int op) > value = ufs_read_attr_value(u, idn); > ret = UFS_QUERY_RESULT_SUCCESS; > } else { > - value = req->req_upiu.qr.value; > + value = be32_to_cpu(req->req_upiu.qr.value); Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> > ret = ufs_write_attr_value(u, idn, value); > } > req->rsp_upiu.qr.value = cpu_to_be32(value);
On 1/7/2025 4:02 PM, Keoseong Park wrote: > In ufs_write_attr_value(), the value parameter is handled in the CPU's > endian format but provided in big-endian format by the caller. Thus, it > is converted accordingly. > > Signed-off-by: Keoseong Park <keosung.park@samsung.com> > --- > hw/ufs/ufs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c > index 8d26d13791..428fe927ad 100644 > --- a/hw/ufs/ufs.c > +++ b/hw/ufs/ufs.c > @@ -1164,7 +1164,7 @@ static QueryRespCode ufs_exec_query_attr(UfsRequest *req, int op) > value = ufs_read_attr_value(u, idn); > ret = UFS_QUERY_RESULT_SUCCESS; > } else { > - value = req->req_upiu.qr.value; > + value = be32_to_cpu(req->req_upiu.qr.value); > ret = ufs_write_attr_value(u, idn, value); > } > req->rsp_upiu.qr.value = cpu_to_be32(value); Thank you for fixing this bug! I reviewed the changes and noticed that some changes to |ufs-test| are also needed to fully fix the problem. Could you please include the following changes and send a v2 patch? Thank you. diff --git a/tests/qtest/ufs-test.c b/tests/qtest/ufs-test.c index 60199abbee..1f860b41c0 100644 --- a/tests/qtest/ufs-test.c +++ b/tests/qtest/ufs-test.c @@ -145,7 +145,7 @@ static void ufs_send_query(QUfs *ufs, uint8_t slot, uint8_t query_function, req_upiu.qr.idn = idn; req_upiu.qr.index = index; req_upiu.qr.selector = selector; - req_upiu.qr.value = attr_value; + req_upiu.qr.value = cpu_to_be32(attr_value); req_upiu.qr.length = UFS_QUERY_DESC_MAX_SIZE; qtest_memwrite(ufs->dev.bus->qts, req_upiu_addr, &req_upiu, sizeof(req_upiu));
diff --git a/hw/ufs/ufs.c b/hw/ufs/ufs.c index 8d26d13791..428fe927ad 100644 --- a/hw/ufs/ufs.c +++ b/hw/ufs/ufs.c @@ -1164,7 +1164,7 @@ static QueryRespCode ufs_exec_query_attr(UfsRequest *req, int op) value = ufs_read_attr_value(u, idn); ret = UFS_QUERY_RESULT_SUCCESS; } else { - value = req->req_upiu.qr.value; + value = be32_to_cpu(req->req_upiu.qr.value); ret = ufs_write_attr_value(u, idn, value); } req->rsp_upiu.qr.value = cpu_to_be32(value);
In ufs_write_attr_value(), the value parameter is handled in the CPU's endian format but provided in big-endian format by the caller. Thus, it is converted accordingly. Signed-off-by: Keoseong Park <keosung.park@samsung.com> --- hw/ufs/ufs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)