summaryrefslogtreecommitdiffstats
path: root/SD-VBS/benchmarks/mser/data/qcif/expected.m
diff options
context:
space:
mode:
authorJoshua Bakita <jbakita@cs.unc.edu>2021-03-07 19:14:19 -0500
committerJoshua Bakita <jbakita@cs.unc.edu>2021-03-07 19:25:21 -0500
commit899765845196007c695a2f858dbe3a41b8db4a2b (patch)
tree98754916059357c0829fd8acc73130565d866ace /SD-VBS/benchmarks/mser/data/qcif/expected.m
parentafcfb8ee7b005edeba8163f00ce5300cf77ede85 (diff)
SD-VBS: Fix memory leaks and tweak allocation bounds
- Fix leaks in localization, multi_ncut, svm, and texture_synthesis - Lower preallocation for sift and texture_synthesis to match memory profile with QCIF - Remove trailing whitespace in script_localization.c
Diffstat (limited to 'SD-VBS/benchmarks/mser/data/qcif/expected.m')
0 files changed, 0 insertions, 0 deletions
f='#n119'>119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573




























































































































































































































































































































































































































































































































































































                                                                                                       
/*
 * Copyright (c) 2016-2018, NVIDIA CORPORATION.  All rights reserved.
 *
 * Permission is hereby granted, free of charge, to any person obtaining a
 * copy of this software and associated documentation files (the "Software"),
 * to deal in the Software without restriction, including without limitation
 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
 * and/or sell copies of the Software, and to permit persons to whom the
 * Software is furnished to do so, subject to the following conditions:
 *
 * The above copyright notice and this permission notice shall be included in
 * all copies or substantial portions of the Software.
 *
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
 * DEALINGS IN THE SOFTWARE.
 */

#include <nvgpu/bios.h>
#include <nvgpu/pmuif/nvgpu_gpmu_cmdif.h>
#include <nvgpu/io.h>
#include <nvgpu/gk20a.h>

#include "boardobj/boardobjgrp.h"
#include "boardobj/boardobjgrp_e32.h"

#include "ctrl/ctrlvolt.h"

#include "gp106/bios_gp106.h"

#include "clk.h"
#include "clk_vin.h"

static int devinit_get_vin_device_table(struct gk20a *g,
		struct avfsvinobjs *pvinobjs);

static int vin_device_construct_v10(struct gk20a *g,
					struct boardobj **ppboardobj,
					u16 size, void *pargs);
static int vin_device_construct_v20(struct gk20a *g,
					struct boardobj **ppboardobj,
					u16 size, void *pargs);
static int vin_device_construct_super(struct gk20a *g,
					struct boardobj **ppboardobj,
					u16 size, void *pargs);
static struct vin_device *construct_vin_device(struct gk20a *g, void *pargs);

static int vin_device_init_pmudata_v10(struct gk20a *g,
				  struct boardobj *board_obj_ptr,
				  struct nv_pmu_boardobj *ppmudata);
static int vin_device_init_pmudata_v20(struct gk20a *g,
				  struct boardobj *board_obj_ptr,
				  struct nv_pmu_boardobj *ppmudata);
static int vin_device_init_pmudata_super(struct gk20a *g,
				  struct boardobj *board_obj_ptr,
				  struct nv_pmu_boardobj *ppmudata);

u32 clk_avfs_get_vin_cal_fuse_v10(struct gk20a *g,
					struct avfsvinobjs *pvinobjs,
					struct vin_device_v20 *pvindev)
{
	u32 status = 0;
	u32 slope, intercept;
	u8 i;

