driver.c (594ce0b8a998aa4d05827cd7c0d0dcec9a1e3ae2) driver.c (9dd15934f60d1298ad1c427711f338a194294a78)
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Arm Firmware Framework for ARMv8-A(FFA) interface driver
4 *
5 * The Arm FFA specification[1] describes a software architecture to
6 * leverages the virtualization extension to isolate software images
7 * provided by an ecosystem of vendors from each other and describes
8 * interfaces that standardize communication between the various software

--- 1210 unchanged lines hidden (view full) ---

1219 .notifier_ops = &ffa_drv_notifier_ops,
1220};
1221
1222void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
1223{
1224 int count, idx;
1225 struct ffa_partition_info *pbuf, *tpbuf;
1226
1// SPDX-License-Identifier: GPL-2.0-only
2/*
3 * Arm Firmware Framework for ARMv8-A(FFA) interface driver
4 *
5 * The Arm FFA specification[1] describes a software architecture to
6 * leverages the virtualization extension to isolate software images
7 * provided by an ecosystem of vendors from each other and describes
8 * interfaces that standardize communication between the various software

--- 1210 unchanged lines hidden (view full) ---

1219 .notifier_ops = &ffa_drv_notifier_ops,
1220};
1221
1222void ffa_device_match_uuid(struct ffa_device *ffa_dev, const uuid_t *uuid)
1223{
1224 int count, idx;
1225 struct ffa_partition_info *pbuf, *tpbuf;
1226
1227 /*
1228 * FF-A v1.1 provides UUID for each partition as part of the discovery
1229 * API, the discovered UUID must be populated in the device's UUID and
1230 * there is no need to copy the same from the driver table.
1231 */
1232 if (drv_info->version > FFA_VERSION_1_0)
1233 return;
1234
1235 count = ffa_partition_probe(uuid, &pbuf);
1236 if (count <= 0)
1237 return;
1238
1239 for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++)
1240 if (tpbuf->id == ffa_dev->vm_id)
1241 uuid_copy(&ffa_dev->uuid, uuid);
1242 kfree(pbuf);
1243}
1244
1227 count = ffa_partition_probe(uuid, &pbuf);
1228 if (count <= 0)
1229 return;
1230
1231 for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++)
1232 if (tpbuf->id == ffa_dev->vm_id)
1233 uuid_copy(&ffa_dev->uuid, uuid);
1234 kfree(pbuf);
1235}
1236
1237static int
1238ffa_bus_notifier(struct notifier_block *nb, unsigned long action, void *data)
1239{
1240 struct device *dev = data;
1241 struct ffa_device *fdev = to_ffa_dev(dev);
1242
1243 if (action == BUS_NOTIFY_BIND_DRIVER) {
1244 struct ffa_driver *ffa_drv = to_ffa_driver(dev->driver);
1245 const struct ffa_device_id *id_table= ffa_drv->id_table;
1246
1247 /*
1248 * FF-A v1.1 provides UUID for each partition as part of the
1249 * discovery API, the discovered UUID must be populated in the
1250 * device's UUID and there is no need to workaround by copying
1251 * the same from the driver table.
1252 */
1253 if (uuid_is_null(&fdev->uuid))
1254 ffa_device_match_uuid(fdev, &id_table->uuid);
1255
1256 return NOTIFY_OK;
1257 }
1258
1259 return NOTIFY_DONE;
1260}
1261
1262static struct notifier_block ffa_bus_nb = {
1263 .notifier_call = ffa_bus_notifier,
1264};
1265
1245static int ffa_setup_partitions(void)
1246{
1247 int count, idx, ret;
1248 uuid_t uuid;
1249 struct ffa_device *ffa_dev;
1250 struct ffa_dev_part_info *info;
1251 struct ffa_partition_info *pbuf, *tpbuf;
1252
1266static int ffa_setup_partitions(void)
1267{
1268 int count, idx, ret;
1269 uuid_t uuid;
1270 struct ffa_device *ffa_dev;
1271 struct ffa_dev_part_info *info;
1272 struct ffa_partition_info *pbuf, *tpbuf;
1273
1274 if (drv_info->version == FFA_VERSION_1_0) {
1275 ret = bus_register_notifier(&ffa_bus_type, &ffa_bus_nb);
1276 if (ret)
1277 pr_err("Failed to register FF-A bus notifiers\n");
1278 }
1279
1253 count = ffa_partition_probe(&uuid_null, &pbuf);
1254 if (count <= 0) {
1255 pr_info("%s: No partitions found, error %d\n", __func__, count);
1256 return -EINVAL;
1257 }
1258
1259 xa_init(&drv_info->partition_info);
1260 for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
1261 import_uuid(&uuid, (u8 *)tpbuf->uuid);
1262
1263 /* Note that if the UUID will be uuid_null, that will require
1280 count = ffa_partition_probe(&uuid_null, &pbuf);
1281 if (count <= 0) {
1282 pr_info("%s: No partitions found, error %d\n", __func__, count);
1283 return -EINVAL;
1284 }
1285
1286 xa_init(&drv_info->partition_info);
1287 for (idx = 0, tpbuf = pbuf; idx < count; idx++, tpbuf++) {
1288 import_uuid(&uuid, (u8 *)tpbuf->uuid);
1289
1290 /* Note that if the UUID will be uuid_null, that will require
1264 * ffa_device_match() to find the UUID of this partition id
1291 * ffa_bus_notifier() to find the UUID of this partition id
1265 * with help of ffa_device_match_uuid(). FF-A v1.1 and above
1266 * provides UUID here for each partition as part of the
1267 * discovery API and the same is passed.
1268 */
1269 ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops);
1270 if (!ffa_dev) {
1271 pr_err("%s: failed to register partition ID 0x%x\n",
1272 __func__, tpbuf->id);

--- 401 unchanged lines hidden ---
1292 * with help of ffa_device_match_uuid(). FF-A v1.1 and above
1293 * provides UUID here for each partition as part of the
1294 * discovery API and the same is passed.
1295 */
1296 ffa_dev = ffa_device_register(&uuid, tpbuf->id, &ffa_drv_ops);
1297 if (!ffa_dev) {
1298 pr_err("%s: failed to register partition ID 0x%x\n",
1299 __func__, tpbuf->id);

--- 401 unchanged lines hidden ---