Received: by 10.223.185.116 with SMTP id b49csp1524181wrg; Wed, 14 Feb 2018 19:35:08 -0800 (PST) X-Google-Smtp-Source: AH8x224KecP31pROO2odLk62GgIB0Yii7DrCNMzvA28U3YASf7IFW+wo+MDCU32txUsUk6Xa2T8F X-Received: by 10.167.129.129 with SMTP id g1mr1248368pfi.224.1518665708052; Wed, 14 Feb 2018 19:35:08 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1518665707; cv=none; d=google.com; s=arc-20160816; b=yVRI4J3clseRlFEbDp09csIh1YMHIXJ2GNuvT1aoDmytqGPsdR15VFOQzZyUdve/Vr iiXOA8/NciH9j9D8mfiASFCZIcLc/zYkcNoV4xasTMz7EEYKt9zMxI8JCr3/CcTYrcxW tRtQllo5l9DwmZkRh0dX/icISv+GBisuku0q5GgqoXXnKZSHy5Qd+R4s0yl7Mfm98qwa 2aAIf5AdtLCQc6/RvzTAz09hKJFpScNt70/O1Fo0YydD7jQx0mqyfZbFY27ZW8KrfDUq ZHlfRWhOj+8HIJfchOg63YdOZYz1gKhi2+dt3rW9kQqbFJw8+x+PGOkPpOzlSSSc9Zou hU5A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :arc-authentication-results; bh=jLzHIBa0h0PfVBlmQ60k6Z3MN/RUXEhQ3g1N03Tb8K8=; b=p1B6NkQpqdwfqfaRCYeWG1MtMS3pZnEPcn5UD7O536oNaUFHOmlqSsUR25wMmgjic9 1CuxL4JBGYcC33VCTswnYWE9ApN2nSa86d7qMv+hRJQhR/RUnA3y5yiFR2pOOnwyu91+ qYdmxy74QctYRh638rVIMVZysPlo44P0b8EEszoH3hRyGvrB/JjHixFuBbrIk83kKYSC lM4GK6jowJWhzelk1ZiXsV+uAZvkB0Zp+XMwC8sBchnxJ627fVyiOUy0W4BY4XtxZXS0 k9ewBis3f0yn3zAM2SHWOQcsCtge9Q8mquiB5exr6O/Kfw7JmDve5PU8FnMw3oKBnDsO +Jpw== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id r39-v6si3868316pld.39.2018.02.14.19.34.51; Wed, 14 Feb 2018 19:35:07 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1754214AbeBODeL (ORCPT + 99 others); Wed, 14 Feb 2018 22:34:11 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42744 "EHLO mx0a-001b2d01.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751035AbeBODeJ (ORCPT ); Wed, 14 Feb 2018 22:34:09 -0500 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.22/8.16.0.22) with SMTP id w1F3OXBX051965 for ; Wed, 14 Feb 2018 22:34:09 -0500 Received: from e06smtp11.uk.ibm.com (e06smtp11.uk.ibm.com [195.75.94.107]) by mx0a-001b2d01.pphosted.com with ESMTP id 2g4tvaevgv-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Wed, 14 Feb 2018 22:34:08 -0500 Received: from localhost by e06smtp11.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 15 Feb 2018 03:34:07 -0000 Received: from b06cxnps4075.portsmouth.uk.ibm.com (9.149.109.197) by e06smtp11.uk.ibm.com (192.168.101.141) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 15 Feb 2018 03:34:03 -0000 Received: from d06av21.portsmouth.uk.ibm.com (d06av21.portsmouth.uk.ibm.com [9.149.105.232]) by b06cxnps4075.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id w1F3Y2Oo42860674; Thu, 15 Feb 2018 03:34:02 GMT Received: from d06av21.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E48425203F; Thu, 15 Feb 2018 02:26:02 +0000 (GMT) Received: from localhost.in.ibm.com (unknown [9.77.195.158]) by d06av21.portsmouth.uk.ibm.com (Postfix) with ESMTP id 15FA852041; Thu, 15 Feb 2018 02:25:59 +0000 (GMT) From: Anshuman Khandual To: linux-kernel@vger.kernel.org, gregkh@linuxfoundation.org, bart.vanassche@wdc.com, jthumshirn@suse.de, axboe@kernel.dk, chris@chris-wilson.co.uk, tvrtko.ursulin@intel.com Cc: khandual@linux.vnet.ibm.com Subject: [PATCH V2] lib/scatterlist: Add SG_CHAIN and SG_END macros for LSB encodings Date: Thu, 15 Feb 2018 09:03:56 +0530 X-Mailer: git-send-email 2.9.3 X-TM-AS-GCONF: 00 x-cbid: 18021503-0040-0000-0000-0000042FE8C8 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 18021503-0041-0000-0000-000020D3B248 Message-Id: <20180215033356.6978-1-khandual@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:,, definitions=2018-02-15_01:,, signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1709140000 definitions=main-1802150042 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This replaces scatterlist->page_link LSB encodings with SG_CHAIN and SG_END definitions without any functional change. Signed-off-by: Anshuman Khandual --- Changes in V2: - Changed SG_EMARK as SG_END as per Johannes and Tvrtko - Added 'UL' to the constants as per Bart include/linux/scatterlist.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/include/linux/scatterlist.h b/include/linux/scatterlist.h index 22b2131bcdcd..b6fe1815f5c4 100644 --- a/include/linux/scatterlist.h +++ b/include/linux/scatterlist.h @@ -65,16 +65,18 @@ struct sg_table { */ #define SG_MAGIC 0x87654321 +#define SG_CHAIN 0x01UL +#define SG_END 0x02UL /* * We overload the LSB of the page pointer to indicate whether it's * a valid sg entry, or whether it points to the start of a new scatterlist. * Those low bits are there for everyone! (thanks mason :-) */ -#define sg_is_chain(sg) ((sg)->page_link & 0x01) -#define sg_is_last(sg) ((sg)->page_link & 0x02) +#define sg_is_chain(sg) ((sg)->page_link & SG_CHAIN) +#define sg_is_last(sg) ((sg)->page_link & SG_END) #define sg_chain_ptr(sg) \ - ((struct scatterlist *) ((sg)->page_link & ~0x03)) + ((struct scatterlist *) ((sg)->page_link & ~(SG_CHAIN | SG_END))) /** * sg_assign_page - Assign a given page to an SG entry @@ -88,13 +90,13 @@ struct sg_table { **/ static inline void sg_assign_page(struct scatterlist *sg, struct page *page) { - unsigned long page_link = sg->page_link & 0x3; + unsigned long page_link = sg->page_link & (SG_CHAIN | SG_END); /* * In order for the low bit stealing approach to work, pages * must be aligned at a 32-bit boundary as a minimum. */ - BUG_ON((unsigned long) page & 0x03); + BUG_ON((unsigned long) page & (SG_CHAIN | SG_END)); #ifdef CONFIG_DEBUG_SG BUG_ON(sg->sg_magic != SG_MAGIC); BUG_ON(sg_is_chain(sg)); @@ -130,7 +132,7 @@ static inline struct page *sg_page(struct scatterlist *sg) BUG_ON(sg->sg_magic != SG_MAGIC); BUG_ON(sg_is_chain(sg)); #endif - return (struct page *)((sg)->page_link & ~0x3); + return (struct page *)((sg)->page_link & ~(SG_CHAIN | SG_END)); } /** @@ -178,7 +180,8 @@ static inline void sg_chain(struct scatterlist *prv, unsigned int prv_nents, * Set lowest bit to indicate a link pointer, and make sure to clear * the termination bit if it happens to be set. */ - prv[prv_nents - 1].page_link = ((unsigned long) sgl | 0x01) & ~0x02; + prv[prv_nents - 1].page_link = ((unsigned long) sgl | SG_CHAIN) + & ~SG_END; } /** @@ -198,8 +201,8 @@ static inline void sg_mark_end(struct scatterlist *sg) /* * Set termination bit, clear potential chain bit */ - sg->page_link |= 0x02; - sg->page_link &= ~0x01; + sg->page_link |= SG_END; + sg->page_link &= ~SG_CHAIN; } /** @@ -215,7 +218,7 @@ static inline void sg_unmark_end(struct scatterlist *sg) #ifdef CONFIG_DEBUG_SG BUG_ON(sg->sg_magic != SG_MAGIC); #endif - sg->page_link &= ~0x02; + sg->page_link &= ~SG_END; } /** -- 2.11.0