From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.6 required=3.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS,USER_AGENT_SANE_1 autolearn=no autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C78ECC433DF for ; Tue, 23 Jun 2020 07:48:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A7BCD20780 for ; Tue, 23 Jun 2020 07:48:51 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="Dvb9jWrW" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731609AbgFWHsu (ORCPT ); Tue, 23 Jun 2020 03:48:50 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48690 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731585AbgFWHst (ORCPT ); Tue, 23 Jun 2020 03:48:49 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CBA94C061795 for ; Tue, 23 Jun 2020 00:48:49 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id j12so7482225pfn.10 for ; Tue, 23 Jun 2020 00:48:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=iXMHLbguntKcuTgr1nAq0fpxZctLmOVLPocRZ01HV1s=; b=Dvb9jWrWxYf0cUS7+mre8Ce7N6LCPCbgM4TfzIgO9x/j/Sz44QbFtHYcBvV6YcHykC /UOjUDAlRBaipXGhgPtfj5VOhd0MjmoLTxYmHS14ROKFa4k7B6adT6mjHgV2lQZYAb2L 9lBtnjHKiulqZ7h6mF5QFFytTHA5SEJIAChcsfvKC0+xwvXLEhh4oJ/sXC4FDnOEad0q wFvAaXsf3se/vnfb3bW1sYXvPN+QVKdtP6yU8qG9ZHjQx6589ayIzIweyVGj7eNLSCdB qISGLxSJaNs+JUUvbM8FXzy2OTirEzU1whLCBwbJsuBLePOiMyrCufoYlY4bb/bJX8TB Kruw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding :content-language; bh=iXMHLbguntKcuTgr1nAq0fpxZctLmOVLPocRZ01HV1s=; b=A41vd6UVMPTtvGUwK0LcT85XjL7AP8FQZb1WTt1zE42lLIuTEczEfPP73k+pZh/Xj7 jzwrPvc25knOXBsZic49fzM5rb8Lq0H6OtwtqzPENzO5Ta7GyWqaTGJB2+mrNQOK/FSu dmKqRGq6GXIkbDyJjZf/Q7EbeYk0jUBRhuysw7fXGrGO91IkcDFyS0Xana7NdNJRUv8g zQz6jxwwF3PLLyvLrBXRTbqABJN05/uFRxvStP+jFVRsd6y5baB2fGXUBaNEnTOJnGRK OOfuNtHmzp4NDCW/5tp8s+jZMGkVhUY8DmBQkOBsMoPWcxH4E/FDsFWGU7Frb1Qecmom BSDw== X-Gm-Message-State: AOAM530iJDAfMVVqKPTZ/SaT/xGfRL4jVzJ9JGFdsdhPvdbmRuyVRU2E w2a0IfBFSp16eL44OvpKlRlnbA== X-Google-Smtp-Source: ABdhPJxwJ+AW8uQAXY8Win57SIEKcys5G+XsLikqbv6KNfk0Z4v0oLWW7NunPD5K78dMacn0DXTtuQ== X-Received: by 2002:a62:f201:: with SMTP id m1mr25533751pfh.198.1592898529334; Tue, 23 Jun 2020 00:48:49 -0700 (PDT) Received: from [10.37.1.30] ([45.135.186.125]) by smtp.gmail.com with ESMTPSA id u6sm16409369pfc.83.2020.06.23.00.48.32 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 23 Jun 2020 00:48:48 -0700 (PDT) Subject: Re: [PATCH 0/2] Introduce PCI_FIXUP_IOMMU To: Joerg Roedel Cc: Bjorn Helgaas , Bjorn Helgaas , Arnd Bergmann , Lorenzo Pieralisi , Hanjun Guo , Sudeep Holla , "Rafael J. Wysocki" , Len Brown , jean-philippe , Greg Kroah-Hartman , Herbert Xu , kenneth-lee-2012@foxmail.com, Wangzhou , linux-kernel@vger.kernel.org, linux-crypto@vger.kernel.org, iommu@lists.linux-foundation.org, linux-acpi@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-pci@vger.kernel.org References: <20200601174104.GA734973@bjorn-Precision-5520> <779f4044-cf6a-b0d3-916f-0274450c07d3@linaro.org> <20200622115536.GH3701@8bytes.org> From: Zhangfei Gao Message-ID: Date: Tue, 23 Jun 2020 15:48:25 +0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.8.0 MIME-Version: 1.0 In-Reply-To: <20200622115536.GH3701@8bytes.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, Joerg On 2020/6/22 下午7:55, Joerg Roedel wrote: > On Thu, Jun 04, 2020 at 09:33:07PM +0800, Zhangfei Gao wrote: >> +++ b/drivers/iommu/iommu.c >> @@ -2418,6 +2418,10 @@ int iommu_fwspec_init(struct device *dev, struct >> fwnode_handle *iommu_fwnode, >>         fwspec->iommu_fwnode = iommu_fwnode; >>         fwspec->ops = ops; >>         dev_iommu_fwspec_set(dev, fwspec); >> + >> +       if (dev_is_pci(dev)) >> +               pci_fixup_device(pci_fixup_final, to_pci_dev(dev)); >> + > That's not going to fly, I don't think we should run the fixups twice, > and they should not be run from IOMMU code. Is the only reason for this > second pass that iommu_fwspec is not yet allocated when it runs the > first time? I ask because it might be easier to just allocate the struct > earlier then. Thanks for looking this. Yes, it is the only reason calling fixup secondly after iommu_fwspec is allocated. The first time fixup final is very early in pci_bus_add_device. If allocating iommu_fwspec earlier, it maybe in pci_alloc_dev. And assigning ops still in iommu_fwspec_init. Have tested it works. Not sure is it acceptable? Alternatively, adding can_stall to struct pci_dev is simple but ugly too, since pci does not know stall now. Thanks