Received: by 2002:a05:6a10:7420:0:0:0:0 with SMTP id hk32csp262388pxb; Tue, 15 Feb 2022 12:47:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7HyIORrxCL+9hdTC1t/C24SM8DfPadQUJ9IZWw5HlcqWauMMpJuF0NmWDnICH2Or5NGed X-Received: by 2002:a17:90b:38d2:b0:1b8:c05f:9bf4 with SMTP id nn18-20020a17090b38d200b001b8c05f9bf4mr6291757pjb.137.1644958074132; Tue, 15 Feb 2022 12:47:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644958074; cv=none; d=google.com; s=arc-20160816; b=WFixVWQmg4GxHvtXXeteP2NY5TSwgaeBUKEoacjPmVK0lYNJAt5uERzWY40WZNRIpR 3A7klfZPWPmqBvLfaAgWARdCPtli0GRmhTNX4cnbJ0I1hjl2KxiHLlTgOi+DsR8Rx09X yIcb2so9E5stwcT3d313QANnanF02l/ZRh209A9Cf3LizfeOuKtT+rDHkbc2oetwc4m1 G0Mv3U8Z9yV8QARIFTT8rXEGoNCQECDhKLlu29gUiP+GPkkC5ZpS13P0RlPQ20vMAH9y 0pijWgdC0gGZDMFThcmEPuOKugH129dUlZp1Xu39Y7ItmhjB/BX9mmVrmtrPZzMvVVcJ w93Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-language:content-transfer-encoding :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=AQuhuF7IKOqYCKxv1Xz0llTmBI5LAygxnXZl/GDmFGk=; b=QvhcKqtx6dTeEzthgzFJioWWzSxLyD5t3xfW900XhLwqkr4QGYuwlJdEHuxxEtXQEL YzjJthi3NqNueOVCLla1TG26WF2Nzjb3seMvE1R+f6KIuiufyRC6kaEKmtezW7S9B0mz NK9kQeOKXLnQQhJvoqKAFjg3UDv3LaDe2NzDhngHmtpcryadgI5IaZKw6JGraRKj18js 8E8GiWvj3OR0v1CJZqRTY7y0KZ9dGBF4onZT3NvbvU2sLIFlDMpuiPZwgbNxUVS2V3/m Vi5Qz3k99iHRKd3Kaldqt1guSLZuIMuvkeJuWhZrMBjOINn88pLY7Ssv+E+G5o9XvJm8 +9sA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IhfFGrrz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id d11si35084702pfl.285.2022.02.15.12.47.38; Tue, 15 Feb 2022 12:47:54 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=IhfFGrrz; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236148AbiBOOvm (ORCPT + 99 others); Tue, 15 Feb 2022 09:51:42 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:33140 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239155AbiBOOvZ (ORCPT ); Tue, 15 Feb 2022 09:51:25 -0500 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id 367E1119433 for ; Tue, 15 Feb 2022 06:49:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644936551; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=AQuhuF7IKOqYCKxv1Xz0llTmBI5LAygxnXZl/GDmFGk=; b=IhfFGrrz01EQcj/B0bm6rusNoI+jK/sbGM+My3OBtRMZQwTDPfzZuI60YGQGchB3MBVUsh /Oa9BhF/WFRFuJv+3P0mivmG9ziiZkAVdpYAXGKOFNfpu3cfC9+yHzc0fHOPY2MCLzDrGv 0nD4JQyuUsT2OUtO/BoGaFb75prAlVg= Received: from mail-ot1-f69.google.com (mail-ot1-f69.google.com [209.85.210.69]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-336-p8cr_AJpNpCnBs4AzT7KDA-1; Tue, 15 Feb 2022 09:49:10 -0500 X-MC-Unique: p8cr_AJpNpCnBs4AzT7KDA-1 Received: by mail-ot1-f69.google.com with SMTP id h3-20020a9d6003000000b005acef9b2c7dso457799otj.17 for ; Tue, 15 Feb 2022 06:49:10 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=AQuhuF7IKOqYCKxv1Xz0llTmBI5LAygxnXZl/GDmFGk=; b=bdVf2mGZSL/FQhnVcZTJGdnCPUT8t/XWGqbALMwQMP18l4qvdwyb165+LXum82LPRA Mv6LgrT2jwzWXAn4wyM56dZX+DMy6ZJMPbGWnK877Cvo3PxPzI5tUrGxB82fh1zedkpg y7BbF3ATYLGXcZ35IeGz5OeGAXGJZzqowXPnYDvw+iWSPD7JC8TMYv3BQuv7iWRK4WXV zILeXYRIj8iPrzc/s/dFJN+GBkBOMQ5nSnWfIZzf7dhozuVx8ufG3VPqQD+QxOnlalsI s1fFP9TSL1Qg13T/jFA7CAtaXckzhR7Q+F4ffbTLcwRJS6iJ6i3BMIIHI5gez6fiWryN e5gA== X-Gm-Message-State: AOAM532I0hXzKnPWL62UoO/9l2MgveT4ay+qjh8cK7hETXB2sWHTiYPB R6QM2lwoLMJ7ai+dH3fqCxP8I9tkmq6l7F+y9qrie3pVmbIAJZP+Ck4n2NMwUMQOHv0Y3nn1bbJ VU1EgECmC3WTvVE6OkHe+wF9Q X-Received: by 2002:a9d:6a54:: with SMTP id h20mr1420696otn.69.1644936549412; Tue, 15 Feb 2022 06:49:09 -0800 (PST) X-Received: by 2002:a9d:6a54:: with SMTP id h20mr1420684otn.69.1644936549204; Tue, 15 Feb 2022 06:49:09 -0800 (PST) Received: from localhost.localdomain (024-205-208-113.res.spectrum.com. [24.205.208.113]) by smtp.gmail.com with ESMTPSA id v10sm13728219oto.53.2022.02.15.06.49.06 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 15 Feb 2022 06:49:07 -0800 (PST) Subject: Re: [PATCH v1 2/7] fpga: dfl: check feature type before parse irq info To: Tianfei zhang , hao.wu@intel.com, mdf@kernel.org, yilun.xu@intel.com, linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org Cc: corbet@lwn.net References: <20220214112619.219761-1-tianfei.zhang@intel.com> <20220214112619.219761-3-tianfei.zhang@intel.com> From: Tom Rix Message-ID: <0de9c8fb-0f04-684f-630c-1d13b0b55ba1@redhat.com> Date: Tue, 15 Feb 2022 06:49:05 -0800 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.10.1 MIME-Version: 1.0 In-Reply-To: <20220214112619.219761-3-tianfei.zhang@intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US X-Spam-Status: No, score=-2.9 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,NICE_REPLY_A, RCVD_IN_DNSWL_LOW,SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2/14/22 3:26 AM, Tianfei zhang wrote: > From: Tianfei Zhang > > The feature ID of "Port User Interrupt" and the > "PMCI Subsystem" are identical, 0x12, but one is for FME, > other is for Port. It should check the feature type While > parsing the irq info in parse_feature_irqs(). This seems like a bug fix and not part of iofs feature. Split this out of the patchset. This is a workaround a hardware problem, there should be some comments to the effect that you can't trust _this_ or _that_ feature id and some special handling earlier. The ambiguity of feature id is a problem, and this sort of bug will happen again. What can be done to prevent this in the future ? > > Signed-off-by: Tianfei Zhang > --- > drivers/fpga/dfl.c | 11 +++++++++++ > 1 file changed, 11 insertions(+) > > diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c > index 599bb21d86af..26f8cf890700 100644 > --- a/drivers/fpga/dfl.c > +++ b/drivers/fpga/dfl.c > @@ -940,9 +940,14 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, > { > void __iomem *base = binfo->ioaddr + ofst; > unsigned int i, ibase, inr = 0; > + enum dfl_id_type type; > int virq; > u64 v; > > + type = feature_dev_id_type(binfo->feature_dev); > + if (type >= DFL_ID_MAX) > + return -EINVAL; > + > /* > * Ideally DFL framework should only read info from DFL header, but > * current version DFL only provides mmio resources information for > @@ -959,16 +964,22 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, > */ > switch (fid) { > case PORT_FEATURE_ID_UINT: > + if (type != PORT_ID) > + break; Instead of embedding a break in the switch, break the switch into fme switch and port switch if (type == PORT_ID)   port-switch else if (type == FME_ID   fme-switch Tom > v = readq(base + PORT_UINT_CAP); > ibase = FIELD_GET(PORT_UINT_CAP_FST_VECT, v); > inr = FIELD_GET(PORT_UINT_CAP_INT_NUM, v); > break; > case PORT_FEATURE_ID_ERROR: > + if (type != PORT_ID) > + break; > v = readq(base + PORT_ERROR_CAP); > ibase = FIELD_GET(PORT_ERROR_CAP_INT_VECT, v); > inr = FIELD_GET(PORT_ERROR_CAP_SUPP_INT, v); > break; > case FME_FEATURE_ID_GLOBAL_ERR: > + if (type != FME_ID) > + break; > v = readq(base + FME_ERROR_CAP); > ibase = FIELD_GET(FME_ERROR_CAP_INT_VECT, v); > inr = FIELD_GET(FME_ERROR_CAP_SUPP_INT, v);