	if (pvinobjs->calibration_rev_vbios == g->ops.fuse.read_vin_cal_fuse_rev(g)) {
		BOARDOBJGRP_FOR_EACH(&(pvinobjs->super.super),
				     struct vin_device_v20 *, pvindev, i) {
			slope = 0;
			intercept = 0;
			pvindev = (struct vin_device_v20 *)CLK_GET_VIN_DEVICE(pvinobjs, i);
			status = g->ops.fuse.read_vin_cal_slope_intercept_fuse(g,
					pvindev->super.id, &slope, &intercept);
			if (status) {
				nvgpu_err(g,
				"err reading vin cal for id %x", pvindev->super.id);
				return status;
			}
			pvindev->data.vin_cal.cal_v10.slope = slope;
			pvindev->data.vin_cal.cal_v10.intercept = intercept;
		}
	}
	return status;

}

u32 clk_avfs_get_vin_cal_fuse_v20(struct gk20a *g,
					struct avfsvinobjs *pvinobjs,
					struct vin_device_v20 *pvindev)
{
	u32 status = 0;
	s8 gain, offset;
	u8 i;

	if (pvinobjs->calibration_rev_vbios == g->ops.fuse.read_vin_cal_fuse_rev(g)) {
		BOARDOBJGRP_FOR_EACH(&(pvinobjs->super.super),
				     struct vin_device_v20 *, pvindev, i) {
			gain = '\0';
			offset = '\0';
			pvindev = (struct vin_device_v20 *)CLK_GET_VIN_DEVICE(pvinobjs, i);
			status = g->ops.fuse.read_vin_cal_gain_offset_fuse(g,
					pvindev->super.id, &gain, &offset);
			if (status) {
				nvgpu_err(g,
				"err reading vin cal for id %x", pvindev->super.id);
				return status;
			}
			pvindev->data.vin_cal.cal_v20.gain = gain;
			pvindev->data.vin_cal.cal_v20.offset = offset;
		}
	}
	return status;

}

static int _clk_vin_devgrp_pmudatainit_super(struct gk20a *g,
					     struct boardobjgrp *pboardobjgrp,
					     struct nv_pmu_boardobjgrp_super *pboardobjgrppmu)
{
	struct nv_pmu_clk_clk_vin_device_boardobjgrp_set_header *pset =
		(struct nv_pmu_clk_clk_vin_device_boardobjgrp_set_header *)
		pboardobjgrppmu;
	struct avfsvinobjs *pvin_obbj = (struct avfsvinobjs *)pboardobjgrp;
	int status = 0;

	nvgpu_log_info(g, " ");

	status = boardobjgrp_pmudatainit_e32(g, pboardobjgrp, pboardobjgrppmu);

	pset->b_vin_is_disable_allowed = pvin_obbj->vin_is_disable_allowed;

	nvgpu_log_info(g, " Done");
	return status;
}

static int _clk_vin_devgrp_pmudata_instget(struct gk20a *g,
					   struct nv_pmu_boardobjgrp *pmuboardobjgrp,
					   struct nv_pmu_boardobj **ppboardobjpmudata,
					   u8 idx)
{
	struct nv_pmu_clk_clk_vin_device_boardobj_grp_set *pgrp_set =
		(struct nv_pmu_clk_clk_vin_device_boardobj_grp_set *)
		pmuboardobjgrp;

	nvgpu_log_info(g, " ");

	/*check whether pmuboardobjgrp has a valid boardobj in index*/
	if (((u32)BIT(idx) &
		pgrp_set->hdr.data.super.obj_mask.super.data[0]) == 0) {
		return -EINVAL;
	}

	*ppboardobjpmudata = (struct nv_pmu_boardobj *)
		&pgrp_set->objects[idx].data.board_obj;
	nvgpu_log_info(g, " Done");
	return 0;
}

static int _clk_vin_devgrp_pmustatus_instget(struct gk20a *g,
					     void *pboardobjgrppmu,
					     struct nv_pmu_boardobj_query **ppboardobjpmustatus,
					     u8 idx)
{
	struct nv_pmu_clk_clk_vin_device_boardobj_grp_get_status *pgrp_get_status =
		(struct nv_pmu_clk_clk_vin_device_boardobj_grp_get_status *)
		pboardobjgrppmu;

	/*check whether pmuboardobjgrp has a valid boardobj in index*/
	if (((u32)BIT(idx) &
		pgrp_get_status->hdr.data.super.obj_mask.super.data[0]) == 0) {
		return -EINVAL;
	}

	*ppboardobjpmustatus = (struct nv_pmu_boardobj_query *)
			&pgrp_get_status->objects[idx].data.board_obj;
	return 0;
}

