/** * mei_txe_reg_read - Reads 32bit data from the txe device * * @base_addr: registers base address * @offset: register offset * * Return: register value
*/ staticinline u32 mei_txe_reg_read(void __iomem *base_addr, unsignedlong offset)
{ return ioread32(base_addr + offset);
}
/** * mei_txe_reg_write - Writes 32bit data to the txe device * * @base_addr: registers base address * @offset: register offset * @value: the value to write
*/ staticinlinevoid mei_txe_reg_write(void __iomem *base_addr, unsignedlong offset, u32 value)
{
iowrite32(value, base_addr + offset);
}
/** * mei_txe_sec_reg_read_silent - Reads 32bit data from the SeC BAR * * @hw: the txe hardware structure * @offset: register offset * * Doesn't check for aliveness while Reads 32bit data from the SeC BAR * * Return: register value
*/ staticinline u32 mei_txe_sec_reg_read_silent(struct mei_txe_hw *hw, unsignedlong offset)
{ return mei_txe_reg_read(hw->mem_addr[SEC_BAR], offset);
}
/** * mei_txe_sec_reg_read - Reads 32bit data from the SeC BAR * * @hw: the txe hardware structure * @offset: register offset * * Reads 32bit data from the SeC BAR and shout loud if aliveness is not set * * Return: register value
*/ staticinline u32 mei_txe_sec_reg_read(struct mei_txe_hw *hw, unsignedlong offset)
{
WARN(!hw->aliveness, "sec read: aliveness not asserted\n"); return mei_txe_sec_reg_read_silent(hw, offset);
} /** * mei_txe_sec_reg_write_silent - Writes 32bit data to the SeC BAR * doesn't check for aliveness * * @hw: the txe hardware structure * @offset: register offset * @value: value to write * * Doesn't check for aliveness while writes 32bit data from to the SeC BAR
*/ staticinlinevoid mei_txe_sec_reg_write_silent(struct mei_txe_hw *hw, unsignedlong offset, u32 value)
{
mei_txe_reg_write(hw->mem_addr[SEC_BAR], offset, value);
}
/** * mei_txe_sec_reg_write - Writes 32bit data to the SeC BAR * * @hw: the txe hardware structure * @offset: register offset * @value: value to write * * Writes 32bit data from the SeC BAR and shout loud if aliveness is not set
*/ staticinlinevoid mei_txe_sec_reg_write(struct mei_txe_hw *hw, unsignedlong offset, u32 value)
{
WARN(!hw->aliveness, "sec write: aliveness not asserted\n");
mei_txe_sec_reg_write_silent(hw, offset, value);
} /** * mei_txe_br_reg_read - Reads 32bit data from the Bridge BAR * * @hw: the txe hardware structure * @offset: offset from which to read the data * * Return: the byte read.
*/ staticinline u32 mei_txe_br_reg_read(struct mei_txe_hw *hw, unsignedlong offset)
{ return mei_txe_reg_read(hw->mem_addr[BRIDGE_BAR], offset);
}
/** * mei_txe_br_reg_write - Writes 32bit data to the Bridge BAR * * @hw: the txe hardware structure * @offset: offset from which to write the data * @value: the byte to write
*/ staticinlinevoid mei_txe_br_reg_write(struct mei_txe_hw *hw, unsignedlong offset, u32 value)
{
mei_txe_reg_write(hw->mem_addr[BRIDGE_BAR], offset, value);
}
/** * mei_txe_aliveness_set - request for aliveness change * * @dev: the device structure * @req: requested aliveness value * * Request for aliveness change and returns true if the change is * really needed and false if aliveness is already * in the requested state * * Locking: called under "dev->device_lock" lock * * Return: true if request was send
*/ staticbool mei_txe_aliveness_set(struct mei_device *dev, u32 req)
{
/** * mei_txe_aliveness_poll - waits for aliveness to settle * * @dev: the device structure * @expected: expected aliveness value * * Polls for HICR_HOST_ALIVENESS_RESP.ALIVENESS_RESP to be set * * Return: 0 if the expected value was received, -ETIME otherwise
*/ staticint mei_txe_aliveness_poll(struct mei_device *dev, u32 expected)
{ struct mei_txe_hw *hw = to_txe_hw(dev);
ktime_t stop, start;
start = ktime_get();
stop = ktime_add(start, ms_to_ktime(SEC_ALIVENESS_WAIT_TIMEOUT)); do {
hw->aliveness = mei_txe_aliveness_get(dev); if (hw->aliveness == expected) {
dev->pg_event = MEI_PG_EVENT_IDLE;
dev_dbg(dev->dev, "aliveness settled after %lld usecs\n",
ktime_to_us(ktime_sub(ktime_get(), start))); return 0;
}
usleep_range(20, 50);
} while (ktime_before(ktime_get(), stop));
/** * mei_txe_aliveness_wait - waits for aliveness to settle * * @dev: the device structure * @expected: expected aliveness value * * Waits for HICR_HOST_ALIVENESS_RESP.ALIVENESS_RESP to be set * * Return: 0 on success and < 0 otherwise
*/ staticint mei_txe_aliveness_wait(struct mei_device *dev, u32 expected)
{ struct mei_txe_hw *hw = to_txe_hw(dev); constunsignedlong timeout =
msecs_to_jiffies(SEC_ALIVENESS_WAIT_TIMEOUT); long err; int ret;
hw->aliveness = mei_txe_aliveness_get(dev); if (hw->aliveness == expected) return 0;
/** * mei_txe_aliveness_set_sync - sets an wait for aliveness to complete * * @dev: the device structure * @req: requested aliveness value * * Return: 0 on success and < 0 otherwise
*/ int mei_txe_aliveness_set_sync(struct mei_device *dev, u32 req)
{ if (mei_txe_aliveness_set(dev, req)) return mei_txe_aliveness_wait(dev, req); return 0;
}
/** * mei_txe_pg_in_transition - is device now in pg transition * * @dev: the device structure * * Return: true if in pg transition, false otherwise
*/ staticbool mei_txe_pg_in_transition(struct mei_device *dev)
{ return dev->pg_event == MEI_PG_EVENT_WAIT;
}
/** * mei_txe_pg_is_enabled - detect if PG is supported by HW * * @dev: the device structure * * Return: true is pg supported, false otherwise
*/ staticbool mei_txe_pg_is_enabled(struct mei_device *dev)
{ returntrue;
}
/** * mei_txe_pg_state - translate aliveness register value * to the mei power gating state * * @dev: the device structure * * Return: MEI_PG_OFF if aliveness is on and MEI_PG_ON otherwise
*/ staticinlineenum mei_pg_state mei_txe_pg_state(struct mei_device *dev)
{ struct mei_txe_hw *hw = to_txe_hw(dev);
/** * mei_txe_input_doorbell_set - sets bit 0 in * SEC_IPC_INPUT_DOORBELL.IPC_INPUT_DOORBELL. * * @hw: the txe hardware structure
*/ staticvoid mei_txe_input_doorbell_set(struct mei_txe_hw *hw)
{ /* Clear the interrupt cause */
clear_bit(TXE_INTR_IN_READY_BIT, &hw->intr_cause);
mei_txe_sec_reg_write(hw, SEC_IPC_INPUT_DOORBELL_REG, 1);
}
/** * mei_txe_output_ready_set - Sets the SICR_SEC_IPC_OUTPUT_STATUS bit to 1 * * @hw: the txe hardware structure
*/ staticvoid mei_txe_output_ready_set(struct mei_txe_hw *hw)
{
mei_txe_br_reg_write(hw,
SICR_SEC_IPC_OUTPUT_STATUS_REG,
SEC_IPC_OUTPUT_STATUS_RDY);
}
/** * mei_txe_is_input_ready - check if TXE is ready for receiving data * * @dev: the device structure * * Return: true if INPUT STATUS READY bit is set
*/ staticbool mei_txe_is_input_ready(struct mei_device *dev)
{ struct mei_txe_hw *hw = to_txe_hw(dev);
u32 status;
status = mei_txe_sec_reg_read(hw, SEC_IPC_INPUT_STATUS_REG); return !!(SEC_IPC_INPUT_STATUS_RDY & status);
}
/** * mei_txe_pending_interrupts - check if there are pending interrupts * only Aliveness, Input ready, and output doorbell are of relevance * * @dev: the device structure * * Checks if there are pending interrupts * only Aliveness, Readiness, Input ready, and Output doorbell are relevant * * Return: true if there are pending interrupts
*/ staticbool mei_txe_pending_interrupts(struct mei_device *dev)
{
/** * mei_txe_out_data_read - read dword from the device buffer * at offset idx * * @dev: the device structure * @idx: index in the device buffer * * Return: register value at index
*/ static u32 mei_txe_out_data_read(conststruct mei_device *dev, unsignedlong idx)
{ struct mei_txe_hw *hw = to_txe_hw(dev);
/** * mei_txe_fw_status - read fw status register from pci config space * * @dev: mei device * @fw_status: fw status register values * * Return: 0 on success, error otherwise
*/ staticint mei_txe_fw_status(struct mei_device *dev, struct mei_fw_status *fw_status)
{ conststruct mei_fw_status *fw_src = &mei_txe_fw_sts; struct pci_dev *pdev = to_pci_dev(dev->dev); int ret; int i;
if (!fw_status) return -EINVAL;
fw_status->count = fw_src->count; for (i = 0; i < fw_src->count && i < MEI_FW_STATUS_MAX; i++) {
ret = pci_read_config_dword(pdev, fw_src->status[i],
&fw_status->status[i]);
trace_mei_pci_cfg_read(dev->dev, "PCI_CFG_HSF_X",
fw_src->status[i],
fw_status->status[i]); if (ret) return ret;
}
return 0;
}
/** * mei_txe_hw_config - configure hardware at the start of the devices * * @dev: the device structure * * Configure hardware at the start of the device should be done only * once at the device probe time * * Return: always 0
*/ staticint mei_txe_hw_config(struct mei_device *dev)
{
for (i = 0; i < len / MEI_SLOT_SIZE; i++) { /* skip header: index starts from 1 */
reg = mei_txe_out_data_read(dev, i + 1);
dev_dbg(dev->dev, "buf[%d] = 0x%08X\n", i, reg);
*reg_buf++ = reg;
}
if (rem) {
reg = mei_txe_out_data_read(dev, i + 1);
memcpy(reg_buf, ®, rem);
}
mei_txe_output_ready_set(hw); return 0;
}
/** * mei_txe_hw_reset - resets host and fw. * * @dev: the device structure * @intr_enable: if interrupt should be enabled after reset. * * Return: 0 on success and < 0 in case of error
*/ staticint mei_txe_hw_reset(struct mei_device *dev, bool intr_enable)
{ struct mei_txe_hw *hw = to_txe_hw(dev);
u32 aliveness_req; /* * read input doorbell to ensure consistency between Bridge and SeC * return value might be garbage return
*/
(void)mei_txe_sec_reg_read_silent(hw, SEC_IPC_INPUT_DOORBELL_REG);
/* Disable interrupts in this stage we will poll */
mei_txe_intr_disable(dev);
/* * If Aliveness Request and Aliveness Response are not equal then * wait for them to be equal * Since we might have interrupts disabled - poll for it
*/ if (aliveness_req != hw->aliveness) if (mei_txe_aliveness_poll(dev, aliveness_req) < 0) {
dev_err(dev->dev, "wait for aliveness settle failed ... bailing out\n"); return -EIO;
}
/* * If Aliveness Request and Aliveness Response are set then clear them
*/ if (aliveness_req) {
mei_txe_aliveness_set(dev, 0); if (mei_txe_aliveness_poll(dev, 0) < 0) {
dev_err(dev->dev, "wait for aliveness failed ... bailing out\n"); return -EIO;
}
}
/* * Set readiness RDY_CLR bit
*/
mei_txe_readiness_clear(dev);
return 0;
}
/** * mei_txe_hw_start - start the hardware after reset * * @dev: the device structure * * Return: 0 on success an error code otherwise
*/ staticint mei_txe_hw_start(struct mei_device *dev)
{ struct mei_txe_hw *hw = to_txe_hw(dev); int ret;
u32 hisr;
/* bring back interrupts */
mei_txe_intr_enable(dev);
ret = mei_txe_readiness_wait(dev); if (ret < 0) {
dev_err(dev->dev, "waiting for readiness failed\n"); return ret;
}
/* * If HISR.INT2_STS interrupt status bit is set then clear it.
*/
hisr = mei_txe_br_reg_read(hw, HISR_REG); if (hisr & HISR_INT_2_STS)
mei_txe_br_reg_write(hw, HISR_REG, HISR_INT_2_STS);
/* Clear the interrupt cause of OutputDoorbell */
clear_bit(TXE_INTR_OUT_DB_BIT, &hw->intr_cause);
ret = mei_txe_aliveness_set_sync(dev, 1); if (ret < 0) {
dev_err(dev->dev, "wait for aliveness failed ... bailing out\n"); return ret;
}
if (do_ack) { /* Save the interrupt causes */
hw->intr_cause |= hisr & HISR_INT_STS_MSK; if (ipc_isr & SEC_IPC_HOST_INT_STATUS_IN_RDY)
hw->intr_cause |= TXE_INTR_IN_READY;
mei_txe_intr_disable(dev); /* Clear the interrupts in hierarchy:
* IPC and Bridge, than the High Level */
mei_txe_sec_reg_write_silent(hw,
SEC_IPC_HOST_INT_STATUS_REG, ipc_isr);
mei_txe_br_reg_write(hw, HISR_REG, hisr);
mei_txe_br_reg_write(hw, HHISR_REG, hhisr);
}
out: return generated;
}
/** * mei_txe_irq_quick_handler - The ISR of the MEI device * * @irq: The irq number * @dev_id: pointer to the device structure * * Return: IRQ_WAKE_THREAD if interrupt is designed for the device * IRQ_NONE otherwise
*/
irqreturn_t mei_txe_irq_quick_handler(int irq, void *dev_id)
{ struct mei_device *dev = dev_id;
if (mei_txe_check_and_ack_intrs(dev, true)) return IRQ_WAKE_THREAD; return IRQ_NONE;
}
/* Readiness: * Detection of TXE driver going through reset * or TXE driver resetting the HECI interface.
*/ if (test_and_clear_bit(TXE_INTR_READINESS_BIT, &hw->intr_cause)) {
dev_dbg(dev->dev, "Readiness Interrupt was received...\n");
/* Check if SeC is going through reset */ if (mei_txe_readiness_is_sec_rdy(hw->readiness)) {
dev_dbg(dev->dev, "we need to start the dev.\n");
dev->recvd_hw_ready = true;
} else {
dev->recvd_hw_ready = false; if (dev->dev_state != MEI_DEV_RESETTING) {
dev_warn(dev->dev, "FW not ready: resetting.\n");
schedule_work(&dev->reset_work); goto end;
}
}
wake_up(&dev->wait_hw_ready);
}
/************************************************************/ /* Check interrupt cause: * Aliveness: Detection of SeC acknowledge of host request that * it remain alive or host cancellation of that request.
*/
if (test_and_clear_bit(TXE_INTR_ALIVENESS_BIT, &hw->intr_cause)) { /* Clear the interrupt cause */
dev_dbg(dev->dev, "Aliveness Interrupt: Status: %d\n", hw->aliveness);
dev->pg_event = MEI_PG_EVENT_RECEIVED; if (waitqueue_active(&hw->wait_aliveness_resp))
wake_up(&hw->wait_aliveness_resp);
}
/* Output Doorbell: * Detection of SeC having sent output to host
*/
slots = mei_count_full_read_slots(dev); if (test_and_clear_bit(TXE_INTR_OUT_DB_BIT, &hw->intr_cause)) { /* Read from TXE */
rets = mei_irq_read_handler(dev, &cmpl_list, &slots); if (rets &&
(dev->dev_state != MEI_DEV_RESETTING &&
dev->dev_state != MEI_DEV_POWER_DOWN)) {
dev_err(dev->dev, "mei_irq_read_handler ret = %d.\n", rets);
schedule_work(&dev->reset_work); goto end;
}
} /* Input Ready: Detection if host can write to SeC */ if (test_and_clear_bit(TXE_INTR_IN_READY_BIT, &hw->intr_cause)) {
dev->hbuf_is_ready = true;
hw->slots = TXE_HBUF_DEPTH;
}
if (hw->aliveness && dev->hbuf_is_ready) { /* get the real register value */
dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
rets = mei_irq_write_handler(dev, &cmpl_list); if (rets && rets != -EMSGSIZE)
dev_err(dev->dev, "mei_irq_write_handler ret = %d.\n",
rets);
dev->hbuf_is_ready = mei_hbuf_is_ready(dev);
}
mei_irq_compl_handler(dev, &cmpl_list);
end:
dev_dbg(dev->dev, "interrupt thread end ret = %d\n", rets);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.