From mboxrd@z Thu Jan 1 00:00:00 1970 From: Yijing Wang Subject: Re: [Patch Part3 V5 5/8] iommu/vt-d: Enhance intel_irq_remapping driver to support DMAR unit hotplug Date: Tue, 16 Sep 2014 15:53:31 +0800 Message-ID: <5417EC7B.4060400@huawei.com> References: <1410487848-6027-1-git-send-email-jiang.liu@linux.intel.com> <1410487848-6027-6-git-send-email-jiang.liu@linux.intel.com> <54164D01.4060003@huawei.com> <5417E00D.5000108@linux.intel.com> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <5417E00D.5000108@linux.intel.com> Sender: linux-pci-owner@vger.kernel.org To: Jiang Liu , Joerg Roedel , David Woodhouse , Yinghai Lu , Bjorn Helgaas , Dan Williams , Vinod Koul , "Rafael J . Wysocki" Cc: Ashok Raj , Tony Luck , iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, linux-hotplug@vger.kernel.org, linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org List-Id: iommu@lists.linux-foundation.org On 2014/9/16 15:00, Jiang Liu wrote: > On 2014/9/15 10:20, Yijing Wang wrote: >>> +static void ir_remove_ioapic_hpet_scope(struct intel_iommu *iommu) >>> +{ >>> + int i; >>> >>> - ir_parse_one_hpet_scope(scope, iommu); >>> - } >>> - start += scope->length; >>> - } >>> + for (i = 0; i < MAX_HPET_TBS; i++) >>> + if (ir_hpet[i].iommu == iommu) >>> + ir_hpet[i].iommu = NULL; >> >> Hi Gerry, why not reset whole ir_hpe and ir_ioapic data struct? > Hi Yijing, > Thanks for review. Zero is legal for id, bus and devfn in > struct ioapic_scope and struct hpet_scope. So we use domain field > as a flag to mark entry valid or invalid and only reset iommu field. Hi Gerry, use iommu field as a flag to mark entry valid may be not safe enough, I found map_hpet_to_ir() and map_ioapic_to_ir() still only check the id field to return the valid iommu. What about this case: E.g. ir_hpet[2].id = N, ir_hpet[2].iommu = NULL, ir_hpet[4].id = N, ir_hpet[4].iommu = iommu; ir_hpet[2] maybe released yet, and the hpet now has been saved in ir_hpet[4], but map_hpet_to_irq() will return the wrong iommu(NULL). static struct intel_iommu *map_hpet_to_ir(u8 hpet_id) { int i; for (i = 0; i < MAX_HPET_TBS; i++) if (ir_hpet[i].id == hpet_id) return ir_hpet[i].iommu; return NULL; } > > Regards! > Gerry >> >> >> >>> >>> - return 0; >>> + for (i = 0; i < MAX_IO_APICS; i++) >>> + if (ir_ioapic[i].iommu == iommu) >>> + ir_ioapic[i].iommu = NULL; >>> } >>> >> >> -- >> To unsubscribe from this list: send the line "unsubscribe linux-kernel" in >> the body of a message to majordomo@vger.kernel.org >> More majordomo info at http://vger.kernel.org/majordomo-info.html >> Please read the FAQ at http://www.tux.org/lkml/ >> > > . > -- Thanks! Yijing