From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Google-Smtp-Source: AH8x226CX36Nlgzzfd83gP68wH7UM0EkripXPoyPviJcAG7vkwH43xy99QVDZx6Eylcotvb85hKH ARC-Seal: i=1; a=rsa-sha256; t=1516922845; cv=none; d=google.com; s=arc-20160816; b=DbznctYmS19Kh2zQX+8M5smAG1vNbo/UMAn9hBSGuAVw7YcNLVQfcz6wgr19FAp2Y+ rdm3xEQPfOuNDdj0U6gyCp3G4ko+u4Oiv1PwSwEwTWzOFA1Ay9Jjmuc/ZSyzowUb3G2x i/MaNSf5qiKuNqQKW1t0q7TQRHaEi3oKVZg19jg9iEy7Xxyswr8TPKEcq3Ub7H0JuxQS UbZRYtnElrGPUVoubMa5j9ZoSfIZ8Y/kRlFYvkFkGfBjeWe8DDd9AYZ3w+E56QWiP9EH Q3kj6CgV37h/05JSvT8RdRzx8JbAT6zC4Q2SY/FMyKtZZfOA2+kUxcbqMN/2utGg0F0/ H0OQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=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=upllXxBqk7UBje3zxdXmKd5qpiW4XwaigNN4aMfMscL+jxGQWg0/iK+BZqXiOmv3Fx JWIxHE8buP+9CG+htzpVpaPltHuvsk6ILJ3qxjyQ0su405CED7mJ7CEWhc2KiLn928UQ 5yhttEDXta2nRBq5bAM6Kl2xE/nLP3Q6syHrCLFPSAYpgKJ+7jyvc7HCA4UZjZV4XnNC DrX69vuDMq6wUGFhs+JCm+Mj0fPq2vS7m2HA5aK2YxKduj6ud1ryym6vifvbFiZT1AaI dsPMyVNdjZQudBKtSURW/hj8mZB4rqx+zFx87F3xaA6bPL/4NOScFNd8KFlH1S4U8KbU 05Ew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=uB/4G7CZ; spf=pass (google.com: best guess record for domain of rdunlap@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=rdunlap@infradead.org Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=bombadil.20170209 header.b=uB/4G7CZ; spf=pass (google.com: best guess record for domain of rdunlap@infradead.org designates 65.50.211.133 as permitted sender) smtp.mailfrom=rdunlap@infradead.org 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: =?utf-8?q?1590583083024984574?= X-GMAIL-MSGID: =?utf-8?q?1590608889903881511?= X-Mailing-List: linux-kernel@vger.kernel.org List-ID: 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