Received: by 2002:a25:8b91:0:0:0:0:0 with SMTP id j17csp17924849ybl; Thu, 2 Jan 2020 14:56:06 -0800 (PST) X-Google-Smtp-Source: APXvYqyXi9URHfzOrS9DfTchfCn/0SyJ87UmGReEYQ9hv/s6axH7quMjWtdC5nxkb4lKZ7BcHNhv X-Received: by 2002:a05:6830:14d9:: with SMTP id t25mr86748434otq.258.1578005766508; Thu, 02 Jan 2020 14:56:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1578005766; cv=none; d=google.com; s=arc-20160816; b=b08ekvbLpN9j96E1T7/SUN1pE4bor5x3Ry/HEentGPZoBkyw1uEdp0KIB5ZzFJomhz 5FfYCTQMcpa3nfRLnq1ht1PPvtiwnoXiPNS82Ze29OOsruS9Jv3id2VEHpwkNJGXfci8 UVSG2yvwjDE0ZO1biWChaprcZVgu+1gghePoI9cEdQnp5ooqJIY+jl4Vb9SPSJX1k30P AwwOFcAv4jNi4xuzOCzI8R0gJhvgscacLDMdJkKhtIh4/6ZydXW/60Uc4acmvuA2T5bw pPlYCb1RrpSpIjtTFKCSp003MGcXfMvIWvShCl7TQcc1QsoCQ4UUN+VX8CVDZSX9Ktp4 K4UA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=AAFaIvlZ9qtBK31aOO87t8gP5GVaCFk+1qToVqm8y7Y=; b=auvAUNDBxs2sJjOGNDxivYNI2AHnBow7BvBP32UYqwEGcfp4ugVz7RrCCZymHehmA0 0jTb7rnTm4Tq5Q9aXP4mCiESb7MkLF91CYj6YKPcv+TX0NY36XRnT2bR919oj8fntlDK D2Jl/H2L7yeyrM1D0p3SM67pNqIWtj5dcXuM4B1KvN4OvmlPMA3Cxp93ffMepuZlxZjj d9s3VmX2zOByqesCO+7zhU67r77+C/vZGWvfNHjLZLaUMas/BE/ZmX9FH7JKrCs/szAQ 8G4pjjQNbcNsN4NyHUNmwJUBiVXfiwaDK7nuote14SUWaByxsCGPY309ZNRKk1UqFEK+ V+zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="H6J/FSYm"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i198si28001910oib.111.2020.01.02.14.55.54; Thu, 02 Jan 2020 14:56:06 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b="H6J/FSYm"; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728778AbgABWUZ (ORCPT + 99 others); Thu, 2 Jan 2020 17:20:25 -0500 Received: from mail.kernel.org ([198.145.29.99]:37316 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728053AbgABWUL (ORCPT ); Thu, 2 Jan 2020 17:20:11 -0500 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 42AC621582; Thu, 2 Jan 2020 22:20:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1578003610; bh=BmOf4eX506gey7d/fY6qrWHZaCqMP9oFOn8fOgVOkiQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=H6J/FSYmlmnfmqUnhUOVmR+CFm5ElRIZSslti9VNotY3AWZa8vnCoeJL16uwEJsPh onuLbmkoUGzXQRba95FGXNfbOvvqjUvF6JRuiiyNJ84nsP42/+vk/4E3NC4gSeBdAF W92xNhXMYPfzG+CAAj3sKsCZtVeNyAjjoA/bX6mA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Tyrel Datwyler , Bjorn Helgaas , Michael Ellerman , Sasha Levin Subject: [PATCH 4.19 040/114] PCI: rpaphp: Correctly match ibm, my-drc-index to drc-name when using drc-info Date: Thu, 2 Jan 2020 23:06:52 +0100 Message-Id: <20200102220033.132193106@linuxfoundation.org> X-Mailer: git-send-email 2.24.1 In-Reply-To: <20200102220029.183913184@linuxfoundation.org> References: <20200102220029.183913184@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Tyrel Datwyler [ Upstream commit 4f9f2d3d7a434b7f882b72550194c9278f4a3925 ] The newer ibm,drc-info property is a condensed description of the old ibm,drc-* properties (ie. names, types, indexes, and power-domains). When matching a drc-index to a drc-name we need to verify that the index is within the start and last drc-index range and map it to a drc-name using the drc-name-prefix and logical index. Fix the mapping by checking that the index is within the range of the current drc-info entry, and build the name from the drc-name-prefix concatenated with the starting drc-name-suffix value and the sequential index obtained by subtracting ibm,my-drc-index from this entries drc-start-index. Signed-off-by: Tyrel Datwyler Acked-by: Bjorn Helgaas Signed-off-by: Michael Ellerman Link: https://lore.kernel.org/r/1573449697-5448-10-git-send-email-tyreld@linux.ibm.com Signed-off-by: Sasha Levin --- drivers/pci/hotplug/rpaphp_core.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/pci/hotplug/rpaphp_core.c b/drivers/pci/hotplug/rpaphp_core.c index 7d74fe875225..a306cad70470 100644 --- a/drivers/pci/hotplug/rpaphp_core.c +++ b/drivers/pci/hotplug/rpaphp_core.c @@ -248,9 +248,10 @@ static int rpaphp_check_drc_props_v2(struct device_node *dn, char *drc_name, /* Should now know end of current entry */ /* Found it */ - if (my_index <= drc.last_drc_index) { + if (my_index >= drc.drc_index_start && my_index <= drc.last_drc_index) { + int index = my_index - drc.drc_index_start; sprintf(cell_drc_name, "%s%d", drc.drc_name_prefix, - my_index); + drc.drc_name_suffix_start + index); break; } } -- 2.20.1