From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 67B4919CD1D for ; Thu, 29 Jan 2026 15:45:19 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769701520; cv=none; b=OTwMhmNStTpdSRNwpvEC6aPnNisy9rlKMk0GfcqIpzb5rqpYgB7Shw/s2nbyGCjhE400qjdjy5Ldg9x7H1qiMxOK/D+gnHWfuATZ6MR2YzP2csmw2H+rj+wMRz5Lf7z8T3W+gNtNJNwWPVZX28eO1LZj2bLzV+/OiN2ljb5qK4Y= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1769701520; c=relaxed/simple; bh=0ygmEQM+uXYQUqBj7JsWwXJ7b7Kzre4X9O7SloOWm4E=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=gtt2K/4uL0NaiJcwwgPJveT/HMNNqDBkbe3PoFctRVcEWPELKVcFHYQfX+5bm9ShkLnnTKxMpQRFoUFIy7bhsEBuJ8TQ3i7mgmkwOoGj9sCzl1f+rRG4KOE5JQNKQ/4B3j3xrGulmzI4nntYjt+WVkKT43AF28JMoe9oTcbJwk0= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=PibzQ4CJ; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=a9SbKDPp; arc=none smtp.client-ip=205.220.168.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="PibzQ4CJ"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="a9SbKDPp" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 60TA8gui2059988 for ; Thu, 29 Jan 2026 15:45:18 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= kvLiGYJjsQay7+umkOjbbZzrGr1HQQCSJ8GYCT4p4Yo=; b=PibzQ4CJCCEXO47n Mj3vgIX15EAe4ca2hCochgvknJja6DjMgTL9+UDwDXLOTFMNAA5BuoiimOHj1WCt niTHuISWVvDcfiB96eUnEpxBN6pDjRNecefdZhoMW43tXHlv78MKyi9hMedvQHfd 285QCGgdIYFQ3RikjhibkKn4ao7y33sIn8vifddsm0lIquBX5v4LaUXW6NfOeVMt TdBcxtrHTUT+RwOsSEsmkn2nwusZXONHu6TVctffeZ30ecKA3stXVfwBSycvc97P Lt6MjUrT6s4dJmHYVXqbkEIpGM4JccQtwYcn154cg99DS/1jM3/RJyZ8vUhrqlGB n35HQA== Received: from mail-pg1-f198.google.com (mail-pg1-f198.google.com [209.85.215.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4bypgrm1q8-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 29 Jan 2026 15:45:18 +0000 (GMT) Received: by mail-pg1-f198.google.com with SMTP id 41be03b00d2f7-c52d37d346dso666638a12.3 for ; Thu, 29 Jan 2026 07:45:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1769701518; x=1770306318; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=kvLiGYJjsQay7+umkOjbbZzrGr1HQQCSJ8GYCT4p4Yo=; b=a9SbKDPpyd0g3AZ7AJo/IbBUVxK3FXkGeLCCYHbS9sWsy3ZNaxiZaDc/wIcb/XxORP amhf8x8inOceLoDdt0PgqtadZINABkimk+bLzyNZCBUBcMpQImkgzLIbkRjqilSMXyJL NZBkSd8SICdt1NzWYlJZiHics8sCndBozUnxr1uvjl1QC7Vo1TSwvj6c3oYaskCubPl+ 0PqCFh/bq73dAHwvbS81rrBcpVfSCFLUH3t9aqlu338ISWflJlOIj6EAejFngvangFnY dqDdL4yAU+fZs432tU7sCXd8auFevxUSkCujUcr3TJEJ23WSIeF69QMdIAx5zkjIo2ds SJFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1769701518; x=1770306318; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:user-agent:mime-version:date:message-id :x-gm-gg:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=kvLiGYJjsQay7+umkOjbbZzrGr1HQQCSJ8GYCT4p4Yo=; b=jBo5u0pf1tE3DggF7YxX+zKz+v/YvISjVsL1EO5IIM2zD0Jj+blPwNwnOgcbxZQqvN UHfVj9XlJWn2ryPGr+eDDJmTZG+siULFCVbYHK66p83Tizwzcp4agNW2f4tK6i60htMV GZVG1GtESL4thsQ1/+mklFEV9P80HmLnGh6WYk+O2xfruZJhFiro5zNMvjNcqpbeDye+ MiePWVqa+nS96viAqCzSsvAwYc2vbCS5ChCn/HPCk0LfM0A5JElU3WndEhuTIW7wJgDh 6Ini4FGzTtCnRhAs7INzUqmaQeuxyZnBfGXBJCJvKrJ9J+KMfXmHq7XXzlmHxgDTdykP X0Vg== X-Forwarded-Encrypted: i=1; AJvYcCVd9oUPlvkajBnfx4hMRWLH/H0prJrGjR+j9CZiSWjUpWlt2691sH5JFqVjqO0scbAqFvTyn7RXu7djmGI=@vger.kernel.org X-Gm-Message-State: AOJu0YyqnnJanESnN7Mx5TkR+aez9niLsZrBv1bKVNDw0PdsX78dT0D2 O7j9JsCnH9h8hAQMR8aMWKoM9k6M+fyCeWNGZiiS0P+34SI2OaL0wbG0oTF1ihna+EmbZaP7EqZ apTFhudazskBzNAaDcqdTAcsh9vEMFk9gOEUlLDgeiYxZeWb7SPsVYinoTkgOT47swG0= X-Gm-Gg: AZuq6aIf+ujSuSVOlyGnCV2r4gvLmquUVzqOAnEdE9Figjmfe9ZZ47AYvBc52S6kBug iCzVjnjV39hAQqkXSfAegwDSd3elibCghC4yVwaMizLn8pEd3M6A02F7Km/vE9DnesDoxpXW7Mo FNJj8KcAcMtrvcW4Jr856YeQ5SD3xQfCwDgBROTp/OXZm3OICkZxABwNwKj3YNO1OkNUiOFJWaf 0FNFqq6jO5+Vjl4ui0JcejhvscgEOoMr3hwOK+OlhtNBf/8T+rwo6wvUoclQbTDLRxpdfoqOyq4 b9qGCTtNm8ZoYB1a34gi0NNYnDfEyF54VQJlJZfIWWmXJH+cwPsSQdAKcoySAd80FMnR3VuIHkj isrn5pgF9I4gPxqrpH8iwU0yMbh7Evp3DOXKkVrtFdQ== X-Received: by 2002:a05:6a20:9151:b0:34f:241f:aa1e with SMTP id adf61e73a8af0-38ec62e4127mr8136272637.31.1769701517396; Thu, 29 Jan 2026 07:45:17 -0800 (PST) X-Received: by 2002:a05:6a20:9151:b0:34f:241f:aa1e with SMTP id adf61e73a8af0-38ec62e4127mr8136248637.31.1769701516673; Thu, 29 Jan 2026 07:45:16 -0800 (PST) Received: from [192.168.1.2] ([49.204.110.251]) by smtp.gmail.com with ESMTPSA id 41be03b00d2f7-c642add55adsm5038069a12.32.2026.01.29.07.45.11 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 29 Jan 2026 07:45:16 -0800 (PST) Message-ID: <57cb30cf-2da6-4df9-954d-953955969b02@oss.qualcomm.com> Date: Thu, 29 Jan 2026 21:15:08 +0530 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v1 1/3] spi: geni-qcom: Improve target mode allocation by using proper allocation functions To: Konrad Dybcio , Mark Brown , linux-arm-msm@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, bjorn.andersson@oss.qualcomm.com, dmitry.baryshkov@oss.qualcomm.com Cc: prasad.sodagudi@oss.qualcomm.com, mukesh.savaliya@oss.qualcomm.com, quic_vtanuku@quicinc.com, aniket.randive@oss.qualcomm.com, chandana.chiluveru@oss.qualcomm.com, jyothi.seerapu@oss.qualcomm.com References: <20260122151008.2149252-1-praveen.talari@oss.qualcomm.com> <20260122151008.2149252-2-praveen.talari@oss.qualcomm.com> <847290c3-d5aa-45cf-a75b-ff119b608433@oss.qualcomm.com> Content-Language: en-US From: Praveen Talari In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Authority-Analysis: v=2.4 cv=d7T4CBjE c=1 sm=1 tr=0 ts=697b808e cx=c_pps a=Qgeoaf8Lrialg5Z894R3/Q==:117 a=hmzEZbfuJy6/QR5cQt8XuQ==:17 a=IkcTkHD0fZMA:10 a=vUbySO9Y5rIA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=EUspDBNiAAAA:8 a=Wb7jJ4ESybac-VDgsCgA:9 a=3ZKOabzyN94A:10 a=QEXdDO2ut3YA:10 a=x9snwWr2DeNwDh03kgHS:22 X-Proofpoint-GUID: puPqxT2_ReIYxKqF46SL5Zv7GiDy92Db X-Proofpoint-ORIG-GUID: puPqxT2_ReIYxKqF46SL5Zv7GiDy92Db X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMTI5MDEwOSBTYWx0ZWRfX+HIw3IB6euTT 8UglkjO8QlcmIPbtyM1ptOm9Npn88LfkvyZsJnZnAYGJEbXcxgR3VCykO5CCcPCdHycU4Gutwsx pTahOGL5lW4E86cB+rk+D0evS2OwwA+fEkdNqQXXxdkEkDlLYnx0EcD8N9w39+R99axAHzRfhxr 2euUSVw0Ftdpsa61OhfCYQ6ByTwb6k/+r3wIQMq0wJeXtaxfZevCQFoSKXELz40iLt88LF1qLv0 BZf8ntFJYp8XgcL5L8PnOA0XSlC0FpkeZKMOXFXJTHr/u3j662ziJuImC1qxS/NTvJvnLrO8W8B /EZfIBeP8caWMml3HAmLx/sqtgtDBTxMkVS6UdqZkozcdZiyBPNCXxiJ/IABj9JBe+fLEnE+/em J9sRe7xRlDpV/WUQa6M6+73uWnpax2BqilGLmarMo8xJ1gHrx2IZVlM2r8jKqa5za4JdTu3QHOn lCqHwJuS2YnZ0ncfYsQ== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1121,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-01-29_02,2026-01-28_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 lowpriorityscore=0 suspectscore=0 adultscore=0 malwarescore=0 impostorscore=0 bulkscore=0 spamscore=0 clxscore=1015 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2601150000 definitions=main-2601290109 Hi Konrad, On 1/29/2026 5:12 PM, Konrad Dybcio wrote: > On 1/28/26 5:32 PM, Praveen Talari wrote: >> Hi Konrad >> >> On 1/27/2026 6:45 PM, Konrad Dybcio wrote: >>> On 1/22/26 4:10 PM, Praveen Talari wrote: >>>> The current implementation always allocates a host controller and sets the >>>> target flag later when the "spi-slave" device tree property is present. >>>> This approach is suboptimal as it doesn't utilize the dedicated allocation >>>> functions designed for target mode. >>>> >>>> Use devm_spi_alloc_target() when "spi-slave" device tree property is >>>> present, otherwise use devm_spi_alloc_host(). This replaces the previous >>>> approach of always allocating a host controller and setting target flag >>>> later. >>>> >>>> Signed-off-by: Praveen Talari >>>> --- >>>>   drivers/spi/spi-geni-qcom.c | 15 ++++++++------- >>>>   1 file changed, 8 insertions(+), 7 deletions(-) >>>> >>>> diff --git a/drivers/spi/spi-geni-qcom.c b/drivers/spi/spi-geni-qcom.c >>>> index 0e5fd9df1a8f..f5d05025b196 100644 >>>> --- a/drivers/spi/spi-geni-qcom.c >>>> +++ b/drivers/spi/spi-geni-qcom.c >>>> @@ -1017,6 +1017,14 @@ static int spi_geni_probe(struct platform_device *pdev) >>>>       struct clk *clk; >>>>       struct device *dev = &pdev->dev; >>>>   +    if (device_property_read_bool(dev, "spi-slave")) >>>> +        spi = devm_spi_alloc_target(dev, sizeof(*mas)); >>>> +    else >>>> +        spi = devm_spi_alloc_host(dev, sizeof(*mas)); >>>> + >>>> +    if (!spi) >>>> +        return -ENOMEM; >>>> + >>>>       irq = platform_get_irq(pdev, 0); >>>>       if (irq < 0) >>>>           return irq; >>>> @@ -1033,10 +1041,6 @@ static int spi_geni_probe(struct platform_device *pdev) >>>>       if (IS_ERR(clk)) >>>>           return PTR_ERR(clk); >>>>   -    spi = devm_spi_alloc_host(dev, sizeof(*mas)); >>>> -    if (!spi) >>>> -        return -ENOMEM; >>> >>> Is there a reason you're moving this code to the top of the function? >> >> When CONFIG_SPI_SLAVE is disabled, the call returns NULL; therefore, I placed this check at the start of the probe() function. >> >> ref: >> static inline struct spi_controller *devm_spi_alloc_target(struct device *dev, unsigned int size) >> { >>     if (!IS_ENABLED(CONFIG_SPI_SLAVE)) >>         return NULL; >> >>     return __devm_spi_alloc_controller(dev, size, true); >> } > > That doesn't really matter since spi is not accessed beforehand > and it'd return a NULL if it failed to allocate either way I agree. I had also reviewed other SPI drivers as a reference for this implementation. Do you want me to keep the change where earlier the host allocation was present, or is the current modification acceptable? Please help on this. Thanks, Praveen > > I'm not sure this is a concern nowadays with fw_devlink and > friends, but today the allocation happens after we get a clock > reference, which could throw an eprobe_defer, which I think would > cause the memory to be de-allocated again, wasting cycles > > Konrad