Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp2074709imu; Fri, 23 Nov 2018 04:21:06 -0800 (PST) X-Google-Smtp-Source: AFSGD/UTXML/nhAVpEBPTWgnHSC50LqOFYDR/saf/J/iPwoWMqfhFurWLDggdPZVyLCpZeItohT2 X-Received: by 2002:a17:902:1005:: with SMTP id b5mr7412590pla.310.1542975666725; Fri, 23 Nov 2018 04:21:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542975666; cv=none; d=google.com; s=arc-20160816; b=zJzF1M83tRYKyC5rQGBr6pZ+mbl1osLkVRyDBCFI73OMkERxF6sbGXbHN3Ft2Zc6lt FY8gyaxj2CZVIWL1dNlFjZoyG4WERvnlH+MWeHEzpttchEdutBYFgplj7cXU4rkUkJjE INOWvi2/4y41ho7EtrM/gTrO80bxaeUl5BgF/AjbR+hCcQEApMV1M2WnThOKgCtyBVlx IB69PnQRjNLx5AGWnoUNtztWWgjb9krkCiN/fGoptHtOiH7dFWRHt4yvGgQoQQin89qs vNBcB9VXDNzg5iMIl91yrPXhHyx5DMDucIkx13Y45lyxrTYyXBwl98eL5hd3Ayzb2sOK l3wg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from; bh=s9v45kBcW7c61pHVYb9quu1pvFrope1DXGAPkPfIAWo=; b=zMVHVpdDpJQU/r3mHlvLXZSo6lcoZChWuJyBDoZNfJkMWawsT6cCYKlm46HPrmSq9f QO+2vT9bXOOma/zz6SjtIRqdUdGeZofps68lZnLH8vbxVnTLH1RXgj8tTc+/W3eCYTC8 +kHk3VxxrWyxCvXBaxE08+DzDV4aNR0n+7V3QsAjPrpB9aNpAu3hmCK08Nsl/95EBChG 9KMRY2Qy+mIU/NjjZPCPFzGe3O0NXK/I0m+eZAtL5QWS5rnqdIBUXZ6KBX3OQ2bE9EFo 9ikz9ShFDPcdCTqGs3e4IlJzn6kNRJ2G+T6ml9/SN1+7frDBGIcwNG9xHNQQAw10W3Ap VoVA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q129-v6si50232857pga.96.2018.11.23.04.20.29; Fri, 23 Nov 2018 04:21:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2394552AbeKVVuy (ORCPT + 99 others); Thu, 22 Nov 2018 16:50:54 -0500 Received: from mga03.intel.com ([134.134.136.65]:39305 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387933AbeKVVux (ORCPT ); Thu, 22 Nov 2018 16:50:53 -0500 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga007.jf.intel.com ([10.7.209.58]) by orsmga103.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 22 Nov 2018 03:11:59 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,265,1539673200"; d="scan'208";a="91290777" Received: from twinkler-lnx.jer.intel.com ([10.12.91.48]) by orsmga007.jf.intel.com with ESMTP; 22 Nov 2018 03:11:56 -0800 From: Tomas Winkler To: Greg Kroah-Hartman Cc: Alexander Usyskin , linux-kernel@vger.kernel.org, Tomas Winkler Subject: [char-misc-next v2 3/7] mei: hw: add dma ring control block Date: Thu, 22 Nov 2018 13:11:38 +0200 Message-Id: <20181122111142.18653-4-tomas.winkler@intel.com> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181122111142.18653-1-tomas.winkler@intel.com> References: <20181122111142.18653-1-tomas.winkler@intel.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org The DMA ring control block contains write and read indices for host and device circular buffers. Signed-off-by: Tomas Winkler Signed-off-by: Alexander Usyskin --- drivers/misc/mei/dma-ring.c | 20 ++++++++++++++++++++ drivers/misc/mei/hbm.c | 2 ++ drivers/misc/mei/hw.h | 23 +++++++++++++++++++++++ drivers/misc/mei/mei_dev.h | 1 + 4 files changed, 46 insertions(+) diff --git a/drivers/misc/mei/dma-ring.c b/drivers/misc/mei/dma-ring.c index 56f4c0882a20..b73d5ab54070 100644 --- a/drivers/misc/mei/dma-ring.c +++ b/drivers/misc/mei/dma-ring.c @@ -97,3 +97,23 @@ bool mei_dma_ring_is_allocated(struct mei_device *dev) { return !!dev->dr_dscr[DMA_DSCR_HOST].vaddr; } + +static inline +struct hbm_dma_ring_ctrl *mei_dma_ring_ctrl(struct mei_device *dev) +{ + return (struct hbm_dma_ring_ctrl *)dev->dr_dscr[DMA_DSCR_CTRL].vaddr; +} + +/** + * mei_dma_ring_reset() - reset the dma control block + * @dev: mei device + */ +void mei_dma_ring_reset(struct mei_device *dev) +{ + struct hbm_dma_ring_ctrl *ctrl = mei_dma_ring_ctrl(dev); + + if (!ctrl) + return; + + memset(ctrl, 0, sizeof(*ctrl)); +} diff --git a/drivers/misc/mei/hbm.c b/drivers/misc/mei/hbm.c index b458c5612245..78c26cebf5d4 100644 --- a/drivers/misc/mei/hbm.c +++ b/drivers/misc/mei/hbm.c @@ -323,6 +323,8 @@ static int mei_hbm_dma_setup_req(struct mei_device *dev) req.dma_dscr[i].size = dev->dr_dscr[i].size; } + mei_dma_ring_reset(dev); + ret = mei_hbm_write_message(dev, &mei_hdr, &req); if (ret) { dev_err(dev->dev, "dma setup request write failed: ret = %d.\n", diff --git a/drivers/misc/mei/hw.h b/drivers/misc/mei/hw.h index 65655925791a..4f09bbcdbc2a 100644 --- a/drivers/misc/mei/hw.h +++ b/drivers/misc/mei/hw.h @@ -512,4 +512,27 @@ struct hbm_dma_setup_response { u8 reserved[2]; } __packed; +/** + * struct mei_dma_ring_ctrl - dma ring control block + * + * @hbuf_wr_idx: host circular buffer write index in slots + * @reserved1: reserved for alignment + * @hbuf_rd_idx: host circular buffer read index in slots + * @reserved2: reserved for alignment + * @dbuf_wr_idx: device circular buffer write index in slots + * @reserved3: reserved for alignment + * @dbuf_rd_idx: device circular buffer read index in slots + * @reserved4: reserved for alignment + */ +struct hbm_dma_ring_ctrl { + u32 hbuf_wr_idx; + u32 reserved1; + u32 hbuf_rd_idx; + u32 reserved2; + u32 dbuf_wr_idx; + u32 reserved3; + u32 dbuf_rd_idx; + u32 reserved4; +} __packed; + #endif diff --git a/drivers/misc/mei/mei_dev.h b/drivers/misc/mei/mei_dev.h index a6796e3f712b..033b5eff8e59 100644 --- a/drivers/misc/mei/mei_dev.h +++ b/drivers/misc/mei/mei_dev.h @@ -597,6 +597,7 @@ void mei_cancel_work(struct mei_device *dev); int mei_dmam_ring_alloc(struct mei_device *dev); void mei_dmam_ring_free(struct mei_device *dev); bool mei_dma_ring_is_allocated(struct mei_device *dev); +void mei_dma_ring_reset(struct mei_device *dev); /* * MEI interrupt functions prototype -- 2.17.2