Received: by 10.223.176.46 with SMTP id f43csp2792794wra; Thu, 25 Jan 2018 15:28:09 -0800 (PST) X-Google-Smtp-Source: AH8x2263NJDkj/bGwvmK5DleEzIIyM06JkhJKTTt5ls61tTmO7hAfR4rLH4vkUCR2efCe09xIbJb X-Received: by 10.99.175.3 with SMTP id w3mr14225713pge.328.1516922889576; Thu, 25 Jan 2018 15:28:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1516922889; cv=none; d=google.com; s=arc-20160816; b=FZqyMPjE/g0+IEqdHY+OMA6dEVuoGEigQLtIPB06fKggjgHTsjYWhhYlxSTNieL3V/ bkYSUhJTA78tpsNNgbt5a2LMtpTBebcBrNIbVdR0RzBL8Hhcq+uyPI+/t14RNTOEdRrm /RpgujT8nSAXTn0PF6VDVz9hzfyWBL3Oa6dOafjivx9H/GWAqh8YsjcIqDKDfcEKcJfZ l5+vnDCJWV6776Mnxv32+RGdX/TKP9XV8Ywdey9azGxjLE0U9XLyDQlnRKL+wszv5ewZ mpUbUq5Az3EyYCXIUkcNIU5HkMrTFJ3dMTc+i2Aalxv+YT/1x1nQ/pGDnR40Z59O/X9q OpGw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:dkim-signature :arc-authentication-results; bh=EwZm3xwOwB06kfgfa57xFMlizfMT3NAn3HkaHQIF3Vs=; b=0cLot0cHfl7+ZqFCINhTvbRXNMRqiLAyvtR7E0dL/fg63AVdz/wf79p1b0xdeK8+RP oOxZyuU//ctVcrFfLzf8MjhaEqmlyOA2Yh8BhZrCecemc53onOOSPXYPcM6YhOOMCSn0 nOQ97ZCgufTw4rlX5S2P3VUQdjrxtoRfCrvIccXbPxVRY+tg0fCHhPotQ48mIjzRzK+8 dF4zJSgNzaUZnO5hak0DoXxvKZe9NLz/01jk4m4jYo8WcnSBGyrHs40D0lVkgcv2vgTD 1ZTYBa/Dvk4VCPQS9g43soTo0xVLc4OwITRGzYCXZRVGTw7HL30/pIWf7ZiPScZLT9C0 tpkQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uB/4G7CZ; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h33-v6si2705045plh.78.2018.01.25.15.27.51; Thu, 25 Jan 2018 15:28:09 -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; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=uB/4G7CZ; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751372AbeAYX10 (ORCPT + 99 others); Thu, 25 Jan 2018 18:27:26 -0500 Received: from bombadil.infradead.org ([65.50.211.133]:52865 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751268AbeAYX1Y (ORCPT ); Thu, 25 Jan 2018 18:27:24 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.20170209; h=Content-Transfer-Encoding: Content-Type:In-Reply-To:MIME-Version:Date:Message-ID:From:References:Cc:To: Subject:Sender:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EwZm3xwOwB06kfgfa57xFMlizfMT3NAn3HkaHQIF3Vs=; b=uB/4G7CZuPhceQjwIlBM4Jfvn 6GdGajxMxRg1LSe4mDeZA4XmemCvI581hsyG1ZAQMGZDENFI1/Hpa4XaWAc7bbNm99BWV+lZbHPe1 qI9cBESGjPdDS9hrkgqPRK37WvujxElV2nY/KvLHusP81VUASUEv9jJGbm0NY4n3lHQ1x6lK1RoYG snpLM1VGtbvoC4V/V+yDPIEn90ONvnNi+bUWw+Kygavf2z565kMN7yoQJ3trZeMvvZ6mI/nD2awIW ozSU8vxaIQqVr58z6eF4zrftp1blz528csDKkhmH1wxHJ17EtpewTyNugX4w72sORXGWdrfLM1/r+ VsJ28zvLA==; Received: from static-50-53-52-16.bvtn.or.frontiernet.net ([50.53.52.16] helo=dragon.site) by bombadil.infradead.org with esmtpsa (Exim 4.89 #1 (Red Hat Linux)) id 1eeqvT-00016W-Tw; Thu, 25 Jan 2018 23:27:23 +0000 Subject: Re: [PATCHv1] driver: misc: add Intel Stratix10 service layer driver To: richard.gong@linux.intel.com, arnd@arndb.de, gregkh@linuxfoundation.org Cc: linux-kernel@vger.kernel.org, richard.gong@intel.com References: <1516898344-20020-1-git-send-email-richard.gong@linux.intel.com> <1516898344-20020-2-git-send-email-richard.gong@linux.intel.com> From: Randy Dunlap Message-ID: <2b2e5eb3-1786-c772-fb60-d1f9c3ad9036@infradead.org> Date: Thu, 25 Jan 2018 15:27:20 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.3.0 MIME-Version: 1.0 In-Reply-To: <1516898344-20020-2-git-send-email-richard.gong@linux.intel.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 01/25/2018 08:39 AM, richard.gong@linux.intel.com wrote: > From: Richard Gong > > > Signed-off-by: Richard Gong > --- > drivers/misc/Kconfig | 3 +- > drivers/misc/Makefile | 3 +- > drivers/misc/intel-service/Kconfig | 9 + > drivers/misc/intel-service/Makefile | 2 + > drivers/misc/intel-service/intel_service.c | 703 +++++++++++++++++++++++++++++ > include/linux/intel-service-client.h | 227 ++++++++++ > include/linux/intel-service.h | 122 +++++ > include/linux/intel-smc.h | 246 ++++++++++ > 8 files changed, 1313 insertions(+), 2 deletions(-) > create mode 100644 drivers/misc/intel-service/Kconfig > create mode 100644 drivers/misc/intel-service/Makefile > create mode 100644 drivers/misc/intel-service/intel_service.c > create mode 100644 include/linux/intel-service-client.h > create mode 100644 include/linux/intel-service.h > create mode 100644 include/linux/intel-smc.h > > diff --git a/drivers/misc/intel-service/intel_service.c b/drivers/misc/intel-service/intel_service.c > new file mode 100644 > index 0000000..90f883c > --- /dev/null > +++ b/drivers/misc/intel-service/intel_service.c > @@ -0,0 +1,703 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (C) 2017-2018, Intel Corporation > + > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define SVC_FO_LEN 32 > +#define SVC_MAX_CHANNEL 2 > + > +static LIST_HEAD(svc_cons); > +static LIST_HEAD(svc_private_mem); > +static DEFINE_MUTEX(svc_mutex); > + > +svc_invoke_fn *invoke_fn; Is that calling into firmware or what? > + /* timeout for polling FPGA configuration status > + * it is set to 30 seconds (30 * 1000) at Intel Stratix10 SoC > + */ Fix multi-line comment style (several places). > diff --git a/include/linux/intel-service-client.h b/include/linux/intel-service-client.h > new file mode 100644 > index 0000000..5bb6513 > --- /dev/null > +++ b/include/linux/intel-service-client.h > @@ -0,0 +1,227 @@ > + > +#ifndef __INTEL_SERVICE_CLIENT_H > +#define __INTEL_SERVICE_CLIENT_H > + > +#include > +#include > + > +/** In kernel source files, /** means that the following is a kernel-doc formatted comment. This is close, but not quite. Others also are just close. > + * Service driver supports client names > + * @fpga: for FPGA configuration > + * @dummy: for integration/debug/trouble-shooting > + */ > +#define SVC_CLIENT_FPGA "fpga" > +#define SVC_CLIENT_DUMMY "dummy" > + > +/** Hm, these comments would be close to kernel-doc notation for an enum type, but not for a list of #defines. > + * Status of the sent command, in bit number > + * @SVC_COMMAND_STATUS_RECONFIG_REQUEST_OK > + * SDM accepts the request of FPGA reconfiguration > + * @SVC_STATUS_RECONFIG_BUFFER_SUBMITTED > + * Service client successfully submits FPGA configuration > + * data buffer to SDM > + * @SVC_COMMAND_STATUS_RECONFIG_BUFFER_DONE > + * SDM completes data process, ready to accept the > + * next WRITE transaction > + * @SVC_COMMAND_STATUS_RECONFIG_COMPLETED > + * SDM completes FPGA configuration successfully, FPGA should > + * be in user mode > + * @SVC_COMMAND_STATUS_RECONFIG_BUSY > + * FPGA configuration is still in process > + * @SVC_COMMAND_STATUS_RECONFIG_ERROR > + * Error encountered during FPGA configuration > + */ > +#define SVC_STATUS_RECONFIG_REQUEST_OK 0 > +#define SVC_STATUS_RECONFIG_BUFFER_SUBMITTED 1 > +#define SVC_STATUS_RECONFIG_BUFFER_DONE 2 > +#define SVC_STATUS_RECONFIG_COMPLETED 3 > +#define SVC_STATUS_RECONFIG_BUSY 4 > +#define SVC_STATUS_RECONFIG_ERROR 5 > + > +struct intel_svc_chan; > + > diff --git a/include/linux/intel-service.h b/include/linux/intel-service.h > new file mode 100644 > index 0000000..fdf21b3 > --- /dev/null > +++ b/include/linux/intel-service.h > @@ -0,0 +1,122 @@ > +/* SPDX-License-Identifier: GPL-2.0 */ > + > +#ifndef __INTEL_SERVICE_H > +#define __INTEL_SERVICE_H > + > +#include > +#include > +#include > +#include > +#include > +#include > + > + > +/** Ah, this one is formatted correctly as kernel-doc. > + * struct intel_svc_sh_memory - service shared memory info > + * > + * @sync_complete: maintain state for a completion > + * @start_addr: starting address of shared memory > + * @size: size of shared memory > + */ > +struct intel_svc_sh_memory { > + struct completion sync_complete; > + unsigned long start_addr; > + unsigned long size; > +}; > + > +/** > + * struct intel_svc_private_mem - service private memory info > + * > + * @kaddr: virtual address > + * @paddr: physical address > + * @size: size of memory > + * @node: link list head node > + */ > +struct intel_svc_private_mem { > + void *kaddr; > + phys_addr_t paddr; > + size_t size; > + struct list_head node; > +}; > + > +/** > + * struct intel_svc_private_data - service private data > + * > + * @chan: service channel > + * @paddr: play-load physical address > + * @size: play-load size > + * @ommand: service request command @command: > + */ > +struct intel_svc_private_data { > + struct intel_svc_chan *chan; > + phys_addr_t paddr; > + size_t size; > + u32 command; > +}; > + > +/** > + * struct intel_svc_controller - service controller > + * > + * @dev: device backing this controller > + * @chans: array of service channels > + * $num_chans: number of channels in 'chans' array > + * @node: list management missing 2 entries. > + * @intel_svc_fifo: a queue for storing service message data > + * @svc_fifo_lock: protect access to service message data queue > + */ > +struct intel_svc_controller { > + struct device *dev; > + struct intel_svc_chan *chans; > + int num_chans; > + > + struct list_head node; > + > + struct gen_pool *genpool; > + struct intel_svc_prviate_mem *private_mem; > + > + DECLARE_KFIFO_PTR(intel_svc_fifo, struct intel_svc_private_data *); > + /* protect access to the service message data queue*/ > + spinlock_t svc_fifo_lock; > +}; > + > +/** > + * struct intel_svc_chan - service communication channel > + * > + * @ctrl: pointer to the provider of this channel > + * @scl: pointer to service client which owns this channel > + * $name: name associated with this service channel @name: > + * @lock: protect access to the channel > + */ > +struct intel_svc_chan { > + struct intel_svc_controller *ctrl; > + struct intel_svc_client *scl; > + char *name; > + /* protect access to the channel*/ > + spinlock_t lock; > +}; > + > +static int intel_svc_smc_thread(void *data); > + > +#endif -- ~Randy