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

Re: [PATCH v9 08/13] iommu/ipmmu-vmsa: Implement suspend/resume callbacks


  • To: Oleksandr Tyshchenko <olekstysh@xxxxxxxxx>
  • From: Luca Fancellu <Luca.Fancellu@xxxxxxx>
  • Date: Mon, 18 May 2026 11:56:40 +0000
  • Accept-language: en-GB, en-US
  • Arc-authentication-results: i=2; mx.microsoft.com 1; spf=pass (sender ip is 4.158.2.129) smtp.rcpttodomain=gmail.com smtp.mailfrom=arm.com; dmarc=pass (p=none sp=none pct=100) action=none header.from=arm.com; dkim=pass (signature was verified) header.d=arm.com; arc=pass (0 oda=1 ltdi=1 spf=[1,1,smtp.mailfrom=arm.com] dkim=[1,1,header.d=arm.com] dmarc=[1,1,header.from=arm.com])
  • 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=2; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=R/1HiXZGd5kMDQbez5oI4Sz4hF6yTx2Ci0hHCedUqSs=; b=x+THQZ8EB6uallYa7gBNH2t7x9dHHd0snQCcUigKJKS4Q5BDduWOjdzheZKkH1VIbr/Bn0WI7SzfN3lo4t7k6zTjEHVZXLcqMbR2XlknbycfGilk1m3MywbZodnVbUXNuGJvcHsOf4DwdgiVcaMkQx0uoxJq9B8HzgoR3TwOGLvEQzqo/AcNXBEXxwGhNW/mgF6V/aqw1RUJ9VEBTVpOhUCyTarySP1On0LFntkMclp3LHoaWxWc83bsygFODlVk9+8ClGLqv5v+CMoUVUuw6Kf4tCkdycG8ftUSYEA67QHUfQftLVJI2owLpqtNV7wV2H++HEVDNtrmaCjfFf6kIw==
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector10001; 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=R/1HiXZGd5kMDQbez5oI4Sz4hF6yTx2Ci0hHCedUqSs=; b=KSPTs6DZ4Dlon6UbhW5jUMywJzacD3sKHB0csDNLbBcPYWfuvc5998k7gfZ2vD8JDqqWuACXLG0mXVX7sCj9EaGg25MqCqt69wkyO9m3xm3liqAxiC0TJ/CGYh/Uzt4haf1HfhvKPZMqQgirVpdrp35PcIhWPt0ph0vwzhGiKGsEc4zh8mwUJNsaIG6ALPs2DxHG2zp//Mb2w8l0TzipxztiToFlzoUHJsvkwdEY0e4bZaUsNQkz5cIEo7HtAHWpaql1KrJa1rZjaw5PWbuj/NqrsbrZgpZqbw2aYtt8mcIJiYV7D8gdiNISOmu4amFOr6aQcFNYDGxUNstm+980uA==
  • Arc-seal: i=2; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=pass; b=QxetJcdytp65tn25ZzeXcKrAB1GbAN3PXhyPIV+X0LD7F+4qqu36iPBTKYtdvDv35Yyt1M3bbRtuitFUg60IxxOlT7bY2P/ax/s/Ps0g93JHuNIe6QbSqfWc7B01ErvhIZOCNmQIjIO42iRU2jdfDCVgsyFQkMLerDF6oIYX7uOlonrMbBAA6ctRJJaMkEBv05myBYKa1RSvdkEFQMBLEoXbaBGAI66oK34i/Fpr30FIkUQPuzlw0pDI5+zPdiBDF1jhtJIjOcS7SixrKpFM/fhpuqMDcKx9vPzHXhuui9dHrRApRGOm06zuJ6CWfJgiJwX2J6xxSWhMJpWvUZJwjQ==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector10001; d=microsoft.com; cv=none; b=ZCKE8mHPXrmP6QuSPbQmwAt+YLCYdyg8oGEVdlzt1GkRFWWf2ng4bpFiaULH+pfgzX3RP7ykY6IfTX/8Eai/y65go/mo91t4aT1F2PxGRqlp9566+wva3jDxjnqOfLTMwpYsizjv3+lHVB0RI0lvcLHPT/37T+65PXdKnwxrRhkh2d0P16TylVBX6j+MMK6D6n/7j58KijiV/R3rCAjBJE/92He2gguWxZRAQRfiX74evAZwSMOLEWbVgUJWWXkul3+pW2yp4VJH4xlobkmyAkE+ZkAqw3kg17pML5CUyuq0K90NJEeFwRtSrMd4GQwoDVScRd5f7bzgdBWFOpvXkw==
  • Authentication-results: eu.smtp.expurgate.cloud; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"; dkim=pass header.s=selector1 header.d=arm.com header.i="@arm.com" header.h="From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck"
  • Authentication-results-original: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=arm.com;
  • Cc: Mykola Kvach <xakep.amatop@xxxxxxxxx>, "xen-devel@xxxxxxxxxxxxxxxxxxxx" <xen-devel@xxxxxxxxxxxxxxxxxxxx>, Mykola Kvach <mykola_kvach@xxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Julien Grall <julien@xxxxxxx>, Bertrand Marquis <Bertrand.Marquis@xxxxxxx>, Michal Orzel <michal.orzel@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>
  • Delivery-date: Mon, 18 May 2026 11:58:01 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>
  • Nodisclaimer: true
  • Thread-index: AQHc4jI0ue/pVmX78UiKnsCn9gvTibYNsCmAgASqsACAAVtlAA==
  • Thread-topic: [PATCH v9 08/13] iommu/ipmmu-vmsa: Implement suspend/resume callbacks