int clk_vin_sw_setup(struct gk20a *g)
{
	int status;
	struct boardobjgrp *pboardobjgrp = NULL;
	struct vin_device_v20 *pvindev = NULL;
	struct avfsvinobjs *pvinobjs;

	nvgpu_log_info(g, " ");

	status = boardobjgrpconstruct_e32(g, &g->clk_pmu.avfs_vinobjs.super);
	if (status) {
		nvgpu_err(g,
			"error creating boardobjgrp for clk vin, statu - 0x%x",
			status);
		goto done;
	}

	pboardobjgrp = &g->clk_pmu.avfs_vinobjs.super.super;
	pvinobjs = &g->clk_pmu.avfs_vinobjs;

	BOARDOBJGRP_PMU_CONSTRUCT(pboardobjgrp, CLK, VIN_DEVICE);

	status = BOARDOBJGRP_PMU_CMD_GRP_SET_CONSTRUCT(g, pboardobjgrp,
			clk, CLK, clk_vin_device, CLK_VIN_DEVICE);
	if (status) {
		nvgpu_err(g,
			"error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
			status);
		goto done;
	}

	pboardobjgrp->pmudatainit  = _clk_vin_devgrp_pmudatainit_super;
	pboardobjgrp->pmudatainstget  = _clk_vin_devgrp_pmudata_instget;
	pboardobjgrp->pmustatusinstget  = _clk_vin_devgrp_pmustatus_instget;

	status = devinit_get_vin_device_table(g, &g->clk_pmu.avfs_vinobjs);
	if (status) {
		goto done;
	}

	/*update vin calibration to fuse */
	g->ops.pmu_ver.clk.clk_avfs_get_vin_cal_data(g, pvinobjs, pvindev);

	status = BOARDOBJGRP_PMU_CMD_GRP_GET_STATUS_CONSTRUCT(g,
				&g->clk_pmu.avfs_vinobjs.super.super,
				clk, CLK, clk_vin_device, CLK_VIN_DEVICE);
	if (status) {
		nvgpu_err(g,
			"error constructing PMU_BOARDOBJ_CMD_GRP_SET interface - 0x%x",
			status);
		goto done;
	}

done:
	nvgpu_log_info(g, " done status %x", status);
	return status;
}

int clk_vin_pmu_setup(struct gk20a *g)
{
	int status;
	struct boardobjgrp *pboardobjgrp = NULL;

	nvgpu_log_info(g, " ");

	pboardobjgrp = &g->clk_pmu.avfs_vinobjs.super.super;

	if (!pboardobjgrp->bconstructed) {
		return -EINVAL;
	}

	status = pboardobjgrp->pmuinithandle(g, pboardobjgrp);

	nvgpu_log_info(g, "Done");
	return status;
}

static int devinit_get_vin_device_table(struct gk20a *g,
		struct avfsvinobjs *pvinobjs)
{
	int status = 0;
	u8 *vin_table_ptr = NULL;
	struct vin_descriptor_header_10 vin_desc_table_header = { 0 };
	struct vin_descriptor_entry_10 vin_desc_table_entry = { 0 };
	u8 *vin_tbl_entry_ptr = NULL;
	u32 index = 0;
	u32 slope=0, intercept=0;
	s8 offset='\0', gain='\0';
	struct vin_device *pvin_dev;
	u32 cal_type;

	union {
		struct boardobj boardobj;
		struct vin_device vin_device;
		struct vin_device_v10 vin_device_v10;
		struct vin_device_v20 vin_device_v20;
	} vin_device_data;

	nvgpu_log_info(g, " ");

