Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 8ecabc72 authored by Linux Build Service Account's avatar Linux Build Service Account Committed by Gerrit - the friendly Code Review server
Browse files

Merge "msm: ipa3: using rate limit api for ioctl calls"

parents d96c71eb f766cc34
Loading
Loading
Loading
Loading
+37 −0
Original line number Diff line number Diff line
@@ -19,6 +19,10 @@
#include <linux/ipa.h>
#include <linux/ipa_uc_offload.h>
#include <linux/ipa_wdi3.h>
#include <linux/ratelimit.h>

#define WARNON_RATELIMIT_BURST 1
#define IPA_RATELIMIT_BURST 1

#define __FILENAME__ \
	(strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
@@ -104,6 +108,39 @@
		ipa_dec_client_disable_clks(&log_info); \
	} while (0)

/*
 * Printing one warning message in 5 seconds if multiple warning messages
 * are coming back to back.
 */

#define WARN_ON_RATELIMIT_IPA(condition)				\
({								\
	static DEFINE_RATELIMIT_STATE(_rs,			\
				DEFAULT_RATELIMIT_INTERVAL,	\
				WARNON_RATELIMIT_BURST);	\
	int rtn = !!(condition);				\
								\
	if (unlikely(rtn && __ratelimit(&_rs)))			\
		WARN_ON(rtn);					\
})

/*
 * Printing one error message in 5 seconds if multiple error messages
 * are coming back to back.
 */

