[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [BUG]SMMU-V3 queue need no-cache memory


  • To: Julien Grall <julien@xxxxxxx>
  • From: Rahul Singh <Rahul.Singh@xxxxxxx>
  • Date: Thu, 8 Dec 2022 13:04:02 +0000
  • Accept-language: en-US
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=arm.com; dmarc=pass action=none header.from=arm.com; dkim=pass header.d=arm.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=8GvbttyS3pbC5Lw1ZTCP3RpWdU6wZIaPUwK9bocah2k=; b=lZAGvGf6WobK5Tck3URLsvoomA6oDgTZzIX0TS8ErgakLgBH2+CZB1thDvIZAO39QRTQsK9UkjTRXg21aX2nRWzVuqM/BYrCmXTFyrGOseZJmlfkvPkbAXH0Fu3WKWZViWeuMBXRfEHUN+aKRg1F7V9RzXD7+YdETqesyp5AU7IEzXHtFn6tu+z1V0iJCSoQ2MpqBBdkhT02LC/XDQkTqWHbOg51x7fXk0+SbEqcgSOJgBxyJ42lb3CT40fKUk9h8S67XQ4Ovx9lEIthwSfew/5Pp5Qs5c1pjlIaxoTDF3mywfdeCEa7bVz6URv9jdwzXB6aE6+xxZrqEqxRGLE03A==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=OuSvLLrMNpH0+dEdBwn/bsAOZXjiZ6sNfxAFck/V/xSQ05YBLV47A3YDEYIMjMMkL2Q2C5Yugx+MkOdHRIv3fyiCNXCp6gYxnHgffaTBmNTSEh58NBO4FtOBC+JcTFulsfilFmmhIx4pgZ+HZ6ucakLNXSO+/oYQK/jlL93vUkBdAXGHIMqkLvGjQfuxgThYmDUlUSKMfMLRLfjMAPz/o2h5gadRTHc+9lpen+yiXs+43le1AOcYbllyEQpXcym2CYGb8iYrfRfA4Ni+BtP2o43HFNZD2Iz3p6ezJniS8peqTm6kBWYYzJ2YVc2VqvMnE97MTYxRHadhz2tzKyxxNg==
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: sisyphean <sisyphean@zlw.email>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>
  • Delivery-date: Thu, 08 Dec 2022 13:04:55 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Original-authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Thread-index: AQHZCfprdLwUdaBZYka2kYynmoAiD65iOCsAgAAelICAAaBWAA==
  • Thread-topic: [BUG]SMMU-V3 queue need no-cache memory

Hi Julien,

> On 7 Dec 2022, at 12:13 pm, Julien Grall <julien@xxxxxxx> wrote:
> 
> Hi,
> 
> I only noticed this e-mail because I was skimming xen-devel. If you want to 
> get our attention, then I would suggest to CC both of us because I (and I 
> guess Stefano) have filter rules so those e-mails land directly in my inbox.
> 
> On 07/12/2022 10:24, Rahul Singh wrote:
>>> On 7 Dec 2022, at 2:04 am, sisyphean <sisyphean@zlw.email> wrote:
>>> 
>>> Hi,
>>> 
>>>     I try to run XEN on my ARM board(Sorry, for some commercial reasons, I 
>>> can't tell you
>>>     on which platform I run XEN)  and enable SMMU-V3, but all cmds in cmdq 
>>> failed when XEN started.
>>> 
>>>     After using the debugger to track debugging, the reason for this 
>>> problem is that
>>>     the queue in the smmu-v3 driver is not no-cache, so after the function 
>>> arm_smmu_cmdq_build_cmd
>>>     is executed, the cmd is still in cache.Therefore, the SMMU-V3 hardware 
>>> cannot obtain the correct cmd
>>>     from the memory for execution.
>> Yes you are right as of now we are allocating the memory for cmdqueue via 
>> _xzalloc() which is cached
>> memory because of that you are observing the issue. We have tested the Xen 
>> SMMUv3 driver on SOC
>> where SMMUv3 HW is in the coherency domain, and because of that we have not 
>> encountered this issue.
>> I think In your case SMMUv3 HW is not in the coherency domain. Please 
>> confirm from your side if the
>> "dma-coherent” property is not set in DT.
>> I think there is no function available as of now to request Xen to allocate 
>> memory that is not cached.
> 
> You are correct.
> 
>> @Julien and @Stefano do you have any suggestion on how we can request memory 
>> from Xen that is not
>> cached something like dma_alloc_coherent() in Linux.
> 
> At the moment all the RAM is mapped cacheable in Xen. So it will require some 
> work to have some memory uncacheable.
> 
> There are two options:
> 1) Allocate a pool of memory at boot time that will be mapped with different 
> memory attribute. This means we would need a separate pool and the user will 
> have to size it.
> 2) Modify after the allocation the caching attribute in the memory and then 
> revert back after freeing. The cons is we would end up to shatter superpage. 
> We also can't re-create superpage (yet), but that might be fine if the memory 
> is never freed.
> 
> Option two would probably the best. But before going that route I have one 
> question...
> 
> > The temporary solution I use is to execute function clean_dcache every
> > time cmd is copied to cmdq in function queue_write. But it is obvious
> > that this will seriously affect the efficiency.
> 
> I agree you will see some performance impact in micro-benchmark. But I am not 
> sure about normal use-cases. How often do you expect the command queue to be 
> used?

To be precise command queue will be used when
 - Set up the stage-2 translation when we assigned the devices to guests. This 
happens typically dom0 boot and domU creation. 
 - When there is a call to iommu_iotlb_flush() that will call IOMMU specific 
iotlb_flush. SMMuv3 driver will send the command to
   SMMUv3 HW to invalidate the entries.
  
Regards,
Rahul
> 
> Also, I am a bit surprised you are seing issue with the command queue but not 
> with the stage-2 page-tables. Does your SMMU support coherent walk but cannot 
> snoop for the command queue?
> 
> Cheers,
> 
> -- 
> Julien Grall
> 


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.