Received: by 2002:a05:6359:c8b:b0:c7:702f:21d4 with SMTP id go11csp1058328rwb; Fri, 23 Sep 2022 07:43:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5MBth3DT3QExb6NmwG7pmJJkm35/ns49yhfsvQN2bI00UrgeWF9cCqjjLxJAuqQGHr1w+3 X-Received: by 2002:a17:907:60c6:b0:77f:875f:9580 with SMTP id hv6-20020a17090760c600b0077f875f9580mr7491138ejc.269.1663944185678; Fri, 23 Sep 2022 07:43:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1663944185; cv=none; d=google.com; s=arc-20160816; b=s5bgMhKSjGTJPSVSwt7M0WFVDReBjX/mW8VIH8LkwZxcoitBCM+Mw/navyRIXzZaiO LJWrgo1P+Xdu2QVO/kYc7p6l/QOYzpBWzvR2h6dbxhGeIOmAT1cJJTol03PQ72+/t0gu z4ETvDbFg5pjXlBdvKD5hXP3Ltbu2JV7V8K9E6kW31yo6R5sBD0ljOk4+xpvdGnPMQUa VVFFRTQHKZByZn1pvSsGRBe3SNPPhCTddCedtZst4PwjFoG+oCJVohAm/bBPYDPdl0pz 4mcx+Dx6s/3R620GZV80MgenZRi/t6XGQE3hK5evnbOfDgVONzREjQ5uusfKpmF4eK7i nm1Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:message-id:in-reply-to :subject:cc:to:from:date:dkim-signature; bh=eW+n7y9kxOTDAT4wEC9KxJcvFuYjsvp1PYMnVV25SoQ=; b=JMmrf0+R66woXksdhlycenf4SkgoaFjXK6cmWu4+Ce/CACMNlNDG7F55nscTm8ds/y Xu8O60F7+5lFBK7Y1IXe+LTMC87ATYvQYBN/h8ISdmw65amCQEv7mBexXdgFGuy6iO8B 6yaHoVDIF/tJ5zDVD9AEhNdwz/Cu2SD8EtE2OgyTvdcnzg63WDC5jyRpf/wJvA/j2vXi 9qtkyyyDSINmblr2KDrYNAEfEHTl+sZ+k8kxDmhbz/X6SWjpj1K7gTstlfhKW+x0fkvA Qo0dsadn/JM7JmMDALmmHp8vFVRq+lAKbS7TVl1wsa3/+DagTv9hREucaCeOTBwBu1Lb tQZw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@intel.com header.s=Intel header.b=LWzpU+VI; 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=intel.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id x24-20020a170906b09800b0077087c45329si6595387ejy.968.2022.09.23.07.42.40; Fri, 23 Sep 2022 07:43:05 -0700 (PDT) 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=@intel.com header.s=Intel header.b=LWzpU+VI; 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=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232527AbiIWOQx (ORCPT + 99 others); Fri, 23 Sep 2022 10:16:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232521AbiIWOQs (ORCPT ); Fri, 23 Sep 2022 10:16:48 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 16965122A78; Fri, 23 Sep 2022 07:16:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1663942607; x=1695478607; h=date:from:to:cc:subject:in-reply-to:message-id: references:mime-version; bh=YxdtYMXoEwBQTvm4QHgP6aL9/JiSU6i4piy+cSeCJ7E=; b=LWzpU+VI6IMnQT4IcXSHPKverXEY/vIX2jXZA+SxHJ+wVc2pcuvlqk8J jp2qI9YrC+ESxUuNp9Qt2hhMC1Bg57WTLeCV6ByPUOD+osKS05r6B9bb+ k3g558GE8t98R4Si/LZSj1jvz2EpcpbGPiA4OLuidO5+sQaczg4I1mlko XDcdqWVs7ByxKF4RrJPGSv3rPR7mSJcOIwCmHn/7AMiN3wS6ZIrbriWro 8pBXxo/p57M/tdAjRTKUK1CZn2YcapdXExFs4LtoZiTV2ECYvS93GKB7r /tVATWBxb3E/JR4EwjoCqRU+o9Z4SyR2cKbckxHrbw5wFxOt24OVoBot0 g==; X-IronPort-AV: E=McAfee;i="6500,9779,10479"; a="300583472" X-IronPort-AV: E=Sophos;i="5.93,339,1654585200"; d="scan'208";a="300583472" Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2022 07:16:46 -0700 X-IronPort-AV: E=Sophos;i="5.93,339,1654585200"; d="scan'208";a="653412626" Received: from alutz-mobl.ger.corp.intel.com ([10.252.35.146]) by orsmga001-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 23 Sep 2022 07:16:40 -0700 Date: Fri, 23 Sep 2022 17:16:38 +0300 (EEST) From: =?ISO-8859-15?Q?Ilpo_J=E4rvinen?= To: Matthew Gerlach cc: hao.wu@intel.com, yilun.xu@intel.com, russell.h.weight@intel.com, basheer.ahmed.muddebihal@intel.com, trix@redhat.com, mdf@kernel.org, linux-fpga@vger.kernel.org, linux-doc@vger.kernel.org, LKML , tianfei.zhang@intel.com, corbet@lwn.net, Greg Kroah-Hartman , linux-serial , Jiri Slaby , geert+renesas@glider.be, Andy Shevchenko , niklas.soderlund+renesas@ragnatech.se, phil.edworthy@renesas.com, macro@orcam.me.uk, johan@kernel.org, Lukas Wunner Subject: Re: [PATCH v2 4/6] fpga: dfl: add generic support for MSIX interrupts In-Reply-To: <20220923121745.129167-5-matthew.gerlach@linux.intel.com> Message-ID: References: <20220923121745.129167-1-matthew.gerlach@linux.intel.com> <20220923121745.129167-5-matthew.gerlach@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-7.0 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_EF,RCVD_IN_DNSWL_HI,SPF_HELO_NONE, SPF_NONE autolearn=ham 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 Fri, 23 Sep 2022, matthew.gerlach@linux.intel.com wrote: > From: Matthew Gerlach > > Define and use a DFHv1 parameter to add generic support for MSIX > interrupts for DFL devices. > > Signed-off-by: Matthew Gerlach > --- > v2: fix kernel doc > clarify use of DFH_VERSION field > --- > drivers/fpga/dfl.c | 60 +++++++++++++++++++++++++++++++++++++++++---- > include/linux/dfl.h | 14 +++++++++++ > 2 files changed, 69 insertions(+), 5 deletions(-) > > diff --git a/drivers/fpga/dfl.c b/drivers/fpga/dfl.c > index 1132f3c10440..dfd3f563c92d 100644 > --- a/drivers/fpga/dfl.c > +++ b/drivers/fpga/dfl.c > @@ -941,23 +941,22 @@ 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; > + int virq, off; > u64 v; > > type = feature_dev_id_type(binfo->feature_dev); > > /* > * Ideally DFL framework should only read info from DFL header, but > - * current version DFL only provides mmio resources information for > + * current version, DFHv0, only provides mmio resources information for > * each feature in DFL Header, no field for interrupt resources. > * Interrupt resource information is provided by specific mmio > * registers of each private feature which supports interrupt. So in > * order to parse and assign irq resources, DFL framework has to look > * into specific capability registers of these private features. > * > - * Once future DFL version supports generic interrupt resource > - * information in common DFL headers, the generic interrupt parsing > - * code will be added. But in order to be compatible to old version > + * DFHv1 supports generic interrupt resource information in DFHv1 > + * parameter blocks. But in order to be compatible to old version > * DFL, the driver may still fall back to these quirks. > */ > if (type == PORT_ID) { > @@ -981,6 +980,36 @@ static int parse_feature_irqs(struct build_feature_devs_info *binfo, > } > } > > + if (fid != FEATURE_ID_AFU && fid != PORT_FEATURE_ID_ERROR && > + fid != PORT_FEATURE_ID_UINT && fid != FME_FEATURE_ID_GLOBAL_ERR) { > + > + v = FIELD_GET(DFH_VERSION, readq(base)); I'd call this variable version (or ver) if you want to store it but it would also fit to switch () line so that no extra variable is needed. > + switch (v) { > + case 0: > + break; > + > + case 1: > + v = readq(base + DFHv1_CSR_SIZE_GRP); Extra space. > + if (FIELD_GET(DFHv1_CSR_SIZE_GRP_HAS_PARAMS, v)) { > + off = dfl_find_param(base + DFHv1_PARAM_HDR, ofst, > + DFHv1_PARAM_ID_MSIX); > + if (off >= 0) { I'd reverse these 2 conditions and break when there's nothing to do. > + ibase = readl(base + DFHv1_PARAM_HDR + > + off + DFHv1_PARAM_MSIX_STARTV); > + inr = readl(base + DFHv1_PARAM_HDR + > + off + DFHv1_PARAM_MSIX_NUMV); > + dev_dbg(binfo->dev, "start %d num %d fid 0x%x\n", > + ibase, inr, fid); > + } > + } > + break; > + > + default: > + dev_warn(binfo->dev, "unexpected DFH version %lld\n", v); > + break; > + } > + } > + > if (!inr) { > *irq_base = 0; > *nr_irqs = 0; -- i.