Hi Oleksandr,

>>> +
>>> +static void ipmmu_domain_backup_context(struct ipmmu_vmsa_domain *domain)
>>> +{
>>> +    struct ipmmu_vmsa_device *mmu = domain->mmu->root;
>>> +    struct ipmmu_reg_ctx *regs = mmu->reg_backup[domain->context_id];
>>> +
>>> +    dev_dbg(mmu->dev, "Handle domain context %u backup\n", 
>>> domain->context_id);
>>> +
>>> +    regs->imttlbr0 = ipmmu_ctx_read_root(domain, IMTTLBR0);
>>> +    regs->imttubr0 = ipmmu_ctx_read_root(domain, IMTTUBR0);
>>> +    regs->imttbcr  = ipmmu_ctx_read_root(domain, IMTTBCR);
>>> +    regs->imctr    = ipmmu_ctx_read_root(domain, IMCTR);
>>> +}
>>> +
>>> +static void ipmmu_domain_restore_context(struct ipmmu_vmsa_domain *domain)
>>> +{
>>> +    struct ipmmu_vmsa_device *mmu = domain->mmu->root;
>>> +    struct ipmmu_reg_ctx *regs  = mmu->reg_backup[domain->context_id];
>> NIT: There is a double space before the `=`
>>> +
>>> +    dev_dbg(mmu->dev, "Handle domain context %u restore\n", 
>>> domain->context_id);
>>> +
>>> +    ipmmu_ctx_write_root(domain, IMTTLBR0, regs->imttlbr0);
>>> +    ipmmu_ctx_write_root(domain, IMTTUBR0, regs->imttubr0);
>>> +    ipmmu_ctx_write_root(domain, IMTTBCR,  regs->imttbcr);
>>> +    ipmmu_ctx_write_all(domain,  IMCTR,    regs->imctr | IMCTR_FLUSH);
>> I see in ipmmu_tlb_invalidate() we do:
>> dsb(sy);
>> ipmmu_tlb_sync(domain);
>> Is it safe to omit them here?
> 
> Luca, good question, thanks. Below my understanding (which might be wrong):
> 
> The IMCTR_FLUSH bit here is not an explicit TLB invalidation request — it is 
> required by the HW whenever context registers are modified (regardless of 
> whether an actual TLB flush is the intent). For example, 
> ipmmu_domain_init_context() similarly writes:
> 
> ipmmu_ctx_write_root(domain, IMCTR,
>                     IMCTR_VA64 | IMCTR_INTEN | IMCTR_FLUSH | IMCTR_MMUEN);
> 
> and does not follow it with dsb(sy) / ipmmu_tlb_sync().
> 
> In contrast, ipmmu_tlb_invalidate() does include the sync because it is an 
> explicit flush request from the P2M framework, and we need a guarantee that 
> the invalidation has completed before proceeding.
> 
> Here, we are simply restoring context registers after resume, there is no 
> caller waiting on flush completion, so the additional synchronization is not 
> necessary from my PoV.
> 

yes I had a closer look into Linux and for restore only there is no 
dsb/tlb_sync:

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/iommu/ipmmu-vmsa.c?h=v7.1-rc4#n1119

So I think we are safe to omit them here

Cheers,
Luca

 


Rackspace

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