From mboxrd@z Thu Jan 1 00:00:00 1970 From: Wan Zongshun Subject: Re: [PATCH 5/6] iommu/amd: Add support for non-pci devices Date: Fri, 8 Jan 2016 22:52:59 +0800 Message-ID: <568FCD4B.4000807@iommu.org> References: <1451988444-4694-1-git-send-email-vincent.wan@amd.com> <1451988444-4694-6-git-send-email-vincent.wan@amd.com> <20160107120422.GB19149@8bytes.org> <20160108121855.GU18805@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; Format="flowed" Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: <20160108121855.GU18805-zLv9SwRftAIdnm+yROfE0A@public.gmane.org> List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org Errors-To: iommu-bounces-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org To: Joerg Roedel , Wan ZongShun Cc: linux-kernel , Wan Zongshun , iommu-cunTk1MwBs9QetFLy7KEm3xJsTq8ys+cHZ5vskTnxNA@public.gmane.org, Ray Huang , Borislav Petkov , ken.xue-5C7GfCeVMHo@public.gmane.org List-Id: iommu@lists.linux-foundation.org >> >> >> static bool check_device(struct device *dev) >> { >> u16 devid; >> ...... >> >> /* No PCI device */ >> if (!dev_is_pci(dev) && (get_acpihid_device_id(dev, NULL) < 0)) >> return false; >> >> devid = get_device_id(dev); > > That is true for this case, but the other call-sites of get_device_id() > still have to care about a potential negative return value, right? > Actually I am supposing the '.add_device' will be the first called in iommu initializing stage, so I think as long as having no error of check device here, any call-sites of get_device_id() will be fine, because adding device successfully should be the pre-condition of any iommu function can be performed, please correct me. static int amd_iommu_add_device(struct device *dev) { struct iommu_dev_data *dev_data; struct iommu_domain *domain; struct amd_iommu *iommu; u16 devid; int ret; if (!check_device(dev) || get_dev_data(dev)) return 0; devid = get_device_id(dev); iommu = amd_iommu_rlookup_table[devid]; Vincent. > > Joerg > > From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755270AbcAHSA1 (ORCPT ); Fri, 8 Jan 2016 13:00:27 -0500 Received: from mr213138.mail.yeah.net ([223.252.213.138]:33726 "EHLO mr213138.mail.yeah.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753946AbcAHSA0 (ORCPT ); Fri, 8 Jan 2016 13:00:26 -0500 X-Greylist: delayed 4207 seconds by postgrey-1.27 at vger.kernel.org; Fri, 08 Jan 2016 13:00:25 EST Subject: Re: [PATCH 5/6] iommu/amd: Add support for non-pci devices To: Joerg Roedel , Wan ZongShun References: <1451988444-4694-1-git-send-email-vincent.wan@amd.com> <1451988444-4694-6-git-send-email-vincent.wan@amd.com> <20160107120422.GB19149@8bytes.org> <20160108121855.GU18805@8bytes.org> Cc: Wan Zongshun , linux-kernel , iommu@lists.linux-foundation.org, Ray Huang , Borislav Petkov , ken.xue@amd.com From: Wan Zongshun Message-ID: <568FCD4B.4000807@iommu.org> Date: Fri, 8 Jan 2016 22:52:59 +0800 User-Agent: Mozilla/5.0 (Windows NT 6.2; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 MIME-Version: 1.0 In-Reply-To: <20160108121855.GU18805@8bytes.org> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit X-HM-Spam-Status: e1koWUFPN1dZCBgUCR5ZQUpKVU9MQkJCQk5PSUlITUhJQ1dZCQ4XHghZQV koKz0kKzooKCQyNSQzPjo*PilBS1VLQDYjJCI#KCQyNSQzPjo*PilBS1VLQCsvKSQiPigkMjUkMz 46Pz4pQUtVS0A4NC41LykiJDg1QUtVS0ApPjwyNDUkOigyOkFLVUtAKyk0LTI1OD4kNzI6NDUyNT xBS1VLQD8iNTo2MjgkMiskNTQkMjUkMz46Pz4pQUtVS0ApPjo3JDIrJDI1JCk5NyQyNSQzPjo*Pi lBSklVS0A2LjcvMiQpOCsvJD8yPT0#KT41LyQyNSQzPjo*PilBSVVLQDIrJEhLJDYyNS4vPiQ4NS 8kSyROS0FLVUtAMiskTiQ2MjUuLz4kODUvJEskSktBS1VLQDIrJEokNjI1Li8#JDg1LyRLJEpLQU tVS0AyKyRKJDM0LikkODUvJEskSktLQUtVS0AyKyQvND86IiQ4NS8kSyRKS0tBS1VLQCguOTE#OC 8kTiQ2MjUuLz4kODUvJEskSktBS1VLQCguOTE#OC8kLzQ*OiIkODUvJEskSktLQUtVS0AoLjkxPj gvJEokMzQuKSQ4NS8kSyRKS0tBS1VLQD0rJCk#JD0sJDM3MSRLQ0tIS01BVkxVTkA9NSQoLjkkPj UsNCk*KCQzNzEkSktLSUtKQUtVSUNAKC45JD5BSlVOTkA9NSQ5Mi9MJDM3MSRLTEpJS0lBSFVKTl kG X-HM-Sender-Digest: e1kSHx4VD1lBWUc6MUk6Sio*EDorNxEpGgMCAytPIyMaCQFVSlVKT05J SU1PQ0JIT0lIVTMWGhIXVQ0MOxIUFhYOVRQJHEVZV1kMHhlZQR0aFwgeV1kIAVlBSUJITjdXWRIL WUFZTkJVT05VTE9VQk9ZBg++ X-HM-Tid: 0a5221bbab757d8a9de2b101de1 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org >> >> >> static bool check_device(struct device *dev) >> { >> u16 devid; >> ...... >> >> /* No PCI device */ >> if (!dev_is_pci(dev) && (get_acpihid_device_id(dev, NULL) < 0)) >> return false; >> >> devid = get_device_id(dev); > > That is true for this case, but the other call-sites of get_device_id() > still have to care about a potential negative return value, right? > Actually I am supposing the '.add_device' will be the first called in iommu initializing stage, so I think as long as having no error of check device here, any call-sites of get_device_id() will be fine, because adding device successfully should be the pre-condition of any iommu function can be performed, please correct me. static int amd_iommu_add_device(struct device *dev) { struct iommu_dev_data *dev_data; struct iommu_domain *domain; struct amd_iommu *iommu; u16 devid; int ret; if (!check_device(dev) || get_dev_data(dev)) return 0; devid = get_device_id(dev); iommu = amd_iommu_rlookup_table[devid]; Vincent. > > Joerg > >