From: leizhen <thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
To: Will Deacon <will.deacon-5wv7dgnIgG8@public.gmane.org>
Cc: "huxinwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org"
<huxinwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
iommu
<iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org>,
Zefan Li <lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
Tianhong Ding
<dingtianhong-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>,
linux-arm-kernel
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>
Subject: Re: [PATCH 1/8] iommu/arm-smmu: fix the assignment of log2size field
Date: Tue, 30 Jun 2015 11:47:38 +0800 [thread overview]
Message-ID: <5592115A.8000502@huawei.com> (raw)
In-Reply-To: <20150629170517.GH17474-5wv7dgnIgG8@public.gmane.org>
On 2015/6/30 1:05, Will Deacon wrote:
> Hi Zhen Lei,
>
> On Fri, Jun 26, 2015 at 09:32:57AM +0100, Zhen Lei wrote:
>> Add a new local variable to store the value of log2size, so that it will
>> not be overridden by L1 table size.
>>
>> Signed-off-by: Zhen Lei <thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
>> ---
>> drivers/iommu/arm-smmu-v3.c | 14 +++++++-------
>> 1 file changed, 7 insertions(+), 7 deletions(-)
>>
>> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
>> index f141301..ba7fe2d 100644
>> --- a/drivers/iommu/arm-smmu-v3.c
>> +++ b/drivers/iommu/arm-smmu-v3.c
>> @@ -2021,19 +2021,19 @@ static int arm_smmu_init_strtab_2lvl(struct arm_smmu_device *smmu)
>> {
>> void *strtab;
>> u64 reg;
>> - u32 size;
>> + u32 size, log2size;
>> int ret;
>> struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
>>
>> /* Calculate the L1 size, capped to the SIDSIZE */
>> - size = STRTAB_L1_SZ_SHIFT - (ilog2(STRTAB_L1_DESC_DWORDS) + 3);
>> - size = min(size, smmu->sid_bits - STRTAB_SPLIT);
>> - if (size + STRTAB_SPLIT < smmu->sid_bits)
>> + log2size = STRTAB_L1_SZ_SHIFT - (ilog2(STRTAB_L1_DESC_DWORDS) + 3);
>> + log2size = min(log2size, smmu->sid_bits - STRTAB_SPLIT);
>> + if (log2size + STRTAB_SPLIT < smmu->sid_bits)
>
> I still think this is wrong. LOG2SIZE should correspond to the whole
> stream-table, not just the first level. How about the (totally untested)
> patch below, instead?
I tested the patch below, It's passed.
I use log2size, because this is the field name in SMMU_STRTAB_BASE_CFG. In fact,
it means log2(entries). Yes, I also think log2size is confused. So, I prefer yours.
>
> Will
>
> --->8
>
> diff --git a/drivers/iommu/arm-smmu-v3.c b/drivers/iommu/arm-smmu-v3.c
> index 8e9ec81ce4bb..1942a45f68b2 100644
> --- a/drivers/iommu/arm-smmu-v3.c
> +++ b/drivers/iommu/arm-smmu-v3.c
> @@ -2020,21 +2020,23 @@ static int arm_smmu_init_strtab_2lvl(struct arm_smmu_device *smmu)
> {
> void *strtab;
> u64 reg;
> - u32 size;
> + u32 size, l1size;
> int ret;
> struct arm_smmu_strtab_cfg *cfg = &smmu->strtab_cfg;
>
> /* Calculate the L1 size, capped to the SIDSIZE */
> size = STRTAB_L1_SZ_SHIFT - (ilog2(STRTAB_L1_DESC_DWORDS) + 3);
> size = min(size, smmu->sid_bits - STRTAB_SPLIT);
> - if (size + STRTAB_SPLIT < smmu->sid_bits)
> + cfg->num_l1_ents = 1 << size;
> +
> + size += STRTAB_SPLIT;
> + if (size < smmu->sid_bits)
> dev_warn(smmu->dev,
> "2-level strtab only covers %u/%u bits of SID\n",
> - size + STRTAB_SPLIT, smmu->sid_bits);
> + size, smmu->sid_bits);
>
> - cfg->num_l1_ents = 1 << size;
> - size = cfg->num_l1_ents * (STRTAB_L1_DESC_DWORDS << 3);
> - strtab = dma_zalloc_coherent(smmu->dev, size, &cfg->strtab_dma,
> + l1size = cfg->num_l1_ents * (STRTAB_L1_DESC_DWORDS << 3);
> + strtab = dma_zalloc_coherent(smmu->dev, l1size, &cfg->strtab_dma,
> GFP_KERNEL);
> if (!strtab) {
> dev_err(smmu->dev,
> @@ -2055,8 +2057,7 @@ static int arm_smmu_init_strtab_2lvl(struct arm_smmu_device *smmu)
> ret = arm_smmu_init_l1_strtab(smmu);
> if (ret)
> dma_free_coherent(smmu->dev,
> - cfg->num_l1_ents *
> - (STRTAB_L1_DESC_DWORDS << 3),
> + l1size,
> strtab,
> cfg->strtab_dma);
> return ret;
>
> .
>
next prev parent reply other threads:[~2015-06-30 3:47 UTC|newest]
Thread overview: 25+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-26 8:32 [PATCH 0/8] iommu/arm-smmu: bugfixs and add support for non-pci devices Zhen Lei
[not found] ` <1435307584-9812-1-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-26 8:32 ` [PATCH 1/8] iommu/arm-smmu: fix the assignment of log2size field Zhen Lei
[not found] ` <1435307584-9812-2-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-29 17:05 ` Will Deacon
[not found] ` <20150629170517.GH17474-5wv7dgnIgG8@public.gmane.org>
2015-06-30 3:47 ` leizhen [this message]
2015-06-26 8:32 ` [PATCH 2/8] iommu/arm-smmu: fix the index calculation of strtab Zhen Lei
[not found] ` <1435307584-9812-3-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-29 17:17 ` Will Deacon
2015-06-26 8:32 ` [PATCH 3/8] iommu/arm-smmu: fix the values of ARM64_TCR_IRGN0_SHIFT and ARM64_TCR_ORGN0_SHIFT Zhen Lei
[not found] ` <1435307584-9812-4-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-29 17:25 ` Will Deacon
[not found] ` <20150629172531.GJ17474-5wv7dgnIgG8@public.gmane.org>
2015-06-30 3:57 ` leizhen
[not found] ` <559213AE.6060206-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-30 14:11 ` Will Deacon
2015-06-26 8:33 ` [PATCH 4/8] iommu/arm-smmu: set EPD1 to disable TT1 translation table walk Zhen Lei
[not found] ` <1435307584-9812-5-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-29 17:26 ` Will Deacon
[not found] ` <20150629172622.GK17474-5wv7dgnIgG8@public.gmane.org>
2015-06-30 4:40 ` leizhen
2015-06-26 8:33 ` [PATCH 5/8] iommu/arm-smmu: rename __arm_smmu_get_pci_sid Zhen Lei
2015-06-26 8:33 ` [PATCH 6/8] iommu/arm-smmu: add support for non-pci devices Zhen Lei
[not found] ` <1435307584-9812-7-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-29 17:28 ` Will Deacon
[not found] ` <20150629172831.GL17474-5wv7dgnIgG8@public.gmane.org>
2015-06-30 8:51 ` leizhen
2015-06-30 11:26 ` Robin Murphy
[not found] ` <55927CEC.4090900-5wv7dgnIgG8@public.gmane.org>
2015-07-01 2:16 ` leizhen
2015-06-26 8:33 ` [PATCH 7/8] iommu/arm-smmu: enlarge STRTAB_L1_SZ_SHIFT to support larger sidsize Zhen Lei
[not found] ` <1435307584-9812-8-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-29 17:35 ` Will Deacon
[not found] ` <20150629173539.GM17474-5wv7dgnIgG8@public.gmane.org>
2015-06-30 8:57 ` leizhen
2015-06-26 8:33 ` [PATCH 8/8] iommu/arm-smmu: suppress fault information about CMD_PREFETCH_CONFIG execution Zhen Lei
[not found] ` <1435307584-9812-9-git-send-email-thunder.leizhen-hv44wF8Li93QT0dZR+AlfA@public.gmane.org>
2015-06-29 17:49 ` Will Deacon
[not found] ` <20150629174909.GN17474-5wv7dgnIgG8@public.gmane.org>
2015-06-30 9:18 ` leizhen
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=5592115A.8000502@huawei.com \
--to=thunder.leizhen-hv44wf8li93qt0dzr+alfa@public.gmane.org \
--cc=dingtianhong-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=huxinwei-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=lizefan-hv44wF8Li93QT0dZR+AlfA@public.gmane.org \
--cc=will.deacon-5wv7dgnIgG8@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox