<commit_before>#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <errno.h>

#include "intel_io.h"
#include "intel_reg.h"
#include "igt_core.h"

#define TIMEOUT_US 500000

/* Standard MMIO read, non-posted */
#define SB_MRD_NP      0x00
/* Standard MMIO write, non-posted */
#define SB_MWR_NP      0x01
/* Private register read, double-word addressing, non-posted */
#define SB_CRRDDA_NP   0x06
/* Private register write, double-word addressing, non-posted */
#define SB_CRWRDA_NP   0x07

static int vlv_sideband_rw(uint32_t port, uint8_t opcode, uint32_t addr,
			   uint32_t *val)
{
	int timeout = 0;
	uint32_t cmd, devfn, be, bar;
	int is_read = (opcode == SB_CRRDDA_NP || opcode == SB_MRD_NP);

	bar = 0;
	be = 0xf;
	devfn = 16;

	cmd = (devfn << IOSF_DEVFN_SHIFT) | (opcode << IOSF_OPCODE_SHIFT) |
		(port << IOSF_PORT_SHIFT) | (be << IOSF_BYTE_ENABLES_SHIFT) |
		(bar << IOSF_BAR_SHIFT);

	if (intel_register_read(VLV_IOSF_DOORBELL_REQ) & IOSF_SB_BUSY) {
		igt_warn("warning: pcode (%s) mailbox access failed\n", is_read ? "read" : "write");
		return -EAGAIN;
	}

	intel_register_write(VLV_IOSF_ADDR, addr);
	if (!is_read)
		intel_register_write(VLV_IOSF_DATA, *val);

	intel_register_write(VLV_IOSF_DOORBELL_REQ, cmd);

	do {
		usleep(1);
		timeout++;
	} while (intel_register_read(VLV_IOSF_DOORBELL_REQ) & IOSF_SB_BUSY &&
		 timeout < TIMEOUT_US);

	if (timeout >= TIMEOUT_US) {
		igt_warn("timeout waiting for pcode %s (%d) to finish\n", is_read ? "read" : "write", addr);
		return -ETIMEDOUT;
	}

	if (is_read)<commit_msg>lib: Change IOSF SB devfn to 0.0<commit_after>#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <err.h>
#include <errno.h>

#include "intel_io.h"
#include "intel_reg.h"
#include "igt_core.h"

#define TIMEOUT_US 500000

/* Standard MMIO read, non-posted */
#define SB_MRD_NP      0x00
/* Standard MMIO write, non-posted */
#define SB_MWR_NP      0x01
/* Private register read, double-word addressing, non-posted */
#define SB_CRRDDA_NP   0x06
/* Private register write, double-word addressing, non-posted */
#define SB_CRWRDA_NP   0x07

static int vlv_sideband_rw(uint32_t port, uint8_t opcode, uint32_t addr,
			   uint32_t *val)
{
	int timeout = 0;
	uint32_t cmd, devfn, be, bar;
	int is_read = (opcode == SB_CRRDDA_NP || opcode == SB_MRD_NP);

	bar = 0;
	be = 0xf;
	devfn = 0;

	cmd = (devfn << IOSF_DEVFN_SHIFT) | (opcode << IOSF_OPCODE_SHIFT) |
		(port << IOSF_PORT_SHIFT) | (be << IOSF_BYTE_ENABLES_SHIFT) |
		(bar << IOSF_BAR_SHIFT);

	if (intel_register_read(VLV_IOSF_DOORBELL_REQ) & IOSF_SB_BUSY) {
		igt_warn("warning: pcode (%s) mailbox access failed\n", is_read ? "read" : "write");
		return -EAGAIN;
	}

	intel_register_write(VLV_IOSF_ADDR, addr);
	if (!is_read)
		intel_register_write(VLV_IOSF_DATA, *val);

	intel_register_write(VLV_IOSF_DOORBELL_REQ, cmd);

	do {
		usleep(1);
		timeout++;
	} while (intel_register_read(VLV_IOSF_DOORBELL_REQ) & IOSF_SB_BUSY &&
		 timeout < TIMEOUT_US);

	if (timeout >= TIMEOUT_US) {
		igt_warn("timeout waiting for pcode %s (%d) to finish\n", is_read ? "read" : "write", addr);
		return -ETIMEDOUT;
	}

	if (is_read)
{'fraction_non_alphanumeric': 0.13396825396825396, 'fraction_numerical': 0.02126984126984127, 'mean_word_length': 4.586879432624113, 'pattern_counts': {'":': 0, '<': 35, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1407128', 'n_tokens_mistral': 1419, 'n_tokens_neox': 1329, 'n_words': 287}