rpmsg: Add snapshot of RPMSG drivers for lahaina

This snapshot is taken as of msm-4.19 'commit <d2f41beab007i>
("Merge "msm: npu: Add bandwidth monitor support"")'.

This change brings the rpmsg and rpmsg glink drivers up to date with
the fixes from msm-4.19. In addition, change the copyrights to SPDX format.

Also, irq_set_affinity and sched_setaffinity can not be used when compiling
a driver as a module. Hence, moving to module-friendly APIs.

Change-Id: Id8c0bd13535c91cbecb11445bf798be44083abb6
Signed-off-by: Jay Jayanna <jayanna@codeaurora.org>
This commit is contained in:
Jay Jayanna 2019-08-12 18:34:26 -07:00
commit f1d8e56eb5
7 changed files with 591 additions and 58 deletions

File diff suppressed because it is too large Load diff

View file

@ -22,6 +22,8 @@ struct qcom_glink_pipe {
void (*write)(struct qcom_glink_pipe *glink_pipe,
const void *hdr, size_t hlen,
const void *data, size_t dlen);
void (*reset)(struct qcom_glink_pipe *glink_pipe);
};
struct qcom_glink;

View file

@ -1,6 +1,7 @@
// SPDX-License-Identifier: GPL-2.0
/*
* Copyright (c) 2016, 2019 Linaro Ltd
* Copyright (c) 2018-2019, The Linux Foundation, All rights reserved.
*/
#include <linux/io.h>
@ -114,7 +115,7 @@ static void glink_smem_rx_advance(struct qcom_glink_pipe *np,
tail = le32_to_cpu(*pipe->tail);
tail += count;
if (tail > pipe->native.length)
if (tail >= pipe->native.length)
tail %= pipe->native.length;
*pipe->tail = cpu_to_le32(tail);

View file

@ -4,6 +4,7 @@
*
* Copyright (C) 2011 Texas Instruments, Inc.
* Copyright (C) 2011 Google, Inc.
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*
* Ohad Ben-Cohen <ohad@wizery.com>
* Brian Swetland <swetland@google.com>
@ -81,7 +82,7 @@ EXPORT_SYMBOL(rpmsg_create_ept);
*/
void rpmsg_destroy_ept(struct rpmsg_endpoint *ept)
{
if (ept)
if (ept && ept->ops)
ept->ops->destroy_ept(ept);
}
EXPORT_SYMBOL(rpmsg_destroy_ept);
@ -283,6 +284,42 @@ int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
}
EXPORT_SYMBOL(rpmsg_trysend_offchannel);
/**
* rpmsg_get_sigs() - get the signals for this endpoint
* @ept: the rpmsg endpoint
* @sigs: serial signals bitmask
*
* Returns 0 on success and an appropriate error value on failure.
*/
int rpmsg_get_sigs(struct rpmsg_endpoint *ept, u32 *lsigs, u32 *rsigs)
{
if (WARN_ON(!ept))
return -EINVAL;
if (!ept->ops->get_sigs)
return -ENXIO;
return ept->ops->get_sigs(ept, lsigs, rsigs);
}
EXPORT_SYMBOL(rpmsg_get_sigs);
/**
* rpmsg_set_sigs() - set the remote signals for this endpoint
* @ept: the rpmsg endpoint
* @sigs: serial signals bitmask
*
* Returns 0 on success and an appropriate error value on failure.
*/
int rpmsg_set_sigs(struct rpmsg_endpoint *ept, u32 sigs)
{
if (WARN_ON(!ept))
return -EINVAL;
if (!ept->ops->set_sigs)
return -ENXIO;
return ept->ops->set_sigs(ept, sigs);
}
EXPORT_SYMBOL(rpmsg_set_sigs);
/*
* match an rpmsg channel with a channel info struct.
* this is used to make sure we're not creating rpmsg devices for channels
@ -468,6 +505,10 @@ static int rpmsg_dev_probe(struct device *dev)
rpdev->ept = ept;
rpdev->src = ept->addr;
if (rpdrv->signals)
ept->sig_cb = rpdrv->signals;
}
err = rpdrv->probe(rpdev);

View file

@ -4,6 +4,7 @@
*
* Copyright (C) 2011 Texas Instruments, Inc.
* Copyright (C) 2011 Google, Inc.
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
*
* Ohad Ben-Cohen <ohad@wizery.com>
* Brian Swetland <swetland@google.com>
@ -46,6 +47,8 @@ struct rpmsg_device_ops {
* @trysend: see @rpmsg_trysend(), required
* @trysendto: see @rpmsg_trysendto(), optional
* @trysend_offchannel: see @rpmsg_trysend_offchannel(), optional
* @get_sigs: see @rpmsg_get_sigs(), optional
* @set_sigs: see @rpmsg_set_sigs(), optional
*
* Indirection table for the operations that a rpmsg backend should implement.
* In addition to @destroy_ept, the backend must at least implement @send and
@ -65,6 +68,8 @@ struct rpmsg_endpoint_ops {
void *data, int len);
__poll_t (*poll)(struct rpmsg_endpoint *ept, struct file *filp,
poll_table *wait);
int (*get_sigs)(struct rpmsg_endpoint *ept, u32 *lsigs, u32 *rsigs);
int (*set_sigs)(struct rpmsg_endpoint *ept, u32 sigs);
};
int rpmsg_register_device(struct rpmsg_device *rpdev);

View file

@ -4,6 +4,7 @@
*
* Copyright (C) 2011 Texas Instruments, Inc.
* Copyright (C) 2011 Google, Inc.
* Copyright (c) 2018-2019, The Linux Foundation. All rights reserved.
* All rights reserved.
*/
@ -60,12 +61,14 @@ struct rpmsg_device {
};
typedef int (*rpmsg_rx_cb_t)(struct rpmsg_device *, void *, int, void *, u32);
typedef int (*rpmsg_rx_sig_t)(struct rpmsg_device *, u32, u32);
/**
* struct rpmsg_endpoint - binds a local rpmsg address to its user
* @rpdev: rpmsg channel device
* @refcount: when this drops to zero, the ept is deallocated
* @cb: rx callback handler
* @sig_cb: rx serial signal handler
* @cb_lock: must be taken before accessing/changing @cb
* @addr: local rpmsg address
* @priv: private data for the driver's use
@ -88,6 +91,7 @@ struct rpmsg_endpoint {
struct rpmsg_device *rpdev;
struct kref refcount;
rpmsg_rx_cb_t cb;
rpmsg_rx_sig_t sig_cb;
struct mutex cb_lock;
u32 addr;
void *priv;
@ -102,6 +106,7 @@ struct rpmsg_endpoint {
* @probe: invoked when a matching rpmsg channel (i.e. device) is found
* @remove: invoked when the rpmsg channel is removed
* @callback: invoked when an inbound message is received on the channel
* @signals: invoked when a serial signal change is received on the channel
*/
struct rpmsg_driver {
struct device_driver drv;
@ -109,6 +114,7 @@ struct rpmsg_driver {
int (*probe)(struct rpmsg_device *dev);
void (*remove)(struct rpmsg_device *dev);
int (*callback)(struct rpmsg_device *, void *, int, void *, u32);
int (*signals)(struct rpmsg_device *rpdev, u32 old, u32 new);
};
#if IS_ENABLED(CONFIG_RPMSG)
@ -135,6 +141,9 @@ int rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst,
__poll_t rpmsg_poll(struct rpmsg_endpoint *ept, struct file *filp,
poll_table *wait);
int rpmsg_get_sigs(struct rpmsg_endpoint *ept, u32 *lsigs, u32 *rsigs);
int rpmsg_set_sigs(struct rpmsg_endpoint *ept, u32 sigs);
#else
static inline int register_rpmsg_device(struct rpmsg_device *dev)
@ -242,6 +251,23 @@ static inline __poll_t rpmsg_poll(struct rpmsg_endpoint *ept,
return 0;
}
static inline int rpmsg_get_sigs(struct rpmsg_endpoint *ept, u32 *lsigs,
u32 *rsigs)
{
/* This shouldn't be possible */
WARN_ON(1);
return -ENXIO;
}
static inline int rpmsg_set_sigs(struct rpmsg_endpoint *ept, u32 sigs)
{
/* This shouldn't be possible */
WARN_ON(1);
return -ENXIO;
}
#endif /* IS_ENABLED(CONFIG_RPMSG) */
/* use a macro to avoid include chaining to get THIS_MODULE */

View file

@ -6,6 +6,7 @@
#include <linux/device.h>
struct qcom_glink;
struct glink_spi;
#if IS_ENABLED(CONFIG_RPMSG_QCOM_GLINK_SMEM)
@ -26,4 +27,44 @@ static inline void qcom_glink_smem_unregister(struct qcom_glink *glink) {}
#endif
#if IS_ENABLED(CONFIG_RPMSG_QCOM_GLINK_SPSS)
struct qcom_glink *qcom_glink_spss_register(struct device *parent,
struct device_node *node);
void qcom_glink_spss_unregister(struct qcom_glink *glink);
#else
static inline struct qcom_glink *
qcom_glink_spss_register(struct device *parent,
struct device_node *node)
{
return NULL;
}
static inline void qcom_glink_spss_unregister(struct qcom_glink *glink) {}
#endif
#if IS_ENABLED(CONFIG_RPMSG_QCOM_GLINK_SPI)
struct glink_spi *qcom_glink_spi_register(struct device *parent,
struct device_node *node);
void qcom_glink_spi_unregister(struct glink_spi *glink);
#else
static inline struct glink_spi *
qcom_glink_spi_register(struct device *parent, struct device_node *node)
{
return NULL;
}
static inline void qcom_glink_spi_unregister(struct glink_spi *glink) {}
#endif
#endif