Skip to content

Commit e2516ab

Browse files
committed
Merge tag 'for-linus-fwctl' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma
Pull fwctl fixes from Jason Gunthorpe: "Three small changes from further build testing: - Don't rely on the userspace uuid.h for the uapi header - Fix sparse warnings in pds - Typo in log message" * tag 'for-linus-fwctl' of git://git.kernel.org/pub/scm/linux/kernel/git/rdma/rdma: fwctl: Fix repeated device word in log message pds_fwctl: Fix type and endian complaints fwctl/cxl: Fix uuid_t usage in uapi
2 parents 8176e77 + c92ae5d commit e2516ab

File tree

3 files changed

+36
-20
lines changed

3 files changed

+36
-20
lines changed

drivers/fwctl/main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ static int fwctl_cmd_rpc(struct fwctl_ucmd *ucmd)
105105
if (!test_and_set_bit(0, &fwctl_tainted)) {
106106
dev_warn(
107107
&fwctl->dev,
108-
"%s(%d): has requested full access to the physical device device",
108+
"%s(%d): has requested full access to the physical device",
109109
current->comm, task_pid_nr(current));
110110
add_taint(TAINT_FWCTL, LOCKDEP_STILL_OK);
111111
}

drivers/fwctl/pds/main.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,12 +105,14 @@ static int pdsfc_identify(struct pdsfc_dev *pdsfc)
105105
static void pdsfc_free_endpoints(struct pdsfc_dev *pdsfc)
106106
{
107107
struct device *dev = &pdsfc->fwctl.dev;
108+
u32 num_endpoints;
108109
int i;
109110

110111
if (!pdsfc->endpoints)
111112
return;
112113

113-
for (i = 0; pdsfc->endpoint_info && i < pdsfc->endpoints->num_entries; i++)
114+
num_endpoints = le32_to_cpu(pdsfc->endpoints->num_entries);
115+
for (i = 0; pdsfc->endpoint_info && i < num_endpoints; i++)
114116
mutex_destroy(&pdsfc->endpoint_info[i].lock);
115117
vfree(pdsfc->endpoint_info);
116118
pdsfc->endpoint_info = NULL;
@@ -199,7 +201,7 @@ static int pdsfc_init_endpoints(struct pdsfc_dev *pdsfc)
199201
ep_entry = (struct pds_fwctl_query_data_endpoint *)pdsfc->endpoints->entries;
200202
for (i = 0; i < num_endpoints; i++) {
201203
mutex_init(&pdsfc->endpoint_info[i].lock);
202-
pdsfc->endpoint_info[i].endpoint = ep_entry[i].id;
204+
pdsfc->endpoint_info[i].endpoint = le32_to_cpu(ep_entry[i].id);
203205
}
204206

205207
return 0;
@@ -214,6 +216,7 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
214216
struct pds_fwctl_query_data *data;
215217
union pds_core_adminq_cmd cmd;
216218
dma_addr_t data_pa;
219+
u32 num_entries;
217220
int err;
218221
int i;
219222

@@ -246,8 +249,9 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
246249
*pa = data_pa;
247250

248251
entries = (struct pds_fwctl_query_data_operation *)data->entries;
249-
dev_dbg(dev, "num_entries %d\n", data->num_entries);
250-
for (i = 0; i < data->num_entries; i++) {
252+
num_entries = le32_to_cpu(data->num_entries);
253+
dev_dbg(dev, "num_entries %d\n", num_entries);
254+
for (i = 0; i < num_entries; i++) {
251255

252256
/* Translate FW command attribute to fwctl scope */
253257
switch (entries[i].scope) {
@@ -267,7 +271,7 @@ static struct pds_fwctl_query_data *pdsfc_get_operations(struct pdsfc_dev *pdsfc
267271
break;
268272
}
269273
dev_dbg(dev, "endpoint %d operation: id %x scope %d\n",
270-
ep, entries[i].id, entries[i].scope);
274+
ep, le32_to_cpu(entries[i].id), entries[i].scope);
271275
}
272276

273277
return data;
@@ -280,24 +284,26 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
280284
struct pds_fwctl_query_data_operation *op_entry;
281285
struct pdsfc_rpc_endpoint_info *ep_info = NULL;
282286
struct device *dev = &pdsfc->fwctl.dev;
287+
u32 num_entries;
283288
int i;
284289

285290
/* validate rpc in_len & out_len based
286291
* on ident.max_req_sz & max_resp_sz
287292
*/
288-
if (rpc->in.len > pdsfc->ident.max_req_sz) {
293+
if (rpc->in.len > le32_to_cpu(pdsfc->ident.max_req_sz)) {
289294
dev_dbg(dev, "Invalid request size %u, max %u\n",
290-
rpc->in.len, pdsfc->ident.max_req_sz);
295+
rpc->in.len, le32_to_cpu(pdsfc->ident.max_req_sz));
291296
return -EINVAL;
292297
}
293298

294-
if (rpc->out.len > pdsfc->ident.max_resp_sz) {
299+
if (rpc->out.len > le32_to_cpu(pdsfc->ident.max_resp_sz)) {
295300
dev_dbg(dev, "Invalid response size %u, max %u\n",
296-
rpc->out.len, pdsfc->ident.max_resp_sz);
301+
rpc->out.len, le32_to_cpu(pdsfc->ident.max_resp_sz));
297302
return -EINVAL;
298303
}
299304

300-
for (i = 0; i < pdsfc->endpoints->num_entries; i++) {
305+
num_entries = le32_to_cpu(pdsfc->endpoints->num_entries);
306+
for (i = 0; i < num_entries; i++) {
301307
if (pdsfc->endpoint_info[i].endpoint == rpc->in.ep) {
302308
ep_info = &pdsfc->endpoint_info[i];
303309
break;
@@ -326,8 +332,9 @@ static int pdsfc_validate_rpc(struct pdsfc_dev *pdsfc,
326332

327333
/* reject unsupported and/or out of scope commands */
328334
op_entry = (struct pds_fwctl_query_data_operation *)ep_info->operations->entries;
329-
for (i = 0; i < ep_info->operations->num_entries; i++) {
330-
if (PDS_FWCTL_RPC_OPCODE_CMP(rpc->in.op, op_entry[i].id)) {
335+
num_entries = le32_to_cpu(ep_info->operations->num_entries);
336+
for (i = 0; i < num_entries; i++) {
337+
if (PDS_FWCTL_RPC_OPCODE_CMP(rpc->in.op, le32_to_cpu(op_entry[i].id))) {
331338
if (scope < op_entry[i].scope)
332339
return -EPERM;
333340
return 0;
@@ -402,7 +409,7 @@ static void *pdsfc_fw_rpc(struct fwctl_uctx *uctx, enum fwctl_rpc_scope scope,
402409
cmd = (union pds_core_adminq_cmd) {
403410
.fwctl_rpc = {
404411
.opcode = PDS_FWCTL_CMD_RPC,
405-
.flags = PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP,
412+
.flags = cpu_to_le16(PDS_FWCTL_RPC_IND_REQ | PDS_FWCTL_RPC_IND_RESP),
406413
.ep = cpu_to_le32(rpc->in.ep),
407414
.op = cpu_to_le32(rpc->in.op),
408415
.req_pa = cpu_to_le64(in_payload_dma_addr),

include/uapi/cxl/features.h

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,19 @@
88
#define _UAPI_CXL_FEATURES_H_
99

1010
#include <linux/types.h>
11-
#ifndef __KERNEL__
12-
#include <uuid/uuid.h>
13-
#else
11+
12+
typedef unsigned char __uapi_uuid_t[16];
13+
14+
#ifdef __KERNEL__
1415
#include <linux/uuid.h>
16+
/*
17+
* Note, __uapi_uuid_t is 1-byte aligned on modern compilers and 4-byte
18+
* aligned on others. Ensure that __uapi_uuid_t in a struct is placed at
19+
* a 4-byte aligned offset, or the structure is packed, to ensure
20+
* consistent padding.
21+
*/
22+
static_assert(sizeof(__uapi_uuid_t) == sizeof(uuid_t));
23+
#define __uapi_uuid_t uuid_t
1524
#endif
1625

1726
/*
@@ -60,7 +69,7 @@ struct cxl_mbox_get_sup_feats_in {
6069
* Get Supported Features Supported Feature Entry
6170
*/
6271
struct cxl_feat_entry {
63-
uuid_t uuid;
72+
__uapi_uuid_t uuid;
6473
__le16 id;
6574
__le16 get_feat_size;
6675
__le16 set_feat_size;
@@ -110,7 +119,7 @@ struct cxl_mbox_get_sup_feats_out {
110119
* CXL spec r3.2 section 8.2.9.6.2 Table 8-99
111120
*/
112121
struct cxl_mbox_get_feat_in {
113-
uuid_t uuid;
122+
__uapi_uuid_t uuid;
114123
__le16 offset;
115124
__le16 count;
116125
__u8 selection;
@@ -143,7 +152,7 @@ enum cxl_get_feat_selection {
143152
*/
144153
struct cxl_mbox_set_feat_in {
145154
__struct_group(cxl_mbox_set_feat_hdr, hdr, /* no attrs */,
146-
uuid_t uuid;
155+
__uapi_uuid_t uuid;
147156
__le32 flags;
148157
__le16 offset;
149158
__u8 version;

0 commit comments

Comments
 (0)