Merge branch 'staging-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6
* 'staging-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6: (38 commits) Revert "staging: tidspbridge: replace iommu custom for opensource implementation" Revert "staging: tidspbridge - move shared memory iommu maps to tiomap3430.c" Revert "staging: tidspbridge - rename bridge_brd_mem_map/unmap to a proper name" Revert "staging: tidspbridge - remove custom mmu code from tiomap3430.c" Revert "staging: tidspbridge - fix mmufault support" Revert "staging: tidspbridge - remove hw directory" Revert "staging: tidspbridge - move all iommu related code to a new file" Revert "staging: tidspbridge: remove dw_dmmu_base from cfg_hostres struct" Revert "staging: tidspbridge - remove reserved memory clean up" Revert "staging: tidspbridge - deprecate reserve/unreserve_memory funtions" Revert "staging: tidspbridge - remove dmm custom module" Revert "staging: tidspbridge - update Kconfig to select IOMMU module" staging: tidspbridge: hardcode SCM macros while fix is upstreamed Staging: keucr driver: fix uninitialized variable & proper memset length omap: dsp: remove shm from normal memory Staging: wlan-ng: Fix wrong #ifdef #endif sequence Staging: Update parameters for cfg80211 key management operation Staging: ath6kl: Fix pointer casts on 64-bit architectures Staging: batman-adv: suppress false warning when changing the mac address Staging: batman-adv: fix interface alternating and bonding reggression ...
This commit is contained in:
commit
1c32ca9f63
|
@ -5676,7 +5676,7 @@ S: Maintained
|
|||
|
||||
STAGING SUBSYSTEM
|
||||
M: Greg Kroah-Hartman <gregkh@suse.de>
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-next-2.6.git
|
||||
T: git git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging-2.6.git
|
||||
L: devel@driverdev.osuosl.org
|
||||
S: Maintained
|
||||
F: drivers/staging/
|
||||
|
|
|
@ -284,12 +284,14 @@ void __init omap_dsp_reserve_sdram_memblock(void)
|
|||
if (!size)
|
||||
return;
|
||||
|
||||
paddr = __memblock_alloc_base(size, SZ_1M, MEMBLOCK_REAL_LIMIT);
|
||||
paddr = memblock_alloc(size, SZ_1M);
|
||||
if (!paddr) {
|
||||
pr_err("%s: failed to reserve %x bytes\n",
|
||||
__func__, size);
|
||||
return;
|
||||
}
|
||||
memblock_free(paddr, size);
|
||||
memblock_remove(paddr, size);
|
||||
|
||||
omap_dsp_phys_mempool_base = paddr;
|
||||
}
|
||||
|
|
|
@ -102,7 +102,7 @@ config AR600x_BT_RESET_PIN
|
|||
|
||||
config ATH6KL_CFG80211
|
||||
bool "CFG80211 support"
|
||||
depends on ATH6K_LEGACY
|
||||
depends on ATH6K_LEGACY && CFG80211
|
||||
help
|
||||
Enables support for CFG80211 APIs. The default option is to use WEXT. Even with this option enabled, WEXT is not explicitly disabled and the onus of not exercising WEXT lies on the application(s) running in the user space.
|
||||
|
||||
|
|
|
@ -1126,7 +1126,7 @@ ar6000_transfer_bin_file(AR_SOFTC_T *ar, AR6K_BIN_FILE file, A_UINT32 address, A
|
|||
if ((board_ext_address) && (fw_entry->size == (board_data_size + board_ext_data_size))) {
|
||||
A_UINT32 param;
|
||||
|
||||
status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (A_UCHAR *)(((A_UINT32)fw_entry->data) + board_data_size), board_ext_data_size);
|
||||
status = BMIWriteMemory(ar->arHifDevice, board_ext_address, (A_UCHAR *)(fw_entry->data + board_data_size), board_ext_data_size);
|
||||
|
||||
if (status != A_OK) {
|
||||
AR_DEBUG_PRINTF(ATH_DEBUG_ERR, ("BMI operation failed: %d\n", __LINE__));
|
||||
|
@ -3030,7 +3030,8 @@ ar6000_data_tx(struct sk_buff *skb, struct net_device *dev)
|
|||
A_UINT8 csumDest=0;
|
||||
A_UINT8 csum=skb->ip_summed;
|
||||
if(csumOffload && (csum==CHECKSUM_PARTIAL)){
|
||||
csumStart=skb->csum_start-(skb->network_header-skb->head)+sizeof(ATH_LLC_SNAP_HDR);
|
||||
csumStart = (skb->head + skb->csum_start - skb_network_header(skb) +
|
||||
sizeof(ATH_LLC_SNAP_HDR));
|
||||
csumDest=skb->csum_offset+csumStart;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -808,7 +808,7 @@ ar6k_cfg80211_scanComplete_event(AR_SOFTC_T *ar, A_STATUS status)
|
|||
|
||||
static int
|
||||
ar6k_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
|
||||
A_UINT8 key_index, const A_UINT8 *mac_addr,
|
||||
A_UINT8 key_index, bool pairwise, const A_UINT8 *mac_addr,
|
||||
struct key_params *params)
|
||||
{
|
||||
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(ndev);
|
||||
|
@ -901,7 +901,7 @@ ar6k_cfg80211_add_key(struct wiphy *wiphy, struct net_device *ndev,
|
|||
|
||||
static int
|
||||
ar6k_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
|
||||
A_UINT8 key_index, const A_UINT8 *mac_addr)
|
||||
A_UINT8 key_index, bool pairwise, const A_UINT8 *mac_addr)
|
||||
{
|
||||
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(ndev);
|
||||
|
||||
|
@ -936,7 +936,8 @@ ar6k_cfg80211_del_key(struct wiphy *wiphy, struct net_device *ndev,
|
|||
|
||||
static int
|
||||
ar6k_cfg80211_get_key(struct wiphy *wiphy, struct net_device *ndev,
|
||||
A_UINT8 key_index, const A_UINT8 *mac_addr, void *cookie,
|
||||
A_UINT8 key_index, bool pairwise, const A_UINT8 *mac_addr,
|
||||
void *cookie,
|
||||
void (*callback)(void *cookie, struct key_params*))
|
||||
{
|
||||
AR_SOFTC_T *ar = (AR_SOFTC_T *)ar6k_priv(ndev);
|
||||
|
|
|
@ -165,7 +165,7 @@ static void update_mac_addresses(struct batman_if *batman_if)
|
|||
batman_if->net_dev->dev_addr, ETH_ALEN);
|
||||
}
|
||||
|
||||
static void check_known_mac_addr(uint8_t *addr)
|
||||
static void check_known_mac_addr(struct net_device *net_dev)
|
||||
{
|
||||
struct batman_if *batman_if;
|
||||
|
||||
|
@ -175,11 +175,16 @@ static void check_known_mac_addr(uint8_t *addr)
|
|||
(batman_if->if_status != IF_TO_BE_ACTIVATED))
|
||||
continue;
|
||||
|
||||
if (!compare_orig(batman_if->net_dev->dev_addr, addr))
|
||||
if (batman_if->net_dev == net_dev)
|
||||
continue;
|
||||
|
||||
if (!compare_orig(batman_if->net_dev->dev_addr,
|
||||
net_dev->dev_addr))
|
||||
continue;
|
||||
|
||||
pr_warning("The newly added mac address (%pM) already exists "
|
||||
"on: %s\n", addr, batman_if->net_dev->name);
|
||||
"on: %s\n", net_dev->dev_addr,
|
||||
batman_if->net_dev->name);
|
||||
pr_warning("It is strongly recommended to keep mac addresses "
|
||||
"unique to avoid problems!\n");
|
||||
}
|
||||
|
@ -430,7 +435,7 @@ static struct batman_if *hardif_add_interface(struct net_device *net_dev)
|
|||
atomic_set(&batman_if->refcnt, 0);
|
||||
hardif_hold(batman_if);
|
||||
|
||||
check_known_mac_addr(batman_if->net_dev->dev_addr);
|
||||
check_known_mac_addr(batman_if->net_dev);
|
||||
|
||||
spin_lock(&if_list_lock);
|
||||
list_add_tail_rcu(&batman_if->list, &if_list);
|
||||
|
@ -515,7 +520,7 @@ static int hard_if_event(struct notifier_block *this,
|
|||
goto out;
|
||||
}
|
||||
|
||||
check_known_mac_addr(batman_if->net_dev->dev_addr);
|
||||
check_known_mac_addr(batman_if->net_dev);
|
||||
update_mac_addresses(batman_if);
|
||||
|
||||
bat_priv = netdev_priv(batman_if->soft_iface);
|
||||
|
|
|
@ -1000,10 +1000,10 @@ int recv_icmp_packet(struct sk_buff *skb, struct batman_if *recv_if)
|
|||
|
||||
/* find a suitable router for this originator, and use
|
||||
* bonding if possible. */
|
||||
struct neigh_node *find_router(struct orig_node *orig_node,
|
||||
struct neigh_node *find_router(struct bat_priv *bat_priv,
|
||||
struct orig_node *orig_node,
|
||||
struct batman_if *recv_if)
|
||||
{
|
||||
struct bat_priv *bat_priv;
|
||||
struct orig_node *primary_orig_node;
|
||||
struct orig_node *router_orig;
|
||||
struct neigh_node *router, *first_candidate, *best_router;
|
||||
|
@ -1019,13 +1019,9 @@ struct neigh_node *find_router(struct orig_node *orig_node,
|
|||
/* without bonding, the first node should
|
||||
* always choose the default router. */
|
||||
|
||||
if (!recv_if)
|
||||
return orig_node->router;
|
||||
|
||||
bat_priv = netdev_priv(recv_if->soft_iface);
|
||||
bonding_enabled = atomic_read(&bat_priv->bonding_enabled);
|
||||
|
||||
if (!bonding_enabled)
|
||||
if ((!recv_if) && (!bonding_enabled))
|
||||
return orig_node->router;
|
||||
|
||||
router_orig = orig_node->router->orig_node;
|
||||
|
@ -1154,7 +1150,7 @@ static int route_unicast_packet(struct sk_buff *skb,
|
|||
orig_node = ((struct orig_node *)
|
||||
hash_find(bat_priv->orig_hash, unicast_packet->dest));
|
||||
|
||||
router = find_router(orig_node, recv_if);
|
||||
router = find_router(bat_priv, orig_node, recv_if);
|
||||
|
||||
if (!router) {
|
||||
spin_unlock_irqrestore(&bat_priv->orig_hash_lock, flags);
|
||||
|
|
|
@ -38,8 +38,8 @@ int recv_ucast_frag_packet(struct sk_buff *skb, struct batman_if *recv_if);
|
|||
int recv_bcast_packet(struct sk_buff *skb, struct batman_if *recv_if);
|
||||
int recv_vis_packet(struct sk_buff *skb, struct batman_if *recv_if);
|
||||
int recv_bat_packet(struct sk_buff *skb, struct batman_if *recv_if);
|
||||
struct neigh_node *find_router(struct orig_node *orig_node,
|
||||
struct batman_if *recv_if);
|
||||
struct neigh_node *find_router(struct bat_priv *bat_priv,
|
||||
struct orig_node *orig_node, struct batman_if *recv_if);
|
||||
void update_bonding_candidates(struct bat_priv *bat_priv,
|
||||
struct orig_node *orig_node);
|
||||
|
||||
|
|
|
@ -224,7 +224,7 @@ int unicast_send_skb(struct sk_buff *skb, struct bat_priv *bat_priv)
|
|||
if (!orig_node)
|
||||
orig_node = transtable_search(bat_priv, ethhdr->h_dest);
|
||||
|
||||
router = find_router(orig_node, NULL);
|
||||
router = find_router(bat_priv, orig_node, NULL);
|
||||
|
||||
if (!router)
|
||||
goto unlock;
|
||||
|
|
|
@ -1001,13 +1001,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
}
|
||||
#endif
|
||||
case IOCTL_BE_BUCKET_SIZE:
|
||||
Adapter->BEBucketSize = *(PULONG)arg;
|
||||
Status = STATUS_SUCCESS;
|
||||
Status = 0;
|
||||
if (get_user(Adapter->BEBucketSize, (unsigned long __user *)arg))
|
||||
Status = -EFAULT;
|
||||
break;
|
||||
|
||||
case IOCTL_RTPS_BUCKET_SIZE:
|
||||
Adapter->rtPSBucketSize = *(PULONG)arg;
|
||||
Status = STATUS_SUCCESS;
|
||||
Status = 0;
|
||||
if (get_user(Adapter->rtPSBucketSize, (unsigned long __user *)arg))
|
||||
Status = -EFAULT;
|
||||
break;
|
||||
case IOCTL_CHIP_RESET:
|
||||
{
|
||||
|
@ -1028,11 +1030,15 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
case IOCTL_QOS_THRESHOLD:
|
||||
{
|
||||
USHORT uiLoopIndex;
|
||||
for(uiLoopIndex = 0 ; uiLoopIndex < NO_OF_QUEUES ; uiLoopIndex++)
|
||||
{
|
||||
Adapter->PackInfo[uiLoopIndex].uiThreshold = *(PULONG)arg;
|
||||
|
||||
Status = 0;
|
||||
for (uiLoopIndex = 0; uiLoopIndex < NO_OF_QUEUES; uiLoopIndex++) {
|
||||
if (get_user(Adapter->PackInfo[uiLoopIndex].uiThreshold,
|
||||
(unsigned long __user *)arg)) {
|
||||
Status = -EFAULT;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Status = STATUS_SUCCESS;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1093,7 +1099,8 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
}
|
||||
case IOCTL_BCM_GET_CURRENT_STATUS:
|
||||
{
|
||||
LINK_STATE *plink_state = NULL;
|
||||
LINK_STATE plink_state;
|
||||
|
||||
/* Copy Ioctl Buffer structure */
|
||||
if(copy_from_user(&IoBuffer, argp, sizeof(IOCTL_BUFFER)))
|
||||
{
|
||||
|
@ -1101,13 +1108,19 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
Status = -EFAULT;
|
||||
break;
|
||||
}
|
||||
plink_state = (LINK_STATE*)arg;
|
||||
plink_state->bIdleMode = (UCHAR)Adapter->IdleMode;
|
||||
plink_state->bShutdownMode = Adapter->bShutStatus;
|
||||
plink_state->ucLinkStatus = (UCHAR)Adapter->LinkStatus;
|
||||
if(copy_to_user(IoBuffer.OutputBuffer,
|
||||
(PUCHAR)plink_state, (UINT)IoBuffer.OutputLength))
|
||||
{
|
||||
if (IoBuffer.OutputLength != sizeof(plink_state)) {
|
||||
Status = -EINVAL;
|
||||
break;
|
||||
}
|
||||
|
||||
if (copy_from_user(&plink_state, (void __user *)arg, sizeof(plink_state))) {
|
||||
Status = -EFAULT;
|
||||
break;
|
||||
}
|
||||
plink_state.bIdleMode = (UCHAR)Adapter->IdleMode;
|
||||
plink_state.bShutdownMode = Adapter->bShutStatus;
|
||||
plink_state.ucLinkStatus = (UCHAR)Adapter->LinkStatus;
|
||||
if (copy_to_user(IoBuffer.OutputBuffer, &plink_state, IoBuffer.OutputLength)) {
|
||||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0, "Copy_to_user Failed..\n");
|
||||
Status = -EFAULT;
|
||||
break;
|
||||
|
@ -1331,7 +1344,9 @@ static long bcm_char_ioctl(struct file *filp, UINT cmd, ULONG arg)
|
|||
BCM_DEBUG_PRINT(Adapter,DBG_TYPE_PRINTK, 0, 0,"Copy From User space failed. status :%d", Status);
|
||||
return -EFAULT;
|
||||
}
|
||||
uiSectorSize = *((PUINT)(IoBuffer.InputBuffer)); /* FIXME: unchecked __user access */
|
||||
if (get_user(uiSectorSize, (unsigned int __user *)IoBuffer.InputBuffer))
|
||||
return -EFAULT;
|
||||
|
||||
if((uiSectorSize < MIN_SECTOR_SIZE) || (uiSectorSize > MAX_SECTOR_SIZE))
|
||||
{
|
||||
|
||||
|
|
|
@ -90,5 +90,5 @@ Contact Info:
|
|||
=============
|
||||
Brett Rudley brudley@broadcom.com
|
||||
Henry Ptasinski henryp@broadcom.com
|
||||
Nohee Ko noheek@broadcom.com
|
||||
Dowan Kim dowan@broadcom.com
|
||||
|
||||
|
|
|
@ -45,5 +45,5 @@ Contact
|
|||
=====
|
||||
Brett Rudley <brudley@broadcom.com>
|
||||
Henry Ptasinski <henryp@broadcom.com>
|
||||
Nohee Ko <noheek@broadcom.com>
|
||||
Dowan Kim <dowan@broadcom.com>
|
||||
|
||||
|
|
|
@ -2222,8 +2222,6 @@ int dhd_net_attach(dhd_pub_t *dhdp, int ifidx)
|
|||
ASSERT(net);
|
||||
|
||||
ASSERT(!net->netdev_ops);
|
||||
net->netdev_ops = &dhd_ops_virt;
|
||||
|
||||
net->netdev_ops = &dhd_ops_pri;
|
||||
|
||||
/*
|
||||
|
|
|
@ -95,12 +95,12 @@ static s32 wl_cfg80211_config_default_key(struct wiphy *wiphy,
|
|||
struct net_device *dev,
|
||||
u8 key_idx);
|
||||
static s32 wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_idx, const u8 *mac_addr,
|
||||
u8 key_idx, bool pairwise, const u8 *mac_addr,
|
||||
struct key_params *params);
|
||||
static s32 wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_idx, const u8 *mac_addr);
|
||||
u8 key_idx, bool pairwise, const u8 *mac_addr);
|
||||
static s32 wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_idx, const u8 *mac_addr,
|
||||
u8 key_idx, bool pairwise, const u8 *mac_addr,
|
||||
void *cookie, void (*callback) (void *cookie,
|
||||
struct
|
||||
key_params *
|
||||
|
@ -1615,7 +1615,7 @@ wl_add_keyext(struct wiphy *wiphy, struct net_device *dev,
|
|||
|
||||
static s32
|
||||
wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_idx, const u8 *mac_addr,
|
||||
u8 key_idx, bool pairwise, const u8 *mac_addr,
|
||||
struct key_params *params)
|
||||
{
|
||||
struct wl_wsec_key key;
|
||||
|
@ -1700,7 +1700,7 @@ wl_cfg80211_add_key(struct wiphy *wiphy, struct net_device *dev,
|
|||
|
||||
static s32
|
||||
wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_idx, const u8 *mac_addr)
|
||||
u8 key_idx, bool pairwise, const u8 *mac_addr)
|
||||
{
|
||||
struct wl_wsec_key key;
|
||||
s32 err = 0;
|
||||
|
@ -1756,7 +1756,7 @@ wl_cfg80211_del_key(struct wiphy *wiphy, struct net_device *dev,
|
|||
|
||||
static s32
|
||||
wl_cfg80211_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_idx, const u8 *mac_addr, void *cookie,
|
||||
u8 key_idx, bool pairwise, const u8 *mac_addr, void *cookie,
|
||||
void (*callback) (void *cookie, struct key_params * params))
|
||||
{
|
||||
struct key_params params;
|
||||
|
|
|
@ -3184,13 +3184,9 @@ static int cpia_open(struct file *file)
|
|||
goto oops;
|
||||
}
|
||||
|
||||
err = -EINTR;
|
||||
if(signal_pending(current))
|
||||
goto oops;
|
||||
|
||||
/* Set ownership of /proc/cpia/videoX to current user */
|
||||
if(cam->proc_entry)
|
||||
cam->proc_entry->uid = current_uid();
|
||||
cam->proc_entry->uid = current_euid();
|
||||
|
||||
/* set mark for loading first frame uncompressed */
|
||||
cam->first_frame = 1;
|
||||
|
|
|
@ -286,7 +286,6 @@ int ft1000_CreateDevice(struct ft1000_device *dev)
|
|||
pid = kernel_thread (exec_mknod, (void *)info, 0);
|
||||
|
||||
// initialize application information
|
||||
info->appcnt = 0;
|
||||
|
||||
// if (ft1000_flarion_cnt == 0) {
|
||||
//
|
||||
|
|
|
@ -211,9 +211,6 @@ static void heartbeat_onchannelcallback(void *context)
|
|||
DPRINT_DBG(VMBUS, "heartbeat packet: len=%d, requestid=%lld",
|
||||
recvlen, requestid);
|
||||
|
||||
icmsghdrp = (struct icmsg_hdr *)&buf[
|
||||
sizeof(struct vmbuspipe_hdr)];
|
||||
|
||||
icmsghdrp = (struct icmsg_hdr *)&buf[
|
||||
sizeof(struct vmbuspipe_hdr)];
|
||||
|
||||
|
|
|
@ -244,12 +244,12 @@ static int intel_sst_mmap_play_capture(u32 str_id,
|
|||
int retval, i;
|
||||
struct stream_info *stream;
|
||||
struct snd_sst_mmap_buff_entry *buf_entry;
|
||||
struct snd_sst_mmap_buff_entry *tmp_buf;
|
||||
|
||||
pr_debug("sst:called for str_id %d\n", str_id);
|
||||
retval = sst_validate_strid(str_id);
|
||||
if (retval)
|
||||
return -EINVAL;
|
||||
BUG_ON(!mmap_buf);
|
||||
|
||||
stream = &sst_drv_ctx->streams[str_id];
|
||||
if (stream->mmapped != true)
|
||||
|
@ -262,14 +262,24 @@ static int intel_sst_mmap_play_capture(u32 str_id,
|
|||
stream->curr_bytes = 0;
|
||||
stream->cumm_bytes = 0;
|
||||
|
||||
tmp_buf = kcalloc(mmap_buf->entries, sizeof(*tmp_buf), GFP_KERNEL);
|
||||
if (!tmp_buf)
|
||||
return -ENOMEM;
|
||||
if (copy_from_user(tmp_buf, (void __user *)mmap_buf->buff,
|
||||
mmap_buf->entries * sizeof(*tmp_buf))) {
|
||||
retval = -EFAULT;
|
||||
goto out_free;
|
||||
}
|
||||
|
||||
pr_debug("sst:new buffers count %d status %d\n",
|
||||
mmap_buf->entries, stream->status);
|
||||
buf_entry = mmap_buf->buff;
|
||||
buf_entry = tmp_buf;
|
||||
for (i = 0; i < mmap_buf->entries; i++) {
|
||||
BUG_ON(!buf_entry);
|
||||
bufs = kzalloc(sizeof(*bufs), GFP_KERNEL);
|
||||
if (!bufs)
|
||||
return -ENOMEM;
|
||||
if (!bufs) {
|
||||
retval = -ENOMEM;
|
||||
goto out_free;
|
||||
}
|
||||
bufs->size = buf_entry->size;
|
||||
bufs->offset = buf_entry->offset;
|
||||
bufs->addr = sst_drv_ctx->mmap_mem;
|
||||
|
@ -293,13 +303,15 @@ static int intel_sst_mmap_play_capture(u32 str_id,
|
|||
if (sst_play_frame(str_id) < 0) {
|
||||
pr_warn("sst: play frames fail\n");
|
||||
mutex_unlock(&stream->lock);
|
||||
return -EIO;
|
||||
retval = -EIO;
|
||||
goto out_free;
|
||||
}
|
||||
} else if (stream->ops == STREAM_OPS_CAPTURE) {
|
||||
if (sst_capture_frame(str_id) < 0) {
|
||||
pr_warn("sst: capture frame fail\n");
|
||||
mutex_unlock(&stream->lock);
|
||||
return -EIO;
|
||||
retval = -EIO;
|
||||
goto out_free;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -314,6 +326,9 @@ static int intel_sst_mmap_play_capture(u32 str_id,
|
|||
if (retval >= 0)
|
||||
retval = stream->cumm_bytes;
|
||||
pr_debug("sst:end of play/rec ioctl bytes = %d!!\n", retval);
|
||||
|
||||
out_free:
|
||||
kfree(tmp_buf);
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -377,7 +392,7 @@ static int snd_sst_fill_kernel_list(struct stream_info *stream,
|
|||
{
|
||||
struct sst_stream_bufs *stream_bufs;
|
||||
unsigned long index, mmap_len;
|
||||
unsigned char *bufp;
|
||||
unsigned char __user *bufp;
|
||||
unsigned long size, copied_size;
|
||||
int retval = 0, add_to_list = 0;
|
||||
static int sent_offset;
|
||||
|
@ -512,9 +527,7 @@ static int snd_sst_copy_userbuf_capture(struct stream_info *stream,
|
|||
/* copy to user */
|
||||
list_for_each_entry_safe(entry, _entry,
|
||||
copy_to_list, node) {
|
||||
if (copy_to_user((void *)
|
||||
iovec[entry->iov_index].iov_base +
|
||||
entry->iov_offset,
|
||||
if (copy_to_user(iovec[entry->iov_index].iov_base + entry->iov_offset,
|
||||
kbufs->addr + entry->offset,
|
||||
entry->size)) {
|
||||
/* Clean up the list and return error */
|
||||
|
@ -590,7 +603,7 @@ static int intel_sst_read_write(unsigned int str_id, char __user *buf,
|
|||
buf, (int) count, (int) stream->status);
|
||||
|
||||
stream->buf_type = SST_BUF_USER_STATIC;
|
||||
iovec.iov_base = (void *)buf;
|
||||
iovec.iov_base = buf;
|
||||
iovec.iov_len = count;
|
||||
nr_segs = 1;
|
||||
|
||||
|
@ -838,7 +851,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
|
||||
case _IOC_NR(SNDRV_SST_STREAM_SET_PARAMS): {
|
||||
struct snd_sst_params *str_param = (struct snd_sst_params *)arg;
|
||||
struct snd_sst_params str_param;
|
||||
|
||||
pr_debug("sst: IOCTL_SET_PARAMS recieved!\n");
|
||||
if (minor != STREAM_MODULE) {
|
||||
|
@ -846,17 +859,25 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
}
|
||||
|
||||
if (copy_from_user(&str_param, (void __user *)arg,
|
||||
sizeof(str_param))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
if (!str_id) {
|
||||
|
||||
retval = sst_get_stream(str_param);
|
||||
retval = sst_get_stream(&str_param);
|
||||
if (retval > 0) {
|
||||
struct stream_info *str_info;
|
||||
char __user *dest;
|
||||
|
||||
sst_drv_ctx->stream_cnt++;
|
||||
data->str_id = retval;
|
||||
str_info = &sst_drv_ctx->streams[retval];
|
||||
str_info->src = SST_DRV;
|
||||
retval = copy_to_user(&str_param->stream_id,
|
||||
&retval, sizeof(__u32));
|
||||
dest = (char __user *)arg + offsetof(struct snd_sst_params, stream_id);
|
||||
retval = copy_to_user(dest, &retval, sizeof(__u32));
|
||||
if (retval)
|
||||
retval = -EFAULT;
|
||||
} else {
|
||||
|
@ -866,16 +887,14 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
} else {
|
||||
pr_debug("sst: SET_STREAM_PARAMS recieved!\n");
|
||||
/* allocated set params only */
|
||||
retval = sst_set_stream_param(str_id, str_param);
|
||||
retval = sst_set_stream_param(str_id, &str_param);
|
||||
/* Block the call for reply */
|
||||
if (!retval) {
|
||||
int sfreq = 0, word_size = 0, num_channel = 0;
|
||||
sfreq = str_param->sparams.uc.pcm_params.sfreq;
|
||||
word_size = str_param->sparams.
|
||||
uc.pcm_params.pcm_wd_sz;
|
||||
num_channel = str_param->
|
||||
sparams.uc.pcm_params.num_chan;
|
||||
if (str_param->ops == STREAM_OPS_CAPTURE) {
|
||||
sfreq = str_param.sparams.uc.pcm_params.sfreq;
|
||||
word_size = str_param.sparams.uc.pcm_params.pcm_wd_sz;
|
||||
num_channel = str_param.sparams.uc.pcm_params.num_chan;
|
||||
if (str_param.ops == STREAM_OPS_CAPTURE) {
|
||||
sst_drv_ctx->scard_ops->\
|
||||
set_pcm_audio_params(sfreq,
|
||||
word_size, num_channel);
|
||||
|
@ -885,41 +904,39 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
}
|
||||
case _IOC_NR(SNDRV_SST_SET_VOL): {
|
||||
struct snd_sst_vol *set_vol;
|
||||
struct snd_sst_vol *rec_vol = (struct snd_sst_vol *)arg;
|
||||
pr_debug("sst: SET_VOLUME recieved for %d!\n",
|
||||
rec_vol->stream_id);
|
||||
if (minor == STREAM_MODULE && rec_vol->stream_id == 0) {
|
||||
pr_debug("sst: invalid operation!\n");
|
||||
retval = -EPERM;
|
||||
break;
|
||||
}
|
||||
set_vol = kzalloc(sizeof(*set_vol), GFP_ATOMIC);
|
||||
if (!set_vol) {
|
||||
pr_debug("sst: mem allocation failed\n");
|
||||
retval = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (copy_from_user(set_vol, rec_vol, sizeof(*set_vol))) {
|
||||
struct snd_sst_vol set_vol;
|
||||
|
||||
if (copy_from_user(&set_vol, (void __user *)arg,
|
||||
sizeof(set_vol))) {
|
||||
pr_debug("sst: copy failed\n");
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
retval = sst_set_vol(set_vol);
|
||||
kfree(set_vol);
|
||||
break;
|
||||
}
|
||||
case _IOC_NR(SNDRV_SST_GET_VOL): {
|
||||
struct snd_sst_vol *rec_vol = (struct snd_sst_vol *)arg;
|
||||
struct snd_sst_vol get_vol;
|
||||
pr_debug("sst: IOCTL_GET_VOLUME recieved for stream = %d!\n",
|
||||
rec_vol->stream_id);
|
||||
if (minor == STREAM_MODULE && rec_vol->stream_id == 0) {
|
||||
pr_debug("sst: SET_VOLUME recieved for %d!\n",
|
||||
set_vol.stream_id);
|
||||
if (minor == STREAM_MODULE && set_vol.stream_id == 0) {
|
||||
pr_debug("sst: invalid operation!\n");
|
||||
retval = -EPERM;
|
||||
break;
|
||||
}
|
||||
retval = sst_set_vol(&set_vol);
|
||||
break;
|
||||
}
|
||||
case _IOC_NR(SNDRV_SST_GET_VOL): {
|
||||
struct snd_sst_vol get_vol;
|
||||
|
||||
if (copy_from_user(&get_vol, (void __user *)arg,
|
||||
sizeof(get_vol))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
pr_debug("sst: IOCTL_GET_VOLUME recieved for stream = %d!\n",
|
||||
get_vol.stream_id);
|
||||
if (minor == STREAM_MODULE && get_vol.stream_id == 0) {
|
||||
pr_debug("sst: invalid operation!\n");
|
||||
retval = -EPERM;
|
||||
break;
|
||||
}
|
||||
get_vol.stream_id = rec_vol->stream_id;
|
||||
retval = sst_get_vol(&get_vol);
|
||||
if (retval) {
|
||||
retval = -EIO;
|
||||
|
@ -928,7 +945,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
pr_debug("sst: id:%d\n, vol:%d, ramp_dur:%d, ramp_type:%d\n",
|
||||
get_vol.stream_id, get_vol.volume,
|
||||
get_vol.ramp_duration, get_vol.ramp_type);
|
||||
if (copy_to_user((struct snd_sst_vol *)arg,
|
||||
if (copy_to_user((struct snd_sst_vol __user *)arg,
|
||||
&get_vol, sizeof(get_vol))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
|
@ -938,25 +955,20 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
}
|
||||
|
||||
case _IOC_NR(SNDRV_SST_MUTE): {
|
||||
struct snd_sst_mute *set_mute;
|
||||
struct snd_sst_vol *rec_mute = (struct snd_sst_vol *)arg;
|
||||
pr_debug("sst: SNDRV_SST_SET_VOLUME recieved for %d!\n",
|
||||
rec_mute->stream_id);
|
||||
if (minor == STREAM_MODULE && rec_mute->stream_id == 0) {
|
||||
retval = -EPERM;
|
||||
break;
|
||||
}
|
||||
set_mute = kzalloc(sizeof(*set_mute), GFP_ATOMIC);
|
||||
if (!set_mute) {
|
||||
retval = -ENOMEM;
|
||||
break;
|
||||
}
|
||||
if (copy_from_user(set_mute, rec_mute, sizeof(*set_mute))) {
|
||||
struct snd_sst_mute set_mute;
|
||||
|
||||
if (copy_from_user(&set_mute, (void __user *)arg,
|
||||
sizeof(set_mute))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
retval = sst_set_mute(set_mute);
|
||||
kfree(set_mute);
|
||||
pr_debug("sst: SNDRV_SST_SET_VOLUME recieved for %d!\n",
|
||||
set_mute.stream_id);
|
||||
if (minor == STREAM_MODULE && set_mute.stream_id == 0) {
|
||||
retval = -EPERM;
|
||||
break;
|
||||
}
|
||||
retval = sst_set_mute(&set_mute);
|
||||
break;
|
||||
}
|
||||
case _IOC_NR(SNDRV_SST_STREAM_GET_PARAMS): {
|
||||
|
@ -973,7 +985,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
retval = -EIO;
|
||||
break;
|
||||
}
|
||||
if (copy_to_user((struct snd_sst_get_stream_params *)arg,
|
||||
if (copy_to_user((struct snd_sst_get_stream_params __user *)arg,
|
||||
&get_params, sizeof(get_params))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
|
@ -983,16 +995,22 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
}
|
||||
|
||||
case _IOC_NR(SNDRV_SST_MMAP_PLAY):
|
||||
case _IOC_NR(SNDRV_SST_MMAP_CAPTURE):
|
||||
case _IOC_NR(SNDRV_SST_MMAP_CAPTURE): {
|
||||
struct snd_sst_mmap_buffs mmap_buf;
|
||||
|
||||
pr_debug("sst: SNDRV_SST_MMAP_PLAY/CAPTURE recieved!\n");
|
||||
if (minor != STREAM_MODULE) {
|
||||
retval = -EBADRQC;
|
||||
break;
|
||||
}
|
||||
retval = intel_sst_mmap_play_capture(str_id,
|
||||
(struct snd_sst_mmap_buffs *)arg);
|
||||
if (copy_from_user(&mmap_buf, (void __user *)arg,
|
||||
sizeof(mmap_buf))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
retval = intel_sst_mmap_play_capture(str_id, &mmap_buf);
|
||||
break;
|
||||
|
||||
}
|
||||
case _IOC_NR(SNDRV_SST_STREAM_DROP):
|
||||
pr_debug("sst: SNDRV_SST_IOCTL_DROP recieved!\n");
|
||||
if (minor != STREAM_MODULE) {
|
||||
|
@ -1003,7 +1021,6 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
|
||||
case _IOC_NR(SNDRV_SST_STREAM_GET_TSTAMP): {
|
||||
unsigned long long *ms = (unsigned long long *)arg;
|
||||
struct snd_sst_tstamp tstamp = {0};
|
||||
unsigned long long time, freq, mod;
|
||||
|
||||
|
@ -1013,14 +1030,14 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
}
|
||||
memcpy_fromio(&tstamp,
|
||||
((void *)(sst_drv_ctx->mailbox + SST_TIME_STAMP)
|
||||
+(str_id * sizeof(tstamp))),
|
||||
sst_drv_ctx->mailbox + SST_TIME_STAMP + str_id * sizeof(tstamp),
|
||||
sizeof(tstamp));
|
||||
time = tstamp.samples_rendered;
|
||||
freq = (unsigned long long) tstamp.sampling_frequency;
|
||||
time = time * 1000; /* converting it to ms */
|
||||
mod = do_div(time, freq);
|
||||
if (copy_to_user(ms, &time, sizeof(*ms)))
|
||||
if (copy_to_user((void __user *)arg, &time,
|
||||
sizeof(unsigned long long)))
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
@ -1065,92 +1082,118 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
}
|
||||
|
||||
case _IOC_NR(SNDRV_SST_SET_TARGET_DEVICE): {
|
||||
struct snd_sst_target_device *target_device;
|
||||
struct snd_sst_target_device target_device;
|
||||
|
||||
pr_debug("sst: SET_TARGET_DEVICE recieved!\n");
|
||||
target_device = (struct snd_sst_target_device *)arg;
|
||||
BUG_ON(!target_device);
|
||||
if (copy_from_user(&target_device, (void __user *)arg,
|
||||
sizeof(target_device))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
if (minor != AM_MODULE) {
|
||||
retval = -EBADRQC;
|
||||
break;
|
||||
}
|
||||
retval = sst_target_device_select(target_device);
|
||||
retval = sst_target_device_select(&target_device);
|
||||
break;
|
||||
}
|
||||
|
||||
case _IOC_NR(SNDRV_SST_DRIVER_INFO): {
|
||||
struct snd_sst_driver_info *info =
|
||||
(struct snd_sst_driver_info *)arg;
|
||||
struct snd_sst_driver_info info;
|
||||
|
||||
pr_debug("sst: SNDRV_SST_DRIVER_INFO recived\n");
|
||||
info->version = SST_VERSION_NUM;
|
||||
info.version = SST_VERSION_NUM;
|
||||
/* hard coding, shud get sumhow later */
|
||||
info->active_pcm_streams = sst_drv_ctx->stream_cnt -
|
||||
info.active_pcm_streams = sst_drv_ctx->stream_cnt -
|
||||
sst_drv_ctx->encoded_cnt;
|
||||
info->active_enc_streams = sst_drv_ctx->encoded_cnt;
|
||||
info->max_pcm_streams = MAX_ACTIVE_STREAM - MAX_ENC_STREAM;
|
||||
info->max_enc_streams = MAX_ENC_STREAM;
|
||||
info->buf_per_stream = sst_drv_ctx->mmap_len;
|
||||
info.active_enc_streams = sst_drv_ctx->encoded_cnt;
|
||||
info.max_pcm_streams = MAX_ACTIVE_STREAM - MAX_ENC_STREAM;
|
||||
info.max_enc_streams = MAX_ENC_STREAM;
|
||||
info.buf_per_stream = sst_drv_ctx->mmap_len;
|
||||
if (copy_to_user((void __user *)arg, &info,
|
||||
sizeof(info)))
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
case _IOC_NR(SNDRV_SST_STREAM_DECODE): {
|
||||
struct snd_sst_dbufs *param =
|
||||
(struct snd_sst_dbufs *)arg, dbufs_local;
|
||||
int i;
|
||||
struct snd_sst_dbufs param;
|
||||
struct snd_sst_dbufs dbufs_local;
|
||||
struct snd_sst_buffs ibufs, obufs;
|
||||
struct snd_sst_buff_entry ibuf_temp[param->ibufs->entries],
|
||||
obuf_temp[param->obufs->entries];
|
||||
struct snd_sst_buff_entry *ibuf_tmp, *obuf_tmp;
|
||||
char __user *dest;
|
||||
|
||||
pr_debug("sst: SNDRV_SST_STREAM_DECODE recived\n");
|
||||
if (minor != STREAM_MODULE) {
|
||||
retval = -EBADRQC;
|
||||
break;
|
||||
}
|
||||
if (!param) {
|
||||
retval = -EINVAL;
|
||||
if (copy_from_user(¶m, (void __user *)arg,
|
||||
sizeof(param))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
dbufs_local.input_bytes_consumed = param->input_bytes_consumed;
|
||||
dbufs_local.input_bytes_consumed = param.input_bytes_consumed;
|
||||
dbufs_local.output_bytes_produced =
|
||||
param->output_bytes_produced;
|
||||
dbufs_local.ibufs = &ibufs;
|
||||
dbufs_local.obufs = &obufs;
|
||||
dbufs_local.ibufs->entries = param->ibufs->entries;
|
||||
dbufs_local.ibufs->type = param->ibufs->type;
|
||||
dbufs_local.obufs->entries = param->obufs->entries;
|
||||
dbufs_local.obufs->type = param->obufs->type;
|
||||
param.output_bytes_produced;
|
||||
|
||||
dbufs_local.ibufs->buff_entry = ibuf_temp;
|
||||
for (i = 0; i < dbufs_local.ibufs->entries; i++) {
|
||||
ibuf_temp[i].buffer =
|
||||
param->ibufs->buff_entry[i].buffer;
|
||||
ibuf_temp[i].size =
|
||||
param->ibufs->buff_entry[i].size;
|
||||
if (copy_from_user(&ibufs, (void __user *)param.ibufs, sizeof(ibufs))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
dbufs_local.obufs->buff_entry = obuf_temp;
|
||||
for (i = 0; i < dbufs_local.obufs->entries; i++) {
|
||||
obuf_temp[i].buffer =
|
||||
param->obufs->buff_entry[i].buffer;
|
||||
obuf_temp[i].size =
|
||||
param->obufs->buff_entry[i].size;
|
||||
if (copy_from_user(&obufs, (void __user *)param.obufs, sizeof(obufs))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
}
|
||||
|
||||
ibuf_tmp = kcalloc(ibufs.entries, sizeof(*ibuf_tmp), GFP_KERNEL);
|
||||
obuf_tmp = kcalloc(obufs.entries, sizeof(*obuf_tmp), GFP_KERNEL);
|
||||
if (!ibuf_tmp || !obuf_tmp) {
|
||||
retval = -ENOMEM;
|
||||
goto free_iobufs;
|
||||
}
|
||||
|
||||
if (copy_from_user(ibuf_tmp, (void __user *)ibufs.buff_entry,
|
||||
ibufs.entries * sizeof(*ibuf_tmp))) {
|
||||
retval = -EFAULT;
|
||||
goto free_iobufs;
|
||||
}
|
||||
ibufs.buff_entry = ibuf_tmp;
|
||||
dbufs_local.ibufs = &ibufs;
|
||||
|
||||
if (copy_from_user(obuf_tmp, (void __user *)obufs.buff_entry,
|
||||
obufs.entries * sizeof(*obuf_tmp))) {
|
||||
retval = -EFAULT;
|
||||
goto free_iobufs;
|
||||
}
|
||||
obufs.buff_entry = obuf_tmp;
|
||||
dbufs_local.obufs = &obufs;
|
||||
|
||||
retval = sst_decode(str_id, &dbufs_local);
|
||||
if (retval)
|
||||
retval = -EAGAIN;
|
||||
if (copy_to_user(¶m->input_bytes_consumed,
|
||||
if (retval) {
|
||||
retval = -EAGAIN;
|
||||
goto free_iobufs;
|
||||
}
|
||||
|
||||
dest = (char __user *)arg + offsetof(struct snd_sst_dbufs, input_bytes_consumed);
|
||||
if (copy_to_user(dest,
|
||||
&dbufs_local.input_bytes_consumed,
|
||||
sizeof(unsigned long long))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
retval = -EFAULT;
|
||||
goto free_iobufs;
|
||||
}
|
||||
if (copy_to_user(¶m->output_bytes_produced,
|
||||
|
||||
dest = (char __user *)arg + offsetof(struct snd_sst_dbufs, input_bytes_consumed);
|
||||
if (copy_to_user(dest,
|
||||
&dbufs_local.output_bytes_produced,
|
||||
sizeof(unsigned long long))) {
|
||||
retval = -EFAULT;
|
||||
break;
|
||||
retval = -EFAULT;
|
||||
goto free_iobufs;
|
||||
}
|
||||
free_iobufs:
|
||||
kfree(ibuf_tmp);
|
||||
kfree(obuf_tmp);
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -1164,7 +1207,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
|
||||
case _IOC_NR(SNDRV_SST_STREAM_BYTES_DECODED): {
|
||||
unsigned long long *bytes = (unsigned long long *)arg;
|
||||
unsigned long long __user *bytes = (unsigned long long __user *)arg;
|
||||
struct snd_sst_tstamp tstamp = {0};
|
||||
|
||||
pr_debug("sst: STREAM_BYTES_DECODED recieved!\n");
|
||||
|
@ -1173,8 +1216,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
break;
|
||||
}
|
||||
memcpy_fromio(&tstamp,
|
||||
((void *)(sst_drv_ctx->mailbox + SST_TIME_STAMP)
|
||||
+(str_id * sizeof(tstamp))),
|
||||
sst_drv_ctx->mailbox + SST_TIME_STAMP + str_id * sizeof(tstamp),
|
||||
sizeof(tstamp));
|
||||
if (copy_to_user(bytes, &tstamp.bytes_processed,
|
||||
sizeof(*bytes)))
|
||||
|
@ -1197,7 +1239,7 @@ long intel_sst_ioctl(struct file *file_ptr, unsigned int cmd, unsigned long arg)
|
|||
kfree(fw_info);
|
||||
break;
|
||||
}
|
||||
if (copy_to_user((struct snd_sst_dbufs *)arg,
|
||||
if (copy_to_user((struct snd_sst_dbufs __user *)arg,
|
||||
fw_info, sizeof(*fw_info))) {
|
||||
kfree(fw_info);
|
||||
retval = -EFAULT;
|
||||
|
|
|
@ -231,8 +231,8 @@ struct stream_info {
|
|||
spinlock_t pcm_lock;
|
||||
bool mmapped;
|
||||
unsigned int sg_index; /* current buf Index */
|
||||
unsigned char *cur_ptr; /* Current static bufs */
|
||||
struct snd_sst_buf_entry *buf_entry;
|
||||
unsigned char __user *cur_ptr; /* Current static bufs */
|
||||
struct snd_sst_buf_entry __user *buf_entry;
|
||||
struct sst_block data_blk; /* stream ops block */
|
||||
struct sst_block ctrl_blk; /* stream control cmd block */
|
||||
enum snd_sst_buf_type buf_type;
|
||||
|
|
|
@ -22,7 +22,7 @@ int ENE_InitMedia(struct us_data *us)
|
|||
int result;
|
||||
BYTE MiscReg03 = 0;
|
||||
|
||||
printk("--- Initial Nedia ---\n");
|
||||
printk("--- Init Media ---\n");
|
||||
result = ENE_Read_BYTE(us, REG_CARD_STATUS, &MiscReg03);
|
||||
if (result != USB_STOR_XFER_GOOD)
|
||||
{
|
||||
|
@ -64,7 +64,7 @@ int ENE_Read_BYTE(struct us_data *us, WORD index, void *buf)
|
|||
struct bulk_cb_wrap *bcb = (struct bulk_cb_wrap *) us->iobuf;
|
||||
int result;
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x01;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -92,7 +92,7 @@ int ENE_SDInit(struct us_data *us)
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
}
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->Flags = 0x80;
|
||||
bcb->CDB[0] = 0xF2;
|
||||
|
@ -112,7 +112,7 @@ int ENE_SDInit(struct us_data *us)
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
}
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -161,7 +161,7 @@ int ENE_MSInit(struct us_data *us)
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
}
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -219,7 +219,7 @@ int ENE_SMInit(struct us_data *us)
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
}
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -341,7 +341,7 @@ int ENE_LoadBinCode(struct us_data *us, BYTE flag)
|
|||
break;
|
||||
}
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x800;
|
||||
bcb->Flags =0x00;
|
||||
|
@ -433,7 +433,7 @@ int ENE_Read_Data(struct us_data *us, void *buf, unsigned int length)
|
|||
|
||||
//printk("transport --- ENE_Read_Data\n");
|
||||
// set up the command wrapper
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = length;
|
||||
bcb->Flags =0x80;
|
||||
|
@ -470,7 +470,7 @@ int ENE_Write_Data(struct us_data *us, void *buf, unsigned int length)
|
|||
|
||||
//printk("transport --- ENE_Write_Data\n");
|
||||
// set up the command wrapper
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = length;
|
||||
bcb->Flags =0x00;
|
||||
|
|
|
@ -15,7 +15,7 @@ int MS_ReaderCopyBlock(struct us_data *us, WORD oldphy, WORD newphy, WORD PhyBlo
|
|||
if (result != USB_STOR_XFER_GOOD)
|
||||
return USB_STOR_TRANSPORT_ERROR;
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200*len;
|
||||
bcb->Flags = 0x00;
|
||||
|
@ -53,7 +53,7 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWO
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
|
||||
// Read Page Data
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -69,7 +69,7 @@ int MS_ReaderReadPage(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, PDWO
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
|
||||
// Read Extra Data
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x4;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -108,7 +108,7 @@ int MS_ReaderEraseBlock(struct us_data *us, DWORD PhyBlockAddr)
|
|||
if (result != USB_STOR_XFER_GOOD)
|
||||
return USB_STOR_TRANSPORT_ERROR;
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -673,7 +673,7 @@ int MS_LibReadExtraBlock(struct us_data *us, DWORD PhyBlock, BYTE PageNum, BYTE
|
|||
//printk("MS_LibReadExtraBlock --- PhyBlock = %x, PageNum = %x, blen = %x\n", PhyBlock, PageNum, blen);
|
||||
|
||||
// Read Extra Data
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x4 * blen;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -700,7 +700,7 @@ int MS_LibReadExtra(struct us_data *us, DWORD PhyBlock, BYTE PageNum, MS_LibType
|
|||
BYTE ExtBuf[4];
|
||||
|
||||
//printk("MS_LibReadExtra --- PhyBlock = %x, PageNum = %x\n", PhyBlock, PageNum);
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x4;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -807,7 +807,7 @@ int MS_LibOverwriteExtra(struct us_data *us, DWORD PhyBlockAddr, BYTE PageNum, B
|
|||
if (result != USB_STOR_XFER_GOOD)
|
||||
return USB_STOR_TRANSPORT_ERROR;
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x4;
|
||||
bcb->Flags = 0x80;
|
||||
|
|
|
@ -145,7 +145,7 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
|
|||
}
|
||||
|
||||
// set up the command wrapper
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = blenByte;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -193,7 +193,7 @@ int MS_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
|
|||
blkno = phyblk * 0x20 + PageNum;
|
||||
|
||||
// set up the command wrapper
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200 * len;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -250,7 +250,7 @@ int MS_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
|
|||
}
|
||||
|
||||
// set up the command wrapper
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = blenByte;
|
||||
bcb->Flags = 0x00;
|
||||
|
|
|
@ -152,7 +152,7 @@ int SD_SCSI_Read(struct us_data *us, struct scsi_cmnd *srb)
|
|||
bnByte = bn;
|
||||
|
||||
// set up the command wrapper
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = blenByte;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -192,7 +192,7 @@ int SD_SCSI_Write(struct us_data *us, struct scsi_cmnd *srb)
|
|||
bnByte = bn;
|
||||
|
||||
// set up the command wrapper
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = blenByte;
|
||||
bcb->Flags = 0x00;
|
||||
|
|
|
@ -266,7 +266,7 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf,BYTE *redundant)
|
|||
addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
|
||||
|
||||
// Read sect data
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -281,7 +281,7 @@ int Ssfdc_D_ReadSect(struct us_data *us, BYTE *buf,BYTE *redundant)
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
|
||||
// Read redundant
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x10;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -319,7 +319,7 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant)
|
|||
addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
|
||||
|
||||
// Read sect data
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200*count;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -334,7 +334,7 @@ int Ssfdc_D_ReadBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant)
|
|||
return USB_STOR_TRANSPORT_ERROR;
|
||||
|
||||
// Read redundant
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x10;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -536,7 +536,7 @@ int Ssfdc_D_CopyBlock(struct us_data *us, WORD count, BYTE *buf,BYTE *redundant)
|
|||
WriteAddr = WriteAddr*(WORD)Ssfdc.MaxSectors;
|
||||
|
||||
// Write sect data
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200*count;
|
||||
bcb->Flags = 0x00;
|
||||
|
@ -754,7 +754,7 @@ int Ssfdc_D_WriteSectForCopy(struct us_data *us, BYTE *buf, BYTE *redundant)
|
|||
addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
|
||||
|
||||
// Write sect data
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x00;
|
||||
|
@ -791,7 +791,7 @@ int Ssfdc_D_EraseBlock(struct us_data *us)
|
|||
addr=(WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
|
||||
addr=addr*(WORD)Ssfdc.MaxSectors;
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x200;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -827,7 +827,7 @@ int Ssfdc_D_ReadRedtData(struct us_data *us, BYTE *redundant)
|
|||
addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
|
||||
addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x10;
|
||||
bcb->Flags = 0x80;
|
||||
|
@ -870,7 +870,7 @@ int Ssfdc_D_WriteRedtData(struct us_data *us, BYTE *redundant)
|
|||
addr = (WORD)Media.Zone*Ssfdc.MaxBlocks+Media.PhyBlock;
|
||||
addr = addr*(WORD)Ssfdc.MaxSectors+Media.Sector;
|
||||
|
||||
memset(bcb, 0, sizeof(bcb));
|
||||
memset(bcb, 0, sizeof(struct bulk_cb_wrap));
|
||||
bcb->Signature = cpu_to_le32(US_BULK_CB_SIGN);
|
||||
bcb->DataTransferLength = 0x10;
|
||||
bcb->Flags = 0x80;
|
||||
|
|
|
@ -40,7 +40,7 @@ static int usb_stor_msg_common(struct us_data *us, int timeout)
|
|||
us->current_urb->error_count = 0;
|
||||
us->current_urb->status = 0;
|
||||
|
||||
// us->current_urb->transfer_flags = URB_NO_SETUP_DMA_MAP;
|
||||
us->current_urb->transfer_flags = 0;
|
||||
if (us->current_urb->transfer_buffer == us->iobuf)
|
||||
us->current_urb->transfer_flags |= URB_NO_TRANSFER_DMA_MAP;
|
||||
us->current_urb->transfer_dma = us->iobuf_dma;
|
||||
|
|
|
@ -330,8 +330,6 @@ void construct_mic_iv(unsigned char *mic_iv,
|
|||
for (i = 8; i < 14; i++)
|
||||
mic_iv[i] = pn_vector[13 - i]; /* mic_iv[8:13] = PN[5:0] */
|
||||
#endif
|
||||
i = (payload_length / 256);
|
||||
i = (payload_length % 256);
|
||||
mic_iv[14] = (unsigned char)(payload_length / 256);
|
||||
mic_iv[15] = (unsigned char)(payload_length % 256);
|
||||
|
||||
|
|
|
@ -65,6 +65,7 @@ struct usb_device_id rtusb_usb_id[] = {
|
|||
{USB_DEVICE(0x14B2, 0x3C07)}, /* AL */
|
||||
{USB_DEVICE(0x050D, 0x8053)}, /* Belkin */
|
||||
{USB_DEVICE(0x050D, 0x825B)}, /* Belkin */
|
||||
{USB_DEVICE(0x050D, 0x935A)}, /* Belkin F6D4050 v1 */
|
||||
{USB_DEVICE(0x050D, 0x935B)}, /* Belkin F6D4050 v2 */
|
||||
{USB_DEVICE(0x14B2, 0x3C23)}, /* Airlink */
|
||||
{USB_DEVICE(0x14B2, 0x3C27)}, /* Airlink */
|
||||
|
|
|
@ -5829,6 +5829,9 @@ static void rtl8192_rx(struct net_device *dev)
|
|||
}
|
||||
}
|
||||
|
||||
pci_unmap_single(priv->pdev, *((dma_addr_t *) skb->cb),
|
||||
priv->rxbuffersize, PCI_DMA_FROMDEVICE);
|
||||
|
||||
skb = new_skb;
|
||||
priv->rx_buf[priv->rx_idx] = skb;
|
||||
*((dma_addr_t *) skb->cb) = pci_map_single(priv->pdev, skb_tail_pointer(skb), priv->rxbuffersize, PCI_DMA_FROMDEVICE);
|
||||
|
|
|
@ -1286,6 +1286,7 @@ static long saa_ioctl(struct file *file,
|
|||
case VIDIOCGCAP:
|
||||
{
|
||||
struct video_capability b;
|
||||
memset(&b, 0, sizeof(b));
|
||||
strcpy(b.name, saa->video_dev.name);
|
||||
b.type = VID_TYPE_CAPTURE | VID_TYPE_OVERLAY |
|
||||
VID_TYPE_CLIPPING | VID_TYPE_FRAMERAM |
|
||||
|
@ -1416,6 +1417,7 @@ static long saa_ioctl(struct file *file,
|
|||
case VIDIOCGWIN:
|
||||
{
|
||||
struct video_window vw;
|
||||
memset(&vw, 0, sizeof(vw));
|
||||
vw.x = saa->win.x;
|
||||
vw.y = saa->win.y;
|
||||
vw.width = saa->win.width;
|
||||
|
@ -1448,6 +1450,7 @@ static long saa_ioctl(struct file *file,
|
|||
case VIDIOCGFBUF:
|
||||
{
|
||||
struct video_buffer v;
|
||||
memset(&v, 0, sizeof(v));
|
||||
v.base = (void *)saa->win.vidadr;
|
||||
v.height = saa->win.sheight;
|
||||
v.width = saa->win.swidth;
|
||||
|
@ -1492,6 +1495,7 @@ static long saa_ioctl(struct file *file,
|
|||
case VIDIOCGAUDIO:
|
||||
{
|
||||
struct video_audio v;
|
||||
memset(&v, 0, sizeof(v));
|
||||
v = saa->audio_dev;
|
||||
v.flags &= ~(VIDEO_AUDIO_MUTE | VIDEO_AUDIO_MUTABLE);
|
||||
v.flags |= VIDEO_AUDIO_MUTABLE | VIDEO_AUDIO_VOLUME;
|
||||
|
@ -1534,6 +1538,7 @@ static long saa_ioctl(struct file *file,
|
|||
case VIDIOCGUNIT:
|
||||
{
|
||||
struct video_unit vu;
|
||||
memset(&vu, 0, sizeof(vu));
|
||||
vu.video = saa->video_dev.minor;
|
||||
vu.vbi = VIDEO_NO_UNIT;
|
||||
vu.radio = VIDEO_NO_UNIT;
|
||||
|
@ -1888,6 +1893,7 @@ static int saa_open(struct file *file)
|
|||
|
||||
saa->user++;
|
||||
if (saa->user > 1) {
|
||||
saa->user--;
|
||||
unlock_kernel();
|
||||
return 0; /* device open already, don't reset */
|
||||
}
|
||||
|
@ -2000,10 +2006,13 @@ static int __devinit configure_saa7146(struct pci_dev *pdev, int num)
|
|||
if (retval < 0) {
|
||||
dev_err(&pdev->dev, "%d: error in registering video device!\n",
|
||||
num);
|
||||
goto errio;
|
||||
goto errirq;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
errirq:
|
||||
free_irq(saa->irq, saa);
|
||||
errio:
|
||||
iounmap(saa->saa7146_mem);
|
||||
err:
|
||||
|
|
|
@ -6,7 +6,6 @@ menuconfig TIDSPBRIDGE
|
|||
tristate "DSP Bridge driver"
|
||||
depends on ARCH_OMAP3
|
||||
select OMAP_MBOX_FWK
|
||||
select OMAP_IOMMU
|
||||
help
|
||||
DSP/BIOS Bridge is designed for platforms that contain a GPP and
|
||||
one or more attached DSPs. The GPP is considered the master or
|
||||
|
|
|
@ -2,18 +2,19 @@ obj-$(CONFIG_TIDSPBRIDGE) += bridgedriver.o
|
|||
|
||||
libgen = gen/gb.o gen/gs.o gen/gh.o gen/uuidutil.o
|
||||
libcore = core/chnl_sm.o core/msg_sm.o core/io_sm.o core/tiomap3430.o \
|
||||
core/tiomap3430_pwr.o core/tiomap_io.o core/dsp-mmu.o \
|
||||
core/tiomap3430_pwr.o core/tiomap_io.o \
|
||||
core/ue_deh.o core/wdt.o core/dsp-clock.o core/sync.o
|
||||
libpmgr = pmgr/chnl.o pmgr/io.o pmgr/msg.o pmgr/cod.o pmgr/dev.o pmgr/dspapi.o \
|
||||
pmgr/cmm.o pmgr/dbll.o
|
||||
pmgr/dmm.o pmgr/cmm.o pmgr/dbll.o
|
||||
librmgr = rmgr/dbdcd.o rmgr/disp.o rmgr/drv.o rmgr/mgr.o rmgr/node.o \
|
||||
rmgr/proc.o rmgr/pwr.o rmgr/rmm.o rmgr/strm.o rmgr/dspdrv.o \
|
||||
rmgr/nldr.o rmgr/drv_interface.o
|
||||
libdload = dynload/cload.o dynload/getsection.o dynload/reloc.o \
|
||||
dynload/tramp.o
|
||||
libhw = hw/hw_mmu.o
|
||||
|
||||
bridgedriver-y := $(libgen) $(libservices) $(libcore) $(libpmgr) $(librmgr) \
|
||||
$(libdload)
|
||||
$(libdload) $(libhw)
|
||||
|
||||
#Machine dependent
|
||||
ccflags-y += -D_TI_ -D_DB_TIOMAP -DTMS32060 \
|
||||
|
|
|
@ -27,8 +27,9 @@
|
|||
struct deh_mgr {
|
||||
struct bridge_dev_context *hbridge_context; /* Bridge context. */
|
||||
struct ntfy_object *ntfy_obj; /* NTFY object */
|
||||
|
||||
/* MMU Fault DPC */
|
||||
struct tasklet_struct dpc_tasklet;
|
||||
};
|
||||
|
||||
int mmu_fault_isr(struct iommu *mmu);
|
||||
|
||||
#endif /* _DEH_ */
|
||||
|
|
|
@ -23,8 +23,8 @@
|
|||
#include <plat/clockdomain.h>
|
||||
#include <mach-omap2/prm-regbits-34xx.h>
|
||||
#include <mach-omap2/cm-regbits-34xx.h>
|
||||
#include <dspbridge/dsp-mmu.h>
|
||||
#include <dspbridge/devdefs.h>
|
||||
#include <hw_defs.h>
|
||||
#include <dspbridge/dspioctl.h> /* for bridge_ioctl_extproc defn */
|
||||
#include <dspbridge/sync.h>
|
||||
#include <dspbridge/clk.h>
|
||||
|
@ -306,18 +306,6 @@ static const struct bpwr_clk_t bpwr_clks[] = {
|
|||
|
||||
#define CLEAR_BIT_INDEX(reg, index) (reg &= ~(1 << (index)))
|
||||
|
||||
struct shm_segs {
|
||||
u32 seg0_da;
|
||||
u32 seg0_pa;
|
||||
u32 seg0_va;
|
||||
u32 seg0_size;
|
||||
u32 seg1_da;
|
||||
u32 seg1_pa;
|
||||
u32 seg1_va;
|
||||
u32 seg1_size;
|
||||
};
|
||||
|
||||
|
||||
/* This Bridge driver's device context: */
|
||||
struct bridge_dev_context {
|
||||
struct dev_object *hdev_obj; /* Handle to Bridge device object. */
|
||||
|
@ -328,6 +316,7 @@ struct bridge_dev_context {
|
|||
*/
|
||||
u32 dw_dsp_ext_base_addr; /* See the comment above */
|
||||
u32 dw_api_reg_base; /* API mem map'd registers */
|
||||
void __iomem *dw_dsp_mmu_base; /* DSP MMU Mapped registers */
|
||||
u32 dw_api_clk_base; /* CLK Registers */
|
||||
u32 dw_dsp_clk_m2_base; /* DSP Clock Module m2 */
|
||||
u32 dw_public_rhea; /* Pub Rhea */
|
||||
|
@ -339,8 +328,7 @@ struct bridge_dev_context {
|
|||
u32 dw_internal_size; /* Internal memory size */
|
||||
|
||||
struct omap_mbox *mbox; /* Mail box handle */
|
||||
struct iommu *dsp_mmu; /* iommu for iva2 handler */
|
||||
struct shm_segs sh_s;
|
||||
|
||||
struct cfg_hostres *resources; /* Host Resources */
|
||||
|
||||
/*
|
||||
|
@ -353,6 +341,7 @@ struct bridge_dev_context {
|
|||
|
||||
/* TC Settings */
|
||||
bool tc_word_swap_on; /* Traffic Controller Word Swap */
|
||||
struct pg_table_attrs *pt_attrs;
|
||||
u32 dsp_per_clks;
|
||||
};
|
||||
|
||||
|
|
|
@ -1,317 +0,0 @@
|
|||
/*
|
||||
* dsp-mmu.c
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* DSP iommu.
|
||||
*
|
||||
* Copyright (C) 2010 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <dspbridge/host_os.h>
|
||||
#include <plat/dmtimer.h>
|
||||
#include <dspbridge/dbdefs.h>
|
||||
#include <dspbridge/dev.h>
|
||||
#include <dspbridge/io_sm.h>
|
||||
#include <dspbridge/dspdeh.h>
|
||||
#include "_tiomap.h"
|
||||
|
||||
#include <dspbridge/dsp-mmu.h>
|
||||
|
||||
#define MMU_CNTL_TWL_EN (1 << 2)
|
||||
|
||||
static struct tasklet_struct mmu_tasklet;
|
||||
|
||||
#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
|
||||
static void mmu_fault_print_stack(struct bridge_dev_context *dev_context)
|
||||
{
|
||||
void *dummy_addr;
|
||||
u32 fa, tmp;
|
||||
struct iotlb_entry e;
|
||||
struct iommu *mmu = dev_context->dsp_mmu;
|
||||
dummy_addr = (void *)__get_free_page(GFP_ATOMIC);
|
||||
|
||||
/*
|
||||
* Before acking the MMU fault, let's make sure MMU can only
|
||||
* access entry #0. Then add a new entry so that the DSP OS
|
||||
* can continue in order to dump the stack.
|
||||
*/
|
||||
tmp = iommu_read_reg(mmu, MMU_CNTL);
|
||||
tmp &= ~MMU_CNTL_TWL_EN;
|
||||
iommu_write_reg(mmu, tmp, MMU_CNTL);
|
||||
fa = iommu_read_reg(mmu, MMU_FAULT_AD);
|
||||
e.da = fa & PAGE_MASK;
|
||||
e.pa = virt_to_phys(dummy_addr);
|
||||
e.valid = 1;
|
||||
e.prsvd = 1;
|
||||
e.pgsz = IOVMF_PGSZ_4K & MMU_CAM_PGSZ_MASK;
|
||||
e.endian = MMU_RAM_ENDIAN_LITTLE;
|
||||
e.elsz = MMU_RAM_ELSZ_32;
|
||||
e.mixed = 0;
|
||||
|
||||
load_iotlb_entry(mmu, &e);
|
||||
|
||||
dsp_clk_enable(DSP_CLK_GPT8);
|
||||
|
||||
dsp_gpt_wait_overflow(DSP_CLK_GPT8, 0xfffffffe);
|
||||
|
||||
/* Clear MMU interrupt */
|
||||
tmp = iommu_read_reg(mmu, MMU_IRQSTATUS);
|
||||
iommu_write_reg(mmu, tmp, MMU_IRQSTATUS);
|
||||
|
||||
dump_dsp_stack(dev_context);
|
||||
dsp_clk_disable(DSP_CLK_GPT8);
|
||||
|
||||
iopgtable_clear_entry(mmu, fa);
|
||||
free_page((unsigned long)dummy_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
static void fault_tasklet(unsigned long data)
|
||||
{
|
||||
struct iommu *mmu = (struct iommu *)data;
|
||||
struct bridge_dev_context *dev_ctx;
|
||||
struct deh_mgr *dm;
|
||||
u32 fa;
|
||||
dev_get_deh_mgr(dev_get_first(), &dm);
|
||||
dev_get_bridge_context(dev_get_first(), &dev_ctx);
|
||||
|
||||
if (!dm || !dev_ctx)
|
||||
return;
|
||||
|
||||
fa = iommu_read_reg(mmu, MMU_FAULT_AD);
|
||||
|
||||
#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
|
||||
print_dsp_trace_buffer(dev_ctx);
|
||||
dump_dl_modules(dev_ctx);
|
||||
mmu_fault_print_stack(dev_ctx);
|
||||
#endif
|
||||
|
||||
bridge_deh_notify(dm, DSP_MMUFAULT, fa);
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== mmu_fault_isr ========
|
||||
* ISR to be triggered by a DSP MMU fault interrupt.
|
||||
*/
|
||||
static int mmu_fault_callback(struct iommu *mmu)
|
||||
{
|
||||
if (!mmu)
|
||||
return -EPERM;
|
||||
|
||||
iommu_write_reg(mmu, 0, MMU_IRQENABLE);
|
||||
tasklet_schedule(&mmu_tasklet);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* dsp_mmu_init() - initialize dsp_mmu module and returns a handle
|
||||
*
|
||||
* This function initialize dsp mmu module and returns a struct iommu
|
||||
* handle to use it for dsp maps.
|
||||
*
|
||||
*/
|
||||
struct iommu *dsp_mmu_init()
|
||||
{
|
||||
struct iommu *mmu;
|
||||
|
||||
mmu = iommu_get("iva2");
|
||||
|
||||
if (!IS_ERR(mmu)) {
|
||||
tasklet_init(&mmu_tasklet, fault_tasklet, (unsigned long)mmu);
|
||||
mmu->isr = mmu_fault_callback;
|
||||
}
|
||||
|
||||
return mmu;
|
||||
}
|
||||
|
||||
/**
|
||||
* dsp_mmu_exit() - destroy dsp mmu module
|
||||
* @mmu: Pointer to iommu handle.
|
||||
*
|
||||
* This function destroys dsp mmu module.
|
||||
*
|
||||
*/
|
||||
void dsp_mmu_exit(struct iommu *mmu)
|
||||
{
|
||||
if (mmu)
|
||||
iommu_put(mmu);
|
||||
tasklet_kill(&mmu_tasklet);
|
||||
}
|
||||
|
||||
/**
|
||||
* user_va2_pa() - get physical address from userspace address.
|
||||
* @mm: mm_struct Pointer of the process.
|
||||
* @address: Virtual user space address.
|
||||
*
|
||||
*/
|
||||
static u32 user_va2_pa(struct mm_struct *mm, u32 address)
|
||||
{
|
||||
pgd_t *pgd;
|
||||
pmd_t *pmd;
|
||||
pte_t *ptep, pte;
|
||||
|
||||
pgd = pgd_offset(mm, address);
|
||||
if (!(pgd_none(*pgd) || pgd_bad(*pgd))) {
|
||||
pmd = pmd_offset(pgd, address);
|
||||
if (!(pmd_none(*pmd) || pmd_bad(*pmd))) {
|
||||
ptep = pte_offset_map(pmd, address);
|
||||
if (ptep) {
|
||||
pte = *ptep;
|
||||
if (pte_present(pte))
|
||||
return pte & PAGE_MASK;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* get_io_pages() - pin and get pages of io user's buffer.
|
||||
* @mm: mm_struct Pointer of the process.
|
||||
* @uva: Virtual user space address.
|
||||
* @pages Pages to be pined.
|
||||
* @usr_pgs struct page array pointer where the user pages will be stored
|
||||
*
|
||||
*/
|
||||
static int get_io_pages(struct mm_struct *mm, u32 uva, unsigned pages,
|
||||
struct page **usr_pgs)
|
||||
{
|
||||
u32 pa;
|
||||
int i;
|
||||
struct page *pg;
|
||||
|
||||
for (i = 0; i < pages; i++) {
|
||||
pa = user_va2_pa(mm, uva);
|
||||
|
||||
if (!pfn_valid(__phys_to_pfn(pa)))
|
||||
break;
|
||||
|
||||
pg = phys_to_page(pa);
|
||||
usr_pgs[i] = pg;
|
||||
get_page(pg);
|
||||
}
|
||||
return i;
|
||||
}
|
||||
|
||||
/**
|
||||
* user_to_dsp_map() - maps user to dsp virtual address
|
||||
* @mmu: Pointer to iommu handle.
|
||||
* @uva: Virtual user space address.
|
||||
* @da DSP address
|
||||
* @size Buffer size to map.
|
||||
* @usr_pgs struct page array pointer where the user pages will be stored
|
||||
*
|
||||
* This function maps a user space buffer into DSP virtual address.
|
||||
*
|
||||
*/
|
||||
u32 user_to_dsp_map(struct iommu *mmu, u32 uva, u32 da, u32 size,
|
||||
struct page **usr_pgs)
|
||||
{
|
||||
int res, w;
|
||||
unsigned pages;
|
||||
int i;
|
||||
struct vm_area_struct *vma;
|
||||
struct mm_struct *mm = current->mm;
|
||||
struct sg_table *sgt;
|
||||
struct scatterlist *sg;
|
||||
|
||||
if (!size || !usr_pgs)
|
||||
return -EINVAL;
|
||||
|
||||
pages = size / PG_SIZE4K;
|
||||
|
||||
down_read(&mm->mmap_sem);
|
||||
vma = find_vma(mm, uva);
|
||||
while (vma && (uva + size > vma->vm_end))
|
||||
vma = find_vma(mm, vma->vm_end + 1);
|
||||
|
||||
if (!vma) {
|
||||
pr_err("%s: Failed to get VMA region for 0x%x (%d)\n",
|
||||
__func__, uva, size);
|
||||
up_read(&mm->mmap_sem);
|
||||
return -EINVAL;
|
||||
}
|
||||
if (vma->vm_flags & (VM_WRITE | VM_MAYWRITE))
|
||||
w = 1;
|
||||
|
||||
if (vma->vm_flags & VM_IO)
|
||||
i = get_io_pages(mm, uva, pages, usr_pgs);
|
||||
else
|
||||
i = get_user_pages(current, mm, uva, pages, w, 1,
|
||||
usr_pgs, NULL);
|
||||
up_read(&mm->mmap_sem);
|
||||
|
||||
if (i < 0)
|
||||
return i;
|
||||
|
||||
if (i < pages) {
|
||||
res = -EFAULT;
|
||||
goto err_pages;
|
||||
}
|
||||
|
||||
sgt = kzalloc(sizeof(*sgt), GFP_KERNEL);
|
||||
if (!sgt) {
|
||||
res = -ENOMEM;
|
||||
goto err_pages;
|
||||
}
|
||||
|
||||
res = sg_alloc_table(sgt, pages, GFP_KERNEL);
|
||||
|
||||
if (res < 0)
|
||||
goto err_sg;
|
||||
|
||||
for_each_sg(sgt->sgl, sg, sgt->nents, i)
|
||||
sg_set_page(sg, usr_pgs[i], PAGE_SIZE, 0);
|
||||
|
||||
da = iommu_vmap(mmu, da, sgt, IOVMF_ENDIAN_LITTLE | IOVMF_ELSZ_32);
|
||||
|
||||
if (!IS_ERR_VALUE(da))
|
||||
return da;
|
||||
res = (int)da;
|
||||
|
||||
sg_free_table(sgt);
|
||||
err_sg:
|
||||
kfree(sgt);
|
||||
i = pages;
|
||||
err_pages:
|
||||
while (i--)
|
||||
put_page(usr_pgs[i]);
|
||||
return res;
|
||||
}
|
||||
|
||||
/**
|
||||
* user_to_dsp_unmap() - unmaps DSP virtual buffer.
|
||||
* @mmu: Pointer to iommu handle.
|
||||
* @da DSP address
|
||||
*
|
||||
* This function unmaps a user space buffer into DSP virtual address.
|
||||
*
|
||||
*/
|
||||
int user_to_dsp_unmap(struct iommu *mmu, u32 da)
|
||||
{
|
||||
unsigned i;
|
||||
struct sg_table *sgt;
|
||||
struct scatterlist *sg;
|
||||
|
||||
sgt = iommu_vunmap(mmu, da);
|
||||
if (!sgt)
|
||||
return -EFAULT;
|
||||
|
||||
for_each_sg(sgt->sgl, sg, sgt->nents, i)
|
||||
put_page(sg_page(sg));
|
||||
sg_free_table(sgt);
|
||||
kfree(sgt);
|
||||
|
||||
return 0;
|
||||
}
|
|
@ -39,6 +39,10 @@
|
|||
#include <dspbridge/ntfy.h>
|
||||
#include <dspbridge/sync.h>
|
||||
|
||||
/* Hardware Abstraction Layer */
|
||||
#include <hw_defs.h>
|
||||
#include <hw_mmu.h>
|
||||
|
||||
/* Bridge Driver */
|
||||
#include <dspbridge/dspdeh.h>
|
||||
#include <dspbridge/dspio.h>
|
||||
|
@ -287,7 +291,6 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
|
|||
struct cod_manager *cod_man;
|
||||
struct chnl_mgr *hchnl_mgr;
|
||||
struct msg_mgr *hmsg_mgr;
|
||||
struct shm_segs *sm_sg;
|
||||
u32 ul_shm_base;
|
||||
u32 ul_shm_base_offset;
|
||||
u32 ul_shm_limit;
|
||||
|
@ -310,9 +313,18 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
|
|||
struct bridge_ioctl_extproc ae_proc[BRDIOCTL_NUMOFMMUTLB];
|
||||
struct cfg_hostres *host_res;
|
||||
struct bridge_dev_context *pbridge_context;
|
||||
u32 map_attrs;
|
||||
u32 shm0_end;
|
||||
u32 ul_dyn_ext_base;
|
||||
u32 ul_seg1_size = 0;
|
||||
u32 pa_curr = 0;
|
||||
u32 va_curr = 0;
|
||||
u32 gpp_va_curr = 0;
|
||||
u32 num_bytes = 0;
|
||||
u32 all_bits = 0;
|
||||
u32 page_size[] = { HW_PAGE_SIZE16MB, HW_PAGE_SIZE1MB,
|
||||
HW_PAGE_SIZE64KB, HW_PAGE_SIZE4KB
|
||||
};
|
||||
|
||||
status = dev_get_bridge_context(hio_mgr->hdev_obj, &pbridge_context);
|
||||
if (!pbridge_context) {
|
||||
|
@ -325,8 +337,6 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
|
|||
status = -EFAULT;
|
||||
goto func_end;
|
||||
}
|
||||
sm_sg = &pbridge_context->sh_s;
|
||||
|
||||
status = dev_get_cod_mgr(hio_mgr->hdev_obj, &cod_man);
|
||||
if (!cod_man) {
|
||||
status = -EFAULT;
|
||||
|
@ -461,14 +471,129 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
|
|||
if (status)
|
||||
goto func_end;
|
||||
|
||||
sm_sg->seg1_pa = ul_gpp_pa;
|
||||
sm_sg->seg1_da = ul_dyn_ext_base;
|
||||
sm_sg->seg1_va = ul_gpp_va;
|
||||
sm_sg->seg1_size = ul_seg1_size;
|
||||
sm_sg->seg0_pa = ul_gpp_pa + ul_pad_size + ul_seg1_size;
|
||||
sm_sg->seg0_da = ul_dsp_va;
|
||||
sm_sg->seg0_va = ul_gpp_va + ul_pad_size + ul_seg1_size;
|
||||
sm_sg->seg0_size = ul_seg_size;
|
||||
pa_curr = ul_gpp_pa;
|
||||
va_curr = ul_dyn_ext_base * hio_mgr->word_size;
|
||||
gpp_va_curr = ul_gpp_va;
|
||||
num_bytes = ul_seg1_size;
|
||||
|
||||
/*
|
||||
* Try to fit into TLB entries. If not possible, push them to page
|
||||
* tables. It is quite possible that if sections are not on
|
||||
* bigger page boundary, we may end up making several small pages.
|
||||
* So, push them onto page tables, if that is the case.
|
||||
*/
|
||||
map_attrs = 0x00000000;
|
||||
map_attrs = DSP_MAPLITTLEENDIAN;
|
||||
map_attrs |= DSP_MAPPHYSICALADDR;
|
||||
map_attrs |= DSP_MAPELEMSIZE32;
|
||||
map_attrs |= DSP_MAPDONOTLOCK;
|
||||
|
||||
while (num_bytes) {
|
||||
/*
|
||||
* To find the max. page size with which both PA & VA are
|
||||
* aligned.
|
||||
*/
|
||||
all_bits = pa_curr | va_curr;
|
||||
dev_dbg(bridge, "all_bits %x, pa_curr %x, va_curr %x, "
|
||||
"num_bytes %x\n", all_bits, pa_curr, va_curr,
|
||||
num_bytes);
|
||||
for (i = 0; i < 4; i++) {
|
||||
if ((num_bytes >= page_size[i]) && ((all_bits &
|
||||
(page_size[i] -
|
||||
1)) == 0)) {
|
||||
status =
|
||||
hio_mgr->intf_fxns->
|
||||
pfn_brd_mem_map(hio_mgr->hbridge_context,
|
||||
pa_curr, va_curr,
|
||||
page_size[i], map_attrs,
|
||||
NULL);
|
||||
if (status)
|
||||
goto func_end;
|
||||
pa_curr += page_size[i];
|
||||
va_curr += page_size[i];
|
||||
gpp_va_curr += page_size[i];
|
||||
num_bytes -= page_size[i];
|
||||
/*
|
||||
* Don't try smaller sizes. Hopefully we have
|
||||
* reached an address aligned to a bigger page
|
||||
* size.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
pa_curr += ul_pad_size;
|
||||
va_curr += ul_pad_size;
|
||||
gpp_va_curr += ul_pad_size;
|
||||
|
||||
/* Configure the TLB entries for the next cacheable segment */
|
||||
num_bytes = ul_seg_size;
|
||||
va_curr = ul_dsp_va * hio_mgr->word_size;
|
||||
while (num_bytes) {
|
||||
/*
|
||||
* To find the max. page size with which both PA & VA are
|
||||
* aligned.
|
||||
*/
|
||||
all_bits = pa_curr | va_curr;
|
||||
dev_dbg(bridge, "all_bits for Seg1 %x, pa_curr %x, "
|
||||
"va_curr %x, num_bytes %x\n", all_bits, pa_curr,
|
||||
va_curr, num_bytes);
|
||||
for (i = 0; i < 4; i++) {
|
||||
if (!(num_bytes >= page_size[i]) ||
|
||||
!((all_bits & (page_size[i] - 1)) == 0))
|
||||
continue;
|
||||
if (ndx < MAX_LOCK_TLB_ENTRIES) {
|
||||
/*
|
||||
* This is the physical address written to
|
||||
* DSP MMU.
|
||||
*/
|
||||
ae_proc[ndx].ul_gpp_pa = pa_curr;
|
||||
/*
|
||||
* This is the virtual uncached ioremapped
|
||||
* address!!!
|
||||
*/
|
||||
ae_proc[ndx].ul_gpp_va = gpp_va_curr;
|
||||
ae_proc[ndx].ul_dsp_va =
|
||||
va_curr / hio_mgr->word_size;
|
||||
ae_proc[ndx].ul_size = page_size[i];
|
||||
ae_proc[ndx].endianism = HW_LITTLE_ENDIAN;
|
||||
ae_proc[ndx].elem_size = HW_ELEM_SIZE16BIT;
|
||||
ae_proc[ndx].mixed_mode = HW_MMU_CPUES;
|
||||
dev_dbg(bridge, "shm MMU TLB entry PA %x"
|
||||
" VA %x DSP_VA %x Size %x\n",
|
||||
ae_proc[ndx].ul_gpp_pa,
|
||||
ae_proc[ndx].ul_gpp_va,
|
||||
ae_proc[ndx].ul_dsp_va *
|
||||
hio_mgr->word_size, page_size[i]);
|
||||
ndx++;
|
||||
} else {
|
||||
status =
|
||||
hio_mgr->intf_fxns->
|
||||
pfn_brd_mem_map(hio_mgr->hbridge_context,
|
||||
pa_curr, va_curr,
|
||||
page_size[i], map_attrs,
|
||||
NULL);
|
||||
dev_dbg(bridge,
|
||||
"shm MMU PTE entry PA %x"
|
||||
" VA %x DSP_VA %x Size %x\n",
|
||||
ae_proc[ndx].ul_gpp_pa,
|
||||
ae_proc[ndx].ul_gpp_va,
|
||||
ae_proc[ndx].ul_dsp_va *
|
||||
hio_mgr->word_size, page_size[i]);
|
||||
if (status)
|
||||
goto func_end;
|
||||
}
|
||||
pa_curr += page_size[i];
|
||||
va_curr += page_size[i];
|
||||
gpp_va_curr += page_size[i];
|
||||
num_bytes -= page_size[i];
|
||||
/*
|
||||
* Don't try smaller sizes. Hopefully we have reached
|
||||
* an address aligned to a bigger page size.
|
||||
*/
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
* Copy remaining entries from CDB. All entries are 1 MB and
|
||||
|
@ -509,12 +634,38 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
|
|||
"DSP_VA 0x%x\n", ae_proc[ndx].ul_gpp_pa,
|
||||
ae_proc[ndx].ul_dsp_va);
|
||||
ndx++;
|
||||
} else {
|
||||
status = hio_mgr->intf_fxns->pfn_brd_mem_map
|
||||
(hio_mgr->hbridge_context,
|
||||
hio_mgr->ext_proc_info.ty_tlb[i].
|
||||
ul_gpp_phys,
|
||||
hio_mgr->ext_proc_info.ty_tlb[i].
|
||||
ul_dsp_virt, 0x100000, map_attrs,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
if (status)
|
||||
goto func_end;
|
||||
}
|
||||
|
||||
map_attrs = 0x00000000;
|
||||
map_attrs = DSP_MAPLITTLEENDIAN;
|
||||
map_attrs |= DSP_MAPPHYSICALADDR;
|
||||
map_attrs |= DSP_MAPELEMSIZE32;
|
||||
map_attrs |= DSP_MAPDONOTLOCK;
|
||||
|
||||
/* Map the L4 peripherals */
|
||||
i = 0;
|
||||
while (l4_peripheral_table[i].phys_addr) {
|
||||
status = hio_mgr->intf_fxns->pfn_brd_mem_map
|
||||
(hio_mgr->hbridge_context, l4_peripheral_table[i].phys_addr,
|
||||
l4_peripheral_table[i].dsp_virt_addr, HW_PAGE_SIZE4KB,
|
||||
map_attrs, NULL);
|
||||
if (status)
|
||||
goto func_end;
|
||||
i++;
|
||||
}
|
||||
|
||||
for (i = ndx; i < BRDIOCTL_NUMOFMMUTLB; i++) {
|
||||
ae_proc[i].ul_dsp_va = 0;
|
||||
ae_proc[i].ul_gpp_pa = 0;
|
||||
|
@ -537,12 +688,12 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
|
|||
status = -EFAULT;
|
||||
goto func_end;
|
||||
} else {
|
||||
if (sm_sg->seg0_da > ul_shm_base) {
|
||||
if (ae_proc[0].ul_dsp_va > ul_shm_base) {
|
||||
status = -EPERM;
|
||||
goto func_end;
|
||||
}
|
||||
/* ul_shm_base may not be at ul_dsp_va address */
|
||||
ul_shm_base_offset = (ul_shm_base - sm_sg->seg0_da) *
|
||||
ul_shm_base_offset = (ul_shm_base - ae_proc[0].ul_dsp_va) *
|
||||
hio_mgr->word_size;
|
||||
/*
|
||||
* bridge_dev_ctrl() will set dev context dsp-mmu info. In
|
||||
|
@ -566,7 +717,8 @@ int bridge_io_on_loaded(struct io_mgr *hio_mgr)
|
|||
goto func_end;
|
||||
}
|
||||
/* Register SM */
|
||||
status = register_shm_segs(hio_mgr, cod_man, sm_sg->seg0_pa);
|
||||
status =
|
||||
register_shm_segs(hio_mgr, cod_man, ae_proc[0].ul_gpp_pa);
|
||||
}
|
||||
|
||||
hio_mgr->shared_mem = (struct shm *)ul_shm_base;
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -31,6 +31,10 @@
|
|||
#include <dspbridge/dev.h>
|
||||
#include <dspbridge/iodefs.h>
|
||||
|
||||
/* ------------------------------------ Hardware Abstraction Layer */
|
||||
#include <hw_defs.h>
|
||||
#include <hw_mmu.h>
|
||||
|
||||
#include <dspbridge/pwr_sh.h>
|
||||
|
||||
/* ----------------------------------- Bridge Driver */
|
||||
|
|
|
@ -134,16 +134,17 @@ int read_ext_dsp_data(struct bridge_dev_context *dev_ctxt,
|
|||
|
||||
if (!status) {
|
||||
ul_tlb_base_virt =
|
||||
dev_context->sh_s.seg0_da * DSPWORDSIZE;
|
||||
dev_context->atlb_entry[0].ul_dsp_va * DSPWORDSIZE;
|
||||
DBC_ASSERT(ul_tlb_base_virt <= ul_shm_base_virt);
|
||||
dw_ext_prog_virt_mem = dev_context->sh_s.seg0_va;
|
||||
dw_ext_prog_virt_mem =
|
||||
dev_context->atlb_entry[0].ul_gpp_va;
|
||||
|
||||
if (!trace_read) {
|
||||
ul_shm_offset_virt =
|
||||
ul_shm_base_virt - ul_tlb_base_virt;
|
||||
ul_shm_offset_virt +=
|
||||
PG_ALIGN_HIGH(ul_ext_end - ul_dyn_ext_base +
|
||||
1, PAGE_SIZE * 16);
|
||||
1, HW_PAGE_SIZE64KB);
|
||||
dw_ext_prog_virt_mem -= ul_shm_offset_virt;
|
||||
dw_ext_prog_virt_mem +=
|
||||
(ul_ext_base - ul_dyn_ext_base);
|
||||
|
@ -317,9 +318,8 @@ int write_ext_dsp_data(struct bridge_dev_context *dev_context,
|
|||
ret = -EPERM;
|
||||
|
||||
if (!ret) {
|
||||
ul_tlb_base_virt = dev_context->sh_s.seg0_da *
|
||||
DSPWORDSIZE;
|
||||
|
||||
ul_tlb_base_virt =
|
||||
dev_context->atlb_entry[0].ul_dsp_va * DSPWORDSIZE;
|
||||
DBC_ASSERT(ul_tlb_base_virt <= ul_shm_base_virt);
|
||||
|
||||
if (symbols_reloaded) {
|
||||
|
@ -337,7 +337,7 @@ int write_ext_dsp_data(struct bridge_dev_context *dev_context,
|
|||
ul_shm_base_virt - ul_tlb_base_virt;
|
||||
if (trace_load) {
|
||||
dw_ext_prog_virt_mem =
|
||||
dev_context->sh_s.seg0_va;
|
||||
dev_context->atlb_entry[0].ul_gpp_va;
|
||||
} else {
|
||||
dw_ext_prog_virt_mem = host_res->dw_mem_base[1];
|
||||
dw_ext_prog_virt_mem +=
|
||||
|
@ -393,6 +393,7 @@ int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val)
|
|||
omap_dspbridge_dev->dev.platform_data;
|
||||
struct cfg_hostres *resources = dev_context->resources;
|
||||
int status = 0;
|
||||
u32 temp;
|
||||
|
||||
if (!dev_context->mbox)
|
||||
return 0;
|
||||
|
@ -436,7 +437,7 @@ int sm_interrupt_dsp(struct bridge_dev_context *dev_context, u16 mb_val)
|
|||
omap_mbox_restore_ctx(dev_context->mbox);
|
||||
|
||||
/* Access MMU SYS CONFIG register to generate a short wakeup */
|
||||
iommu_read_reg(dev_context->dsp_mmu, MMU_SYSCONFIG);
|
||||
temp = readl(resources->dw_dmmu_base + 0x10);
|
||||
|
||||
dev_context->dw_brd_state = BRD_RUNNING;
|
||||
} else if (dev_context->dw_brd_state == BRD_RETENTION) {
|
||||
|
|
|
@ -31,6 +31,57 @@
|
|||
#include <dspbridge/drv.h>
|
||||
#include <dspbridge/wdt.h>
|
||||
|
||||
static u32 fault_addr;
|
||||
|
||||
static void mmu_fault_dpc(unsigned long data)
|
||||
{
|
||||
struct deh_mgr *deh = (void *)data;
|
||||
|
||||
if (!deh)
|
||||
return;
|
||||
|
||||
bridge_deh_notify(deh, DSP_MMUFAULT, 0);
|
||||
}
|
||||
|
||||
static irqreturn_t mmu_fault_isr(int irq, void *data)
|
||||
{
|
||||
struct deh_mgr *deh = data;
|
||||
struct cfg_hostres *resources;
|
||||
u32 event;
|
||||
|
||||
if (!deh)
|
||||
return IRQ_HANDLED;
|
||||
|
||||
resources = deh->hbridge_context->resources;
|
||||
if (!resources) {
|
||||
dev_dbg(bridge, "%s: Failed to get Host Resources\n",
|
||||
__func__);
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
hw_mmu_event_status(resources->dw_dmmu_base, &event);
|
||||
if (event == HW_MMU_TRANSLATION_FAULT) {
|
||||
hw_mmu_fault_addr_read(resources->dw_dmmu_base, &fault_addr);
|
||||
dev_dbg(bridge, "%s: event=0x%x, fault_addr=0x%x\n", __func__,
|
||||
event, fault_addr);
|
||||
/*
|
||||
* Schedule a DPC directly. In the future, it may be
|
||||
* necessary to check if DSP MMU fault is intended for
|
||||
* Bridge.
|
||||
*/
|
||||
tasklet_schedule(&deh->dpc_tasklet);
|
||||
|
||||
/* Disable the MMU events, else once we clear it will
|
||||
* start to raise INTs again */
|
||||
hw_mmu_event_disable(resources->dw_dmmu_base,
|
||||
HW_MMU_TRANSLATION_FAULT);
|
||||
} else {
|
||||
hw_mmu_event_disable(resources->dw_dmmu_base,
|
||||
HW_MMU_ALL_INTERRUPTS);
|
||||
}
|
||||
return IRQ_HANDLED;
|
||||
}
|
||||
|
||||
int bridge_deh_create(struct deh_mgr **ret_deh,
|
||||
struct dev_object *hdev_obj)
|
||||
{
|
||||
|
@ -58,9 +109,18 @@ int bridge_deh_create(struct deh_mgr **ret_deh,
|
|||
}
|
||||
ntfy_init(deh->ntfy_obj);
|
||||
|
||||
/* Create a MMUfault DPC */
|
||||
tasklet_init(&deh->dpc_tasklet, mmu_fault_dpc, (u32) deh);
|
||||
|
||||
/* Fill in context structure */
|
||||
deh->hbridge_context = hbridge_context;
|
||||
|
||||
/* Install ISR function for DSP MMU fault */
|
||||
status = request_irq(INT_DSP_MMU_IRQ, mmu_fault_isr, 0,
|
||||
"DspBridge\tiommu fault", deh);
|
||||
if (status < 0)
|
||||
goto err;
|
||||
|
||||
*ret_deh = deh;
|
||||
return 0;
|
||||
|
||||
|
@ -80,6 +140,11 @@ int bridge_deh_destroy(struct deh_mgr *deh)
|
|||
ntfy_delete(deh->ntfy_obj);
|
||||
kfree(deh->ntfy_obj);
|
||||
}
|
||||
/* Disable DSP MMU fault */
|
||||
free_irq(INT_DSP_MMU_IRQ, deh);
|
||||
|
||||
/* Free DPC object */
|
||||
tasklet_kill(&deh->dpc_tasklet);
|
||||
|
||||
/* Deallocate the DEH manager object */
|
||||
kfree(deh);
|
||||
|
@ -101,6 +166,48 @@ int bridge_deh_register_notify(struct deh_mgr *deh, u32 event_mask,
|
|||
return ntfy_unregister(deh->ntfy_obj, hnotification);
|
||||
}
|
||||
|
||||
#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
|
||||
static void mmu_fault_print_stack(struct bridge_dev_context *dev_context)
|
||||
{
|
||||
struct cfg_hostres *resources;
|
||||
struct hw_mmu_map_attrs_t map_attrs = {
|
||||
.endianism = HW_LITTLE_ENDIAN,
|
||||
.element_size = HW_ELEM_SIZE16BIT,
|
||||
.mixed_size = HW_MMU_CPUES,
|
||||
};
|
||||
void *dummy_va_addr;
|
||||
|
||||
resources = dev_context->resources;
|
||||
dummy_va_addr = (void*)__get_free_page(GFP_ATOMIC);
|
||||
|
||||
/*
|
||||
* Before acking the MMU fault, let's make sure MMU can only
|
||||
* access entry #0. Then add a new entry so that the DSP OS
|
||||
* can continue in order to dump the stack.
|
||||
*/
|
||||
hw_mmu_twl_disable(resources->dw_dmmu_base);
|
||||
hw_mmu_tlb_flush_all(resources->dw_dmmu_base);
|
||||
|
||||
hw_mmu_tlb_add(resources->dw_dmmu_base,
|
||||
virt_to_phys(dummy_va_addr), fault_addr,
|
||||
HW_PAGE_SIZE4KB, 1,
|
||||
&map_attrs, HW_SET, HW_SET);
|
||||
|
||||
dsp_clk_enable(DSP_CLK_GPT8);
|
||||
|
||||
dsp_gpt_wait_overflow(DSP_CLK_GPT8, 0xfffffffe);
|
||||
|
||||
/* Clear MMU interrupt */
|
||||
hw_mmu_event_ack(resources->dw_dmmu_base,
|
||||
HW_MMU_TRANSLATION_FAULT);
|
||||
dump_dsp_stack(dev_context);
|
||||
dsp_clk_disable(DSP_CLK_GPT8);
|
||||
|
||||
hw_mmu_disable(resources->dw_dmmu_base);
|
||||
free_page((unsigned long)dummy_va_addr);
|
||||
}
|
||||
#endif
|
||||
|
||||
static inline const char *event_to_string(int event)
|
||||
{
|
||||
switch (event) {
|
||||
|
@ -133,7 +240,13 @@ void bridge_deh_notify(struct deh_mgr *deh, int event, int info)
|
|||
#endif
|
||||
break;
|
||||
case DSP_MMUFAULT:
|
||||
dev_err(bridge, "%s: %s, addr=0x%x", __func__, str, info);
|
||||
dev_err(bridge, "%s: %s, addr=0x%x", __func__,
|
||||
str, fault_addr);
|
||||
#ifdef CONFIG_TIDSPBRIDGE_BACKTRACE
|
||||
print_dsp_trace_buffer(dev_context);
|
||||
dump_dl_modules(dev_context);
|
||||
mmu_fault_print_stack(dev_context);
|
||||
#endif
|
||||
break;
|
||||
default:
|
||||
dev_err(bridge, "%s: %s", __func__, str);
|
||||
|
|
|
@ -0,0 +1,41 @@
|
|||
/*
|
||||
* EasiGlobal.h
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* Copyright (C) 2007 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef _EASIGLOBAL_H
|
||||
#define _EASIGLOBAL_H
|
||||
#include <linux/types.h>
|
||||
|
||||
/*
|
||||
* DEFINE: READ_ONLY, WRITE_ONLY & READ_WRITE
|
||||
*
|
||||
* DESCRIPTION: Defines used to describe register types for EASI-checker tests.
|
||||
*/
|
||||
|
||||
#define READ_ONLY 1
|
||||
#define WRITE_ONLY 2
|
||||
#define READ_WRITE 3
|
||||
|
||||
/*
|
||||
* MACRO: _DEBUG_LEVEL1_EASI
|
||||
*
|
||||
* DESCRIPTION: A MACRO which can be used to indicate that a particular beach
|
||||
* register access function was called.
|
||||
*
|
||||
* NOTE: We currently dont use this functionality.
|
||||
*/
|
||||
#define _DEBUG_LEVEL1_EASI(easi_num) ((void)0)
|
||||
|
||||
#endif /* _EASIGLOBAL_H */
|
|
@ -0,0 +1,76 @@
|
|||
/*
|
||||
* MMUAccInt.h
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* Copyright (C) 2007 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef _MMU_ACC_INT_H
|
||||
#define _MMU_ACC_INT_H
|
||||
|
||||
/* Mappings of level 1 EASI function numbers to function names */
|
||||
|
||||
#define EASIL1_MMUMMU_SYSCONFIG_READ_REGISTER32 (MMU_BASE_EASIL1 + 3)
|
||||
#define EASIL1_MMUMMU_SYSCONFIG_IDLE_MODE_WRITE32 (MMU_BASE_EASIL1 + 17)
|
||||
#define EASIL1_MMUMMU_SYSCONFIG_AUTO_IDLE_WRITE32 (MMU_BASE_EASIL1 + 39)
|
||||
#define EASIL1_MMUMMU_IRQSTATUS_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 51)
|
||||
#define EASIL1_MMUMMU_IRQENABLE_READ_REGISTER32 (MMU_BASE_EASIL1 + 102)
|
||||
#define EASIL1_MMUMMU_IRQENABLE_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 103)
|
||||
#define EASIL1_MMUMMU_WALKING_STTWL_RUNNING_READ32 (MMU_BASE_EASIL1 + 156)
|
||||
#define EASIL1_MMUMMU_CNTLTWL_ENABLE_READ32 (MMU_BASE_EASIL1 + 174)
|
||||
#define EASIL1_MMUMMU_CNTLTWL_ENABLE_WRITE32 (MMU_BASE_EASIL1 + 180)
|
||||
#define EASIL1_MMUMMU_CNTLMMU_ENABLE_WRITE32 (MMU_BASE_EASIL1 + 190)
|
||||
#define EASIL1_MMUMMU_FAULT_AD_READ_REGISTER32 (MMU_BASE_EASIL1 + 194)
|
||||
#define EASIL1_MMUMMU_TTB_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 198)
|
||||
#define EASIL1_MMUMMU_LOCK_READ_REGISTER32 (MMU_BASE_EASIL1 + 203)
|
||||
#define EASIL1_MMUMMU_LOCK_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 204)
|
||||
#define EASIL1_MMUMMU_LOCK_BASE_VALUE_READ32 (MMU_BASE_EASIL1 + 205)
|
||||
#define EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_READ32 (MMU_BASE_EASIL1 + 209)
|
||||
#define EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_WRITE32 (MMU_BASE_EASIL1 + 211)
|
||||
#define EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_SET32 (MMU_BASE_EASIL1 + 212)
|
||||
#define EASIL1_MMUMMU_LD_TLB_READ_REGISTER32 (MMU_BASE_EASIL1 + 213)
|
||||
#define EASIL1_MMUMMU_LD_TLB_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 214)
|
||||
#define EASIL1_MMUMMU_CAM_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 226)
|
||||
#define EASIL1_MMUMMU_RAM_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 268)
|
||||
#define EASIL1_MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32 (MMU_BASE_EASIL1 + 322)
|
||||
|
||||
/* Register offset address definitions */
|
||||
#define MMU_MMU_SYSCONFIG_OFFSET 0x10
|
||||
#define MMU_MMU_IRQSTATUS_OFFSET 0x18
|
||||
#define MMU_MMU_IRQENABLE_OFFSET 0x1c
|
||||
#define MMU_MMU_WALKING_ST_OFFSET 0x40
|
||||
#define MMU_MMU_CNTL_OFFSET 0x44
|
||||
#define MMU_MMU_FAULT_AD_OFFSET 0x48
|
||||
#define MMU_MMU_TTB_OFFSET 0x4c
|
||||
#define MMU_MMU_LOCK_OFFSET 0x50
|
||||
#define MMU_MMU_LD_TLB_OFFSET 0x54
|
||||
#define MMU_MMU_CAM_OFFSET 0x58
|
||||
#define MMU_MMU_RAM_OFFSET 0x5c
|
||||
#define MMU_MMU_GFLUSH_OFFSET 0x60
|
||||
#define MMU_MMU_FLUSH_ENTRY_OFFSET 0x64
|
||||
/* Bitfield mask and offset declarations */
|
||||
#define MMU_MMU_SYSCONFIG_IDLE_MODE_MASK 0x18
|
||||
#define MMU_MMU_SYSCONFIG_IDLE_MODE_OFFSET 3
|
||||
#define MMU_MMU_SYSCONFIG_AUTO_IDLE_MASK 0x1
|
||||
#define MMU_MMU_SYSCONFIG_AUTO_IDLE_OFFSET 0
|
||||
#define MMU_MMU_WALKING_ST_TWL_RUNNING_MASK 0x1
|
||||
#define MMU_MMU_WALKING_ST_TWL_RUNNING_OFFSET 0
|
||||
#define MMU_MMU_CNTL_TWL_ENABLE_MASK 0x4
|
||||
#define MMU_MMU_CNTL_TWL_ENABLE_OFFSET 2
|
||||
#define MMU_MMU_CNTL_MMU_ENABLE_MASK 0x2
|
||||
#define MMU_MMU_CNTL_MMU_ENABLE_OFFSET 1
|
||||
#define MMU_MMU_LOCK_BASE_VALUE_MASK 0xfc00
|
||||
#define MMU_MMU_LOCK_BASE_VALUE_OFFSET 10
|
||||
#define MMU_MMU_LOCK_CURRENT_VICTIM_MASK 0x3f0
|
||||
#define MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET 4
|
||||
|
||||
#endif /* _MMU_ACC_INT_H */
|
|
@ -0,0 +1,225 @@
|
|||
/*
|
||||
* MMURegAcM.h
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* Copyright (C) 2007 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef _MMU_REG_ACM_H
|
||||
#define _MMU_REG_ACM_H
|
||||
|
||||
#include <linux/io.h>
|
||||
#include <EasiGlobal.h>
|
||||
|
||||
#include "MMUAccInt.h"
|
||||
|
||||
#if defined(USE_LEVEL_1_MACROS)
|
||||
|
||||
#define MMUMMU_SYSCONFIG_READ_REGISTER32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_SYSCONFIG_READ_REGISTER32),\
|
||||
__raw_readl((base_address)+MMU_MMU_SYSCONFIG_OFFSET))
|
||||
|
||||
#define MMUMMU_SYSCONFIG_IDLE_MODE_WRITE32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_SYSCONFIG_OFFSET;\
|
||||
register u32 data = __raw_readl((base_address)+offset);\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_SYSCONFIG_IDLE_MODE_WRITE32);\
|
||||
data &= ~(MMU_MMU_SYSCONFIG_IDLE_MODE_MASK);\
|
||||
new_value <<= MMU_MMU_SYSCONFIG_IDLE_MODE_OFFSET;\
|
||||
new_value &= MMU_MMU_SYSCONFIG_IDLE_MODE_MASK;\
|
||||
new_value |= data;\
|
||||
__raw_writel(new_value, base_address+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_SYSCONFIG_AUTO_IDLE_WRITE32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_SYSCONFIG_OFFSET;\
|
||||
register u32 data = __raw_readl((base_address)+offset);\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_SYSCONFIG_AUTO_IDLE_WRITE32);\
|
||||
data &= ~(MMU_MMU_SYSCONFIG_AUTO_IDLE_MASK);\
|
||||
new_value <<= MMU_MMU_SYSCONFIG_AUTO_IDLE_OFFSET;\
|
||||
new_value &= MMU_MMU_SYSCONFIG_AUTO_IDLE_MASK;\
|
||||
new_value |= data;\
|
||||
__raw_writel(new_value, base_address+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_IRQSTATUS_READ_REGISTER32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(easil1_mmummu_irqstatus_read_register32),\
|
||||
__raw_readl((base_address)+MMU_MMU_IRQSTATUS_OFFSET))
|
||||
|
||||
#define MMUMMU_IRQSTATUS_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_IRQSTATUS_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_IRQSTATUS_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_IRQENABLE_READ_REGISTER32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_IRQENABLE_READ_REGISTER32),\
|
||||
__raw_readl((base_address)+MMU_MMU_IRQENABLE_OFFSET))
|
||||
|
||||
#define MMUMMU_IRQENABLE_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_IRQENABLE_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_IRQENABLE_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_WALKING_STTWL_RUNNING_READ32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_WALKING_STTWL_RUNNING_READ32),\
|
||||
(((__raw_readl(((base_address)+(MMU_MMU_WALKING_ST_OFFSET))))\
|
||||
& MMU_MMU_WALKING_ST_TWL_RUNNING_MASK) >>\
|
||||
MMU_MMU_WALKING_ST_TWL_RUNNING_OFFSET))
|
||||
|
||||
#define MMUMMU_CNTLTWL_ENABLE_READ32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CNTLTWL_ENABLE_READ32),\
|
||||
(((__raw_readl(((base_address)+(MMU_MMU_CNTL_OFFSET)))) &\
|
||||
MMU_MMU_CNTL_TWL_ENABLE_MASK) >>\
|
||||
MMU_MMU_CNTL_TWL_ENABLE_OFFSET))
|
||||
|
||||
#define MMUMMU_CNTLTWL_ENABLE_WRITE32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_CNTL_OFFSET;\
|
||||
register u32 data = __raw_readl((base_address)+offset);\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CNTLTWL_ENABLE_WRITE32);\
|
||||
data &= ~(MMU_MMU_CNTL_TWL_ENABLE_MASK);\
|
||||
new_value <<= MMU_MMU_CNTL_TWL_ENABLE_OFFSET;\
|
||||
new_value &= MMU_MMU_CNTL_TWL_ENABLE_MASK;\
|
||||
new_value |= data;\
|
||||
__raw_writel(new_value, base_address+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_CNTLMMU_ENABLE_WRITE32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_CNTL_OFFSET;\
|
||||
register u32 data = __raw_readl((base_address)+offset);\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CNTLMMU_ENABLE_WRITE32);\
|
||||
data &= ~(MMU_MMU_CNTL_MMU_ENABLE_MASK);\
|
||||
new_value <<= MMU_MMU_CNTL_MMU_ENABLE_OFFSET;\
|
||||
new_value &= MMU_MMU_CNTL_MMU_ENABLE_MASK;\
|
||||
new_value |= data;\
|
||||
__raw_writel(new_value, base_address+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_FAULT_AD_READ_REGISTER32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_FAULT_AD_READ_REGISTER32),\
|
||||
__raw_readl((base_address)+MMU_MMU_FAULT_AD_OFFSET))
|
||||
|
||||
#define MMUMMU_TTB_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_TTB_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_TTB_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_LOCK_READ_REGISTER32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_READ_REGISTER32),\
|
||||
__raw_readl((base_address)+MMU_MMU_LOCK_OFFSET))
|
||||
|
||||
#define MMUMMU_LOCK_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_LOCK_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_LOCK_BASE_VALUE_READ32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_BASE_VALUE_READ32),\
|
||||
(((__raw_readl(((base_address)+(MMU_MMU_LOCK_OFFSET)))) &\
|
||||
MMU_MMU_LOCK_BASE_VALUE_MASK) >>\
|
||||
MMU_MMU_LOCK_BASE_VALUE_OFFSET))
|
||||
|
||||
#define MMUMMU_LOCK_BASE_VALUE_WRITE32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_LOCK_OFFSET;\
|
||||
register u32 data = __raw_readl((base_address)+offset);\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(easil1_mmummu_lock_base_value_write32);\
|
||||
data &= ~(MMU_MMU_LOCK_BASE_VALUE_MASK);\
|
||||
new_value <<= MMU_MMU_LOCK_BASE_VALUE_OFFSET;\
|
||||
new_value &= MMU_MMU_LOCK_BASE_VALUE_MASK;\
|
||||
new_value |= data;\
|
||||
__raw_writel(new_value, base_address+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_LOCK_CURRENT_VICTIM_READ32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_READ32),\
|
||||
(((__raw_readl(((base_address)+(MMU_MMU_LOCK_OFFSET)))) &\
|
||||
MMU_MMU_LOCK_CURRENT_VICTIM_MASK) >>\
|
||||
MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET))
|
||||
|
||||
#define MMUMMU_LOCK_CURRENT_VICTIM_WRITE32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_LOCK_OFFSET;\
|
||||
register u32 data = __raw_readl((base_address)+offset);\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_WRITE32);\
|
||||
data &= ~(MMU_MMU_LOCK_CURRENT_VICTIM_MASK);\
|
||||
new_value <<= MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET;\
|
||||
new_value &= MMU_MMU_LOCK_CURRENT_VICTIM_MASK;\
|
||||
new_value |= data;\
|
||||
__raw_writel(new_value, base_address+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_LOCK_CURRENT_VICTIM_SET32(var, value)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LOCK_CURRENT_VICTIM_SET32),\
|
||||
(((var) & ~(MMU_MMU_LOCK_CURRENT_VICTIM_MASK)) |\
|
||||
(((value) << MMU_MMU_LOCK_CURRENT_VICTIM_OFFSET) &\
|
||||
MMU_MMU_LOCK_CURRENT_VICTIM_MASK)))
|
||||
|
||||
#define MMUMMU_LD_TLB_READ_REGISTER32(base_address)\
|
||||
(_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LD_TLB_READ_REGISTER32),\
|
||||
__raw_readl((base_address)+MMU_MMU_LD_TLB_OFFSET))
|
||||
|
||||
#define MMUMMU_LD_TLB_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_LD_TLB_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_LD_TLB_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_CAM_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_CAM_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_CAM_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_RAM_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_RAM_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_RAM_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#define MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32(base_address, value)\
|
||||
{\
|
||||
const u32 offset = MMU_MMU_FLUSH_ENTRY_OFFSET;\
|
||||
register u32 new_value = (value);\
|
||||
_DEBUG_LEVEL1_EASI(EASIL1_MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32);\
|
||||
__raw_writel(new_value, (base_address)+offset);\
|
||||
}
|
||||
|
||||
#endif /* USE_LEVEL_1_MACROS */
|
||||
|
||||
#endif /* _MMU_REG_ACM_H */
|
|
@ -0,0 +1,58 @@
|
|||
/*
|
||||
* hw_defs.h
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* Global HW definitions
|
||||
*
|
||||
* Copyright (C) 2007 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef _HW_DEFS_H
|
||||
#define _HW_DEFS_H
|
||||
|
||||
/* Page size */
|
||||
#define HW_PAGE_SIZE4KB 0x1000
|
||||
#define HW_PAGE_SIZE64KB 0x10000
|
||||
#define HW_PAGE_SIZE1MB 0x100000
|
||||
#define HW_PAGE_SIZE16MB 0x1000000
|
||||
|
||||
/* hw_status: return type for HW API */
|
||||
typedef long hw_status;
|
||||
|
||||
/* Macro used to set and clear any bit */
|
||||
#define HW_CLEAR 0
|
||||
#define HW_SET 1
|
||||
|
||||
/* hw_endianism_t: Enumerated Type used to specify the endianism
|
||||
* Do NOT change these values. They are used as bit fields. */
|
||||
enum hw_endianism_t {
|
||||
HW_LITTLE_ENDIAN,
|
||||
HW_BIG_ENDIAN
|
||||
};
|
||||
|
||||
/* hw_element_size_t: Enumerated Type used to specify the element size
|
||||
* Do NOT change these values. They are used as bit fields. */
|
||||
enum hw_element_size_t {
|
||||
HW_ELEM_SIZE8BIT,
|
||||
HW_ELEM_SIZE16BIT,
|
||||
HW_ELEM_SIZE32BIT,
|
||||
HW_ELEM_SIZE64BIT
|
||||
};
|
||||
|
||||
/* hw_idle_mode_t: Enumerated Type used to specify Idle modes */
|
||||
enum hw_idle_mode_t {
|
||||
HW_FORCE_IDLE,
|
||||
HW_NO_IDLE,
|
||||
HW_SMART_IDLE
|
||||
};
|
||||
|
||||
#endif /* _HW_DEFS_H */
|
|
@ -0,0 +1,562 @@
|
|||
/*
|
||||
* hw_mmu.c
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* API definitions to setup MMU TLB and PTE
|
||||
*
|
||||
* Copyright (C) 2007 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#include <linux/io.h>
|
||||
#include "MMURegAcM.h"
|
||||
#include <hw_defs.h>
|
||||
#include <hw_mmu.h>
|
||||
#include <linux/types.h>
|
||||
#include <linux/err.h>
|
||||
|
||||
#define MMU_BASE_VAL_MASK 0xFC00
|
||||
#define MMU_PAGE_MAX 3
|
||||
#define MMU_ELEMENTSIZE_MAX 3
|
||||
#define MMU_ADDR_MASK 0xFFFFF000
|
||||
#define MMU_TTB_MASK 0xFFFFC000
|
||||
#define MMU_SECTION_ADDR_MASK 0xFFF00000
|
||||
#define MMU_SSECTION_ADDR_MASK 0xFF000000
|
||||
#define MMU_PAGE_TABLE_MASK 0xFFFFFC00
|
||||
#define MMU_LARGE_PAGE_MASK 0xFFFF0000
|
||||
#define MMU_SMALL_PAGE_MASK 0xFFFFF000
|
||||
|
||||
#define MMU_LOAD_TLB 0x00000001
|
||||
#define MMU_GFLUSH 0x60
|
||||
|
||||
/*
|
||||
* hw_mmu_page_size_t: Enumerated Type used to specify the MMU Page Size(SLSS)
|
||||
*/
|
||||
enum hw_mmu_page_size_t {
|
||||
HW_MMU_SECTION,
|
||||
HW_MMU_LARGE_PAGE,
|
||||
HW_MMU_SMALL_PAGE,
|
||||
HW_MMU_SUPERSECTION
|
||||
};
|
||||
|
||||
/*
|
||||
* FUNCTION : mmu_flush_entry
|
||||
*
|
||||
* INPUTS:
|
||||
*
|
||||
* Identifier : base_address
|
||||
* Type : const u32
|
||||
* Description : Base Address of instance of MMU module
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* Type : hw_status
|
||||
* Description : 0 -- No errors occured
|
||||
* RET_BAD_NULL_PARAM -- A Pointer
|
||||
* Paramater was set to NULL
|
||||
*
|
||||
* PURPOSE: : Flush the TLB entry pointed by the
|
||||
* lock counter register
|
||||
* even if this entry is set protected
|
||||
*
|
||||
* METHOD: : Check the Input parameter and Flush a
|
||||
* single entry in the TLB.
|
||||
*/
|
||||
static hw_status mmu_flush_entry(const void __iomem *base_address);
|
||||
|
||||
/*
|
||||
* FUNCTION : mmu_set_cam_entry
|
||||
*
|
||||
* INPUTS:
|
||||
*
|
||||
* Identifier : base_address
|
||||
* TypE : const u32
|
||||
* Description : Base Address of instance of MMU module
|
||||
*
|
||||
* Identifier : page_sz
|
||||
* TypE : const u32
|
||||
* Description : It indicates the page size
|
||||
*
|
||||
* Identifier : preserved_bit
|
||||
* Type : const u32
|
||||
* Description : It indicates the TLB entry is preserved entry
|
||||
* or not
|
||||
*
|
||||
* Identifier : valid_bit
|
||||
* Type : const u32
|
||||
* Description : It indicates the TLB entry is valid entry or not
|
||||
*
|
||||
*
|
||||
* Identifier : virtual_addr_tag
|
||||
* Type : const u32
|
||||
* Description : virtual Address
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* Type : hw_status
|
||||
* Description : 0 -- No errors occured
|
||||
* RET_BAD_NULL_PARAM -- A Pointer Paramater
|
||||
* was set to NULL
|
||||
* RET_PARAM_OUT_OF_RANGE -- Input Parameter out
|
||||
* of Range
|
||||
*
|
||||
* PURPOSE: : Set MMU_CAM reg
|
||||
*
|
||||
* METHOD: : Check the Input parameters and set the CAM entry.
|
||||
*/
|
||||
static hw_status mmu_set_cam_entry(const void __iomem *base_address,
|
||||
const u32 page_sz,
|
||||
const u32 preserved_bit,
|
||||
const u32 valid_bit,
|
||||
const u32 virtual_addr_tag);
|
||||
|
||||
/*
|
||||
* FUNCTION : mmu_set_ram_entry
|
||||
*
|
||||
* INPUTS:
|
||||
*
|
||||
* Identifier : base_address
|
||||
* Type : const u32
|
||||
* Description : Base Address of instance of MMU module
|
||||
*
|
||||
* Identifier : physical_addr
|
||||
* Type : const u32
|
||||
* Description : Physical Address to which the corresponding
|
||||
* virtual Address shouldpoint
|
||||
*
|
||||
* Identifier : endianism
|
||||
* Type : hw_endianism_t
|
||||
* Description : endianism for the given page
|
||||
*
|
||||
* Identifier : element_size
|
||||
* Type : hw_element_size_t
|
||||
* Description : The element size ( 8,16, 32 or 64 bit)
|
||||
*
|
||||
* Identifier : mixed_size
|
||||
* Type : hw_mmu_mixed_size_t
|
||||
* Description : Element Size to follow CPU or TLB
|
||||
*
|
||||
* RETURNS:
|
||||
*
|
||||
* Type : hw_status
|
||||
* Description : 0 -- No errors occured
|
||||
* RET_BAD_NULL_PARAM -- A Pointer Paramater
|
||||
* was set to NULL
|
||||
* RET_PARAM_OUT_OF_RANGE -- Input Parameter
|
||||
* out of Range
|
||||
*
|
||||
* PURPOSE: : Set MMU_CAM reg
|
||||
*
|
||||
* METHOD: : Check the Input parameters and set the RAM entry.
|
||||
*/
|
||||
static hw_status mmu_set_ram_entry(const void __iomem *base_address,
|
||||
const u32 physical_addr,
|
||||
enum hw_endianism_t endianism,
|
||||
enum hw_element_size_t element_size,
|
||||
enum hw_mmu_mixed_size_t mixed_size);
|
||||
|
||||
/* HW FUNCTIONS */
|
||||
|
||||
hw_status hw_mmu_enable(const void __iomem *base_address)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
MMUMMU_CNTLMMU_ENABLE_WRITE32(base_address, HW_SET);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_disable(const void __iomem *base_address)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
MMUMMU_CNTLMMU_ENABLE_WRITE32(base_address, HW_CLEAR);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_num_locked_set(const void __iomem *base_address,
|
||||
u32 num_locked_entries)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
MMUMMU_LOCK_BASE_VALUE_WRITE32(base_address, num_locked_entries);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_victim_num_set(const void __iomem *base_address,
|
||||
u32 victim_entry_num)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
MMUMMU_LOCK_CURRENT_VICTIM_WRITE32(base_address, victim_entry_num);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_event_ack(const void __iomem *base_address, u32 irq_mask)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
MMUMMU_IRQSTATUS_WRITE_REGISTER32(base_address, irq_mask);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_event_disable(const void __iomem *base_address, u32 irq_mask)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 irq_reg;
|
||||
|
||||
irq_reg = MMUMMU_IRQENABLE_READ_REGISTER32(base_address);
|
||||
|
||||
MMUMMU_IRQENABLE_WRITE_REGISTER32(base_address, irq_reg & ~irq_mask);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_event_enable(const void __iomem *base_address, u32 irq_mask)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 irq_reg;
|
||||
|
||||
irq_reg = MMUMMU_IRQENABLE_READ_REGISTER32(base_address);
|
||||
|
||||
MMUMMU_IRQENABLE_WRITE_REGISTER32(base_address, irq_reg | irq_mask);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_event_status(const void __iomem *base_address, u32 *irq_mask)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
*irq_mask = MMUMMU_IRQSTATUS_READ_REGISTER32(base_address);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_fault_addr_read(const void __iomem *base_address, u32 *addr)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
/* read values from register */
|
||||
*addr = MMUMMU_FAULT_AD_READ_REGISTER32(base_address);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_ttb_set(const void __iomem *base_address, u32 ttb_phys_addr)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 load_ttb;
|
||||
|
||||
load_ttb = ttb_phys_addr & ~0x7FUL;
|
||||
/* write values to register */
|
||||
MMUMMU_TTB_WRITE_REGISTER32(base_address, load_ttb);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_twl_enable(const void __iomem *base_address)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
MMUMMU_CNTLTWL_ENABLE_WRITE32(base_address, HW_SET);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_twl_disable(const void __iomem *base_address)
|
||||
{
|
||||
hw_status status = 0;
|
||||
|
||||
MMUMMU_CNTLTWL_ENABLE_WRITE32(base_address, HW_CLEAR);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_tlb_flush(const void __iomem *base_address, u32 virtual_addr,
|
||||
u32 page_sz)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 virtual_addr_tag;
|
||||
enum hw_mmu_page_size_t pg_size_bits;
|
||||
|
||||
switch (page_sz) {
|
||||
case HW_PAGE_SIZE4KB:
|
||||
pg_size_bits = HW_MMU_SMALL_PAGE;
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE64KB:
|
||||
pg_size_bits = HW_MMU_LARGE_PAGE;
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE1MB:
|
||||
pg_size_bits = HW_MMU_SECTION;
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE16MB:
|
||||
pg_size_bits = HW_MMU_SUPERSECTION;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
/* Generate the 20-bit tag from virtual address */
|
||||
virtual_addr_tag = ((virtual_addr & MMU_ADDR_MASK) >> 12);
|
||||
|
||||
mmu_set_cam_entry(base_address, pg_size_bits, 0, 0, virtual_addr_tag);
|
||||
|
||||
mmu_flush_entry(base_address);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_tlb_add(const void __iomem *base_address,
|
||||
u32 physical_addr,
|
||||
u32 virtual_addr,
|
||||
u32 page_sz,
|
||||
u32 entry_num,
|
||||
struct hw_mmu_map_attrs_t *map_attrs,
|
||||
s8 preserved_bit, s8 valid_bit)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 lock_reg;
|
||||
u32 virtual_addr_tag;
|
||||
enum hw_mmu_page_size_t mmu_pg_size;
|
||||
|
||||
/*Check the input Parameters */
|
||||
switch (page_sz) {
|
||||
case HW_PAGE_SIZE4KB:
|
||||
mmu_pg_size = HW_MMU_SMALL_PAGE;
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE64KB:
|
||||
mmu_pg_size = HW_MMU_LARGE_PAGE;
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE1MB:
|
||||
mmu_pg_size = HW_MMU_SECTION;
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE16MB:
|
||||
mmu_pg_size = HW_MMU_SUPERSECTION;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
lock_reg = MMUMMU_LOCK_READ_REGISTER32(base_address);
|
||||
|
||||
/* Generate the 20-bit tag from virtual address */
|
||||
virtual_addr_tag = ((virtual_addr & MMU_ADDR_MASK) >> 12);
|
||||
|
||||
/* Write the fields in the CAM Entry Register */
|
||||
mmu_set_cam_entry(base_address, mmu_pg_size, preserved_bit, valid_bit,
|
||||
virtual_addr_tag);
|
||||
|
||||
/* Write the different fields of the RAM Entry Register */
|
||||
/* endianism of the page,Element Size of the page (8, 16, 32, 64 bit) */
|
||||
mmu_set_ram_entry(base_address, physical_addr, map_attrs->endianism,
|
||||
map_attrs->element_size, map_attrs->mixed_size);
|
||||
|
||||
/* Update the MMU Lock Register */
|
||||
/* currentVictim between lockedBaseValue and (MMU_Entries_Number - 1) */
|
||||
MMUMMU_LOCK_CURRENT_VICTIM_WRITE32(base_address, entry_num);
|
||||
|
||||
/* Enable loading of an entry in TLB by writing 1
|
||||
into LD_TLB_REG register */
|
||||
MMUMMU_LD_TLB_WRITE_REGISTER32(base_address, MMU_LOAD_TLB);
|
||||
|
||||
MMUMMU_LOCK_WRITE_REGISTER32(base_address, lock_reg);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
|
||||
u32 physical_addr,
|
||||
u32 virtual_addr,
|
||||
u32 page_sz, struct hw_mmu_map_attrs_t *map_attrs)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 pte_addr, pte_val;
|
||||
s32 num_entries = 1;
|
||||
|
||||
switch (page_sz) {
|
||||
case HW_PAGE_SIZE4KB:
|
||||
pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_SMALL_PAGE_MASK);
|
||||
pte_val =
|
||||
((physical_addr & MMU_SMALL_PAGE_MASK) |
|
||||
(map_attrs->endianism << 9) | (map_attrs->
|
||||
element_size << 4) |
|
||||
(map_attrs->mixed_size << 11) | 2);
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE64KB:
|
||||
num_entries = 16;
|
||||
pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_LARGE_PAGE_MASK);
|
||||
pte_val =
|
||||
((physical_addr & MMU_LARGE_PAGE_MASK) |
|
||||
(map_attrs->endianism << 9) | (map_attrs->
|
||||
element_size << 4) |
|
||||
(map_attrs->mixed_size << 11) | 1);
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE1MB:
|
||||
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_SECTION_ADDR_MASK);
|
||||
pte_val =
|
||||
((((physical_addr & MMU_SECTION_ADDR_MASK) |
|
||||
(map_attrs->endianism << 15) | (map_attrs->
|
||||
element_size << 10) |
|
||||
(map_attrs->mixed_size << 17)) & ~0x40000) | 0x2);
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE16MB:
|
||||
num_entries = 16;
|
||||
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_SSECTION_ADDR_MASK);
|
||||
pte_val =
|
||||
(((physical_addr & MMU_SSECTION_ADDR_MASK) |
|
||||
(map_attrs->endianism << 15) | (map_attrs->
|
||||
element_size << 10) |
|
||||
(map_attrs->mixed_size << 17)
|
||||
) | 0x40000 | 0x2);
|
||||
break;
|
||||
|
||||
case HW_MMU_COARSE_PAGE_SIZE:
|
||||
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_SECTION_ADDR_MASK);
|
||||
pte_val = (physical_addr & MMU_PAGE_TABLE_MASK) | 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while (--num_entries >= 0)
|
||||
((u32 *) pte_addr)[num_entries] = pte_val;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
hw_status hw_mmu_pte_clear(const u32 pg_tbl_va, u32 virtual_addr, u32 page_size)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 pte_addr;
|
||||
s32 num_entries = 1;
|
||||
|
||||
switch (page_size) {
|
||||
case HW_PAGE_SIZE4KB:
|
||||
pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_SMALL_PAGE_MASK);
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE64KB:
|
||||
num_entries = 16;
|
||||
pte_addr = hw_mmu_pte_addr_l2(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_LARGE_PAGE_MASK);
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE1MB:
|
||||
case HW_MMU_COARSE_PAGE_SIZE:
|
||||
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_SECTION_ADDR_MASK);
|
||||
break;
|
||||
|
||||
case HW_PAGE_SIZE16MB:
|
||||
num_entries = 16;
|
||||
pte_addr = hw_mmu_pte_addr_l1(pg_tbl_va,
|
||||
virtual_addr &
|
||||
MMU_SSECTION_ADDR_MASK);
|
||||
break;
|
||||
|
||||
default:
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
while (--num_entries >= 0)
|
||||
((u32 *) pte_addr)[num_entries] = 0;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* mmu_flush_entry */
|
||||
static hw_status mmu_flush_entry(const void __iomem *base_address)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 flush_entry_data = 0x1;
|
||||
|
||||
/* write values to register */
|
||||
MMUMMU_FLUSH_ENTRY_WRITE_REGISTER32(base_address, flush_entry_data);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* mmu_set_cam_entry */
|
||||
static hw_status mmu_set_cam_entry(const void __iomem *base_address,
|
||||
const u32 page_sz,
|
||||
const u32 preserved_bit,
|
||||
const u32 valid_bit,
|
||||
const u32 virtual_addr_tag)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 mmu_cam_reg;
|
||||
|
||||
mmu_cam_reg = (virtual_addr_tag << 12);
|
||||
mmu_cam_reg = (mmu_cam_reg) | (page_sz) | (valid_bit << 2) |
|
||||
(preserved_bit << 3);
|
||||
|
||||
/* write values to register */
|
||||
MMUMMU_CAM_WRITE_REGISTER32(base_address, mmu_cam_reg);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/* mmu_set_ram_entry */
|
||||
static hw_status mmu_set_ram_entry(const void __iomem *base_address,
|
||||
const u32 physical_addr,
|
||||
enum hw_endianism_t endianism,
|
||||
enum hw_element_size_t element_size,
|
||||
enum hw_mmu_mixed_size_t mixed_size)
|
||||
{
|
||||
hw_status status = 0;
|
||||
u32 mmu_ram_reg;
|
||||
|
||||
mmu_ram_reg = (physical_addr & MMU_ADDR_MASK);
|
||||
mmu_ram_reg = (mmu_ram_reg) | ((endianism << 9) | (element_size << 7) |
|
||||
(mixed_size << 6));
|
||||
|
||||
/* write values to register */
|
||||
MMUMMU_RAM_WRITE_REGISTER32(base_address, mmu_ram_reg);
|
||||
|
||||
return status;
|
||||
|
||||
}
|
||||
|
||||
void hw_mmu_tlb_flush_all(const void __iomem *base)
|
||||
{
|
||||
__raw_writeb(1, base + MMU_GFLUSH);
|
||||
}
|
|
@ -0,0 +1,163 @@
|
|||
/*
|
||||
* hw_mmu.h
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* MMU types and API declarations
|
||||
*
|
||||
* Copyright (C) 2007 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef _HW_MMU_H
|
||||
#define _HW_MMU_H
|
||||
|
||||
#include <linux/types.h>
|
||||
|
||||
/* Bitmasks for interrupt sources */
|
||||
#define HW_MMU_TRANSLATION_FAULT 0x2
|
||||
#define HW_MMU_ALL_INTERRUPTS 0x1F
|
||||
|
||||
#define HW_MMU_COARSE_PAGE_SIZE 0x400
|
||||
|
||||
/* hw_mmu_mixed_size_t: Enumerated Type used to specify whether to follow
|
||||
CPU/TLB Element size */
|
||||
enum hw_mmu_mixed_size_t {
|
||||
HW_MMU_TLBES,
|
||||
HW_MMU_CPUES
|
||||
};
|
||||
|
||||
/* hw_mmu_map_attrs_t: Struct containing MMU mapping attributes */
|
||||
struct hw_mmu_map_attrs_t {
|
||||
enum hw_endianism_t endianism;
|
||||
enum hw_element_size_t element_size;
|
||||
enum hw_mmu_mixed_size_t mixed_size;
|
||||
bool donotlockmpupage;
|
||||
};
|
||||
|
||||
extern hw_status hw_mmu_enable(const void __iomem *base_address);
|
||||
|
||||
extern hw_status hw_mmu_disable(const void __iomem *base_address);
|
||||
|
||||
extern hw_status hw_mmu_num_locked_set(const void __iomem *base_address,
|
||||
u32 num_locked_entries);
|
||||
|
||||
extern hw_status hw_mmu_victim_num_set(const void __iomem *base_address,
|
||||
u32 victim_entry_num);
|
||||
|
||||
/* For MMU faults */
|
||||
extern hw_status hw_mmu_event_ack(const void __iomem *base_address,
|
||||
u32 irq_mask);
|
||||
|
||||
extern hw_status hw_mmu_event_disable(const void __iomem *base_address,
|
||||
u32 irq_mask);
|
||||
|
||||
extern hw_status hw_mmu_event_enable(const void __iomem *base_address,
|
||||
u32 irq_mask);
|
||||
|
||||
extern hw_status hw_mmu_event_status(const void __iomem *base_address,
|
||||
u32 *irq_mask);
|
||||
|
||||
extern hw_status hw_mmu_fault_addr_read(const void __iomem *base_address,
|
||||
u32 *addr);
|
||||
|
||||
/* Set the TT base address */
|
||||
extern hw_status hw_mmu_ttb_set(const void __iomem *base_address,
|
||||
u32 ttb_phys_addr);
|
||||
|
||||
extern hw_status hw_mmu_twl_enable(const void __iomem *base_address);
|
||||
|
||||
extern hw_status hw_mmu_twl_disable(const void __iomem *base_address);
|
||||
|
||||
extern hw_status hw_mmu_tlb_flush(const void __iomem *base_address,
|
||||
u32 virtual_addr, u32 page_sz);
|
||||
|
||||
extern hw_status hw_mmu_tlb_add(const void __iomem *base_address,
|
||||
u32 physical_addr,
|
||||
u32 virtual_addr,
|
||||
u32 page_sz,
|
||||
u32 entry_num,
|
||||
struct hw_mmu_map_attrs_t *map_attrs,
|
||||
s8 preserved_bit, s8 valid_bit);
|
||||
|
||||
/* For PTEs */
|
||||
extern hw_status hw_mmu_pte_set(const u32 pg_tbl_va,
|
||||
u32 physical_addr,
|
||||
u32 virtual_addr,
|
||||
u32 page_sz,
|
||||
struct hw_mmu_map_attrs_t *map_attrs);
|
||||
|
||||
extern hw_status hw_mmu_pte_clear(const u32 pg_tbl_va,
|
||||
u32 virtual_addr, u32 page_size);
|
||||
|
||||
void hw_mmu_tlb_flush_all(const void __iomem *base);
|
||||
|
||||
static inline u32 hw_mmu_pte_addr_l1(u32 l1_base, u32 va)
|
||||
{
|
||||
u32 pte_addr;
|
||||
u32 va31_to20;
|
||||
|
||||
va31_to20 = va >> (20 - 2); /* Left-shift by 2 here itself */
|
||||
va31_to20 &= 0xFFFFFFFCUL;
|
||||
pte_addr = l1_base + va31_to20;
|
||||
|
||||
return pte_addr;
|
||||
}
|
||||
|
||||
static inline u32 hw_mmu_pte_addr_l2(u32 l2_base, u32 va)
|
||||
{
|
||||
u32 pte_addr;
|
||||
|
||||
pte_addr = (l2_base & 0xFFFFFC00) | ((va >> 10) & 0x3FC);
|
||||
|
||||
return pte_addr;
|
||||
}
|
||||
|
||||
static inline u32 hw_mmu_pte_coarse_l1(u32 pte_val)
|
||||
{
|
||||
u32 pte_coarse;
|
||||
|
||||
pte_coarse = pte_val & 0xFFFFFC00;
|
||||
|
||||
return pte_coarse;
|
||||
}
|
||||
|
||||
static inline u32 hw_mmu_pte_size_l1(u32 pte_val)
|
||||
{
|
||||
u32 pte_size = 0;
|
||||
|
||||
if ((pte_val & 0x3) == 0x1) {
|
||||
/* Points to L2 PT */
|
||||
pte_size = HW_MMU_COARSE_PAGE_SIZE;
|
||||
}
|
||||
|
||||
if ((pte_val & 0x3) == 0x2) {
|
||||
if (pte_val & (1 << 18))
|
||||
pte_size = HW_PAGE_SIZE16MB;
|
||||
else
|
||||
pte_size = HW_PAGE_SIZE1MB;
|
||||
}
|
||||
|
||||
return pte_size;
|
||||
}
|
||||
|
||||
static inline u32 hw_mmu_pte_size_l2(u32 pte_val)
|
||||
{
|
||||
u32 pte_size = 0;
|
||||
|
||||
if (pte_val & 0x2)
|
||||
pte_size = HW_PAGE_SIZE4KB;
|
||||
else if (pte_val & 0x1)
|
||||
pte_size = HW_PAGE_SIZE64KB;
|
||||
|
||||
return pte_size;
|
||||
}
|
||||
|
||||
#endif /* _HW_MMU_H */
|
|
@ -68,6 +68,7 @@ struct cfg_hostres {
|
|||
void __iomem *dw_per_base;
|
||||
u32 dw_per_pm_base;
|
||||
u32 dw_core_pm_base;
|
||||
void __iomem *dw_dmmu_base;
|
||||
void __iomem *dw_sys_ctrl_base;
|
||||
};
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@
|
|||
#include <dspbridge/nodedefs.h>
|
||||
#include <dspbridge/dispdefs.h>
|
||||
#include <dspbridge/dspdefs.h>
|
||||
#include <dspbridge/dmm.h>
|
||||
#include <dspbridge/host_os.h>
|
||||
|
||||
/* ----------------------------------- This */
|
||||
|
@ -232,6 +233,29 @@ extern int dev_get_chnl_mgr(struct dev_object *hdev_obj,
|
|||
extern int dev_get_cmm_mgr(struct dev_object *hdev_obj,
|
||||
struct cmm_object **mgr);
|
||||
|
||||
/*
|
||||
* ======== dev_get_dmm_mgr ========
|
||||
* Purpose:
|
||||
* Retrieve the handle to the dynamic memory manager created for this
|
||||
* device.
|
||||
* Parameters:
|
||||
* hdev_obj: Handle to device object created with
|
||||
* dev_create_device().
|
||||
* *mgr: Ptr to location to store handle.
|
||||
* Returns:
|
||||
* 0: Success.
|
||||
* -EFAULT: Invalid hdev_obj.
|
||||
* Requires:
|
||||
* mgr != NULL.
|
||||
* DEV Initialized.
|
||||
* Ensures:
|
||||
* 0: *mgr contains a handle to a channel manager object,
|
||||
* or NULL.
|
||||
* else: *mgr is NULL.
|
||||
*/
|
||||
extern int dev_get_dmm_mgr(struct dev_object *hdev_obj,
|
||||
struct dmm_object **mgr);
|
||||
|
||||
/*
|
||||
* ======== dev_get_cod_mgr ========
|
||||
* Purpose:
|
||||
|
|
|
@ -0,0 +1,75 @@
|
|||
/*
|
||||
* dmm.h
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* The Dynamic Memory Mapping(DMM) module manages the DSP Virtual address
|
||||
* space that can be directly mapped to any MPU buffer or memory region.
|
||||
*
|
||||
* Copyright (C) 2005-2006 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef DMM_
|
||||
#define DMM_
|
||||
|
||||
#include <dspbridge/dbdefs.h>
|
||||
|
||||
struct dmm_object;
|
||||
|
||||
/* DMM attributes used in dmm_create() */
|
||||
struct dmm_mgrattrs {
|
||||
u32 reserved;
|
||||
};
|
||||
|
||||
#define DMMPOOLSIZE 0x4000000
|
||||
|
||||
/*
|
||||
* ======== dmm_get_handle ========
|
||||
* Purpose:
|
||||
* Return the dynamic memory manager object for this device.
|
||||
* This is typically called from the client process.
|
||||
*/
|
||||
|
||||
extern int dmm_get_handle(void *hprocessor,
|
||||
struct dmm_object **dmm_manager);
|
||||
|
||||
extern int dmm_reserve_memory(struct dmm_object *dmm_mgr,
|
||||
u32 size, u32 *prsv_addr);
|
||||
|
||||
extern int dmm_un_reserve_memory(struct dmm_object *dmm_mgr,
|
||||
u32 rsv_addr);
|
||||
|
||||
extern int dmm_map_memory(struct dmm_object *dmm_mgr, u32 addr,
|
||||
u32 size);
|
||||
|
||||
extern int dmm_un_map_memory(struct dmm_object *dmm_mgr,
|
||||
u32 addr, u32 *psize);
|
||||
|
||||
extern int dmm_destroy(struct dmm_object *dmm_mgr);
|
||||
|
||||
extern int dmm_delete_tables(struct dmm_object *dmm_mgr);
|
||||
|
||||
extern int dmm_create(struct dmm_object **dmm_manager,
|
||||
struct dev_object *hdev_obj,
|
||||
const struct dmm_mgrattrs *mgr_attrts);
|
||||
|
||||
extern bool dmm_init(void);
|
||||
|
||||
extern void dmm_exit(void);
|
||||
|
||||
extern int dmm_create_tables(struct dmm_object *dmm_mgr,
|
||||
u32 addr, u32 size);
|
||||
|
||||
#ifdef DSP_DMM_DEBUG
|
||||
u32 dmm_mem_map_dump(struct dmm_object *dmm_mgr);
|
||||
#endif
|
||||
|
||||
#endif /* DMM_ */
|
|
@ -108,6 +108,12 @@ struct dmm_map_object {
|
|||
struct bridge_dma_map_info dma_info;
|
||||
};
|
||||
|
||||
/* Used for DMM reserved memory accounting */
|
||||
struct dmm_rsv_object {
|
||||
struct list_head link;
|
||||
u32 dsp_reserved_addr;
|
||||
};
|
||||
|
||||
/* New structure (member of process context) abstracts DMM resource info */
|
||||
struct dspheap_res_object {
|
||||
s32 heap_allocated; /* DMM status */
|
||||
|
@ -159,6 +165,10 @@ struct process_context {
|
|||
struct list_head dmm_map_list;
|
||||
spinlock_t dmm_map_lock;
|
||||
|
||||
/* DMM reserved memory resources */
|
||||
struct list_head dmm_rsv_list;
|
||||
spinlock_t dmm_rsv_lock;
|
||||
|
||||
/* DSP Heap resources */
|
||||
struct dspheap_res_object *pdspheap_list;
|
||||
|
||||
|
|
|
@ -1,67 +0,0 @@
|
|||
/*
|
||||
* dsp-mmu.h
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* DSP iommu.
|
||||
*
|
||||
* Copyright (C) 2005-2010 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
|
||||
#ifndef _DSP_MMU_
|
||||
#define _DSP_MMU_
|
||||
|
||||
#include <plat/iommu.h>
|
||||
#include <plat/iovmm.h>
|
||||
|
||||
/**
|
||||
* dsp_mmu_init() - initialize dsp_mmu module and returns a handle
|
||||
*
|
||||
* This function initialize dsp mmu module and returns a struct iommu
|
||||
* handle to use it for dsp maps.
|
||||
*
|
||||
*/
|
||||
struct iommu *dsp_mmu_init(void);
|
||||
|
||||
/**
|
||||
* dsp_mmu_exit() - destroy dsp mmu module
|
||||
* @mmu: Pointer to iommu handle.
|
||||
*
|
||||
* This function destroys dsp mmu module.
|
||||
*
|
||||
*/
|
||||
void dsp_mmu_exit(struct iommu *mmu);
|
||||
|
||||
/**
|
||||
* user_to_dsp_map() - maps user to dsp virtual address
|
||||
* @mmu: Pointer to iommu handle.
|
||||
* @uva: Virtual user space address.
|
||||
* @da DSP address
|
||||
* @size Buffer size to map.
|
||||
* @usr_pgs struct page array pointer where the user pages will be stored
|
||||
*
|
||||
* This function maps a user space buffer into DSP virtual address.
|
||||
*
|
||||
*/
|
||||
u32 user_to_dsp_map(struct iommu *mmu, u32 uva, u32 da, u32 size,
|
||||
struct page **usr_pgs);
|
||||
|
||||
/**
|
||||
* user_to_dsp_unmap() - unmaps DSP virtual buffer.
|
||||
* @mmu: Pointer to iommu handle.
|
||||
* @da DSP address
|
||||
*
|
||||
* This function unmaps a user space buffer into DSP virtual address.
|
||||
*
|
||||
*/
|
||||
int user_to_dsp_unmap(struct iommu *mmu, u32 da);
|
||||
|
||||
#endif
|
|
@ -161,6 +161,48 @@ typedef int(*fxn_brd_memwrite) (struct bridge_dev_context
|
|||
u32 dsp_addr, u32 ul_num_bytes,
|
||||
u32 mem_type);
|
||||
|
||||
/*
|
||||
* ======== bridge_brd_mem_map ========
|
||||
* Purpose:
|
||||
* Map a MPU memory region to a DSP/IVA memory space
|
||||
* Parameters:
|
||||
* dev_ctxt: Handle to Bridge driver defined device info.
|
||||
* ul_mpu_addr: MPU memory region start address.
|
||||
* virt_addr: DSP/IVA memory region u8 address.
|
||||
* ul_num_bytes: Number of bytes to map.
|
||||
* map_attrs: Mapping attributes (e.g. endianness).
|
||||
* Returns:
|
||||
* 0: Success.
|
||||
* -EPERM: Other, unspecified error.
|
||||
* Requires:
|
||||
* dev_ctxt != NULL;
|
||||
* Ensures:
|
||||
*/
|
||||
typedef int(*fxn_brd_memmap) (struct bridge_dev_context
|
||||
* dev_ctxt, u32 ul_mpu_addr,
|
||||
u32 virt_addr, u32 ul_num_bytes,
|
||||
u32 map_attr,
|
||||
struct page **mapped_pages);
|
||||
|
||||
/*
|
||||
* ======== bridge_brd_mem_un_map ========
|
||||
* Purpose:
|
||||
* UnMap an MPU memory region from DSP/IVA memory space
|
||||
* Parameters:
|
||||
* dev_ctxt: Handle to Bridge driver defined device info.
|
||||
* virt_addr: DSP/IVA memory region u8 address.
|
||||
* ul_num_bytes: Number of bytes to unmap.
|
||||
* Returns:
|
||||
* 0: Success.
|
||||
* -EPERM: Other, unspecified error.
|
||||
* Requires:
|
||||
* dev_ctxt != NULL;
|
||||
* Ensures:
|
||||
*/
|
||||
typedef int(*fxn_brd_memunmap) (struct bridge_dev_context
|
||||
* dev_ctxt,
|
||||
u32 virt_addr, u32 ul_num_bytes);
|
||||
|
||||
/*
|
||||
* ======== bridge_brd_stop ========
|
||||
* Purpose:
|
||||
|
@ -951,6 +993,8 @@ struct bridge_drv_interface {
|
|||
fxn_brd_setstate pfn_brd_set_state; /* Sets the Board State */
|
||||
fxn_brd_memcopy pfn_brd_mem_copy; /* Copies DSP Memory */
|
||||
fxn_brd_memwrite pfn_brd_mem_write; /* Write DSP Memory w/o halt */
|
||||
fxn_brd_memmap pfn_brd_mem_map; /* Maps MPU mem to DSP mem */
|
||||
fxn_brd_memunmap pfn_brd_mem_un_map; /* Unmaps MPU mem to DSP mem */
|
||||
fxn_chnl_create pfn_chnl_create; /* Create channel manager. */
|
||||
fxn_chnl_destroy pfn_chnl_destroy; /* Destroy channel manager. */
|
||||
fxn_chnl_open pfn_chnl_open; /* Create a new channel. */
|
||||
|
|
|
@ -19,6 +19,10 @@
|
|||
#ifndef DSPIOCTL_
|
||||
#define DSPIOCTL_
|
||||
|
||||
/* ------------------------------------ Hardware Abstraction Layer */
|
||||
#include <hw_defs.h>
|
||||
#include <hw_mmu.h>
|
||||
|
||||
/*
|
||||
* Any IOCTLS at or above this value are reserved for standard Bridge driver
|
||||
* interfaces.
|
||||
|
@ -61,6 +65,9 @@ struct bridge_ioctl_extproc {
|
|||
/* GPP virtual address. __va does not work for ioremapped addresses */
|
||||
u32 ul_gpp_va;
|
||||
u32 ul_size; /* Size of the mapped memory in bytes */
|
||||
enum hw_endianism_t endianism;
|
||||
enum hw_mmu_mixed_size_t mixed_mode;
|
||||
enum hw_element_size_t elem_size;
|
||||
};
|
||||
|
||||
#endif /* DSPIOCTL_ */
|
||||
|
|
|
@ -550,6 +550,29 @@ extern int proc_map(void *hprocessor,
|
|||
void **pp_map_addr, u32 ul_map_attr,
|
||||
struct process_context *pr_ctxt);
|
||||
|
||||
/*
|
||||
* ======== proc_reserve_memory ========
|
||||
* Purpose:
|
||||
* Reserve a virtually contiguous region of DSP address space.
|
||||
* Parameters:
|
||||
* hprocessor : The processor handle.
|
||||
* ul_size : Size of the address space to reserve.
|
||||
* pp_rsv_addr : Ptr to DSP side reserved u8 address.
|
||||
* Returns:
|
||||
* 0 : Success.
|
||||
* -EFAULT : Invalid processor handle.
|
||||
* -EPERM : General failure.
|
||||
* -ENOMEM : Cannot reserve chunk of this size.
|
||||
* Requires:
|
||||
* pp_rsv_addr is not NULL
|
||||
* PROC Initialized.
|
||||
* Ensures:
|
||||
* Details:
|
||||
*/
|
||||
extern int proc_reserve_memory(void *hprocessor,
|
||||
u32 ul_size, void **pp_rsv_addr,
|
||||
struct process_context *pr_ctxt);
|
||||
|
||||
/*
|
||||
* ======== proc_un_map ========
|
||||
* Purpose:
|
||||
|
@ -572,4 +595,27 @@ extern int proc_map(void *hprocessor,
|
|||
extern int proc_un_map(void *hprocessor, void *map_addr,
|
||||
struct process_context *pr_ctxt);
|
||||
|
||||
/*
|
||||
* ======== proc_un_reserve_memory ========
|
||||
* Purpose:
|
||||
* Frees a previously reserved region of DSP address space.
|
||||
* Parameters:
|
||||
* hprocessor : The processor handle.
|
||||
* prsv_addr : Ptr to DSP side reservedBYTE address.
|
||||
* Returns:
|
||||
* 0 : Success.
|
||||
* -EFAULT : Invalid processor handle.
|
||||
* -EPERM : General failure.
|
||||
* -ENOENT : Cannot find a reserved region starting with this
|
||||
* : address.
|
||||
* Requires:
|
||||
* prsv_addr is not NULL
|
||||
* PROC Initialized.
|
||||
* Ensures:
|
||||
* Details:
|
||||
*/
|
||||
extern int proc_un_reserve_memory(void *hprocessor,
|
||||
void *prsv_addr,
|
||||
struct process_context *pr_ctxt);
|
||||
|
||||
#endif /* PROC_ */
|
||||
|
|
|
@ -34,6 +34,7 @@
|
|||
#include <dspbridge/cod.h>
|
||||
#include <dspbridge/drv.h>
|
||||
#include <dspbridge/proc.h>
|
||||
#include <dspbridge/dmm.h>
|
||||
|
||||
/* ----------------------------------- Resource Manager */
|
||||
#include <dspbridge/mgr.h>
|
||||
|
@ -74,6 +75,7 @@ struct dev_object {
|
|||
struct msg_mgr *hmsg_mgr; /* Message manager. */
|
||||
struct io_mgr *hio_mgr; /* IO manager (CHNL, msg_ctrl) */
|
||||
struct cmm_object *hcmm_mgr; /* SM memory manager. */
|
||||
struct dmm_object *dmm_mgr; /* Dynamic memory manager. */
|
||||
struct ldr_module *module_obj; /* Bridge Module handle. */
|
||||
u32 word_size; /* DSP word size: quick access. */
|
||||
struct drv_object *hdrv_obj; /* Driver Object */
|
||||
|
@ -248,6 +250,9 @@ int dev_create_device(struct dev_object **device_obj,
|
|||
/* Instantiate the DEH module */
|
||||
status = bridge_deh_create(&dev_obj->hdeh_mgr, dev_obj);
|
||||
}
|
||||
/* Create DMM mgr . */
|
||||
status = dmm_create(&dev_obj->dmm_mgr,
|
||||
(struct dev_object *)dev_obj, NULL);
|
||||
}
|
||||
/* Add the new DEV_Object to the global list: */
|
||||
if (!status) {
|
||||
|
@ -273,6 +278,8 @@ leave:
|
|||
kfree(dev_obj->proc_list);
|
||||
if (dev_obj->cod_mgr)
|
||||
cod_delete(dev_obj->cod_mgr);
|
||||
if (dev_obj->dmm_mgr)
|
||||
dmm_destroy(dev_obj->dmm_mgr);
|
||||
kfree(dev_obj);
|
||||
}
|
||||
|
||||
|
@ -382,6 +389,11 @@ int dev_destroy_device(struct dev_object *hdev_obj)
|
|||
dev_obj->hcmm_mgr = NULL;
|
||||
}
|
||||
|
||||
if (dev_obj->dmm_mgr) {
|
||||
dmm_destroy(dev_obj->dmm_mgr);
|
||||
dev_obj->dmm_mgr = NULL;
|
||||
}
|
||||
|
||||
/* Call the driver's bridge_dev_destroy() function: */
|
||||
/* Require of DevDestroy */
|
||||
if (dev_obj->hbridge_context) {
|
||||
|
@ -461,6 +473,32 @@ int dev_get_cmm_mgr(struct dev_object *hdev_obj,
|
|||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dev_get_dmm_mgr ========
|
||||
* Purpose:
|
||||
* Retrieve the handle to the dynamic memory manager created for this
|
||||
* device.
|
||||
*/
|
||||
int dev_get_dmm_mgr(struct dev_object *hdev_obj,
|
||||
struct dmm_object **mgr)
|
||||
{
|
||||
int status = 0;
|
||||
struct dev_object *dev_obj = hdev_obj;
|
||||
|
||||
DBC_REQUIRE(refs > 0);
|
||||
DBC_REQUIRE(mgr != NULL);
|
||||
|
||||
if (hdev_obj) {
|
||||
*mgr = dev_obj->dmm_mgr;
|
||||
} else {
|
||||
*mgr = NULL;
|
||||
status = -EFAULT;
|
||||
}
|
||||
|
||||
DBC_ENSURE(!status || (mgr != NULL && *mgr == NULL));
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dev_get_cod_mgr ========
|
||||
* Purpose:
|
||||
|
@ -713,8 +751,10 @@ void dev_exit(void)
|
|||
|
||||
refs--;
|
||||
|
||||
if (refs == 0)
|
||||
if (refs == 0) {
|
||||
cmm_exit();
|
||||
dmm_exit();
|
||||
}
|
||||
|
||||
DBC_ENSURE(refs >= 0);
|
||||
}
|
||||
|
@ -726,12 +766,25 @@ void dev_exit(void)
|
|||
*/
|
||||
bool dev_init(void)
|
||||
{
|
||||
bool ret = true;
|
||||
bool cmm_ret, dmm_ret, ret = true;
|
||||
|
||||
DBC_REQUIRE(refs >= 0);
|
||||
|
||||
if (refs == 0)
|
||||
ret = cmm_init();
|
||||
if (refs == 0) {
|
||||
cmm_ret = cmm_init();
|
||||
dmm_ret = dmm_init();
|
||||
|
||||
ret = cmm_ret && dmm_ret;
|
||||
|
||||
if (!ret) {
|
||||
if (cmm_ret)
|
||||
cmm_exit();
|
||||
|
||||
if (dmm_ret)
|
||||
dmm_exit();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (ret)
|
||||
refs++;
|
||||
|
@ -1065,6 +1118,8 @@ static void store_interface_fxns(struct bridge_drv_interface *drv_fxns,
|
|||
STORE_FXN(fxn_brd_setstate, pfn_brd_set_state);
|
||||
STORE_FXN(fxn_brd_memcopy, pfn_brd_mem_copy);
|
||||
STORE_FXN(fxn_brd_memwrite, pfn_brd_mem_write);
|
||||
STORE_FXN(fxn_brd_memmap, pfn_brd_mem_map);
|
||||
STORE_FXN(fxn_brd_memunmap, pfn_brd_mem_un_map);
|
||||
STORE_FXN(fxn_chnl_create, pfn_chnl_create);
|
||||
STORE_FXN(fxn_chnl_destroy, pfn_chnl_destroy);
|
||||
STORE_FXN(fxn_chnl_open, pfn_chnl_open);
|
||||
|
|
|
@ -0,0 +1,533 @@
|
|||
/*
|
||||
* dmm.c
|
||||
*
|
||||
* DSP-BIOS Bridge driver support functions for TI OMAP processors.
|
||||
*
|
||||
* The Dynamic Memory Manager (DMM) module manages the DSP Virtual address
|
||||
* space that can be directly mapped to any MPU buffer or memory region
|
||||
*
|
||||
* Notes:
|
||||
* Region: Generic memory entitiy having a start address and a size
|
||||
* Chunk: Reserved region
|
||||
*
|
||||
* Copyright (C) 2005-2006 Texas Instruments, Inc.
|
||||
*
|
||||
* This package is free software; you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License version 2 as
|
||||
* published by the Free Software Foundation.
|
||||
*
|
||||
* THIS PACKAGE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
|
||||
* IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
|
||||
* WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
||||
*/
|
||||
#include <linux/types.h>
|
||||
|
||||
/* ----------------------------------- Host OS */
|
||||
#include <dspbridge/host_os.h>
|
||||
|
||||
/* ----------------------------------- DSP/BIOS Bridge */
|
||||
#include <dspbridge/dbdefs.h>
|
||||
|
||||
/* ----------------------------------- Trace & Debug */
|
||||
#include <dspbridge/dbc.h>
|
||||
|
||||
/* ----------------------------------- OS Adaptation Layer */
|
||||
#include <dspbridge/sync.h>
|
||||
|
||||
/* ----------------------------------- Platform Manager */
|
||||
#include <dspbridge/dev.h>
|
||||
#include <dspbridge/proc.h>
|
||||
|
||||
/* ----------------------------------- This */
|
||||
#include <dspbridge/dmm.h>
|
||||
|
||||
/* ----------------------------------- Defines, Data Structures, Typedefs */
|
||||
#define DMM_ADDR_VIRTUAL(a) \
|
||||
(((struct map_page *)(a) - virtual_mapping_table) * PG_SIZE4K +\
|
||||
dyn_mem_map_beg)
|
||||
#define DMM_ADDR_TO_INDEX(a) (((a) - dyn_mem_map_beg) / PG_SIZE4K)
|
||||
|
||||
/* DMM Mgr */
|
||||
struct dmm_object {
|
||||
/* Dmm Lock is used to serialize access mem manager for
|
||||
* multi-threads. */
|
||||
spinlock_t dmm_lock; /* Lock to access dmm mgr */
|
||||
};
|
||||
|
||||
/* ----------------------------------- Globals */
|
||||
static u32 refs; /* module reference count */
|
||||
struct map_page {
|
||||
u32 region_size:15;
|
||||
u32 mapped_size:15;
|
||||
u32 reserved:1;
|
||||
u32 mapped:1;
|
||||
};
|
||||
|
||||
/* Create the free list */
|
||||
static struct map_page *virtual_mapping_table;
|
||||
static u32 free_region; /* The index of free region */
|
||||
static u32 free_size;
|
||||
static u32 dyn_mem_map_beg; /* The Beginning of dynamic memory mapping */
|
||||
static u32 table_size; /* The size of virt and phys pages tables */
|
||||
|
||||
/* ----------------------------------- Function Prototypes */
|
||||
static struct map_page *get_region(u32 addr);
|
||||
static struct map_page *get_free_region(u32 len);
|
||||
static struct map_page *get_mapped_region(u32 addrs);
|
||||
|
||||
/* ======== dmm_create_tables ========
|
||||
* Purpose:
|
||||
* Create table to hold the information of physical address
|
||||
* the buffer pages that is passed by the user, and the table
|
||||
* to hold the information of the virtual memory that is reserved
|
||||
* for DSP.
|
||||
*/
|
||||
int dmm_create_tables(struct dmm_object *dmm_mgr, u32 addr, u32 size)
|
||||
{
|
||||
struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
|
||||
int status = 0;
|
||||
|
||||
status = dmm_delete_tables(dmm_obj);
|
||||
if (!status) {
|
||||
dyn_mem_map_beg = addr;
|
||||
table_size = PG_ALIGN_HIGH(size, PG_SIZE4K) / PG_SIZE4K;
|
||||
/* Create the free list */
|
||||
virtual_mapping_table = __vmalloc(table_size *
|
||||
sizeof(struct map_page), GFP_KERNEL |
|
||||
__GFP_HIGHMEM | __GFP_ZERO, PAGE_KERNEL);
|
||||
if (virtual_mapping_table == NULL)
|
||||
status = -ENOMEM;
|
||||
else {
|
||||
/* On successful allocation,
|
||||
* all entries are zero ('free') */
|
||||
free_region = 0;
|
||||
free_size = table_size * PG_SIZE4K;
|
||||
virtual_mapping_table[0].region_size = table_size;
|
||||
}
|
||||
}
|
||||
|
||||
if (status)
|
||||
pr_err("%s: failure, status 0x%x\n", __func__, status);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_create ========
|
||||
* Purpose:
|
||||
* Create a dynamic memory manager object.
|
||||
*/
|
||||
int dmm_create(struct dmm_object **dmm_manager,
|
||||
struct dev_object *hdev_obj,
|
||||
const struct dmm_mgrattrs *mgr_attrts)
|
||||
{
|
||||
struct dmm_object *dmm_obj = NULL;
|
||||
int status = 0;
|
||||
DBC_REQUIRE(refs > 0);
|
||||
DBC_REQUIRE(dmm_manager != NULL);
|
||||
|
||||
*dmm_manager = NULL;
|
||||
/* create, zero, and tag a cmm mgr object */
|
||||
dmm_obj = kzalloc(sizeof(struct dmm_object), GFP_KERNEL);
|
||||
if (dmm_obj != NULL) {
|
||||
spin_lock_init(&dmm_obj->dmm_lock);
|
||||
*dmm_manager = dmm_obj;
|
||||
} else {
|
||||
status = -ENOMEM;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_destroy ========
|
||||
* Purpose:
|
||||
* Release the communication memory manager resources.
|
||||
*/
|
||||
int dmm_destroy(struct dmm_object *dmm_mgr)
|
||||
{
|
||||
struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
|
||||
int status = 0;
|
||||
|
||||
DBC_REQUIRE(refs > 0);
|
||||
if (dmm_mgr) {
|
||||
status = dmm_delete_tables(dmm_obj);
|
||||
if (!status)
|
||||
kfree(dmm_obj);
|
||||
} else
|
||||
status = -EFAULT;
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_delete_tables ========
|
||||
* Purpose:
|
||||
* Delete DMM Tables.
|
||||
*/
|
||||
int dmm_delete_tables(struct dmm_object *dmm_mgr)
|
||||
{
|
||||
int status = 0;
|
||||
|
||||
DBC_REQUIRE(refs > 0);
|
||||
/* Delete all DMM tables */
|
||||
if (dmm_mgr)
|
||||
vfree(virtual_mapping_table);
|
||||
else
|
||||
status = -EFAULT;
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_exit ========
|
||||
* Purpose:
|
||||
* Discontinue usage of module; free resources when reference count
|
||||
* reaches 0.
|
||||
*/
|
||||
void dmm_exit(void)
|
||||
{
|
||||
DBC_REQUIRE(refs > 0);
|
||||
|
||||
refs--;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_get_handle ========
|
||||
* Purpose:
|
||||
* Return the dynamic memory manager object for this device.
|
||||
* This is typically called from the client process.
|
||||
*/
|
||||
int dmm_get_handle(void *hprocessor, struct dmm_object **dmm_manager)
|
||||
{
|
||||
int status = 0;
|
||||
struct dev_object *hdev_obj;
|
||||
|
||||
DBC_REQUIRE(refs > 0);
|
||||
DBC_REQUIRE(dmm_manager != NULL);
|
||||
if (hprocessor != NULL)
|
||||
status = proc_get_dev_object(hprocessor, &hdev_obj);
|
||||
else
|
||||
hdev_obj = dev_get_first(); /* default */
|
||||
|
||||
if (!status)
|
||||
status = dev_get_dmm_mgr(hdev_obj, dmm_manager);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_init ========
|
||||
* Purpose:
|
||||
* Initializes private state of DMM module.
|
||||
*/
|
||||
bool dmm_init(void)
|
||||
{
|
||||
bool ret = true;
|
||||
|
||||
DBC_REQUIRE(refs >= 0);
|
||||
|
||||
if (ret)
|
||||
refs++;
|
||||
|
||||
DBC_ENSURE((ret && (refs > 0)) || (!ret && (refs >= 0)));
|
||||
|
||||
virtual_mapping_table = NULL;
|
||||
table_size = 0;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_map_memory ========
|
||||
* Purpose:
|
||||
* Add a mapping block to the reserved chunk. DMM assumes that this block
|
||||
* will be mapped in the DSP/IVA's address space. DMM returns an error if a
|
||||
* mapping overlaps another one. This function stores the info that will be
|
||||
* required later while unmapping the block.
|
||||
*/
|
||||
int dmm_map_memory(struct dmm_object *dmm_mgr, u32 addr, u32 size)
|
||||
{
|
||||
struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
|
||||
struct map_page *chunk;
|
||||
int status = 0;
|
||||
|
||||
spin_lock(&dmm_obj->dmm_lock);
|
||||
/* Find the Reserved memory chunk containing the DSP block to
|
||||
* be mapped */
|
||||
chunk = (struct map_page *)get_region(addr);
|
||||
if (chunk != NULL) {
|
||||
/* Mark the region 'mapped', leave the 'reserved' info as-is */
|
||||
chunk->mapped = true;
|
||||
chunk->mapped_size = (size / PG_SIZE4K);
|
||||
} else
|
||||
status = -ENOENT;
|
||||
spin_unlock(&dmm_obj->dmm_lock);
|
||||
|
||||
dev_dbg(bridge, "%s dmm_mgr %p, addr %x, size %x\n\tstatus %x, "
|
||||
"chunk %p", __func__, dmm_mgr, addr, size, status, chunk);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_reserve_memory ========
|
||||
* Purpose:
|
||||
* Reserve a chunk of virtually contiguous DSP/IVA address space.
|
||||
*/
|
||||
int dmm_reserve_memory(struct dmm_object *dmm_mgr, u32 size,
|
||||
u32 *prsv_addr)
|
||||
{
|
||||
int status = 0;
|
||||
struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
|
||||
struct map_page *node;
|
||||
u32 rsv_addr = 0;
|
||||
u32 rsv_size = 0;
|
||||
|
||||
spin_lock(&dmm_obj->dmm_lock);
|
||||
|
||||
/* Try to get a DSP chunk from the free list */
|
||||
node = get_free_region(size);
|
||||
if (node != NULL) {
|
||||
/* DSP chunk of given size is available. */
|
||||
rsv_addr = DMM_ADDR_VIRTUAL(node);
|
||||
/* Calculate the number entries to use */
|
||||
rsv_size = size / PG_SIZE4K;
|
||||
if (rsv_size < node->region_size) {
|
||||
/* Mark remainder of free region */
|
||||
node[rsv_size].mapped = false;
|
||||
node[rsv_size].reserved = false;
|
||||
node[rsv_size].region_size =
|
||||
node->region_size - rsv_size;
|
||||
node[rsv_size].mapped_size = 0;
|
||||
}
|
||||
/* get_region will return first fit chunk. But we only use what
|
||||
is requested. */
|
||||
node->mapped = false;
|
||||
node->reserved = true;
|
||||
node->region_size = rsv_size;
|
||||
node->mapped_size = 0;
|
||||
/* Return the chunk's starting address */
|
||||
*prsv_addr = rsv_addr;
|
||||
} else
|
||||
/*dSP chunk of given size is not available */
|
||||
status = -ENOMEM;
|
||||
|
||||
spin_unlock(&dmm_obj->dmm_lock);
|
||||
|
||||
dev_dbg(bridge, "%s dmm_mgr %p, size %x, prsv_addr %p\n\tstatus %x, "
|
||||
"rsv_addr %x, rsv_size %x\n", __func__, dmm_mgr, size,
|
||||
prsv_addr, status, rsv_addr, rsv_size);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_un_map_memory ========
|
||||
* Purpose:
|
||||
* Remove the mapped block from the reserved chunk.
|
||||
*/
|
||||
int dmm_un_map_memory(struct dmm_object *dmm_mgr, u32 addr, u32 *psize)
|
||||
{
|
||||
struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
|
||||
struct map_page *chunk;
|
||||
int status = 0;
|
||||
|
||||
spin_lock(&dmm_obj->dmm_lock);
|
||||
chunk = get_mapped_region(addr);
|
||||
if (chunk == NULL)
|
||||
status = -ENOENT;
|
||||
|
||||
if (!status) {
|
||||
/* Unmap the region */
|
||||
*psize = chunk->mapped_size * PG_SIZE4K;
|
||||
chunk->mapped = false;
|
||||
chunk->mapped_size = 0;
|
||||
}
|
||||
spin_unlock(&dmm_obj->dmm_lock);
|
||||
|
||||
dev_dbg(bridge, "%s: dmm_mgr %p, addr %x, psize %p\n\tstatus %x, "
|
||||
"chunk %p\n", __func__, dmm_mgr, addr, psize, status, chunk);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== dmm_un_reserve_memory ========
|
||||
* Purpose:
|
||||
* Free a chunk of reserved DSP/IVA address space.
|
||||
*/
|
||||
int dmm_un_reserve_memory(struct dmm_object *dmm_mgr, u32 rsv_addr)
|
||||
{
|
||||
struct dmm_object *dmm_obj = (struct dmm_object *)dmm_mgr;
|
||||
struct map_page *chunk;
|
||||
u32 i;
|
||||
int status = 0;
|
||||
u32 chunk_size;
|
||||
|
||||
spin_lock(&dmm_obj->dmm_lock);
|
||||
|
||||
/* Find the chunk containing the reserved address */
|
||||
chunk = get_mapped_region(rsv_addr);
|
||||
if (chunk == NULL)
|
||||
status = -ENOENT;
|
||||
|
||||
if (!status) {
|
||||
/* Free all the mapped pages for this reserved region */
|
||||
i = 0;
|
||||
while (i < chunk->region_size) {
|
||||
if (chunk[i].mapped) {
|
||||
/* Remove mapping from the page tables. */
|
||||
chunk_size = chunk[i].mapped_size;
|
||||
/* Clear the mapping flags */
|
||||
chunk[i].mapped = false;
|
||||
chunk[i].mapped_size = 0;
|
||||
i += chunk_size;
|
||||
} else
|
||||
i++;
|
||||
}
|
||||
/* Clear the flags (mark the region 'free') */
|
||||
chunk->reserved = false;
|
||||
/* NOTE: We do NOT coalesce free regions here.
|
||||
* Free regions are coalesced in get_region(), as it traverses
|
||||
*the whole mapping table
|
||||
*/
|
||||
}
|
||||
spin_unlock(&dmm_obj->dmm_lock);
|
||||
|
||||
dev_dbg(bridge, "%s: dmm_mgr %p, rsv_addr %x\n\tstatus %x chunk %p",
|
||||
__func__, dmm_mgr, rsv_addr, status, chunk);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== get_region ========
|
||||
* Purpose:
|
||||
* Returns a region containing the specified memory region
|
||||
*/
|
||||
static struct map_page *get_region(u32 addr)
|
||||
{
|
||||
struct map_page *curr_region = NULL;
|
||||
u32 i = 0;
|
||||
|
||||
if (virtual_mapping_table != NULL) {
|
||||
/* find page mapped by this address */
|
||||
i = DMM_ADDR_TO_INDEX(addr);
|
||||
if (i < table_size)
|
||||
curr_region = virtual_mapping_table + i;
|
||||
}
|
||||
|
||||
dev_dbg(bridge, "%s: curr_region %p, free_region %d, free_size %d\n",
|
||||
__func__, curr_region, free_region, free_size);
|
||||
return curr_region;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== get_free_region ========
|
||||
* Purpose:
|
||||
* Returns the requested free region
|
||||
*/
|
||||
static struct map_page *get_free_region(u32 len)
|
||||
{
|
||||
struct map_page *curr_region = NULL;
|
||||
u32 i = 0;
|
||||
u32 region_size = 0;
|
||||
u32 next_i = 0;
|
||||
|
||||
if (virtual_mapping_table == NULL)
|
||||
return curr_region;
|
||||
if (len > free_size) {
|
||||
/* Find the largest free region
|
||||
* (coalesce during the traversal) */
|
||||
while (i < table_size) {
|
||||
region_size = virtual_mapping_table[i].region_size;
|
||||
next_i = i + region_size;
|
||||
if (virtual_mapping_table[i].reserved == false) {
|
||||
/* Coalesce, if possible */
|
||||
if (next_i < table_size &&
|
||||
virtual_mapping_table[next_i].reserved
|
||||
== false) {
|
||||
virtual_mapping_table[i].region_size +=
|
||||
virtual_mapping_table
|
||||
[next_i].region_size;
|
||||
continue;
|
||||
}
|
||||
region_size *= PG_SIZE4K;
|
||||
if (region_size > free_size) {
|
||||
free_region = i;
|
||||
free_size = region_size;
|
||||
}
|
||||
}
|
||||
i = next_i;
|
||||
}
|
||||
}
|
||||
if (len <= free_size) {
|
||||
curr_region = virtual_mapping_table + free_region;
|
||||
free_region += (len / PG_SIZE4K);
|
||||
free_size -= len;
|
||||
}
|
||||
return curr_region;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== get_mapped_region ========
|
||||
* Purpose:
|
||||
* Returns the requestedmapped region
|
||||
*/
|
||||
static struct map_page *get_mapped_region(u32 addrs)
|
||||
{
|
||||
u32 i = 0;
|
||||
struct map_page *curr_region = NULL;
|
||||
|
||||
if (virtual_mapping_table == NULL)
|
||||
return curr_region;
|
||||
|
||||
i = DMM_ADDR_TO_INDEX(addrs);
|
||||
if (i < table_size && (virtual_mapping_table[i].mapped ||
|
||||
virtual_mapping_table[i].reserved))
|
||||
curr_region = virtual_mapping_table + i;
|
||||
return curr_region;
|
||||
}
|
||||
|
||||
#ifdef DSP_DMM_DEBUG
|
||||
u32 dmm_mem_map_dump(struct dmm_object *dmm_mgr)
|
||||
{
|
||||
struct map_page *curr_node = NULL;
|
||||
u32 i;
|
||||
u32 freemem = 0;
|
||||
u32 bigsize = 0;
|
||||
|
||||
spin_lock(&dmm_mgr->dmm_lock);
|
||||
|
||||
if (virtual_mapping_table != NULL) {
|
||||
for (i = 0; i < table_size; i +=
|
||||
virtual_mapping_table[i].region_size) {
|
||||
curr_node = virtual_mapping_table + i;
|
||||
if (curr_node->reserved) {
|
||||
/*printk("RESERVED size = 0x%x, "
|
||||
"Map size = 0x%x\n",
|
||||
(curr_node->region_size * PG_SIZE4K),
|
||||
(curr_node->mapped == false) ? 0 :
|
||||
(curr_node->mapped_size * PG_SIZE4K));
|
||||
*/
|
||||
} else {
|
||||
/* printk("UNRESERVED size = 0x%x\n",
|
||||
(curr_node->region_size * PG_SIZE4K));
|
||||
*/
|
||||
freemem += (curr_node->region_size * PG_SIZE4K);
|
||||
if (curr_node->region_size > bigsize)
|
||||
bigsize = curr_node->region_size;
|
||||
}
|
||||
}
|
||||
}
|
||||
spin_unlock(&dmm_mgr->dmm_lock);
|
||||
printk(KERN_INFO "Total DSP VA FREE memory = %d Mbytes\n",
|
||||
freemem / (1024 * 1024));
|
||||
printk(KERN_INFO "Total DSP VA USED memory= %d Mbytes \n",
|
||||
(((table_size * PG_SIZE4K) - freemem)) / (1024 * 1024));
|
||||
printk(KERN_INFO "DSP VA - Biggest FREE block = %d Mbytes \n\n",
|
||||
(bigsize * PG_SIZE4K / (1024 * 1024)));
|
||||
|
||||
return 0;
|
||||
}
|
||||
#endif
|
|
@ -993,10 +993,27 @@ u32 procwrap_register_notify(union trapped_args *args, void *pr_ctxt)
|
|||
/*
|
||||
* ======== procwrap_reserve_memory ========
|
||||
*/
|
||||
u32 __deprecated procwrap_reserve_memory(union trapped_args *args,
|
||||
void *pr_ctxt)
|
||||
u32 procwrap_reserve_memory(union trapped_args *args, void *pr_ctxt)
|
||||
{
|
||||
return 0;
|
||||
int status;
|
||||
void *prsv_addr;
|
||||
void *hprocessor = ((struct process_context *)pr_ctxt)->hprocessor;
|
||||
|
||||
if ((args->args_proc_rsvmem.ul_size <= 0) ||
|
||||
(args->args_proc_rsvmem.ul_size & (PG_SIZE4K - 1)) != 0)
|
||||
return -EINVAL;
|
||||
|
||||
status = proc_reserve_memory(hprocessor,
|
||||
args->args_proc_rsvmem.ul_size, &prsv_addr,
|
||||
pr_ctxt);
|
||||
if (!status) {
|
||||
if (put_user(prsv_addr, args->args_proc_rsvmem.pp_rsv_addr)) {
|
||||
status = -EINVAL;
|
||||
proc_un_reserve_memory(args->args_proc_rsvmem.
|
||||
hprocessor, prsv_addr, pr_ctxt);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1025,10 +1042,15 @@ u32 procwrap_un_map(union trapped_args *args, void *pr_ctxt)
|
|||
/*
|
||||
* ======== procwrap_un_reserve_memory ========
|
||||
*/
|
||||
u32 __deprecated procwrap_un_reserve_memory(union trapped_args *args,
|
||||
void *pr_ctxt)
|
||||
u32 procwrap_un_reserve_memory(union trapped_args *args, void *pr_ctxt)
|
||||
{
|
||||
return 0;
|
||||
int status;
|
||||
void *hprocessor = ((struct process_context *)pr_ctxt)->hprocessor;
|
||||
|
||||
status = proc_un_reserve_memory(hprocessor,
|
||||
args->args_proc_unrsvmem.prsv_addr,
|
||||
pr_ctxt);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
|
|
|
@ -146,6 +146,7 @@ int drv_remove_all_dmm_res_elements(void *process_ctxt)
|
|||
struct process_context *ctxt = (struct process_context *)process_ctxt;
|
||||
int status = 0;
|
||||
struct dmm_map_object *temp_map, *map_obj;
|
||||
struct dmm_rsv_object *temp_rsv, *rsv_obj;
|
||||
|
||||
/* Free DMM mapped memory resources */
|
||||
list_for_each_entry_safe(map_obj, temp_map, &ctxt->dmm_map_list, link) {
|
||||
|
@ -155,6 +156,16 @@ int drv_remove_all_dmm_res_elements(void *process_ctxt)
|
|||
pr_err("%s: proc_un_map failed!"
|
||||
" status = 0x%xn", __func__, status);
|
||||
}
|
||||
|
||||
/* Free DMM reserved memory resources */
|
||||
list_for_each_entry_safe(rsv_obj, temp_rsv, &ctxt->dmm_rsv_list, link) {
|
||||
status = proc_un_reserve_memory(ctxt->hprocessor, (void *)
|
||||
rsv_obj->dsp_reserved_addr,
|
||||
ctxt);
|
||||
if (status)
|
||||
pr_err("%s: proc_un_reserve_memory failed!"
|
||||
" status = 0x%xn", __func__, status);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
@ -732,6 +743,7 @@ static int request_bridge_resources(struct cfg_hostres *res)
|
|||
host_res->dw_sys_ctrl_base = ioremap(OMAP_SYSC_BASE, OMAP_SYSC_SIZE);
|
||||
dev_dbg(bridge, "dw_mem_base[0] 0x%x\n", host_res->dw_mem_base[0]);
|
||||
dev_dbg(bridge, "dw_mem_base[3] 0x%x\n", host_res->dw_mem_base[3]);
|
||||
dev_dbg(bridge, "dw_dmmu_base %p\n", host_res->dw_dmmu_base);
|
||||
|
||||
/* for 24xx base port is not mapping the mamory for DSP
|
||||
* internal memory TODO Do a ioremap here */
|
||||
|
@ -785,6 +797,8 @@ int drv_request_bridge_res_dsp(void **phost_resources)
|
|||
OMAP_PER_PRM_SIZE);
|
||||
host_res->dw_core_pm_base = (u32) ioremap(OMAP_CORE_PRM_BASE,
|
||||
OMAP_CORE_PRM_SIZE);
|
||||
host_res->dw_dmmu_base = ioremap(OMAP_DMMU_BASE,
|
||||
OMAP_DMMU_SIZE);
|
||||
|
||||
dev_dbg(bridge, "dw_mem_base[0] 0x%x\n",
|
||||
host_res->dw_mem_base[0]);
|
||||
|
@ -796,6 +810,7 @@ int drv_request_bridge_res_dsp(void **phost_resources)
|
|||
host_res->dw_mem_base[3]);
|
||||
dev_dbg(bridge, "dw_mem_base[4] 0x%x\n",
|
||||
host_res->dw_mem_base[4]);
|
||||
dev_dbg(bridge, "dw_dmmu_base %p\n", host_res->dw_dmmu_base);
|
||||
|
||||
shm_size = drv_datap->shm_size;
|
||||
if (shm_size >= 0x10000) {
|
||||
|
|
|
@ -509,6 +509,8 @@ static int bridge_open(struct inode *ip, struct file *filp)
|
|||
pr_ctxt->res_state = PROC_RES_ALLOCATED;
|
||||
spin_lock_init(&pr_ctxt->dmm_map_lock);
|
||||
INIT_LIST_HEAD(&pr_ctxt->dmm_map_list);
|
||||
spin_lock_init(&pr_ctxt->dmm_rsv_lock);
|
||||
INIT_LIST_HEAD(&pr_ctxt->dmm_rsv_list);
|
||||
|
||||
pr_ctxt->node_id = kzalloc(sizeof(struct idr), GFP_KERNEL);
|
||||
if (pr_ctxt->node_id) {
|
||||
|
|
|
@ -56,6 +56,7 @@
|
|||
/* ----------------------------------- This */
|
||||
#include <dspbridge/nodepriv.h>
|
||||
#include <dspbridge/node.h>
|
||||
#include <dspbridge/dmm.h>
|
||||
|
||||
/* Static/Dynamic Loader includes */
|
||||
#include <dspbridge/dbll.h>
|
||||
|
@ -316,6 +317,10 @@ int node_allocate(struct proc_object *hprocessor,
|
|||
u32 mapped_addr = 0;
|
||||
u32 map_attrs = 0x0;
|
||||
struct dsp_processorstate proc_state;
|
||||
#ifdef DSP_DMM_DEBUG
|
||||
struct dmm_object *dmm_mgr;
|
||||
struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
|
||||
#endif
|
||||
|
||||
void *node_res;
|
||||
|
||||
|
@ -425,12 +430,34 @@ int node_allocate(struct proc_object *hprocessor,
|
|||
if (status)
|
||||
goto func_cont;
|
||||
|
||||
status = proc_reserve_memory(hprocessor,
|
||||
pnode->create_args.asa.task_arg_obj.
|
||||
heap_size + PAGE_SIZE,
|
||||
(void **)&(pnode->create_args.asa.
|
||||
task_arg_obj.udsp_heap_res_addr),
|
||||
pr_ctxt);
|
||||
if (status) {
|
||||
pr_err("%s: Failed to reserve memory for heap: 0x%x\n",
|
||||
__func__, status);
|
||||
goto func_cont;
|
||||
}
|
||||
#ifdef DSP_DMM_DEBUG
|
||||
status = dmm_get_handle(p_proc_object, &dmm_mgr);
|
||||
if (!dmm_mgr) {
|
||||
status = DSP_EHANDLE;
|
||||
goto func_cont;
|
||||
}
|
||||
|
||||
dmm_mem_map_dump(dmm_mgr);
|
||||
#endif
|
||||
|
||||
map_attrs |= DSP_MAPLITTLEENDIAN;
|
||||
map_attrs |= DSP_MAPELEMSIZE32;
|
||||
map_attrs |= DSP_MAPVIRTUALADDR;
|
||||
status = proc_map(hprocessor, (void *)attr_in->pgpp_virt_addr,
|
||||
pnode->create_args.asa.task_arg_obj.heap_size,
|
||||
NULL, (void **)&mapped_addr, map_attrs,
|
||||
(void *)pnode->create_args.asa.task_arg_obj.
|
||||
udsp_heap_res_addr, (void **)&mapped_addr, map_attrs,
|
||||
pr_ctxt);
|
||||
if (status)
|
||||
pr_err("%s: Failed to map memory for Heap: 0x%x\n",
|
||||
|
@ -2484,7 +2511,11 @@ static void delete_node(struct node_object *hnode,
|
|||
struct stream_chnl stream;
|
||||
struct node_msgargs node_msg_args;
|
||||
struct node_taskargs task_arg_obj;
|
||||
|
||||
#ifdef DSP_DMM_DEBUG
|
||||
struct dmm_object *dmm_mgr;
|
||||
struct proc_object *p_proc_object =
|
||||
(struct proc_object *)hnode->hprocessor;
|
||||
#endif
|
||||
int status;
|
||||
if (!hnode)
|
||||
goto func_end;
|
||||
|
@ -2545,6 +2576,19 @@ static void delete_node(struct node_object *hnode,
|
|||
status = proc_un_map(hnode->hprocessor, (void *)
|
||||
task_arg_obj.udsp_heap_addr,
|
||||
pr_ctxt);
|
||||
|
||||
status = proc_un_reserve_memory(hnode->hprocessor,
|
||||
(void *)
|
||||
task_arg_obj.
|
||||
udsp_heap_res_addr,
|
||||
pr_ctxt);
|
||||
#ifdef DSP_DMM_DEBUG
|
||||
status = dmm_get_handle(p_proc_object, &dmm_mgr);
|
||||
if (dmm_mgr)
|
||||
dmm_mem_map_dump(dmm_mgr);
|
||||
else
|
||||
status = DSP_EHANDLE;
|
||||
#endif
|
||||
}
|
||||
}
|
||||
if (node_type != NODE_MESSAGE) {
|
||||
|
|
|
@ -39,6 +39,7 @@
|
|||
#include <dspbridge/cod.h>
|
||||
#include <dspbridge/dev.h>
|
||||
#include <dspbridge/procpriv.h>
|
||||
#include <dspbridge/dmm.h>
|
||||
|
||||
/* ----------------------------------- Resource Manager */
|
||||
#include <dspbridge/mgr.h>
|
||||
|
@ -51,7 +52,6 @@
|
|||
#include <dspbridge/msg.h>
|
||||
#include <dspbridge/dspioctl.h>
|
||||
#include <dspbridge/drv.h>
|
||||
#include <_tiomap.h>
|
||||
|
||||
/* ----------------------------------- This */
|
||||
#include <dspbridge/proc.h>
|
||||
|
@ -151,21 +151,34 @@ static struct dmm_map_object *add_mapping_info(struct process_context *pr_ctxt,
|
|||
return map_obj;
|
||||
}
|
||||
|
||||
static int match_exact_map_obj(struct dmm_map_object *map_obj,
|
||||
u32 dsp_addr, u32 size)
|
||||
{
|
||||
if (map_obj->dsp_addr == dsp_addr && map_obj->size != size)
|
||||
pr_err("%s: addr match (0x%x), size don't (0x%x != 0x%x)\n",
|
||||
__func__, dsp_addr, map_obj->size, size);
|
||||
|
||||
return map_obj->dsp_addr == dsp_addr &&
|
||||
map_obj->size == size;
|
||||
}
|
||||
|
||||
static void remove_mapping_information(struct process_context *pr_ctxt,
|
||||
u32 dsp_addr)
|
||||
u32 dsp_addr, u32 size)
|
||||
{
|
||||
struct dmm_map_object *map_obj;
|
||||
|
||||
pr_debug("%s: looking for virt 0x%x\n", __func__, dsp_addr);
|
||||
pr_debug("%s: looking for virt 0x%x size 0x%x\n", __func__,
|
||||
dsp_addr, size);
|
||||
|
||||
spin_lock(&pr_ctxt->dmm_map_lock);
|
||||
list_for_each_entry(map_obj, &pr_ctxt->dmm_map_list, link) {
|
||||
pr_debug("%s: candidate: mpu_addr 0x%x virt 0x%x\n",
|
||||
pr_debug("%s: candidate: mpu_addr 0x%x virt 0x%x size 0x%x\n",
|
||||
__func__,
|
||||
map_obj->mpu_addr,
|
||||
map_obj->dsp_addr);
|
||||
map_obj->dsp_addr,
|
||||
map_obj->size);
|
||||
|
||||
if (map_obj->dsp_addr == dsp_addr) {
|
||||
if (match_exact_map_obj(map_obj, dsp_addr, size)) {
|
||||
pr_debug("%s: match, deleting map info\n", __func__);
|
||||
list_del(&map_obj->link);
|
||||
kfree(map_obj->dma_info.sg);
|
||||
|
@ -1077,6 +1090,7 @@ int proc_load(void *hprocessor, const s32 argc_index,
|
|||
s32 cnew_envp; /* " " in new_envp[] */
|
||||
s32 nproc_id = 0; /* Anticipate MP version. */
|
||||
struct dcd_manager *hdcd_handle;
|
||||
struct dmm_object *dmm_mgr;
|
||||
u32 dw_ext_end;
|
||||
u32 proc_id;
|
||||
int brd_state;
|
||||
|
@ -1267,6 +1281,25 @@ int proc_load(void *hprocessor, const s32 argc_index,
|
|||
if (!status)
|
||||
status = cod_get_sym_value(cod_mgr, EXTEND,
|
||||
&dw_ext_end);
|
||||
|
||||
/* Reset DMM structs and add an initial free chunk */
|
||||
if (!status) {
|
||||
status =
|
||||
dev_get_dmm_mgr(p_proc_object->hdev_obj,
|
||||
&dmm_mgr);
|
||||
if (dmm_mgr) {
|
||||
/* Set dw_ext_end to DMM START u8
|
||||
* address */
|
||||
dw_ext_end =
|
||||
(dw_ext_end + 1) * DSPWORDSIZE;
|
||||
/* DMM memory is from EXT_END */
|
||||
status = dmm_create_tables(dmm_mgr,
|
||||
dw_ext_end,
|
||||
DMMPOOLSIZE);
|
||||
} else {
|
||||
status = -EFAULT;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
/* Restore the original argv[0] */
|
||||
|
@ -1319,10 +1352,12 @@ int proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size,
|
|||
{
|
||||
u32 va_align;
|
||||
u32 pa_align;
|
||||
struct dmm_object *dmm_mgr;
|
||||
u32 size_align;
|
||||
int status = 0;
|
||||
struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
|
||||
struct dmm_map_object *map_obj;
|
||||
u32 tmp_addr = 0;
|
||||
|
||||
#ifdef CONFIG_TIDSPBRIDGE_CACHE_LINE_CHECK
|
||||
if ((ul_map_attr & BUFMODE_MASK) != RBUF) {
|
||||
|
@ -1347,30 +1382,33 @@ int proc_map(void *hprocessor, void *pmpu_addr, u32 ul_size,
|
|||
}
|
||||
/* Critical section */
|
||||
mutex_lock(&proc_lock);
|
||||
dmm_get_handle(p_proc_object, &dmm_mgr);
|
||||
if (dmm_mgr)
|
||||
status = dmm_map_memory(dmm_mgr, va_align, size_align);
|
||||
else
|
||||
status = -EFAULT;
|
||||
|
||||
/* Add mapping to the page tables. */
|
||||
if (!status) {
|
||||
|
||||
/* Mapped address = MSB of VA | LSB of PA */
|
||||
tmp_addr = (va_align | ((u32) pmpu_addr & (PG_SIZE4K - 1)));
|
||||
/* mapped memory resource tracking */
|
||||
map_obj = add_mapping_info(pr_ctxt, pa_align, va_align,
|
||||
map_obj = add_mapping_info(pr_ctxt, pa_align, tmp_addr,
|
||||
size_align);
|
||||
if (!map_obj) {
|
||||
if (!map_obj)
|
||||
status = -ENOMEM;
|
||||
} else {
|
||||
va_align = user_to_dsp_map(
|
||||
p_proc_object->hbridge_context->dsp_mmu,
|
||||
pa_align, va_align, size_align,
|
||||
map_obj->pages);
|
||||
if (IS_ERR_VALUE(va_align))
|
||||
status = (int)va_align;
|
||||
}
|
||||
else
|
||||
status = (*p_proc_object->intf_fxns->pfn_brd_mem_map)
|
||||
(p_proc_object->hbridge_context, pa_align, va_align,
|
||||
size_align, ul_map_attr, map_obj->pages);
|
||||
}
|
||||
if (!status) {
|
||||
/* Mapped address = MSB of VA | LSB of PA */
|
||||
map_obj->dsp_addr = (va_align |
|
||||
((u32)pmpu_addr & (PG_SIZE4K - 1)));
|
||||
*pp_map_addr = (void *)map_obj->dsp_addr;
|
||||
*pp_map_addr = (void *) tmp_addr;
|
||||
} else {
|
||||
remove_mapping_information(pr_ctxt, va_align);
|
||||
remove_mapping_information(pr_ctxt, tmp_addr, size_align);
|
||||
dmm_un_map_memory(dmm_mgr, va_align, &size_align);
|
||||
}
|
||||
mutex_unlock(&proc_lock);
|
||||
|
||||
|
@ -1462,6 +1500,55 @@ func_end:
|
|||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== proc_reserve_memory ========
|
||||
* Purpose:
|
||||
* Reserve a virtually contiguous region of DSP address space.
|
||||
*/
|
||||
int proc_reserve_memory(void *hprocessor, u32 ul_size,
|
||||
void **pp_rsv_addr,
|
||||
struct process_context *pr_ctxt)
|
||||
{
|
||||
struct dmm_object *dmm_mgr;
|
||||
int status = 0;
|
||||
struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
|
||||
struct dmm_rsv_object *rsv_obj;
|
||||
|
||||
if (!p_proc_object) {
|
||||
status = -EFAULT;
|
||||
goto func_end;
|
||||
}
|
||||
|
||||
status = dmm_get_handle(p_proc_object, &dmm_mgr);
|
||||
if (!dmm_mgr) {
|
||||
status = -EFAULT;
|
||||
goto func_end;
|
||||
}
|
||||
|
||||
status = dmm_reserve_memory(dmm_mgr, ul_size, (u32 *) pp_rsv_addr);
|
||||
if (status != 0)
|
||||
goto func_end;
|
||||
|
||||
/*
|
||||
* A successful reserve should be followed by insertion of rsv_obj
|
||||
* into dmm_rsv_list, so that reserved memory resource tracking
|
||||
* remains uptodate
|
||||
*/
|
||||
rsv_obj = kmalloc(sizeof(struct dmm_rsv_object), GFP_KERNEL);
|
||||
if (rsv_obj) {
|
||||
rsv_obj->dsp_reserved_addr = (u32) *pp_rsv_addr;
|
||||
spin_lock(&pr_ctxt->dmm_rsv_lock);
|
||||
list_add(&rsv_obj->link, &pr_ctxt->dmm_rsv_list);
|
||||
spin_unlock(&pr_ctxt->dmm_rsv_lock);
|
||||
}
|
||||
|
||||
func_end:
|
||||
dev_dbg(bridge, "%s: hprocessor: 0x%p ul_size: 0x%x pp_rsv_addr: 0x%p "
|
||||
"status 0x%x\n", __func__, hprocessor,
|
||||
ul_size, pp_rsv_addr, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== proc_start ========
|
||||
* Purpose:
|
||||
|
@ -1610,7 +1697,9 @@ int proc_un_map(void *hprocessor, void *map_addr,
|
|||
{
|
||||
int status = 0;
|
||||
struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
|
||||
struct dmm_object *dmm_mgr;
|
||||
u32 va_align;
|
||||
u32 size_align;
|
||||
|
||||
va_align = PG_ALIGN_LOW((u32) map_addr, PG_SIZE4K);
|
||||
if (!p_proc_object) {
|
||||
|
@ -1618,11 +1707,24 @@ int proc_un_map(void *hprocessor, void *map_addr,
|
|||
goto func_end;
|
||||
}
|
||||
|
||||
status = dmm_get_handle(hprocessor, &dmm_mgr);
|
||||
if (!dmm_mgr) {
|
||||
status = -EFAULT;
|
||||
goto func_end;
|
||||
}
|
||||
|
||||
/* Critical section */
|
||||
mutex_lock(&proc_lock);
|
||||
/*
|
||||
* Update DMM structures. Get the size to unmap.
|
||||
* This function returns error if the VA is not mapped
|
||||
*/
|
||||
status = dmm_un_map_memory(dmm_mgr, (u32) va_align, &size_align);
|
||||
/* Remove mapping from the page tables. */
|
||||
status = user_to_dsp_unmap(p_proc_object->hbridge_context->dsp_mmu,
|
||||
va_align);
|
||||
if (!status) {
|
||||
status = (*p_proc_object->intf_fxns->pfn_brd_mem_un_map)
|
||||
(p_proc_object->hbridge_context, va_align, size_align);
|
||||
}
|
||||
|
||||
mutex_unlock(&proc_lock);
|
||||
if (status)
|
||||
|
@ -1633,7 +1735,7 @@ int proc_un_map(void *hprocessor, void *map_addr,
|
|||
* from dmm_map_list, so that mapped memory resource tracking
|
||||
* remains uptodate
|
||||
*/
|
||||
remove_mapping_information(pr_ctxt, (u32) map_addr);
|
||||
remove_mapping_information(pr_ctxt, (u32) map_addr, size_align);
|
||||
|
||||
func_end:
|
||||
dev_dbg(bridge, "%s: hprocessor: 0x%p map_addr: 0x%p status: 0x%x\n",
|
||||
|
@ -1641,6 +1743,55 @@ func_end:
|
|||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== proc_un_reserve_memory ========
|
||||
* Purpose:
|
||||
* Frees a previously reserved region of DSP address space.
|
||||
*/
|
||||
int proc_un_reserve_memory(void *hprocessor, void *prsv_addr,
|
||||
struct process_context *pr_ctxt)
|
||||
{
|
||||
struct dmm_object *dmm_mgr;
|
||||
int status = 0;
|
||||
struct proc_object *p_proc_object = (struct proc_object *)hprocessor;
|
||||
struct dmm_rsv_object *rsv_obj;
|
||||
|
||||
if (!p_proc_object) {
|
||||
status = -EFAULT;
|
||||
goto func_end;
|
||||
}
|
||||
|
||||
status = dmm_get_handle(p_proc_object, &dmm_mgr);
|
||||
if (!dmm_mgr) {
|
||||
status = -EFAULT;
|
||||
goto func_end;
|
||||
}
|
||||
|
||||
status = dmm_un_reserve_memory(dmm_mgr, (u32) prsv_addr);
|
||||
if (status != 0)
|
||||
goto func_end;
|
||||
|
||||
/*
|
||||
* A successful unreserve should be followed by removal of rsv_obj
|
||||
* from dmm_rsv_list, so that reserved memory resource tracking
|
||||
* remains uptodate
|
||||
*/
|
||||
spin_lock(&pr_ctxt->dmm_rsv_lock);
|
||||
list_for_each_entry(rsv_obj, &pr_ctxt->dmm_rsv_list, link) {
|
||||
if (rsv_obj->dsp_reserved_addr == (u32) prsv_addr) {
|
||||
list_del(&rsv_obj->link);
|
||||
kfree(rsv_obj);
|
||||
break;
|
||||
}
|
||||
}
|
||||
spin_unlock(&pr_ctxt->dmm_rsv_lock);
|
||||
|
||||
func_end:
|
||||
dev_dbg(bridge, "%s: hprocessor: 0x%p prsv_addr: 0x%p status: 0x%x\n",
|
||||
__func__, hprocessor, prsv_addr, status);
|
||||
return status;
|
||||
}
|
||||
|
||||
/*
|
||||
* ======== = proc_monitor ======== ==
|
||||
* Purpose:
|
||||
|
|
|
@ -887,7 +887,7 @@ static int dlfb_ops_open(struct fb_info *info, int user)
|
|||
|
||||
struct fb_deferred_io *fbdefio;
|
||||
|
||||
fbdefio = kmalloc(GFP_KERNEL, sizeof(struct fb_deferred_io));
|
||||
fbdefio = kmalloc(sizeof(struct fb_deferred_io), GFP_KERNEL);
|
||||
|
||||
if (fbdefio) {
|
||||
fbdefio->delay = DL_DEFIO_WRITE_DELAY;
|
||||
|
|
|
@ -1675,13 +1675,14 @@ static int device_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) {
|
|||
|
||||
{
|
||||
char essid[IW_ESSID_MAX_SIZE+1];
|
||||
if (wrq->u.essid.pointer)
|
||||
if (wrq->u.essid.pointer) {
|
||||
rc = iwctl_giwessid(dev, NULL,
|
||||
&(wrq->u.essid), essid);
|
||||
if (copy_to_user(wrq->u.essid.pointer,
|
||||
essid,
|
||||
wrq->u.essid.length) )
|
||||
rc = -EFAULT;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
|
|
|
@ -1417,7 +1417,6 @@ cy_as_usb_set_enum_config(cy_as_device_handle handle,
|
|||
*/
|
||||
bus_mask = 0;
|
||||
media_mask = 0;
|
||||
media_mask = 0;
|
||||
for (bus = 0; bus < CY_AS_MAX_BUSES; bus++) {
|
||||
for (device = 0; device < CY_AS_MAX_STORAGE_DEVICES; device++) {
|
||||
if (config_p->devices_to_enumerate[bus][device] ==
|
||||
|
|
|
@ -139,7 +139,7 @@ exit:
|
|||
}
|
||||
|
||||
int prism2_add_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_index, const u8 *mac_addr,
|
||||
u8 key_index, bool pairwise, const u8 *mac_addr,
|
||||
struct key_params *params)
|
||||
{
|
||||
wlandevice_t *wlandev = dev->ml_priv;
|
||||
|
@ -198,7 +198,7 @@ exit:
|
|||
}
|
||||
|
||||
int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_index, const u8 *mac_addr, void *cookie,
|
||||
u8 key_index, bool pairwise, const u8 *mac_addr, void *cookie,
|
||||
void (*callback)(void *cookie, struct key_params*))
|
||||
{
|
||||
wlandevice_t *wlandev = dev->ml_priv;
|
||||
|
@ -227,7 +227,7 @@ int prism2_get_key(struct wiphy *wiphy, struct net_device *dev,
|
|||
}
|
||||
|
||||
int prism2_del_key(struct wiphy *wiphy, struct net_device *dev,
|
||||
u8 key_index, const u8 *mac_addr)
|
||||
u8 key_index, bool pairwise, const u8 *mac_addr)
|
||||
{
|
||||
wlandevice_t *wlandev = dev->ml_priv;
|
||||
u32 did;
|
||||
|
|
|
@ -522,8 +522,8 @@ static int p80211netdev_ethtool(wlandevice_t *wlandev, void __user *useraddr)
|
|||
if (copy_to_user(useraddr, &edata, sizeof(edata)))
|
||||
return -EFAULT;
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
return -EOPNOTSUPP;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue