diff mbox series

firmware: qcom_scm: Use fixed width src vm bitmap

Message ID 20230213181832.3489174-1-quic_eberman@quicinc.com (mailing list archive)
State Not Applicable
Delegated to: Kalle Valo
Headers show
Series firmware: qcom_scm: Use fixed width src vm bitmap | expand

Commit Message

Elliot Berman Feb. 13, 2023, 6:18 p.m. UTC
The maximum VMID for assign_mem is 63. Use a u64 to represent this
bitmap instead of architecture-dependent "unsigned int" which varies in
size on 32-bit and 64-bit platforms.

Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
---
 drivers/firmware/qcom_scm.c            | 12 +++++++-----
 drivers/misc/fastrpc.c                 |  2 +-
 drivers/net/wireless/ath/ath10k/qmi.c  |  4 ++--
 drivers/remoteproc/qcom_q6v5_mss.c     |  8 ++++----
 drivers/remoteproc/qcom_q6v5_pas.c     |  2 +-
 drivers/soc/qcom/rmtfs_mem.c           |  2 +-
 include/linux/firmware/qcom/qcom_scm.h |  2 +-
 7 files changed, 17 insertions(+), 15 deletions(-)


base-commit: 09e41676e35ab06e4bce8870ea3bf1f191c3cb90

Comments

Bjorn Andersson Feb. 13, 2023, 9:44 p.m. UTC | #1
On Mon, Feb 13, 2023 at 10:18:29AM -0800, Elliot Berman wrote:
> The maximum VMID for assign_mem is 63. Use a u64 to represent this
> bitmap instead of architecture-dependent "unsigned int" which varies in
> size on 32-bit and 64-bit platforms.
> 
> Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
> Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>

Reviewed-by: Bjorn Andersson <andersson@kernel.org>

@Greg, would you mind taking this through your tree for v6.3, you
already have a related change in fastrpc.c in your tree...

Regards,
Bjorn

