Commit a8a20a23 authored by Zeng Heng's avatar Zeng Heng
Browse files

arm64/mpam: Try reading again if monitor instance returns not ready

hulk inclusion
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/IAG93D



--------------------------------

If the MSC monitor instance is the first time to configure, this single
monitor need to wait 'not ready' time before getting the valid value.

Components made up of multiple MSC may need values from each MSC, so when
getting the whole component monitor values, need to wait every single
monitor instance 'not ready' time instead of once per component.

Fixes: bb66b4d1 ("arm_mpam: Add mpam_msmon_read() to read monitor value")
Signed-off-by: default avatarZeng Heng <zengheng4@huawei.com>
parent eb0ce17f
Loading
Loading
Loading
Loading
+17 −20
Original line number Diff line number Diff line
@@ -1034,11 +1034,14 @@ static void __ris_msmon_read(void *arg)
	}

	*(m->val) += now;
	m->err = 0;
}

static int _msmon_read(struct mpam_component *comp, struct mon_read *arg)
{
	int err, idx;
	bool read_again;
	u64 wait_jiffies;
	struct mpam_msc *msc;
	struct mpam_msc_ris *ris;

@@ -1047,10 +1050,23 @@ static int _msmon_read(struct mpam_component *comp, struct mon_read *arg)
		arg->ris = ris;

		msc = ris->msc;
		read_again = false;
again:
		mutex_lock(&msc->lock);
		err = smp_call_function_any(&msc->accessibility,
					    __ris_msmon_read, arg, true);
		mutex_unlock(&msc->lock);

		if (arg->err == -EBUSY && !read_again) {
			read_again = true;

			wait_jiffies = usecs_to_jiffies(comp->class->nrdy_usec);
			while (wait_jiffies)
				wait_jiffies = schedule_timeout_uninterruptible(wait_jiffies);

			goto again;
		}

		if (!err && arg->err)
			err = arg->err;
		if (err)
@@ -1064,9 +1080,7 @@ static int _msmon_read(struct mpam_component *comp, struct mon_read *arg)
int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx,
		    enum mpam_device_features type, u64 *val)
{
	int err;
	struct mon_read arg;
	u64 wait_jiffies = 0;
	struct mpam_props *cprops = &comp->class->props;

	might_sleep();
@@ -1083,24 +1097,7 @@ int mpam_msmon_read(struct mpam_component *comp, struct mon_cfg *ctx,
	arg.val = val;
	*val = 0;

	err = _msmon_read(comp, &arg);
	if (err == -EBUSY)
		wait_jiffies = usecs_to_jiffies(comp->class->nrdy_usec);

	while (wait_jiffies)
		wait_jiffies = schedule_timeout_uninterruptible(wait_jiffies);

	if (err == -EBUSY) {
		memset(&arg, 0, sizeof(arg));
		arg.ctx = ctx;
		arg.type = type;
		arg.val = val;
		*val = 0;

		err = _msmon_read(comp, &arg);
	}

	return err;
	return _msmon_read(comp, &arg);
}

void mpam_msmon_reset_all_mbwu(struct mpam_component *comp)