drivers/vdpa/mlx5/core/resources.c

Source file repositories/reference/linux-study-clean/drivers/vdpa/mlx5/core/resources.c

File Facts

System
Linux kernel
Corpus path
drivers/vdpa/mlx5/core/resources.c
Extension
.c
Size
10229 bytes
Lines
394
Domain
Driver Families
Bucket
drivers/vdpa
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (*completed < issued) {
			/* Throttled by own commands: wait for oldest completion. */
			wait_for_completion(&cmds[*completed].cmd_done);
			(*completed)++;

			goto retry;
		} else {
			/* Throttled by external commands: switch to sync api. */
			err = mlx5_cmd_exec(mvdev->mdev,
					    cmd->in, cmd->inlen,
					    cmd->out, cmd->outlen);
			if (!err)
				(*completed)++;
		}
	}

	return err;
}

int mlx5_vdpa_exec_async_cmds(struct mlx5_vdpa_dev *mvdev,
			      struct mlx5_vdpa_async_cmd *cmds,
			      int num_cmds)
{
	int completed = 0;
	int issued = 0;
	int err = 0;

	for (int i = 0; i < num_cmds; i++)
		init_completion(&cmds[i].cmd_done);

	while (issued < num_cmds) {

		err = issue_async_cmd(mvdev, cmds, issued, &completed);
		if (err) {
			mlx5_vdpa_err(mvdev, "error issuing command %d of %d: %d\n",
				      issued, num_cmds, err);
			break;
		}

		issued++;
	}

	while (completed < issued)
		wait_for_completion(&cmds[completed++].cmd_done);

	return err;
}

Annotation

Implementation Notes