> ---
>  drivers/firmware/qcom_scm.c            | 12 +++++++-----
>  drivers/misc/fastrpc.c                 |  2 +-
>  drivers/net/wireless/ath/ath10k/qmi.c  |  4 ++--
>  drivers/remoteproc/qcom_q6v5_mss.c     |  8 ++++----
>  drivers/remoteproc/qcom_q6v5_pas.c     |  2 +-
>  drivers/soc/qcom/rmtfs_mem.c           |  2 +-
>  include/linux/firmware/qcom/qcom_scm.h |  2 +-
>  7 files changed, 17 insertions(+), 15 deletions(-)
> 
> diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
> index 468d4d5ab550..b95616b35bff 100644
> --- a/drivers/firmware/qcom_scm.c
> +++ b/drivers/firmware/qcom_scm.c
> @@ -905,7 +905,7 @@ static int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region,
>   * Return negative errno on failure or 0 on success with @srcvm updated.
>   */
>  int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
> -			unsigned int *srcvm,
> +			u64 *srcvm,
>  			const struct qcom_scm_vmperm *newvm,
>  			unsigned int dest_cnt)
>  {
> @@ -922,9 +922,9 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
>  	__le32 *src;
>  	void *ptr;
>  	int ret, i, b;
> -	unsigned long srcvm_bits = *srcvm;
> +	u64 srcvm_bits = *srcvm;
>  
> -	src_sz = hweight_long(srcvm_bits) * sizeof(*src);
> +	src_sz = hweight64(srcvm_bits) * sizeof(*src);
>  	mem_to_map_sz = sizeof(*mem_to_map);
>  	dest_sz = dest_cnt * sizeof(*destvm);
>  	ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) +
> @@ -937,8 +937,10 @@ int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
>  	/* Fill source vmid detail */
>  	src = ptr;
>  	i = 0;
> -	for_each_set_bit(b, &srcvm_bits, BITS_PER_LONG)
> -		src[i++] = cpu_to_le32(b);
> +	for (b = 0; b < BITS_PER_TYPE(u64); b++) {
> +		if (srcvm_bits & BIT(b))
> +			src[i++] = cpu_to_le32(b);
> +	}
>  
>  	/* Fill details of mem buff to map */
>  	mem_to_map = ptr + ALIGN(src_sz, SZ_64);
> diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
> index a701132638cf..f48466960f1b 100644
> --- a/drivers/misc/fastrpc.c
> +++ b/drivers/misc/fastrpc.c
> @@ -262,7 +262,7 @@ struct fastrpc_channel_ctx {
>  	int domain_id;
>  	int sesscount;
>  	int vmcount;
> -	u32 perms;
> +	u64 perms;
>  	struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
>  	struct rpmsg_device *rpdev;
>  	struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
> diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
> index 90f457b8e1fe..038c5903c0dc 100644
> --- a/drivers/net/wireless/ath/ath10k/qmi.c
> +++ b/drivers/net/wireless/ath/ath10k/qmi.c
> @@ -33,7 +33,7 @@ static int ath10k_qmi_map_msa_permission(struct ath10k_qmi *qmi,
>  {
>  	struct qcom_scm_vmperm dst_perms[3];
>  	struct ath10k *ar = qmi->ar;
> -	unsigned int src_perms;
> +	u64 src_perms;
>  	u32 perm_count;
>  	int ret;
>  
> @@ -65,7 +65,7 @@ static int ath10k_qmi_unmap_msa_permission(struct ath10k_qmi *qmi,
>  {
>  	struct qcom_scm_vmperm dst_perms;
>  	struct ath10k *ar = qmi->ar;
> -	unsigned int src_perms;
> +	u64 src_perms;
>  	int ret;
>  
>  	src_perms = BIT(QCOM_SCM_VMID_MSS_MSA) | BIT(QCOM_SCM_VMID_WLAN);
> diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
> index ab053084f7a2..1ba711bc0100 100644
> --- a/drivers/remoteproc/qcom_q6v5_mss.c
> +++ b/drivers/remoteproc/qcom_q6v5_mss.c
> @@ -235,8 +235,8 @@ struct q6v5 {
>  	bool has_qaccept_regs;
>  	bool has_ext_cntl_regs;
>  	bool has_vq6;
> -	int mpss_perm;
> -	int mba_perm;
> +	u64 mpss_perm;
> +	u64 mba_perm;
>  	const char *hexagon_mdt_image;
>  	int version;
>  };
> @@ -414,7 +414,7 @@ static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds,
>  	}
>  }
>  
> -static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,
> +static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, u64 *current_perm,
>  				   bool local, bool remote, phys_addr_t addr,
>  				   size_t size)
>  {
> @@ -967,7 +967,7 @@ static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw,
>  	unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS;
>  	dma_addr_t phys;
>  	void *metadata;
> -	int mdata_perm;
> +	u64 mdata_perm;
>  	int xferop_ret;
>  	size_t size;
>  	void *ptr;
> diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
> index 1e14ae4d233a..a0fa7176fde7 100644
> --- a/drivers/remoteproc/qcom_q6v5_pas.c
> +++ b/drivers/remoteproc/qcom_q6v5_pas.c
> @@ -94,7 +94,7 @@ struct qcom_adsp {
>  	size_t region_assign_size;
>  
>  	int region_assign_idx;
> -	int region_assign_perms;
> +	u64 region_assign_perms;
>  
>  	struct qcom_rproc_glink glink_subdev;
>  	struct qcom_rproc_subdev smd_subdev;
> diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
> index 2d3ee22b9249..2657c6105bb7 100644
> --- a/drivers/soc/qcom/rmtfs_mem.c
> +++ b/drivers/soc/qcom/rmtfs_mem.c
> @@ -31,7 +31,7 @@ struct qcom_rmtfs_mem {
>  
>  	unsigned int client_id;
>  
> -	unsigned int perms;
> +	u64 perms;
>  };
>  
>  static ssize_t qcom_rmtfs_mem_show(struct device *dev,
> diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
> index 1e449a5d7f5c..250ea4efb7cb 100644
> --- a/include/linux/firmware/qcom/qcom_scm.h
> +++ b/include/linux/firmware/qcom/qcom_scm.h
> @@ -94,7 +94,7 @@ extern int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,
>  					  u32 cp_nonpixel_start,
>  					  u32 cp_nonpixel_size);
>  extern int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
> -			       unsigned int *src,
> +			       u64 *src,
>  			       const struct qcom_scm_vmperm *newvm,
>  			       unsigned int dest_cnt);
>  
> 
> base-commit: 09e41676e35ab06e4bce8870ea3bf1f191c3cb90
> -- 
> 2.39.1
>
Greg KH Feb. 14, 2023, 8:58 a.m. UTC | #2
On Mon, Feb 13, 2023 at 01:44:17PM -0800, Bjorn Andersson wrote:
> On Mon, Feb 13, 2023 at 10:18:29AM -0800, Elliot Berman wrote:
> > The maximum VMID for assign_mem is 63. Use a u64 to represent this
> > bitmap instead of architecture-dependent "unsigned int" which varies in
> > size on 32-bit and 64-bit platforms.
> > 
> > Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
> > Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
> > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> 
> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
> 
> @Greg, would you mind taking this through your tree for v6.3, you
> already have a related change in fastrpc.c in your tree...

I tried, but it doesn't apply to my char-misc tree at all:

checking file drivers/firmware/qcom_scm.c
Hunk #1 succeeded at 898 (offset -7 lines).
Hunk #2 succeeded at 915 (offset -7 lines).
Hunk #3 succeeded at 930 (offset -7 lines).
checking file drivers/misc/fastrpc.c
checking file drivers/net/wireless/ath/ath10k/qmi.c
checking file drivers/remoteproc/qcom_q6v5_mss.c
Hunk #1 succeeded at 227 (offset -8 lines).
Hunk #2 succeeded at 404 (offset -10 lines).
Hunk #3 succeeded at 939 with fuzz 1 (offset -28 lines).
checking file drivers/remoteproc/qcom_q6v5_pas.c
Hunk #1 FAILED at 94.
1 out of 1 hunk FAILED
checking file drivers/soc/qcom/rmtfs_mem.c
Hunk #1 succeeded at 30 (offset -1 lines).
can't find file to patch at input line 167
Perhaps you used the wrong -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/include/linux/firmware/qcom/qcom_scm.h
b/include/linux/firmware/qcom/qcom_scm.h
|index 1e449a5d7f5c..250ea4efb7cb 100644
|--- a/include/linux/firmware/qcom/qcom_scm.h
|+++ b/include/linux/firmware/qcom/qcom_scm.h
--------------------------

What tree is this patch made against?

thanks,

greg k-h
Bjorn Andersson Feb. 14, 2023, 5:23 p.m. UTC | #3
On Tue, Feb 14, 2023 at 09:58:44AM +0100, Greg Kroah-Hartman wrote:
> On Mon, Feb 13, 2023 at 01:44:17PM -0800, Bjorn Andersson wrote:
> > On Mon, Feb 13, 2023 at 10:18:29AM -0800, Elliot Berman wrote:
> > > The maximum VMID for assign_mem is 63. Use a u64 to represent this
> > > bitmap instead of architecture-dependent "unsigned int" which varies in
> > > size on 32-bit and 64-bit platforms.
> > > 
> > > Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
> > > Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
> > > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> > 
> > Reviewed-by: Bjorn Andersson <andersson@kernel.org>
> > 
> > @Greg, would you mind taking this through your tree for v6.3, you
> > already have a related change in fastrpc.c in your tree...
> 
> I tried, but it doesn't apply to my char-misc tree at all:
> 
> checking file drivers/firmware/qcom_scm.c
> Hunk #1 succeeded at 898 (offset -7 lines).
> Hunk #2 succeeded at 915 (offset -7 lines).
> Hunk #3 succeeded at 930 (offset -7 lines).
> checking file drivers/misc/fastrpc.c
> checking file drivers/net/wireless/ath/ath10k/qmi.c
> checking file drivers/remoteproc/qcom_q6v5_mss.c
> Hunk #1 succeeded at 227 (offset -8 lines).
> Hunk #2 succeeded at 404 (offset -10 lines).
> Hunk #3 succeeded at 939 with fuzz 1 (offset -28 lines).
> checking file drivers/remoteproc/qcom_q6v5_pas.c
> Hunk #1 FAILED at 94.
> 1 out of 1 hunk FAILED
> checking file drivers/soc/qcom/rmtfs_mem.c
> Hunk #1 succeeded at 30 (offset -1 lines).
> can't find file to patch at input line 167
> Perhaps you used the wrong -p or --strip option?
> The text leading up to this was:
> --------------------------
> |diff --git a/include/linux/firmware/qcom/qcom_scm.h
> b/include/linux/firmware/qcom/qcom_scm.h
> |index 1e449a5d7f5c..250ea4efb7cb 100644
> |--- a/include/linux/firmware/qcom/qcom_scm.h
> |+++ b/include/linux/firmware/qcom/qcom_scm.h
> --------------------------
> 
> What tree is this patch made against?
> 

Sorry about that, I missed the previous changes in qcom_q6v5_pas in the
remoteproc tree. Elliot said he based it on linux-next, so I expect that
it will merge fine on top of -rc1, once that arrives.

Regards,
Bjorn
Elliot Berman Feb. 14, 2023, 6:52 p.m. UTC | #4
On 2/14/2023 9:23 AM, Bjorn Andersson wrote:
> On Tue, Feb 14, 2023 at 09:58:44AM +0100, Greg Kroah-Hartman wrote:
>> On Mon, Feb 13, 2023 at 01:44:17PM -0800, Bjorn Andersson wrote:
>>> On Mon, Feb 13, 2023 at 10:18:29AM -0800, Elliot Berman wrote:
>>>> The maximum VMID for assign_mem is 63. Use a u64 to represent this
>>>> bitmap instead of architecture-dependent "unsigned int" which varies in
>>>> size on 32-bit and 64-bit platforms.
>>>>
>>>> Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
>>>> Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
>>>> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
>>>
>>> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
>>>
>>> @Greg, would you mind taking this through your tree for v6.3, you
>>> already have a related change in fastrpc.c in your tree...
>>
>> I tried, but it doesn't apply to my char-misc tree at all:
>>
>> checking file drivers/firmware/qcom_scm.c
>> Hunk #1 succeeded at 898 (offset -7 lines).
>> Hunk #2 succeeded at 915 (offset -7 lines).
>> Hunk #3 succeeded at 930 (offset -7 lines).
>> checking file drivers/misc/fastrpc.c
>> checking file drivers/net/wireless/ath/ath10k/qmi.c
>> checking file drivers/remoteproc/qcom_q6v5_mss.c
>> Hunk #1 succeeded at 227 (offset -8 lines).
>> Hunk #2 succeeded at 404 (offset -10 lines).
>> Hunk #3 succeeded at 939 with fuzz 1 (offset -28 lines).
>> checking file drivers/remoteproc/qcom_q6v5_pas.c
>> Hunk #1 FAILED at 94.
>> 1 out of 1 hunk FAILED
>> checking file drivers/soc/qcom/rmtfs_mem.c
>> Hunk #1 succeeded at 30 (offset -1 lines).
>> can't find file to patch at input line 167
>> Perhaps you used the wrong -p or --strip option?
>> The text leading up to this was:
>> --------------------------
>> |diff --git a/include/linux/firmware/qcom/qcom_scm.h
>> b/include/linux/firmware/qcom/qcom_scm.h
>> |index 1e449a5d7f5c..250ea4efb7cb 100644
>> |--- a/include/linux/firmware/qcom/qcom_scm.h
>> |+++ b/include/linux/firmware/qcom/qcom_scm.h
>> --------------------------
>>
>> What tree is this patch made against?
>>
> 
> Sorry about that, I missed the previous changes in qcom_q6v5_pas in the
> remoteproc tree. Elliot said he based it on linux-next, so I expect that
> it will merge fine on top of -rc1, once that arrives.
> 

Yes, this patch applies on next-20230213. I guess there are enough 
changes were coming from QCOM side (via Bjorn's qcom tree) as well as 
the fastrpc change (via Greg's char-misc tree).

Let me know if I should do anything once -rc1 arrives. Happy to post 
version on the -rc1 if it helps.

Thanks,
Elliot

> Regards,
> Bjorn
Elliot Berman March 3, 2023, 9:09 p.m. UTC | #5
On 2/14/2023 10:52 AM, Elliot Berman wrote:
> 
> 
> On 2/14/2023 9:23 AM, Bjorn Andersson wrote:
>> On Tue, Feb 14, 2023 at 09:58:44AM +0100, Greg Kroah-Hartman wrote:
>>> On Mon, Feb 13, 2023 at 01:44:17PM -0800, Bjorn Andersson wrote:
>>>> On Mon, Feb 13, 2023 at 10:18:29AM -0800, Elliot Berman wrote:
>>>>> The maximum VMID for assign_mem is 63. Use a u64 to represent this
>>>>> bitmap instead of architecture-dependent "unsigned int" which 
>>>>> varies in
>>>>> size on 32-bit and 64-bit platforms.
>>>>>
>>>>> Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
>>>>> Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
>>>>> Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
>>>>
>>>> Reviewed-by: Bjorn Andersson <andersson@kernel.org>
>>>>
>>>> @Greg, would you mind taking this through your tree for v6.3, you
>>>> already have a related change in fastrpc.c in your tree...
>>>
>>> I tried, but it doesn't apply to my char-misc tree at all:
>>>
>>> checking file drivers/firmware/qcom_scm.c
>>> Hunk #1 succeeded at 898 (offset -7 lines).
>>> Hunk #2 succeeded at 915 (offset -7 lines).
>>> Hunk #3 succeeded at 930 (offset -7 lines).
>>> checking file drivers/misc/fastrpc.c
>>> checking file drivers/net/wireless/ath/ath10k/qmi.c
>>> checking file drivers/remoteproc/qcom_q6v5_mss.c
>>> Hunk #1 succeeded at 227 (offset -8 lines).
>>> Hunk #2 succeeded at 404 (offset -10 lines).
>>> Hunk #3 succeeded at 939 with fuzz 1 (offset -28 lines).
>>> checking file drivers/remoteproc/qcom_q6v5_pas.c
>>> Hunk #1 FAILED at 94.
>>> 1 out of 1 hunk FAILED
>>> checking file drivers/soc/qcom/rmtfs_mem.c
>>> Hunk #1 succeeded at 30 (offset -1 lines).
>>> can't find file to patch at input line 167
>>> Perhaps you used the wrong -p or --strip option?
>>> The text leading up to this was:
>>> --------------------------
>>> |diff --git a/include/linux/firmware/qcom/qcom_scm.h
>>> b/include/linux/firmware/qcom/qcom_scm.h
>>> |index 1e449a5d7f5c..250ea4efb7cb 100644
>>> |--- a/include/linux/firmware/qcom/qcom_scm.h
>>> |+++ b/include/linux/firmware/qcom/qcom_scm.h
>>> --------------------------
>>>
>>> What tree is this patch made against?
>>>
>>
>> Sorry about that, I missed the previous changes in qcom_q6v5_pas in the
>> remoteproc tree. Elliot said he based it on linux-next, so I expect that
>> it will merge fine on top of -rc1, once that arrives.
>>
> 
> Yes, this patch applies on next-20230213. I guess there are enough 
> changes were coming from QCOM side (via Bjorn's qcom tree) as well as 
> the fastrpc change (via Greg's char-misc tree).
> 
> Let me know if I should do anything once -rc1 arrives. Happy to post 
> version on the -rc1 if it helps.
> 

The patch now applies on tip of Linus's tree and on char-misc.
Bjorn Andersson March 15, 2023, 4:11 a.m. UTC | #6
On Fri, Mar 03, 2023 at 01:09:08PM -0800, Elliot Berman wrote:
> 
> 
> On 2/14/2023 10:52 AM, Elliot Berman wrote:
> > 
> > 
> > On 2/14/2023 9:23 AM, Bjorn Andersson wrote:
> > > On Tue, Feb 14, 2023 at 09:58:44AM +0100, Greg Kroah-Hartman wrote:
> > > > On Mon, Feb 13, 2023 at 01:44:17PM -0800, Bjorn Andersson wrote:
> > > > > On Mon, Feb 13, 2023 at 10:18:29AM -0800, Elliot Berman wrote:
> > > > > > The maximum VMID for assign_mem is 63. Use a u64 to represent this
> > > > > > bitmap instead of architecture-dependent "unsigned int"
> > > > > > which varies in
> > > > > > size on 32-bit and 64-bit platforms.
> > > > > > 
> > > > > > Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
> > > > > > Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
> > > > > > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> > > > > 
> > > > > Reviewed-by: Bjorn Andersson <andersson@kernel.org>
> > > > > 
> > > > > @Greg, would you mind taking this through your tree for v6.3, you
> > > > > already have a related change in fastrpc.c in your tree...
> > > > 
> > > > I tried, but it doesn't apply to my char-misc tree at all:
> > > > 
> > > > checking file drivers/firmware/qcom_scm.c
> > > > Hunk #1 succeeded at 898 (offset -7 lines).
> > > > Hunk #2 succeeded at 915 (offset -7 lines).
> > > > Hunk #3 succeeded at 930 (offset -7 lines).
> > > > checking file drivers/misc/fastrpc.c
> > > > checking file drivers/net/wireless/ath/ath10k/qmi.c
> > > > checking file drivers/remoteproc/qcom_q6v5_mss.c
> > > > Hunk #1 succeeded at 227 (offset -8 lines).
> > > > Hunk #2 succeeded at 404 (offset -10 lines).
> > > > Hunk #3 succeeded at 939 with fuzz 1 (offset -28 lines).
> > > > checking file drivers/remoteproc/qcom_q6v5_pas.c
> > > > Hunk #1 FAILED at 94.
> > > > 1 out of 1 hunk FAILED
> > > > checking file drivers/soc/qcom/rmtfs_mem.c
> > > > Hunk #1 succeeded at 30 (offset -1 lines).
> > > > can't find file to patch at input line 167
> > > > Perhaps you used the wrong -p or --strip option?
> > > > The text leading up to this was:
> > > > --------------------------
> > > > |diff --git a/include/linux/firmware/qcom/qcom_scm.h
> > > > b/include/linux/firmware/qcom/qcom_scm.h
> > > > |index 1e449a5d7f5c..250ea4efb7cb 100644
> > > > |--- a/include/linux/firmware/qcom/qcom_scm.h
> > > > |+++ b/include/linux/firmware/qcom/qcom_scm.h
> > > > --------------------------
> > > > 
> > > > What tree is this patch made against?
> > > > 
> > > 
> > > Sorry about that, I missed the previous changes in qcom_q6v5_pas in the
> > > remoteproc tree. Elliot said he based it on linux-next, so I expect that
> > > it will merge fine on top of -rc1, once that arrives.
> > > 
> > 
> > Yes, this patch applies on next-20230213. I guess there are enough
> > changes were coming from QCOM side (via Bjorn's qcom tree) as well as
> > the fastrpc change (via Greg's char-misc tree).
> > 
> > Let me know if I should do anything once -rc1 arrives. Happy to post
> > version on the -rc1 if it helps.
> > 
> 
> The patch now applies on tip of Linus's tree and on char-misc.

Greg, I have a couple more patches in the scm driver in my inbox. Would
you be okay with me pulling this through the Qualcomm tree for v6.4?

Regards,
Bjorn
Greg KH March 15, 2023, 4:28 a.m. UTC | #7
On Tue, Mar 14, 2023 at 09:11:19PM -0700, Bjorn Andersson wrote:
> On Fri, Mar 03, 2023 at 01:09:08PM -0800, Elliot Berman wrote:
> > 
> > 
> > On 2/14/2023 10:52 AM, Elliot Berman wrote:
> > > 
> > > 
> > > On 2/14/2023 9:23 AM, Bjorn Andersson wrote:
> > > > On Tue, Feb 14, 2023 at 09:58:44AM +0100, Greg Kroah-Hartman wrote:
> > > > > On Mon, Feb 13, 2023 at 01:44:17PM -0800, Bjorn Andersson wrote:
> > > > > > On Mon, Feb 13, 2023 at 10:18:29AM -0800, Elliot Berman wrote:
> > > > > > > The maximum VMID for assign_mem is 63. Use a u64 to represent this
> > > > > > > bitmap instead of architecture-dependent "unsigned int"
> > > > > > > which varies in
> > > > > > > size on 32-bit and 64-bit platforms.
> > > > > > > 
> > > > > > > Acked-by: Kalle Valo <kvalo@kernel.org> (ath10k)
> > > > > > > Tested-by: Gokul krishna Krishnakumar <quic_gokukris@quicinc.com>
> > > > > > > Signed-off-by: Elliot Berman <quic_eberman@quicinc.com>
> > > > > > 
> > > > > > Reviewed-by: Bjorn Andersson <andersson@kernel.org>
> > > > > > 
> > > > > > @Greg, would you mind taking this through your tree for v6.3, you
> > > > > > already have a related change in fastrpc.c in your tree...
> > > > > 
> > > > > I tried, but it doesn't apply to my char-misc tree at all:
> > > > > 
> > > > > checking file drivers/firmware/qcom_scm.c
> > > > > Hunk #1 succeeded at 898 (offset -7 lines).
> > > > > Hunk #2 succeeded at 915 (offset -7 lines).
> > > > > Hunk #3 succeeded at 930 (offset -7 lines).
> > > > > checking file drivers/misc/fastrpc.c
> > > > > checking file drivers/net/wireless/ath/ath10k/qmi.c
> > > > > checking file drivers/remoteproc/qcom_q6v5_mss.c
> > > > > Hunk #1 succeeded at 227 (offset -8 lines).
> > > > > Hunk #2 succeeded at 404 (offset -10 lines).
> > > > > Hunk #3 succeeded at 939 with fuzz 1 (offset -28 lines).
> > > > > checking file drivers/remoteproc/qcom_q6v5_pas.c
> > > > > Hunk #1 FAILED at 94.
> > > > > 1 out of 1 hunk FAILED
> > > > > checking file drivers/soc/qcom/rmtfs_mem.c
> > > > > Hunk #1 succeeded at 30 (offset -1 lines).
> > > > > can't find file to patch at input line 167
> > > > > Perhaps you used the wrong -p or --strip option?
> > > > > The text leading up to this was:
> > > > > --------------------------
> > > > > |diff --git a/include/linux/firmware/qcom/qcom_scm.h
> > > > > b/include/linux/firmware/qcom/qcom_scm.h
> > > > > |index 1e449a5d7f5c..250ea4efb7cb 100644
> > > > > |--- a/include/linux/firmware/qcom/qcom_scm.h
> > > > > |+++ b/include/linux/firmware/qcom/qcom_scm.h
> > > > > --------------------------
> > > > > 
> > > > > What tree is this patch made against?
> > > > > 
> > > > 
> > > > Sorry about that, I missed the previous changes in qcom_q6v5_pas in the
> > > > remoteproc tree. Elliot said he based it on linux-next, so I expect that
> > > > it will merge fine on top of -rc1, once that arrives.
> > > > 
> > > 
> > > Yes, this patch applies on next-20230213. I guess there are enough
> > > changes were coming from QCOM side (via Bjorn's qcom tree) as well as
> > > the fastrpc change (via Greg's char-misc tree).
> > > 
> > > Let me know if I should do anything once -rc1 arrives. Happy to post
> > > version on the -rc1 if it helps.
> > > 
> > 
> > The patch now applies on tip of Linus's tree and on char-misc.
> 
> Greg, I have a couple more patches in the scm driver in my inbox. Would
> you be okay with me pulling this through the Qualcomm tree for v6.4?

Please do!
Bjorn Andersson March 16, 2023, 3:21 a.m. UTC | #8
On Mon, 13 Feb 2023 10:18:29 -0800, Elliot Berman wrote:
> The maximum VMID for assign_mem is 63. Use a u64 to represent this
> bitmap instead of architecture-dependent "unsigned int" which varies in
> size on 32-bit and 64-bit platforms.
> 
> 

Applied, thanks!

[1/1] firmware: qcom_scm: Use fixed width src vm bitmap
      commit: 968a26a07f75377afbd4f7bb18ef587a1443c244

Best regards,
diff mbox series

Patch

diff --git a/drivers/firmware/qcom_scm.c b/drivers/firmware/qcom_scm.c
index 468d4d5ab550..b95616b35bff 100644
--- a/drivers/firmware/qcom_scm.c
+++ b/drivers/firmware/qcom_scm.c
@@ -905,7 +905,7 @@  static int __qcom_scm_assign_mem(struct device *dev, phys_addr_t mem_region,
  * Return negative errno on failure or 0 on success with @srcvm updated.
  */
 int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
-			unsigned int *srcvm,
+			u64 *srcvm,
 			const struct qcom_scm_vmperm *newvm,
 			unsigned int dest_cnt)
 {
@@ -922,9 +922,9 @@  int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
 	__le32 *src;
 	void *ptr;
 	int ret, i, b;
-	unsigned long srcvm_bits = *srcvm;
+	u64 srcvm_bits = *srcvm;
 
-	src_sz = hweight_long(srcvm_bits) * sizeof(*src);
+	src_sz = hweight64(srcvm_bits) * sizeof(*src);
 	mem_to_map_sz = sizeof(*mem_to_map);
 	dest_sz = dest_cnt * sizeof(*destvm);
 	ptr_sz = ALIGN(src_sz, SZ_64) + ALIGN(mem_to_map_sz, SZ_64) +
@@ -937,8 +937,10 @@  int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
 	/* Fill source vmid detail */
 	src = ptr;
 	i = 0;
-	for_each_set_bit(b, &srcvm_bits, BITS_PER_LONG)
-		src[i++] = cpu_to_le32(b);
+	for (b = 0; b < BITS_PER_TYPE(u64); b++) {
+		if (srcvm_bits & BIT(b))
+			src[i++] = cpu_to_le32(b);
+	}
 
 	/* Fill details of mem buff to map */
 	mem_to_map = ptr + ALIGN(src_sz, SZ_64);
diff --git a/drivers/misc/fastrpc.c b/drivers/misc/fastrpc.c
index a701132638cf..f48466960f1b 100644
--- a/drivers/misc/fastrpc.c
+++ b/drivers/misc/fastrpc.c
@@ -262,7 +262,7 @@  struct fastrpc_channel_ctx {
 	int domain_id;
 	int sesscount;
 	int vmcount;
-	u32 perms;
+	u64 perms;
 	struct qcom_scm_vmperm vmperms[FASTRPC_MAX_VMIDS];
 	struct rpmsg_device *rpdev;
 	struct fastrpc_session_ctx session[FASTRPC_MAX_SESSIONS];
diff --git a/drivers/net/wireless/ath/ath10k/qmi.c b/drivers/net/wireless/ath/ath10k/qmi.c
index 90f457b8e1fe..038c5903c0dc 100644
--- a/drivers/net/wireless/ath/ath10k/qmi.c
+++ b/drivers/net/wireless/ath/ath10k/qmi.c
@@ -33,7 +33,7 @@  static int ath10k_qmi_map_msa_permission(struct ath10k_qmi *qmi,
 {
 	struct qcom_scm_vmperm dst_perms[3];
 	struct ath10k *ar = qmi->ar;
-	unsigned int src_perms;
+	u64 src_perms;
 	u32 perm_count;
 	int ret;
 
@@ -65,7 +65,7 @@  static int ath10k_qmi_unmap_msa_permission(struct ath10k_qmi *qmi,
 {
 	struct qcom_scm_vmperm dst_perms;
 	struct ath10k *ar = qmi->ar;
-	unsigned int src_perms;
+	u64 src_perms;
 	int ret;
 
 	src_perms = BIT(QCOM_SCM_VMID_MSS_MSA) | BIT(QCOM_SCM_VMID_WLAN);
diff --git a/drivers/remoteproc/qcom_q6v5_mss.c b/drivers/remoteproc/qcom_q6v5_mss.c
index ab053084f7a2..1ba711bc0100 100644
--- a/drivers/remoteproc/qcom_q6v5_mss.c
+++ b/drivers/remoteproc/qcom_q6v5_mss.c
@@ -235,8 +235,8 @@  struct q6v5 {
 	bool has_qaccept_regs;
 	bool has_ext_cntl_regs;
 	bool has_vq6;
-	int mpss_perm;
-	int mba_perm;
+	u64 mpss_perm;
+	u64 mba_perm;
 	const char *hexagon_mdt_image;
 	int version;
 };
@@ -414,7 +414,7 @@  static void q6v5_pds_disable(struct q6v5 *qproc, struct device **pds,
 	}
 }
 
-static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, int *current_perm,
+static int q6v5_xfer_mem_ownership(struct q6v5 *qproc, u64 *current_perm,
 				   bool local, bool remote, phys_addr_t addr,
 				   size_t size)
 {
@@ -967,7 +967,7 @@  static int q6v5_mpss_init_image(struct q6v5 *qproc, const struct firmware *fw,
 	unsigned long dma_attrs = DMA_ATTR_FORCE_CONTIGUOUS;
 	dma_addr_t phys;
 	void *metadata;
-	int mdata_perm;
+	u64 mdata_perm;
 	int xferop_ret;
 	size_t size;
 	void *ptr;
diff --git a/drivers/remoteproc/qcom_q6v5_pas.c b/drivers/remoteproc/qcom_q6v5_pas.c
index 1e14ae4d233a..a0fa7176fde7 100644
--- a/drivers/remoteproc/qcom_q6v5_pas.c
+++ b/drivers/remoteproc/qcom_q6v5_pas.c
@@ -94,7 +94,7 @@  struct qcom_adsp {
 	size_t region_assign_size;
 
 	int region_assign_idx;
-	int region_assign_perms;
+	u64 region_assign_perms;
 
 	struct qcom_rproc_glink glink_subdev;
 	struct qcom_rproc_subdev smd_subdev;
diff --git a/drivers/soc/qcom/rmtfs_mem.c b/drivers/soc/qcom/rmtfs_mem.c
index 2d3ee22b9249..2657c6105bb7 100644
--- a/drivers/soc/qcom/rmtfs_mem.c
+++ b/drivers/soc/qcom/rmtfs_mem.c
@@ -31,7 +31,7 @@  struct qcom_rmtfs_mem {
 
 	unsigned int client_id;
 
-	unsigned int perms;
+	u64 perms;
 };
 
 static ssize_t qcom_rmtfs_mem_show(struct device *dev,
diff --git a/include/linux/firmware/qcom/qcom_scm.h b/include/linux/firmware/qcom/qcom_scm.h
index 1e449a5d7f5c..250ea4efb7cb 100644
--- a/include/linux/firmware/qcom/qcom_scm.h
+++ b/include/linux/firmware/qcom/qcom_scm.h
@@ -94,7 +94,7 @@  extern int qcom_scm_mem_protect_video_var(u32 cp_start, u32 cp_size,
 					  u32 cp_nonpixel_start,
 					  u32 cp_nonpixel_size);
 extern int qcom_scm_assign_mem(phys_addr_t mem_addr, size_t mem_sz,
-			       unsigned int *src,
+			       u64 *src,
 			       const struct qcom_scm_vmperm *newvm,
 			       unsigned int dest_cnt);