	vin_table_ptr = (u8 *)nvgpu_bios_get_perf_table_ptrs(g,
			g->bios.clock_token, VIN_TABLE);
	if (vin_table_ptr == NULL) {
		status = -1;
		goto done;
	}

	memcpy(&vin_desc_table_header, vin_table_ptr,
	       sizeof(struct vin_descriptor_header_10));

	pvinobjs->calibration_rev_vbios =
			BIOS_GET_FIELD(vin_desc_table_header.flags0,
				NV_VIN_DESC_FLAGS0_VIN_CAL_REVISION);
	pvinobjs->vin_is_disable_allowed =
			BIOS_GET_FIELD(vin_desc_table_header.flags0,
				NV_VIN_DESC_FLAGS0_DISABLE_CONTROL);
	cal_type = BIOS_GET_FIELD(vin_desc_table_header.flags0,
				NV_VIN_DESC_FLAGS0_VIN_CAL_TYPE);
	if (!cal_type) {
		cal_type = CTRL_CLK_VIN_CAL_TYPE_V10;
	}

	switch (cal_type) {
	case CTRL_CLK_VIN_CAL_TYPE_V10:
		/* VIN calibration slope: XX.YYY mV/code => XXYYY uV/code*/
		slope = ((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
				NV_VIN_DESC_VIN_CAL_SLOPE_INTEGER) * 1000)) +
			((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
				NV_VIN_DESC_VIN_CAL_SLOPE_FRACTION)));

		/* VIN calibration intercept: ZZZ.W mV => ZZZW00 uV */
		intercept = ((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
				NV_VIN_DESC_VIN_CAL_INTERCEPT_INTEGER) * 1000)) +
			    ((BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
				NV_VIN_DESC_VIN_CAL_INTERCEPT_FRACTION) * 100));

		break;
	case CTRL_CLK_VIN_CAL_TYPE_V20:
		offset = BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
                                NV_VIN_DESC_VIN_CAL_OFFSET);
		gain = BIOS_GET_FIELD(vin_desc_table_header.vin_cal,
                                NV_VIN_DESC_VIN_CAL_GAIN);
		break;
	default:
		status = -1;
		goto done;
	}
	/* Read table entries*/
	vin_tbl_entry_ptr = vin_table_ptr + vin_desc_table_header.header_sizee;
	for (index = 0; index < vin_desc_table_header.entry_count; index++) {
		memcpy(&vin_desc_table_entry, vin_tbl_entry_ptr,
		       sizeof(struct vin_descriptor_entry_10));

		if (vin_desc_table_entry.vin_device_type == CTRL_CLK_VIN_TYPE_DISABLED) {
			continue;
		}

		vin_device_data.boardobj.type =
			(u8)vin_desc_table_entry.vin_device_type;
		vin_device_data.vin_device.id = (u8)vin_desc_table_entry.vin_device_id;
		vin_device_data.vin_device.volt_domain_vbios =
			(u8)vin_desc_table_entry.volt_domain_vbios;
		vin_device_data.vin_device.flls_shared_mask = 0;

		switch (vin_device_data.boardobj.type) {
		case CTRL_CLK_VIN_TYPE_V10:
			vin_device_data.vin_device_v10.data.vin_cal.slope = slope;
			vin_device_data.vin_device_v10.data.vin_cal.intercept = intercept;
			break;
		case CTRL_CLK_VIN_TYPE_V20:
			vin_device_data.vin_device_v20.data.cal_type = (u8) cal_type;
			vin_device_data.vin_device_v20.data.vin_cal.cal_v20.offset = offset;
			vin_device_data.vin_device_v20.data.vin_cal.cal_v20.gain = gain;
			break;
		default:
			status = -1;
			goto done;
		};

		pvin_dev = construct_vin_device(g, (void *)&vin_device_data);

		status = boardobjgrp_objinsert(&pvinobjs->super.super,
				(struct boardobj *)pvin_dev, index);

		vin_tbl_entry_ptr += vin_desc_table_header.entry_size;
	}

done