#define pr_err_ratelimited_ipa(fmt, ...)				\
	printk_ratelimited_ipa(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
#define printk_ratelimited_ipa(fmt, ...)				\
({									\
	static DEFINE_RATELIMIT_STATE(_rs,				\
				      DEFAULT_RATELIMIT_INTERVAL,	\
				      IPA_RATELIMIT_BURST);		\
									\
	if (__ratelimit(&_rs))						\
		printk(fmt, ##__VA_ARGS__);				\
})

#define ipa_assert_on(condition)\
do {\
	if (unlikely(condition))\
+15 −15
Original line number Diff line number Diff line
@@ -261,7 +261,7 @@ static int ipa3_generate_flt_hw_rule(enum ipa_ip_type ip,
	if (entry->hw_len == 0) {
		entry->hw_len = buf - start;
	} else if (entry->hw_len != (buf - start)) {
		IPAERR("hw_len differs b/w passes passed=0x%x calc=0x%td\n",
		IPAERR_RL("hw_len differs b/w passes passed=0x%x calc=0x%td\n",
			entry->hw_len, (buf - start));
		return -EPERM;
	}
@@ -634,7 +634,7 @@ static int ipa_generate_flt_hw_tbl_img(enum ipa_ip_type ip,
	}

	if (ipa_alloc_init_flt_tbl_hdr(ip, hash_hdr, nhash_hdr)) {
		IPAERR("fail to alloc and init flt tbl hdr\n");
		IPAERR_RL("fail to alloc and init flt tbl hdr\n");
		rc = -ENOMEM;
		goto no_flt_tbls;
	}
@@ -684,13 +684,13 @@ static int ipa_generate_flt_hw_tbl_img(enum ipa_ip_type ip,

	if (ipa_translate_flt_tbl_to_hw_fmt(ip, IPA_RULE_HASHABLE,
		hash_bdy->base, hash_hdr->base, hash_bdy_start_ofst)) {
		IPAERR("fail to translate hashable flt tbls to hw format\n");
		IPAERR_RL("fail to translate hashable flt tbls to hw format\n");
		rc = -EPERM;
		goto translate_fail;
	}
	if (ipa_translate_flt_tbl_to_hw_fmt(ip, IPA_RULE_NON_HASHABLE,
		nhash_bdy->base, nhash_hdr->base, nhash_bdy_start_ofst)) {
		IPAERR("fail to translate non-hash flt tbls to hw format\n");
		IPAERR_RL("fail to translate non-hash flt tbls to hw format\n");
		rc = -EPERM;
		goto translate_fail;
	}
@@ -872,7 +872,7 @@ int __ipa_commit_flt_v3(enum ipa_ip_type ip)

	if (ipa_generate_flt_hw_tbl_img(ip,
		&hash_hdr, &nhash_hdr, &hash_bdy, &nhash_bdy)) {
		IPAERR("fail to generate FLT HW TBL image. IP %d\n", ip);
		IPAERR_RL("fail to generate FLT HW TBL image. IP %d\n", ip);
		rc = -EFAULT;
		goto fail_gen;
	}
@@ -1074,25 +1074,25 @@ static int __ipa_validate_flt_rule(const struct ipa_flt_rule *rule,
	if (rule->action != IPA_PASS_TO_EXCEPTION) {
		if (!rule->eq_attrib_type) {
			if (!rule->rt_tbl_hdl) {
				IPAERR("invalid RT tbl\n");
				IPAERR_RL("invalid RT tbl\n");
				goto error;
			}

			*rt_tbl = ipa3_id_find(rule->rt_tbl_hdl);
			if (*rt_tbl == NULL) {
				IPAERR("RT tbl not found\n");
				IPAERR_RL("RT tbl not found\n");
				goto error;
			}

			if ((*rt_tbl)->cookie != IPA_RT_TBL_COOKIE) {
				IPAERR("RT table cookie is invalid\n");
				IPAERR_RL("RT table cookie is invalid\n");
				goto error;
			}
		} else {
			if (rule->rt_tbl_idx > ((ip == IPA_IP_v4) ?
				IPA_MEM_PART(v4_modem_rt_index_hi) :
				IPA_MEM_PART(v6_modem_rt_index_hi))) {
				IPAERR("invalid RT tbl\n");
				IPAERR_RL("invalid RT tbl\n");
				goto error;
			}
		}
@@ -1101,7 +1101,7 @@ static int __ipa_validate_flt_rule(const struct ipa_flt_rule *rule,
	if (rule->rule_id) {
		if (rule->rule_id >= IPA_RULE_ID_MIN_VAL &&
		    rule->rule_id <= IPA_RULE_ID_MAX_VAL) {
			IPAERR("invalid rule_id provided 0x%x\n"
			IPAERR_RL("invalid rule_id provided 0x%x\n"
				"rule_id 0x%x - 0x%x  are auto generated\n",
				rule->rule_id,
				IPA_RULE_ID_MIN_VAL,
@@ -1137,8 +1137,8 @@ static int __ipa_create_flt_entry(struct ipa3_flt_entry **entry,
	} else {
		id = ipa3_alloc_rule_id(&tbl->rule_ids);
		if (id < 0) {
			IPAERR("failed to allocate rule id\n");
			WARN_ON(1);
			IPAERR_RL("failed to allocate rule id\n");
			WARN_ON_RATELIMIT_IPA(1);
			goto rule_id_fail;
		}
	}
@@ -1162,8 +1162,8 @@ static int __ipa_finish_flt_rule_add(struct ipa3_flt_tbl *tbl,
		entry->rt_tbl->ref_cnt++;
	id = ipa3_id_alloc(entry);
	if (id < 0) {
		IPAERR("failed to add to tree\n");
		WARN_ON(1);
		IPAERR_RL("failed to add to tree\n");
		WARN_ON_RATELIMIT_IPA(1);
		goto ipa_insert_failed;
	}
	*rule_hdl = id;
@@ -1702,7 +1702,7 @@ int ipa3_reset_flt(enum ipa_ip_type ip)
		list_for_each_entry_safe(entry, next, &tbl->head_flt_rule_list,
				link) {
			if (ipa3_id_find(entry->id) == NULL) {
				WARN_ON(1);
				WARN_ON_RATELIMIT_IPA(1);
				mutex_unlock(&ipa3_ctx->lock);
				return -EFAULT;
			}
+9 −9
Original line number Diff line number Diff line
@@ -354,7 +354,7 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
	}
	if (hdr_entry->cookie != IPA_HDR_COOKIE) {
		IPAERR_RL("Invalid header cookie %u\n", hdr_entry->cookie);
		WARN_ON(1);
		WARN_ON_RATELIMIT_IPA(1);
		return -EINVAL;
	}
	IPADBG("Associated header is name=%s is_hdr_proc_ctx=%d\n",
@@ -384,7 +384,7 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,
		bin = IPA_HDR_PROC_CTX_BIN1;
	} else {
		IPAERR_RL("unexpected needed len %d\n", needed_len);
		WARN_ON(1);
		WARN_ON_RATELIMIT_IPA(1);
		goto bad_len;
	}

@@ -429,8 +429,8 @@ static int __ipa_add_hdr_proc_ctx(struct ipa_hdr_proc_ctx_add *proc_ctx,

	id = ipa3_id_alloc(entry);
	if (id < 0) {
		IPAERR("failed to alloc id\n");
		WARN_ON(1);
		IPAERR_RL("failed to alloc id\n");
		WARN_ON_RATELIMIT_IPA(1);
		goto ipa_insert_failed;
	}
	entry->id = id;
@@ -566,8 +566,8 @@ static int __ipa_add_hdr(struct ipa_hdr_add *hdr)

	id = ipa3_id_alloc(entry);
	if (id < 0) {
		IPAERR("failed to alloc id\n");
		WARN_ON(1);
		IPAERR_RL("failed to alloc id\n");
		WARN_ON_RATELIMIT_IPA(1);
		goto ipa_insert_failed;
	}
	entry->id = id;
@@ -995,7 +995,7 @@ int ipa3_reset_hdr(void)
			if (entry->is_hdr_proc_ctx) {
				IPAERR("default header is proc ctx\n");
				mutex_unlock(&ipa3_ctx->lock);
				WARN_ON(1);
				WARN_ON_RATELIMIT_IPA(1);
				return -EFAULT;
			}
			continue;
@@ -1003,7 +1003,7 @@ int ipa3_reset_hdr(void)

		if (ipa3_id_find(entry->id) == NULL) {
			mutex_unlock(&ipa3_ctx->lock);
			WARN_ON(1);
			WARN_ON_RATELIMIT_IPA(1);
			return -EFAULT;
		}
		if (entry->is_hdr_proc_ctx) {
@@ -1057,7 +1057,7 @@ int ipa3_reset_hdr(void)

		if (ipa3_id_find(ctx_entry->id) == NULL) {
			mutex_unlock(&ipa3_ctx->lock);
			WARN_ON(1);
			WARN_ON_RATELIMIT_IPA(1);
			return -EFAULT;
		}
		list_del(&ctx_entry->link);
+1 −1
Original line number Diff line number Diff line
@@ -100,7 +100,7 @@

#define IPAERR_RL(fmt, args...) \
	do { \
		pr_err_ratelimited(DRV_NAME " %s:%d " fmt, __func__,\
		pr_err_ratelimited_ipa(DRV_NAME " %s:%d " fmt, __func__,\
		__LINE__, ## args);\
		if (ipa3_ctx) { \
			IPA_IPC_LOGGING(ipa3_ctx->logbuf, \
+1 −1
Original line number Diff line number Diff line
@@ -221,7 +221,7 @@ int ipa3_query_intf(struct ipa_ioc_query_intf *lookup)
	int result = -EINVAL;

	if (lookup == NULL) {
		IPAERR("invalid param lookup=%p\n", lookup);
		IPAERR_RL("invalid param lookup=%p\n", lookup);
		return result;
	}

Loading