From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-qk1-f169.google.com (mail-qk1-f169.google.com [209.85.222.169]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 7788018A92D for ; Tue, 7 Jan 2025 22:11:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.222.169 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287884; cv=none; b=ZMCcgnkTqA+J7yhd2KetnvrEXBvHdF7C76gZP1vJTNrQEJYWNFj+RmPAeDk9DDUmVrV663891FA7sqYoOAgAMGqMH5f++9E9W3sfLzPrgO7ZXOMOrxVAqMUjwIbmmR2ugg/RpKp1yIA0fFoU0LbObDp5HCQjtO2Txn4ewpPfm1U= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1736287884; c=relaxed/simple; bh=z4Vmfgn+O/OSj4UC/6OVTa6AfwvKJuTth0cPv3Aw9M4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=ZQCpQ5S/x4iY8RUoI00FO9Nk9O1jAxWvFlyA/71RNI8NkV5yw12WCZtIaUjcGKQ/N1IfyOYGj6bjPiv5PBz9+fDIhWvoHxfMeZBEHqwZjDvg/bmRggJ6GtCtYK7umJrAj/vwEKIMv3OWIdMG4l4y+oSX+pB3tWZr+VseBvEEGkw= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net; spf=pass smtp.mailfrom=gourry.net; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b=uiXLblsx; arc=none smtp.client-ip=209.85.222.169 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=gourry.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gourry.net Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gourry.net header.i=@gourry.net header.b="uiXLblsx" Received: by mail-qk1-f169.google.com with SMTP id af79cd13be357-7b6e4d38185so1281309785a.0 for ; Tue, 07 Jan 2025 14:11:21 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gourry.net; s=google; t=1736287880; x=1736892680; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=x1nrG8KENphRBU6xE2gJeK+jv2lpPnut1E3vj779B2g=; b=uiXLblsxpOO7UFNzxkY2w1OU7IFZN3M9zrXfjpN3Ufdpg2LNRNDebcejL1+XZ76C5c 1IWB3jDbgKiEg3LWE3qdbEiiFbMvDPePELdfwRBQr14vNc6rTw4wyvGLoacvcfWpKC2y Lt6SKkL+rtVjAH/MM2E2cDdU0xOyDA6dLM3fUYD4s0Aa0ffOEn1GGNxq2AkGCqQSQsSN /pVycMoeYly21gISOh6G4t0I6IZ4/F/y1iIoQAp225gX1qnwGP2QsZAuJdSvh3cwX6ue qWv9Y6lCyDiMQGux4pT/FUH27VGDnDHURAKABLFhqwsqc8ChzY9yIDDgVUaKs+vo94Q4 Cu4g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1736287880; x=1736892680; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=x1nrG8KENphRBU6xE2gJeK+jv2lpPnut1E3vj779B2g=; b=Rs4HfHt0i2KqgbgRCHpozOOd5ecZ7xw1/V6BNfKUz7WP9wzdRPYbUde1SLmoJVxa3a dgUtDmisbJXD1QcLYyQoxbqyZpptxWHqOgs7zmgvVmNQp2ny7zq4IFbobGHRd1JaHnBv Br/rrV7Dr6JkF9Nl0jYpZUxVaRYpiL4THAD24dbrtT9kQKyLzlbUI16/c/VCtc+VLekM SbpjSdYaTFkNgwsi3zBb2540xWuROmG1oO1FUz1Z0RgrihOqycua+ZQgCCIA2nHgh7Jh f0yCq6akKINKRccXBOwsGkvpxsf67zsGGkZyUg/MSmLfbbbs6Td+katrDec14bCUiNMD XSng== X-Forwarded-Encrypted: i=1; AJvYcCXYYWy1wOuZr38EofSPe99P8V1WwbLcVtSJQ73XDFLsg5dOWHIAquUSOJsNkL7HQDFYaDv2tgtUWgI2hCI=@vger.kernel.org X-Gm-Message-State: AOJu0YyF+o8hMixzQyyReD1uRjqb5jY6rdtlsmAYI1Cba1j6PVqrVMZS r/mZiWWi+BP4XONQfOpDjBhxuRFR23VoidJWXrysHqZkDWpTPAsgKWHdaSCWW4g= X-Gm-Gg: ASbGncts4EeuZKtYnCRKA/St4tigdPEthSt6UvDQrIIeZP67jyeRXlCAdutq9uh54Nv /hhK8fnKyAPE0DJUG2BmMsIl7YnrIaEl8TGgZPGeOVibP9QjQ9rGjTGvRaeJF5Ek2jZdCSPxKvQ UwWCw4eCQpAm8kcMBabR9Oe5vzSYJ055NHizEPuBOy8RaIWcTsnI7sdxTV56n7xlA41I3HZNBDS Hpom+571CQUoBWz8xd1XvpZL0qOKZqffD6dAoWBRE5Ki5tetg15iVCsTZwGYihWvf0Qoay1lgWD +53vYRs8d1bhyyRGv3Ea5RWUarww9qSiUshWBxU= X-Google-Smtp-Source: AGHT+IGDu4UlRwDmROTGjDdJMYNWwTuQnPHkXfRK3kxqx6LqAKPurhWrloIiQ7wQQM2gN9pM9a+DWg== X-Received: by 2002:ac8:5d06:0:b0:466:b2c9:fb00 with SMTP id d75a77b69052e-46c70fd30femr9603021cf.3.1736287880426; Tue, 07 Jan 2025 14:11:20 -0800 (PST) Received: from gourry-fedora-PF4VCD3F (pool-173-79-56-208.washdc.fios.verizon.net. [173.79.56.208]) by smtp.gmail.com with ESMTPSA id d75a77b69052e-46a3e653f52sm190191541cf.16.2025.01.07.14.11.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Jan 2025 14:11:20 -0800 (PST) Date: Tue, 7 Jan 2025 17:11:18 -0500 From: Gregory Price To: Robert Richter Cc: Alison Schofield , Vishal Verma , Ira Weiny , Dan Williams , Jonathan Cameron , Dave Jiang , Davidlohr Bueso , linux-cxl@vger.kernel.org, linux-kernel@vger.kernel.org, "Fabio M. De Francesco" , Terry Bowman Subject: Re: [PATCH v1 18/29] cxl/region: Avoid duplicate call of cxl_find_decoder_early() Message-ID: References: <20250107141015.3367194-1-rrichter@amd.com> <20250107141015.3367194-19-rrichter@amd.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20250107141015.3367194-19-rrichter@amd.com> On Tue, Jan 07, 2025 at 03:10:04PM +0100, Robert Richter wrote: > Function cxl_find_decoder_early() is called twice, in > alloc_region_ref() and cxl_rr_alloc_decoder(). Move it out there and > instead pass the decoder as function argument to both. > > Signed-off-by: Robert Richter > --- > drivers/cxl/core/region.c | 31 +++++++++++++++---------------- > 1 file changed, 15 insertions(+), 16 deletions(-) > Reviewed-by: Gregory Price > diff --git a/drivers/cxl/core/region.c b/drivers/cxl/core/region.c > index 2bc2028988d3..b7f6d8a83e4e 100644 > --- a/drivers/cxl/core/region.c > +++ b/drivers/cxl/core/region.c > @@ -928,7 +928,8 @@ static bool auto_order_ok(struct cxl_port *port, struct cxl_region *cxlr_iter, > > static struct cxl_region_ref * > alloc_region_ref(struct cxl_port *port, struct cxl_region *cxlr, > - struct cxl_endpoint_decoder *cxled) > + struct cxl_endpoint_decoder *cxled, > + struct cxl_decoder *cxld) > { > struct cxl_region_params *p = &cxlr->params; > struct cxl_region_ref *cxl_rr, *iter; > @@ -942,9 +943,6 @@ alloc_region_ref(struct cxl_port *port, struct cxl_region *cxlr, > continue; > > if (test_bit(CXL_REGION_F_AUTO, &cxlr->flags)) { > - struct cxl_decoder *cxld; > - > - cxld = cxl_find_decoder_early(port, cxled, cxlr); > if (auto_order_ok(port, iter->region, cxld)) > continue; > } > @@ -1028,17 +1026,9 @@ static int cxl_rr_ep_add(struct cxl_region_ref *cxl_rr, > > static int cxl_rr_alloc_decoder(struct cxl_port *port, struct cxl_region *cxlr, > struct cxl_endpoint_decoder *cxled, > - struct cxl_region_ref *cxl_rr) > + struct cxl_region_ref *cxl_rr, > + struct cxl_decoder *cxld) > { > - struct cxl_decoder *cxld; > - > - cxld = cxl_find_decoder_early(port, cxled, cxlr); > - if (!cxld) { > - dev_dbg(&cxlr->dev, "%s: no decoder available\n", > - dev_name(&port->dev)); > - return -EBUSY; > - } > - > if (cxld->region) { > dev_dbg(&cxlr->dev, "%s: %s already attached to %s\n", > dev_name(&port->dev), dev_name(&cxld->dev), > @@ -1129,7 +1119,16 @@ static int cxl_port_attach_region(struct cxl_port *port, > nr_targets_inc = true; > } > } else { > - cxl_rr = alloc_region_ref(port, cxlr, cxled); > + struct cxl_decoder *cxld; > + > + cxld = cxl_find_decoder_early(port, cxled, cxlr); > + if (!cxld) { > + dev_dbg(&cxlr->dev, "%s: no decoder available\n", > + dev_name(&port->dev)); > + return -EBUSY; > + } > + > + cxl_rr = alloc_region_ref(port, cxlr, cxled, cxld); > if (IS_ERR(cxl_rr)) { > dev_dbg(&cxlr->dev, > "%s: failed to allocate region reference\n", > @@ -1138,7 +1137,7 @@ static int cxl_port_attach_region(struct cxl_port *port, > } > nr_targets_inc = true; > > - rc = cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr); > + rc = cxl_rr_alloc_decoder(port, cxlr, cxled, cxl_rr, cxld); > if (rc) > goto out_erase; > } > -- > 2.39.5 >